Skip to content

Commit aadec20

Browse files
authored
Added migration support (#48)
## Summary * Added handlers for `MsgClaimMorseApplication`, `MsgClaimMorseAccount`, `MsgClaimMorseSupplier` and `MsgImportMorseClaimableAccounts` * Updated proto and client files because the migration one were outdated * Added handlers for `/cosmos.authz.v1beta1.MsgGrant` and `cosmos.authz.v1beta1.EventGrant` events
1 parent 300daed commit aadec20

File tree

33 files changed

+2073
-451
lines changed

33 files changed

+2073
-451
lines changed

project.ts

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -386,15 +386,37 @@ const project: CosmosProject = {
386386
],
387387
},
388388
],
389+
// --- MIGRATION
390+
[
391+
"pocket.migration_events",
392+
{
393+
file: "./proto/pocket/migration/event.proto",
394+
messages: [
395+
"EventImportMorseClaimableAccounts",
396+
"EventMorseAccountClaimed",
397+
"EventMorseApplicationClaimed",
398+
"EventMorseSupplierClaimed",
399+
],
400+
},
401+
],
402+
[
403+
"pocket.migration_tx",
404+
{
405+
file: "./proto/pocket/migration/tx.proto",
406+
messages: [
407+
"MsgImportMorseClaimableAccounts",
408+
"MsgClaimMorseAccount",
409+
"MsgClaimMorseApplication",
410+
"MsgClaimMorseSupplier",
411+
],
412+
},
413+
],
389414
]),
390415
},
391416
dataSources: [
392417
{
393418
startBlock: 1,
394-
// startBlock: 349, // first set of txs
395-
// startBlock: 34123, // first set of claims
396-
// startBlock: 55330, // damn big block 176k events
397-
// startBlock: 58120, // more than 570 mb in response
419+
// migration at 25507 on alpha
398420
kind: CosmosDatasourceKind.Runtime,
399421
mapping: {
400422
file: "./dist/index.js",

proto/pocket/application/tx.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ message MsgStakeApplication {
5555
cosmos.base.v1beta1.Coin stake = 2; // The total amount of uPOKT the application has staked. Must be ≥ to the current amount that the application has staked (if any)
5656
repeated pocket.shared.ApplicationServiceConfig services = 3; // The list of services this application is staked to request service for
5757

58-
// TODO_POST_MAINNET_CONSIDERATION: Consider allowing applications to delegate
58+
// TODO_POST_MAINNET: Consider allowing applications to delegate
5959
// to gateways at time of staking for a better developer experience.
6060
// repeated string gateway_address
6161
}

proto/pocket/application/types.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ message Application {
3030
// - https://www.notion.so/buildwithgrove/Off-chain-Application-Stake-Tracking-6a8bebb107db4f7f9dc62cbe7ba555f7
3131
repeated pocket.shared.ApplicationServiceConfig service_configs = 3;
3232

33-
// TODO_BETA(@bryanchriswhite): Rename `delegatee_gateway_addresses` to `gateway_addresses_delegated_to`.
33+
// TODO_MAINNET_MIGRATION(@bryanchriswhite): Rename `delegatee_gateway_addresses` to `gateway_addresses_delegated_to`.
3434
// Ensure to rename all relevant configs, comments, variables, function names, etc as well.
3535
// Non-nullable list of Bech32 encoded delegatee Gateway addresses
3636
repeated string delegatee_gateway_addresses = 4 [(cosmos_proto.scalar) = "cosmos.AddressString", (gogoproto.nullable) = false];

proto/pocket/migration/morse_offchain.proto

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ syntax = "proto3";
1616
//
1717
// These types are used by the migration subcommand to transform
1818
// the Morse state export into the Shannon state import like so:
19-
// $ pocketd migrate collect-morse-accounts ...
19+
// $ pocketd tx migration collect-morse-accounts ...
2020
//
2121
// CRITICAL: These types are offchain and ARE NOT persisted onchain (Shannon) at any point.
2222
package pocket.migration;
@@ -98,11 +98,11 @@ message MorseApplication {
9898
bytes address = 1 [(gogoproto.casttype) = "github.com/cometbft/cometbft/crypto.Address", (gogoproto.jsontag) = "address", (gogoproto.moretags) = "yaml:\"address\""];
9999
// PublicKey is the binary representation of a Morse application's ed25519 public key.
100100
bytes public_key = 2 [(gogoproto.jsontag) = "public_key", (gogoproto.moretags) = "yaml:\"public_key\""];
101-
// TODO_MAINNET(@Olshansk): Should status and/or jailed be considered during the migration, and if so, how?
101+
// TODO_MAINNET_MIGRATION(@Olshansk): Should status and/or jailed be considered during the migration, and if so, how?
102102
bool jailed = 3[(gogoproto.jsontag) = "jailed", (gogoproto.moretags) = "yaml:\"jailed\""];
103103
int32 status = 4 [(gogoproto.jsontag) = "status", (gogoproto.moretags) = "yaml:\"status\""];
104104
// The string representation of the BigInt amount of upokt.
105-
string staked_tokens = 6 [(gogoproto.jsontag) = "tokens"];
105+
string staked_tokens = 6 [(gogoproto.jsontag) = "staked_tokens"];
106106
}
107107

108108
// MorseValidator is a subset of the Morse ProtoValidator type.
@@ -118,7 +118,7 @@ message MorseValidator {
118118
bytes address = 1 [(gogoproto.casttype) = "github.com/cometbft/cometbft/crypto.Address", (gogoproto.moretags) = "yaml:\"address\"", (gogoproto.jsontag) = "address"];
119119
// The binary representation of a Morse application's ed25519 public key.
120120
bytes public_key = 2 [(gogoproto.moretags) = "yaml:\"public_key\"", (gogoproto.jsontag) = "public_key"];
121-
// TODO_MAINNET(@Olshansk): Should status and/or jailed be considered during the migration, and if so, how?
121+
// TODO_MAINNET_MIGRATION(@Olshansk): Should status and/or jailed be considered during the migration, and if so, how?
122122
bool jailed = 3 [(gogoproto.jsontag) = "jailed"];
123123
int32 status = 4 [(gogoproto.jsontag) = "status"];
124124
// The string representation of the BigInt amount of upokt.

proto/pocket/migration/morse_onchain.proto

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,12 @@ message MorseClaimableAccount {
2929
// The hex-encoded address of the Morse account whose balance will be claimed.
3030
string morse_src_address = 2 [(gogoproto.jsontag) = "morse_src_address"];
3131

32+
// DEV_NOTE: This field was momentarily used to hold the Morse public key; however, an
33+
// optimization eliminates the need for this. Reserved for backwards compatibility.
34+
//
3235
// The ed25519 public key of the account.
33-
bytes public_key = 4 [(gogoproto.casttype) = "crypto/ed25519.PublicKey"];
36+
// bytes public_key = 4 [(gogoproto.casttype) = "crypto/ed25519.PublicKey"];
37+
reserved 4;
3438

3539
// The unstaked upokt tokens (i.e. account balance) available for claiming.
3640
cosmos.base.v1beta1.Coin unstaked_balance = 5 [(gogoproto.nullable) = false, (gogoproto.jsontag) = "unstaked_balance"];

proto/pocket/migration/params.proto

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,10 @@ option (gogoproto.stable_marshaler_all) = true;
1111
message Params {
1212
option (amino.name) = "pocket/x/migration/Params";
1313
option (gogoproto.equal) = true;
14+
15+
// waive_morse_claim_gas_fees is a feature flag used to enable/disable the waiving of gas fees for txs that:
16+
// - Contain exactly one secp256k1 signer
17+
// - Contain at least one Morse account/actor claim messages
18+
// - Do not contain any other messages other than Morse account/actor claim messages
19+
bool waive_morse_claim_gas_fees = 1 [(gogoproto.jsontag) = "waive_morse_claim_gas_fees", (gogoproto.moretags) = "yaml:\"waive_morse_claim_gas_fees\""];
1420
}

proto/pocket/migration/tx.proto

Lines changed: 69 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ message MsgUpdateParams {
4040

4141
// NOTE: All parameters must be supplied.
4242
Params params = 2 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
43+
44+
// Next free index: 3
4345
}
4446

4547
// MsgUpdateParamsResponse defines the response structure for executing a
@@ -53,20 +55,22 @@ message MsgImportMorseClaimableAccounts {
5355
// authority is the address that controls the module (defaults to x/gov unless overwritten).
5456
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
5557

56-
// the account state derived from the Morse state export and the `pocketd migrate collect-morse-accounts` command.
58+
// the account state derived from the Morse state export and the `pocketd tx migration collect-morse-accounts` command.
5759
MorseAccountState morse_account_state = 2 [(gogoproto.jsontag) = "morse_account_state", (gogoproto.nullable) = false];
5860

5961
// Validates the morse_account_state sha256 hash:
6062
// - Transaction fails if hash doesn't match on-chain computation
6163
// - Off-chain social consensus should be reached off-chain before verification
6264

63-
// Verification can be done by comparing with locally derived Morse state like so:
64-
// $ pocketd migrate collect-morse-accounts $<(pocket util export-genesis-for-reset)
65+
// Verification can be done by comparing with locally derived Morse state like so (at a high-level):
66+
// $ pocketd tx migration collect-morse-accounts $<(pocket util export-genesis-for-reset)
6567

6668
// Additional documentation:
6769
// - pocket util export-genesis-for-migration --help
68-
// - pocketd migrate collect-morse-accounts --help
70+
// - pocketd tx migration collect-morse-accounts --help
6971
bytes morse_account_state_hash = 3 [(gogoproto.jsontag) = "morse_account_state_hash"];
72+
73+
// Next free index: 4
7074
}
7175

7276
// MsgImportMorseClaimableAccountsResponse is returned from MsgImportMorseClaimableAccounts.
@@ -78,6 +82,8 @@ message MsgImportMorseClaimableAccountsResponse {
7882

7983
// Number of claimable accounts (EOAs) collected from Morse state export.
8084
uint64 num_accounts = 2 [(gogoproto.jsontag) = "num_accounts"];
85+
86+
// Next free index: 3
8187
}
8288

8389
// MsgClaimMorseAccount is used to execute a claim (one-time minting of tokens on Shannon),
@@ -88,25 +94,40 @@ message MsgImportMorseClaimableAccountsResponse {
8894
// - The Shannon account specified must be the message signer
8995
// - Authz grants MAY be used to delegate claiming authority to other Shannon accounts
9096
message MsgClaimMorseAccount {
91-
option (cosmos.msg.v1.signer) = "shannon_dest_address";
97+
option (cosmos.msg.v1.signer) = "shannon_signing_address";
98+
99+
// The bech32-encoded address of the Shannon account which is signing for this message.
100+
// This account is liable for any fees incurred by violating the constraints of Morse
101+
// account/actor claim message fee waiving; the tx contains ONE OR MORE Morse account/actor
102+
// claim messages AND has EXACTLY ONE signer.
103+
string shannon_signing_address = 4 [(cosmos_proto.scalar) = "cosmos.AddressString", (gogoproto.jsontag) = "shannon_signing_address"];
92104

93105
// The bech32-encoded address of the Shannon account to which the claimed balance will be minted.
94106
string shannon_dest_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString", (gogoproto.jsontag) = "shannon_dest_address"];
95107

108+
// DEV_NOTE: This field was momentarily used to hold the Morse source
109+
// address; however, an optimization eliminates the need for this.
110+
// Reserved for backwards compatibility.
111+
//
96112
// The hex-encoded address of the Morse account whose balance will be claimed.
97113
// E.g.: 00f9900606fa3d5c9179fc0c8513078a53a2073e
98-
string morse_src_address = 2 [(gogoproto.jsontag) = "morse_src_address"];
114+
// string morse_src_address = 2 [(gogoproto.jsontag) = "morse_src_address"];
115+
reserved 2;
116+
117+
// The ed25519 public key of the morse account with morse_src_address.
118+
bytes morse_public_key = 5 [(gogoproto.casttype) = "github.com/cometbft/cometbft/crypto/ed25519.PubKey"];
99119

100120
// The hex-encoded signature, by the Morse account, of this message (where this field is nil).
101121
// I.e.: morse_signature = private_key.sign(marshal(MsgClaimMorseAccount{morse_signature: nil, ...}))
102122
bytes morse_signature = 3 [(gogoproto.jsontag) = "morse_signature"];
123+
124+
// Next free index: 6
103125
}
104126

105127
// MsgClaimMorseAccountResponse is returned from MsgClaimMorseAccount.
106128
// It indicates the morse_src_address of the account which was claimed, the total
107129
// balance claimed, and the height at which the claim was committed.
108130
message MsgClaimMorseAccountResponse {
109-
110131
// The hex-encoded address of the Morse account whose balance will be claimed.
111132
// E.g.: 00f9900606fa3d5c9179fc0c8513078a53a2073e
112133
string morse_src_address = 1 [(gogoproto.jsontag) = "morse_src_address"];
@@ -116,23 +137,38 @@ message MsgClaimMorseAccountResponse {
116137

117138
// The session end height (on Shannon) in which the claim was committed (i.e. claimed).
118139
int64 session_end_height = 3 [(gogoproto.jsontag) = "session_end_height"];
140+
141+
// Next free index: 4
119142
}
120143

121144
// MsgClaimMorseApplication is used to execute a claim (one-time minting of tokens on Shannon),
122145
// of the total tokens owned by the given Morse account, according to the on-chain MorseClaimableAccounts,
123146
// to the balance of the given Shannon account, followed by staking that Shannon account as an application
124147
// for the given service_config and the same stake amount as on Morse.
125148
message MsgClaimMorseApplication {
126-
option (cosmos.msg.v1.signer) = "shannon_dest_address";
149+
option (cosmos.msg.v1.signer) = "shannon_signing_address";
150+
151+
// The bech32-encoded address of the Shannon account which is signing for this message.
152+
// This account is liable for any fees incurred by violating the constraints of Morse
153+
// account/actor claim message fee waiving; the tx contains ONE OR MORE Morse account/actor
154+
// claim messages AND has EXACTLY ONE signer.
155+
string shannon_signing_address = 5 [(cosmos_proto.scalar) = "cosmos.AddressString", (gogoproto.jsontag) = "shannon_signing_address"];
127156

128157
// The bech32-encoded address of the Shannon account to which the claimed tokens
129158
// will be minted and from which the application will be staked.
130159
string shannon_dest_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString", (gogoproto.jsontag) = "shannon_dest_address"];
131160

161+
// DEV_NOTE: This field was momentarily used to hold the Morse source
162+
// address; however, an optimization eliminates the need for this.
163+
// Reserved for backwards compatibility.
164+
//
132165
// The hex-encoded address of the Morse account whose balance will be claimed.
133166
// E.g.: 00f9900606fa3d5c9179fc0c8513078a53a2073e
167+
// string morse_src_address = 2 [(gogoproto.jsontag) = "morse_src_address"];
168+
reserved 2;
134169

135-
string morse_src_address = 2 [(gogoproto.jsontag) = "morse_src_address"];
170+
// The ed25519 public key of the morse account with morse_src_address.
171+
bytes morse_public_key = 6 [(gogoproto.casttype) = "github.com/cometbft/cometbft/crypto/ed25519.PubKey"];
136172

137173
// The hex-encoded signature, by the Morse account, of this message (where this field is nil).
138174
// I.e.: morse_signature = private_key.sign(marshal(MsgClaimMorseAccount{morse_signature: nil, ...}))
@@ -142,6 +178,8 @@ message MsgClaimMorseApplication {
142178
// NOTE: This is not a repeated field, as in MsgStakeApplication,
143179
// because an application can only be staked for one service.
144180
shared.ApplicationServiceConfig service_config = 4 [(gogoproto.jsontag) = "service_config"];
181+
182+
// Next free index: 7
145183
}
146184

147185
// MsgClaimMorseApplicationResponse is returned from MsgClaimMorseApplication.
@@ -164,6 +202,8 @@ message MsgClaimMorseApplicationResponse {
164202

165203
// The application which was staked as a result of the claim.
166204
application.Application application = 5 [(gogoproto.jsontag) = "application"];
205+
206+
// Next free index: 6
167207
}
168208

169209
// MsgClaimMorseSupplier is used to:
@@ -175,7 +215,13 @@ message MsgClaimMorseApplicationResponse {
175215
// NOTE: The supplier module's staking fee parameter (at the time of claiming) is deducted from the
176216
// claimed balance.
177217
message MsgClaimMorseSupplier {
178-
option (cosmos.msg.v1.signer) = "shannon_owner_address";
218+
option (cosmos.msg.v1.signer) = "shannon_signing_address";
219+
220+
// The bech32-encoded address of the Shannon account which is signing for this message.
221+
// This account is liable for any fees incurred by violating the constraints of Morse
222+
// account/actor claim message fee waiving; the tx contains ONE OR MORE Morse account/actor
223+
// claim messages AND has EXACTLY ONE signer.
224+
string shannon_signing_address = 6 [(cosmos_proto.scalar) = "cosmos.AddressString", (gogoproto.jsontag) = "shannon_signing_address"];
179225

180226
// The bech32-encoded address of the Shannon account to which the claimed tokens
181227
// will be minted and which become the supplier owner.
@@ -187,11 +233,17 @@ message MsgClaimMorseSupplier {
187233
// See: https://dev.poktroll.com/operate/configs/supplier_staking_config#staking-types.
188234
string shannon_operator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString", (gogoproto.jsontag) = "shannon_operator_address"];
189235

236+
// The ed25519 public key of the morse account with morse_src_address.
237+
bytes morse_public_key = 7 [(gogoproto.casttype) = "github.com/cometbft/cometbft/crypto/ed25519.PubKey"];
238+
239+
// DEV_NOTE: This field was momentarily used to hold the Morse source
240+
// address; however, an optimization eliminates the need for this.
241+
// Reserved for backwards compatibility.
242+
//
190243
// The hex-encoded address of the Morse account whose balance will be claimed.
191244
// E.g.: 00f9900606fa3d5c9179fc0c8513078a53a2073e
192-
//
193-
// TODO_MAINNET(@bryanchriswhite, #1126): Rename to `morse_src_owner_address`.
194-
string morse_src_address = 3 [(gogoproto.jsontag) = "morse_src_address"];
245+
// string morse_src_address = 3 [(gogoproto.jsontag) = "morse_src_address"];
246+
reserved 3;
195247

196248
// The hex-encoded signature, by the Morse account, of this message (where this field is nil).
197249
// I.e.: morse_signature = private_key.sign(marshal(MsgClaimMorseAccount{morse_signature: nil, ...}))
@@ -201,6 +253,8 @@ message MsgClaimMorseSupplier {
201253

202254
// The services this supplier is staked to provide service for.
203255
repeated shared.SupplierServiceConfig services = 5 [(gogoproto.jsontag) = "services"];
256+
257+
// Next free index: 8
204258
}
205259

206260
// MsgClaimMorseSupplierResponse is returned from MsgClaimMorseSupplier.
@@ -224,5 +278,7 @@ message MsgClaimMorseSupplierResponse {
224278

225279
// The supplier which was staked as a result of the claim.
226280
shared.Supplier supplier = 5 [(gogoproto.jsontag) = "supplier"];
281+
282+
// Next free index: 6
227283
}
228284

proto/pocket/proof/params.proto

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,20 @@ message Params {
2222
// is equal to or above the threshold. This is in contrast to the this requirement
2323
// being determined probabilistically via ProofRequestProbability.
2424
//
25-
// TODO_MAINNET: Consider renaming this to `proof_requirement_threshold_upokt`.
25+
// TODO_MAINNET_MIGRATION: Consider renaming this to `proof_requirement_threshold_upokt`.
2626
cosmos.base.v1beta1.Coin proof_requirement_threshold = 3 [(gogoproto.jsontag) = "proof_requirement_threshold"];
2727

2828
// proof_missing_penalty is the number of tokens (uPOKT) which should be slashed from a supplier
2929
// when a proof is required (either via proof_requirement_threshold or proof_missing_penalty)
3030
// but is not provided.
31-
// TODO_MAINNET: Consider renaming this to `proof_missing_penalty_upokt`.
31+
// TODO_MAINNET_MIGRATION: Consider renaming this to `proof_missing_penalty_upokt`.
3232
cosmos.base.v1beta1.Coin proof_missing_penalty = 4 [(gogoproto.jsontag) = "proof_missing_penalty"];
3333

3434
// proof_submission_fee is the number of tokens (uPOKT) which should be paid by
3535
// the supplier operator when submitting a proof.
3636
// This is needed to account for the cost of storing proofs onchain and prevent
3737
// spamming (i.e. sybil bloat attacks) the network with non-required proofs.
38-
// TODO_MAINNET: Consider renaming this to `proof_submission_fee_upokt`.
38+
// TODO_MAINNET_MIGRATION: Consider renaming this to `proof_submission_fee_upokt`.
3939
cosmos.base.v1beta1.Coin proof_submission_fee = 5 [(gogoproto.jsontag) = "proof_submission_fee"];
4040

4141
// IMPORTANT: Make sure to update all related files if you're modifying or adding a new parameter.

proto/pocket/proof/types.proto

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,18 @@ enum ClaimProofStatus {
5757
VALIDATED = 1;
5858
INVALID = 2;
5959
}
60+
61+
// **************
62+
// OFFCHAIN TYPES
63+
// The messages defined below are used for offchain logic and should not be used for any onchain logic.
64+
// They are defined in the same file as the onchain types for convenience.
65+
// **************
66+
67+
// SessionSMT is the serializable session's SMST used to persist the session's
68+
// state offchain by the RelayMiner.
69+
// It is not used for any onchain logic.
70+
message SessionSMT {
71+
pocket.session.SessionHeader session_header = 1;
72+
string supplier_operator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
73+
bytes smt_root = 3;
74+
}

proto/pocket/session/params.proto

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
syntax = "proto3";
22
package pocket.session;
33

4-
option go_package = "github.com/pokt-network/poktroll/x/session/types";
5-
option (gogoproto.stable_marshaler_all) = true;
6-
74
import "amino/amino.proto";
85
import "gogoproto/gogo.proto";
96

7+
option go_package = "github.com/pokt-network/poktroll/x/session/types";
8+
option (gogoproto.stable_marshaler_all) = true;
9+
1010
// Params defines the parameters for the module.
1111
message Params {
1212
option (amino.name) = "pocket/x/session/Params";

0 commit comments

Comments
 (0)