Skip to content

Commit 5701a44

Browse files
authored
Optimize balance handling, fix indexing, and update to poktroll events (#60)
- Refactor balance change handling to improve speed - Fix claim indexing - Remove `NativeBalanceChange` since was not used and slowing down the entire process - Updated code to match the changes made to poktroll events: - pokt-network/poktroll#1682 - pokt-network/poktroll#1673 - pokt-network/poktroll#1672
1 parent 6f0222a commit 5701a44

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+8125
-3388
lines changed

proto/pocket/application/module/module.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ option (gogoproto.stable_marshaler_all) = true;
66
import "cosmos/app/v1alpha1/module.proto";
77
import "gogoproto/gogo.proto";
88

9+
option go_package = "github.com/pokt-network/poktroll/x/application/types";
10+
911
// Module is the config object for the module.
1012
message Module {
1113
option (cosmos.app.v1alpha1.module) = {

proto/pocket/application/tx.proto

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ message MsgStakeApplication {
6161
}
6262

6363
message MsgStakeApplicationResponse {
64-
pocket.application.Application application = 1;
64+
// pocket.application.Application application = 1;
65+
reserved 1;
6566
}
6667

6768
message MsgUnstakeApplication {
@@ -70,7 +71,8 @@ message MsgUnstakeApplication {
7071
}
7172

7273
message MsgUnstakeApplicationResponse {
73-
pocket.application.Application application = 1;
74+
// pocket.application.Application application = 1;
75+
reserved 1;
7476
}
7577

7678
message MsgDelegateToGateway {
@@ -80,7 +82,8 @@ message MsgDelegateToGateway {
8082
}
8183

8284
message MsgDelegateToGatewayResponse {
83-
pocket.application.Application application = 1;
85+
// pocket.application.Application application = 1;
86+
reserved 1;
8487
}
8588

8689
message MsgUndelegateFromGateway {
@@ -90,7 +93,8 @@ message MsgUndelegateFromGateway {
9093
}
9194

9295
message MsgUndelegateFromGatewayResponse {
93-
pocket.application.Application application = 1;
96+
// pocket.application.Application application = 1;
97+
reserved 1;
9498
}
9599

96100
message MsgTransferApplication {
@@ -100,7 +104,8 @@ message MsgTransferApplication {
100104
}
101105

102106
message MsgTransferApplicationResponse {
103-
pocket.application.Application application = 1;
107+
// pocket.application.Application application = 1;
108+
reserved 1;
104109
}
105110

106111
message MsgUpdateParam {
@@ -117,6 +122,7 @@ message MsgUpdateParam {
117122
}
118123

119124
message MsgUpdateParamResponse {
120-
Params params = 1;
125+
// Params params = 1;
126+
reserved 1;
121127
}
122128

proto/pocket/application/types.proto

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
// TODO_AUTOMATE: Add a CI workflow that automatically detects .proto files with names incompatible with the package name (e.g., files named exactly as the package, like "application.proto").
2-
// NB: This file CANNOT be named "application.proto" due to an unresolved issue in how cosmos-proto generates the pulsar plugin output Go source code.
3-
// See: https://github.com/pokt-network/poktroll/issues/XXX for tracking and future resolution.
4-
51
syntax = "proto3";
62
package pocket.application;
73

proto/pocket/gateway/module/module.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ option (gogoproto.stable_marshaler_all) = true;
66
import "cosmos/app/v1alpha1/module.proto";
77
import "gogoproto/gogo.proto";
88

9+
option go_package = "github.com/pokt-network/poktroll/x/gateway/types";
10+
911
// Module is the config object for the module.
1012
message Module {
1113
option (cosmos.app.v1alpha1.module) = {

proto/pocket/gateway/tx.proto

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ message MsgStakeGateway {
5252
}
5353

5454
message MsgStakeGatewayResponse {
55-
pocket.gateway.Gateway gateway = 1;
55+
// pocket.gateway.Gateway gateway = 1;
56+
reserved 1;
5657
}
5758

5859
message MsgUnstakeGateway {
@@ -61,7 +62,8 @@ message MsgUnstakeGateway {
6162
}
6263

6364
message MsgUnstakeGatewayResponse {
64-
pocket.gateway.Gateway gateway = 1;
65+
// pocket.gateway.Gateway gateway = 1;
66+
reserved 1;
6567
}
6668

6769
// MsgUpdateParam is the Msg/UpdateParam request type to update a single param.
@@ -78,6 +80,7 @@ message MsgUpdateParam {
7880
}
7981

8082
message MsgUpdateParamResponse {
81-
Params params = 1;
83+
// Params params = 1;
84+
reserved 1;
8285
}
8386

proto/pocket/gateway/types.proto

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
// TODO_AUTOMATE: Add a CI workflow which detects .proto files with incompatible names (i.e. same as the package).
2-
// NB: This file CANNOT be named "application.proto" due to an as of yet unidentified
3-
// issue in how cosmos-proto generates the pulsar plugin output go source code.
4-
51
syntax = "proto3";
62
package pocket.gateway;
73

proto/pocket/migration/event.proto

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ option (gogoproto.stable_marshaler_all) = true;
66

77
import "cosmos_proto/cosmos.proto";
88
import "gogoproto/gogo.proto";
9-
import "cosmos/base/v1beta1/coin.proto";
109

1110
import "pocket/shared/service.proto";
1211
import "pocket/migration/morse_onchain.proto";
@@ -32,51 +31,63 @@ message EventImportMorseClaimableAccounts {
3231
// EventMorseAccountClaimed
3332
// - Emitted when a MorseAccount is claimed on-chain
3433
message EventMorseAccountClaimed {
34+
// Next index: 6
35+
36+
reserved 2; // cosmos.base.v1beta1.Coin claimed_balance = 2 [(gogoproto.jsontag) = "claimed_balance", (gogoproto.nullable) = false];
37+
3538
// Shannon session end height in which the claim was committed
3639
int64 session_end_height = 1 [(gogoproto.jsontag) = "session_end_height"];
3740

38-
// Unstaked balance claimed from Morse
39-
cosmos.base.v1beta1.Coin claimed_balance = 2 [(gogoproto.jsontag) = "claimed_balance", (gogoproto.nullable) = false];
40-
4141
// bech32-encoded Shannon address to mint claimed balance
4242
string shannon_dest_address = 3 [(cosmos_proto.scalar) = "cosmos.AddressString", (gogoproto.jsontag) = "shannon_dest_address"];
4343

4444
// Hex-encoded Morse account address whose balance was claimed
4545
string morse_src_address = 4 [(gogoproto.jsontag) = "morse_src_address"];
46+
47+
// Unstaked balance claimed from Morse
48+
string claimed_balance = 5 [(gogoproto.jsontag) = "claimed_balance"];
4649
}
4750

4851
// EventMorseApplicationClaimed
4952
// - Emitted when a MorseAccount is claimed on-chain as a staked application
5053
message EventMorseApplicationClaimed {
54+
// Next index: 8
55+
56+
reserved 2; // cosmos.base.v1beta1.Coin claimed_balance = 2 [(gogoproto.jsontag) = "claimed_balance", (gogoproto.nullable) = false];
57+
reserved 4; // cosmos.base.v1beta1.Coin claimed_application_stake = 4 [(gogoproto.nullable) = false, (gogoproto.jsontag) = "claimed_application_stake"];
58+
5159
// Shannon session end height in which the claim was committed
5260
int64 session_end_height = 1 [(gogoproto.jsontag) = "session_end_height"];
5361

54-
// Unstaked balance claimed from Morse
55-
cosmos.base.v1beta1.Coin claimed_balance = 2 [(gogoproto.jsontag) = "claimed_balance", (gogoproto.nullable) = false];
56-
5762
// Hex-encoded Morse account address whose balance was claimed
5863
string morse_src_address = 3 [(gogoproto.jsontag) = "morse_src_address"];
5964

60-
// Application stake claimed as a result of the claim
61-
// - Equivalent to Morse application staked amount
62-
cosmos.base.v1beta1.Coin claimed_application_stake = 4 [(gogoproto.nullable) = false, (gogoproto.jsontag) = "claimed_application_stake"];
63-
6465
// Application staked as a result of the claim
6566
// - Mirrors Morse application stake
6667
application.Application application = 5 [(gogoproto.jsontag) = "application"];
68+
69+
// Unstaked balance claimed from Morse
70+
string claimed_balance = 6 [(gogoproto.jsontag) = "claimed_balance"];
71+
72+
// Application stake claimed as a result of the claim
73+
// - Equivalent to Morse application staked amount
74+
string claimed_application_stake = 7 [(gogoproto.jsontag) = "claimed_application_stake"];
6775
}
6876

6977
// EventMorseSupplierClaimed
7078
// - Emitted when a MorseAccount is claimed on-chain as a staked Supplier
7179
message EventMorseSupplierClaimed {
72-
// Next free index: 9
73-
reserved 3;
80+
// Next index: 11
81+
82+
// cosmos.base.v1beta1.Coin claimed_balance = 2 [(gogoproto.jsontag) = "claimed_balance", (gogoproto.nullable) = false];
83+
// cosmos.base.v1beta1.Coin claimed_supplier_stake = 4 [(gogoproto.nullable) = false, (gogoproto.jsontag) = "claimed_supplier_stake"];
84+
reserved 2, 3, 4;
7485

7586
// Shannon session end height in which the claim was committed
7687
int64 session_end_height = 1 [(gogoproto.jsontag) = "session_end_height"];
7788

7889
// Unstaked balance claimed from Morse
79-
cosmos.base.v1beta1.Coin claimed_balance = 2 [(gogoproto.jsontag) = "claimed_balance", (gogoproto.nullable) = false];
90+
string claimed_balance = 9 [(gogoproto.jsontag) = "claimed_balance"];
8091

8192
// The hex-encoded address of the Morse non-custodial (i.e. operator) account.
8293
// - Unstaked balance was migrated 1:1
@@ -103,7 +114,7 @@ message EventMorseSupplierClaimed {
103114

104115
// Supplier stake claimed as a result of the claim
105116
// - Equivalent to Morse supplier staked amount
106-
cosmos.base.v1beta1.Coin claimed_supplier_stake = 4 [(gogoproto.nullable) = false, (gogoproto.jsontag) = "claimed_supplier_stake"];
117+
string claimed_supplier_stake = 10 [(gogoproto.jsontag) = "claimed_supplier_stake"];
107118

108119
// Supplier staked as a result of the claim
109120
// - Mirrors Morse supplier stake
@@ -113,13 +124,18 @@ message EventMorseSupplierClaimed {
113124
// EventMorseAccountRecovered
114125
// - Emitted when a Morse account is recovered on-chain
115126
message EventMorseAccountRecovered {
127+
// Next index: 6
128+
129+
// cosmos.base.v1beta1.Coin recovered_balance = 2 [(gogoproto.jsontag) = "recovered_balance", (gogoproto.nullable) = false];
130+
reserved 2;
131+
116132
// The session end height (on Shannon) in which the recovery was committed (i.e. claimed).
117133
int64 session_end_height = 1 [(gogoproto.jsontag) = "session_end_height"];
118134

119135
// The total balance which was recovered:
120136
// - Includes both unstaked and staked balances (consolidated)
121137
// - Auto-liquidates both unstaked and staked balances at once
122-
cosmos.base.v1beta1.Coin recovered_balance = 2 [(gogoproto.jsontag) = "recovered_balance", (gogoproto.nullable) = false];
138+
string recovered_balance = 5 [(gogoproto.jsontag) = "recovered_balance"];
123139

124140
// The bech32-encoded address of the Shannon account to which the recovered balance was minted.
125141
string shannon_dest_address = 3 [(cosmos_proto.scalar) = "cosmos.AddressString", (gogoproto.jsontag) = "shannon_dest_address"];

proto/pocket/migration/module/module.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ option (gogoproto.stable_marshaler_all) = true;
66
import "cosmos/app/v1alpha1/module.proto";
77
import "gogoproto/gogo.proto";
88

9+
option go_package = "github.com/pokt-network/poktroll/x/migration/types";
10+
911
// Module is the config object for the module.
1012
message Module {
1113
option (cosmos.app.v1alpha1.module) = {

proto/pocket/migration/tx.proto

Lines changed: 26 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,9 @@ message MsgImportMorseClaimableAccounts {
9090
message MsgImportMorseClaimableAccountsResponse {
9191
// Next free index: 3
9292

93-
// On-chain computed sha256 hash of the morse_account_state provided in the corresponding MsgCreateMorseAccountState.
94-
bytes state_hash = 1 [(gogoproto.jsontag) = "state_hash"];
95-
96-
// Number of claimable accounts (EOAs) collected from Morse state export.
97-
uint64 num_accounts = 2 [(gogoproto.jsontag) = "num_accounts"];
93+
// bytes state_hash = 1 [(gogoproto.jsontag) = "state_hash"];
94+
// uint64 num_accounts = 2 [(gogoproto.jsontag) = "num_accounts"];
95+
reserved 1, 2;
9896
}
9997

10098
// MsgClaimMorseAccount is used to:
@@ -136,15 +134,10 @@ message MsgClaimMorseAccount {
136134
message MsgClaimMorseAccountResponse {
137135
// Next free index: 4
138136

139-
// The hex-encoded address of the Morse account whose balance will be claimed.
140-
// E.g.: 00f9900606fa3d5c9179fc0c8513078a53a2073e
141-
string morse_src_address = 1 [(gogoproto.jsontag) = "morse_src_address"];
142-
143-
// The balance which was claimed.
144-
cosmos.base.v1beta1.Coin claimed_balance = 2 [(gogoproto.jsontag) = "claimed_balance", (gogoproto.nullable) = false];
145-
146-
// The session end height (on Shannon) in which the claim was committed (i.e. claimed).
147-
int64 session_end_height = 3 [(gogoproto.jsontag) = "session_end_height"];
137+
// string morse_src_address = 1 [(gogoproto.jsontag) = "morse_src_address"];
138+
// cosmos.base.v1beta1.Coin claimed_balance = 2 [(gogoproto.jsontag) = "claimed_balance", (gogoproto.nullable) = false];
139+
// int64 session_end_height = 3 [(gogoproto.jsontag) = "session_end_height"];
140+
reserved 1, 2, 3;
148141
}
149142

150143
// MsgClaimMorseApplication is used to:
@@ -190,21 +183,12 @@ message MsgClaimMorseApplication {
190183
message MsgClaimMorseApplicationResponse {
191184
// Next free index: 6
192185

193-
// The hex-encoded address of the Morse account whose balance will be claimed.
194-
string morse_src_address = 1 [(gogoproto.jsontag) = "morse_src_address"];
195-
196-
// The unstaked balance which was claimed.
197-
cosmos.base.v1beta1.Coin claimed_balance = 2 [(gogoproto.jsontag) = "claimed_balance", (gogoproto.nullable) = false];
198-
199-
// The stake of the application which was staked as a result of the claim.
200-
// If the application was already staked, this amount does not include the initial stake (i.e. only the portion which was "claimed").
201-
cosmos.base.v1beta1.Coin claimedApplicationStake = 3 [(gogoproto.jsontag) = "claimed_application_stake", (gogoproto.nullable) = false];
202-
203-
// The session end height (on Shannon) in which the claim was committed (i.e. claimed).
204-
int64 session_end_height = 4 [(gogoproto.jsontag) = "session_end_height"];
205-
206-
// The application which was staked as a result of the claim.
207-
application.Application application = 5 [(gogoproto.jsontag) = "application"];
186+
// string morse_src_address = 1 [(gogoproto.jsontag) = "morse_src_address"];
187+
// cosmos.base.v1beta1.Coin claimed_balance = 2 [(gogoproto.jsontag) = "claimed_balance", (gogoproto.nullable) = false];
188+
// cosmos.base.v1beta1.Coin claimedApplicationStake = 3 [(gogoproto.jsontag) = "claimed_application_stake", (gogoproto.nullable) = false];
189+
// int64 session_end_height = 4 [(gogoproto.jsontag) = "session_end_height"];
190+
// application.Application application = 5 [(gogoproto.jsontag) = "application"];
191+
reserved 1, 2, 3, 4, 5;
208192
}
209193

210194
// MsgClaimMorseSupplier is used to:
@@ -279,39 +263,14 @@ message MsgClaimMorseSupplier {
279263
message MsgClaimMorseSupplierResponse {
280264
// Next free index: 10
281265

282-
reserved 1;
283-
284-
// The hex-encoded address of the Morse non-custodial (i.e. operator) account.
285-
// - Unstaked balance will be migrated 1:1
286-
// - Stake will be migrated 1:1 from morse_node_address to shannon_operator_address
287-
// - Morse non-custodial (i.e. operator) address.
288-
// If morse_output_address is not set, this is the custodial address.
289-
// - See 'pocket nodes --help' for more information. Note that this refers to the Morse CLI.
290-
// E.g.: 00f9900606fa3d5c9179fc0c8513078a53a2073e
291-
string morse_node_address = 9 [(gogoproto.jsontag) = "morse_node_address"];
292-
293-
// Hex-encoded address of the Morse output account/wallet associated with the Morse node/supplier.
294-
// - E.g.: 00f9900606fa3d5c9179fc0c8513078a53a2073e
295-
// - Morse custodial (i.e. owner) address, which owns the staked tokens of the operator.
296-
// See 'pocket nodes --help' for more information. Note that this refers to the Morse CLI.
297-
string morse_output_address = 8 [(gogoproto.jsontag) = "morse_output_address"];
298-
299-
// The type of supplier claim signer, indicating which actor executed the claim
300-
// and whether it was a custodial or non-custodial claim.
301-
// - MORSE_SUPPLIER_CLAIM_SIGNER_TYPE_NON_CUSTODIAL_SIGNED_BY_ADDR
302-
// - MORSE_SUPPLIER_CLAIM_SIGNER_TYPE_CUSTODIAL_SIGNED_BY_OPERATOR
303-
// - MORSE_SUPPLIER_CLAIM_SIGNER_TYPE_CUSTODIAL_SIGNED_BY_OWNER
304-
MorseSupplierClaimSignerType claim_signer_type = 7 [(gogoproto.jsontag) = "claim_signer_type"];
305-
306-
// The unstaked balance which was claimed.
307-
cosmos.base.v1beta1.Coin claimed_balance = 2 [(gogoproto.nullable) = false, (gogoproto.jsontag) = "claimed_balance" ];
308-
cosmos.base.v1beta1.Coin claimed_supplier_stake = 3 [(gogoproto.nullable) = false, (gogoproto.jsontag) = "claimed_supplier_stake"];
309-
310-
// The session end height (on Shannon) in which the claim was committed (i.e. claimed).
311-
int64 session_end_height = 4 [(gogoproto.jsontag) = "session_end_height"];
312-
313-
// The supplier which was staked as a result of the claim.
314-
shared.Supplier supplier = 5 [(gogoproto.jsontag) = "supplier"];
266+
// string morse_node_address = 9 [(gogoproto.jsontag) = "morse_node_address"];
267+
// string morse_output_address = 8 [(gogoproto.jsontag) = "morse_output_address"];
268+
// MorseSupplierClaimSignerType claim_signer_type = 7 [(gogoproto.jsontag) = "claim_signer_type"];
269+
// cosmos.base.v1beta1.Coin claimed_balance = 2 [(gogoproto.nullable) = false, (gogoproto.jsontag) = "claimed_balance"];
270+
// cosmos.base.v1beta1.Coin claimed_supplier_stake = 3 [(gogoproto.nullable) = false, (gogoproto.jsontag) = "claimed_supplier_stake"];
271+
// int64 session_end_height = 4 [(gogoproto.jsontag) = "session_end_height"];
272+
// shared.Supplier supplier = 5 [(gogoproto.jsontag) = "supplier"];
273+
reserved 1, 2, 3, 4, 5, 7, 8, 9;
315274
}
316275

317276
// MsgRecoverMorseAccount is used to:
@@ -353,23 +312,11 @@ message MsgRecoverMorseAccount {
353312
message MsgRecoverMorseAccountResponse {
354313
// Next free index: 5
355314

356-
// EITHER:
357-
// - The hex-encoded address of the Morse account whose stake(s) and/or balances were recovered.
358-
// This address MAY be invalid but NEVER empty.
359-
// E.g.: 00f9900606fa3d5c9179fc0c8513078a53a2073e
360-
// - The name of a Morse module account whose balance was recovered.
361-
// E.g. "dao" or "fee-collector"
362-
string morse_src_address = 1 [(gogoproto.jsontag) = "morse_src_address"];
363-
364-
// The sum of any unstaked and staked balances which were recovered.
365-
cosmos.base.v1beta1.Coin recovered_balance = 2 [(gogoproto.nullable) = false, (gogoproto.jsontag) = "recovered_balance"];
366-
367-
// The session end height (on Shannon) in which the recovery was committed (i.e. recovered).
368-
int64 session_end_height = 3 [(gogoproto.jsontag) = "session_end_height"];
369-
370-
// The bech32-encoded address of the Shannon account to which the Morse account's stake(s) and/or
371-
// balance(s) were recovered.
372-
string shannon_dest_address = 4 [(cosmos_proto.scalar) = "cosmos.AddressString", (gogoproto.jsontag) = "shannon_dest_address"];
315+
// string morse_src_address = 1 [(gogoproto.jsontag) = "morse_src_address"];
316+
// cosmos.base.v1beta1.Coin recovered_balance = 2 [(gogoproto.nullable) = false, (gogoproto.jsontag) = "recovered_balance"];
317+
// int64 session_end_height = 3 [(gogoproto.jsontag) = "session_end_height"];
318+
// string shannon_dest_address = 4 [(cosmos_proto.scalar) = "cosmos.AddressString", (gogoproto.jsontag) = "shannon_dest_address"];
319+
reserved 1, 2, 3, 4;
373320

374321
// TODO_MAINNET_MIGRATION(@bryanchriswhite): Add shannon_dest_address to MsgRecoverMorseAccountResponse.
375322
}

0 commit comments

Comments
 (0)