From 7f9e98075857778f5c08512b0e72bcfc2cacd47d Mon Sep 17 00:00:00 2001 From: Bryan White Date: Wed, 12 Feb 2025 10:53:18 +0100 Subject: [PATCH] chore: review feedback improvements Co-authored-by: Daniel Olshansky --- api/poktroll/application/types.pulsar.go | 5 ++-- .../migration/morse_offchain.pulsar.go | 29 ++++++++++--------- .../migration/morse_onchain.pulsar.go | 15 ++++++---- cmd/poktrolld/cmd/migrate/migrate.go | 2 +- proto/poktroll/migration/morse_onchain.proto | 27 ++++------------- x/application/types/types.pb.go | 2 +- x/migration/types/morse_offchain.pb.go | 29 ++++++++++--------- x/migration/types/morse_onchain.pb.go | 13 ++++++--- 8 files changed, 62 insertions(+), 60 deletions(-) diff --git a/api/poktroll/application/types.pulsar.go b/api/poktroll/application/types.pulsar.go index 21eb04ac4..8698757e0 100644 --- a/api/poktroll/application/types.pulsar.go +++ b/api/poktroll/application/types.pulsar.go @@ -3,11 +3,12 @@ package application import ( v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" - shared "github.com/pokt-network/poktroll/api/poktroll/shared" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" + shared "github.com/pokt-network/poktroll/api/poktroll/shared" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" @@ -2182,7 +2183,7 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -// Application represents the on-chain definition and state of an application +// Application represents the onchain definition and state of an application type Application struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache diff --git a/api/poktroll/migration/morse_offchain.pulsar.go b/api/poktroll/migration/morse_offchain.pulsar.go index 3b44382f4..7c367778c 100644 --- a/api/poktroll/migration/morse_offchain.pulsar.go +++ b/api/poktroll/migration/morse_offchain.pulsar.go @@ -4407,7 +4407,7 @@ func (x *fastReflection_MorseValidator) ProtoMethods() *protoiface.Methods { // but are not completely identical to their Morse counterparts, not all of which are defined // as protobuf types in the Morse codebase. // -// Morse also leverages pb.Any types, as well as the gogoproto.casttype option in several places. +// Morse leverages pb.Any types, as well as the gogoproto.casttype option in several places. // All usages of pb.Any have been replaced with equivalent protobuf types // (i.e. an interstitial type with `type` and/or `value` field(s)). // All usages of gogoproto.casttype which previously referenced Morse data structures have been removed. @@ -4415,10 +4415,10 @@ func (x *fastReflection_MorseValidator) ProtoMethods() *protoiface.Methods { // external lib type that the Morse type was wrapping (e.g. address and public key fields). // // These types are used by the migration subcommand to transform -// the Morse state export into the Shannon state import. -// Ref: `poktrolld migrate collect-morse-accounts ...` +// the Morse state export into the Shannon state import like so: +// $ poktrolld migrate collect-morse-accounts ... // -// They ARE NOT persisted on-chain (Shannon) at any point. +// CRITICAL: These types are offchain and ARE NOT persisted onchain (Shannon) at any point. const ( // Verify that this generated code is sufficiently up-to-date. @@ -4427,10 +4427,11 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -// MorseStateExport is the data structure that is serialized and output when running -// `pocket utils export-genesis-for-reset`. +// MorseStateExport is the data structure that is serialized and output when running: // -// See: https://editor.swagger.io/?url=https://raw.githubusercontent.com/pokt-network/pocket-core/staging/doc/specs/rpc-spec.yaml#operations-query-post_query_state +// $ pocket utils export-genesis-for-reset ... +// +// Ref: https://editor.swagger.io/?url=https://raw.githubusercontent.com/pokt-network/pocket-core/staging/doc/specs/rpc-spec.yaml#operations-query-post_query_state type MorseStateExport struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -4571,7 +4572,7 @@ func (x *MorseApplications) GetApplications() []*MorseApplication { return nil } -// A wrapper around a list of Morse accounts. +// A wrapper around a list of MorseAuthAccount. // It encapsulates the minimum information required to import Morse accounts. // // See: https://github.com/pokt-network/pocket-core/blob/staging/x/auth/types/genesis.go#L9 @@ -4611,7 +4612,7 @@ func (x *MorseAuth) GetAccounts() []*MorseAuthAccount { } // MorseAccount: -// * Wraps Morse account information to conform to Morse genesis structure +// * Wraps MorseAuthAccount information to conform to Morse genesis structure // * Represents only externally owned accounts (not module accounts) // * Avoids pb.Any serialization since only external accounts needed for migration type MorseAuthAccount struct { @@ -4710,8 +4711,9 @@ type MorseApplication struct { Address []byte `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` // PublicKey is the binary representation of a Morse application's ed25519 public key. PublicKey []byte `protobuf:"bytes,2,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"` - Jailed bool `protobuf:"varint,3,opt,name=jailed,proto3" json:"jailed,omitempty"` - Status int32 `protobuf:"varint,4,opt,name=status,proto3" json:"status,omitempty"` + // TODO_MAINNET(@Olshansk): Should status and/or jailed be considered during the migration, and if so, how? + Jailed bool `protobuf:"varint,3,opt,name=jailed,proto3" json:"jailed,omitempty"` + Status int32 `protobuf:"varint,4,opt,name=status,proto3" json:"status,omitempty"` // The string representation of the BigInt amount of upokt. StakedTokens string `protobuf:"bytes,6,opt,name=staked_tokens,json=stakedTokens,proto3" json:"staked_tokens,omitempty"` } @@ -4784,8 +4786,9 @@ type MorseValidator struct { Address []byte `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` // The binary representation of a Morse application's ed25519 public key. PublicKey []byte `protobuf:"bytes,2,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"` - Jailed bool `protobuf:"varint,3,opt,name=jailed,proto3" json:"jailed,omitempty"` - Status int32 `protobuf:"varint,4,opt,name=status,proto3" json:"status,omitempty"` + // TODO_MAINNET(@Olshansk): Should status and/or jailed be considered during the migration, and if so, how? + Jailed bool `protobuf:"varint,3,opt,name=jailed,proto3" json:"jailed,omitempty"` + Status int32 `protobuf:"varint,4,opt,name=status,proto3" json:"status,omitempty"` // The string representation of the BigInt amount of upokt. StakedTokens string `protobuf:"bytes,7,opt,name=staked_tokens,json=stakedTokens,proto3" json:"staked_tokens,omitempty"` } diff --git a/api/poktroll/migration/morse_onchain.pulsar.go b/api/poktroll/migration/morse_onchain.pulsar.go index 25980c925..2f450abb1 100644 --- a/api/poktroll/migration/morse_onchain.pulsar.go +++ b/api/poktroll/migration/morse_onchain.pulsar.go @@ -1872,7 +1872,9 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -// MorseAccountState is the on-chain representation of the imported account state from Morse. +// MorseAccountState is the onchain representation of the imported account state from Morse. +// +// TODO_UPNEXT(@bryanchriswhite): Decompose this on-chain structure. type MorseAccountState struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -1925,10 +1927,13 @@ type MorseAccount struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // A binary representation of the address corresponding to a Morse application's ed25519 public key. - Address []byte `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` - PubKey *MorsePublicKey `protobuf:"bytes,2,opt,name=pub_key,json=pubKey,proto3" json:"pub_key,omitempty"` - Coins []*v1beta1.Coin `protobuf:"bytes,3,rep,name=coins,proto3" json:"coins,omitempty"` + // A hex-encoded representation of the address corresponding to a Morse application's ed25519 public key. + Address []byte `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + // The ed25519 public key of the account. + PubKey *MorsePublicKey `protobuf:"bytes,2,opt,name=pub_key,json=pubKey,proto3" json:"pub_key,omitempty"` + // The total amount of uPOKT owned by the account; this is a sum of the balance and any actor stakes. + // NB: The default stake/balance proportion is derived from Morse query response(s) at the time of claiming. + Coins []*v1beta1.Coin `protobuf:"bytes,3,rep,name=coins,proto3" json:"coins,omitempty"` } func (x *MorseAccount) Reset() { diff --git a/cmd/poktrolld/cmd/migrate/migrate.go b/cmd/poktrolld/cmd/migrate/migrate.go index 19a5ca499..a04689be2 100644 --- a/cmd/poktrolld/cmd/migrate/migrate.go +++ b/cmd/poktrolld/cmd/migrate/migrate.go @@ -184,7 +184,7 @@ func collectInputAccountBalances(inputState *migrationtypes.MorseStateExport, mo for exportAccountIdx, exportAccount := range inputState.AppState.Auth.Accounts { // DEV_NOTE: Ignore module accounts. // TODO_MAINNET(@olshansky): Revisit this business logic to ensure that no tokens go missing from Morse to Shannon. - // Ref: https://github.com/pokt-network/poktroll/pull/1039/files#r1934711993 + // See: https://github.com/pokt-network/poktroll/issues/1066 regarding supply validation. if exportAccount.Type != "posmint/Account" { logger.Warn(). Str("type", exportAccount.Type). diff --git a/proto/poktroll/migration/morse_onchain.proto b/proto/poktroll/migration/morse_onchain.proto index f801dae47..2e2352b10 100644 --- a/proto/poktroll/migration/morse_onchain.proto +++ b/proto/poktroll/migration/morse_onchain.proto @@ -10,27 +10,13 @@ option go_package = "github.com/pokt-network/poktroll/x/migration/types"; option (gogoproto.stable_marshaler_all) = true; // MorseAccountState is the onchain representation of the imported account state from Morse. +// +// TODO_UPNEXT(@bryanchriswhite): Decompose this on-chain structure. message MorseAccountState { - // TODO_MAINNET(@bryanchriswhite): Explain the rationale of this mapping/index/#PUC or refactor. map accounts_idx_by_address = 1 [(gogoproto.jsontag) = "accounts_idx_by_address", (gogoproto.moretags) = "yaml:\"accounts_idx_by_address\""]; repeated MorseAccount accounts = 2 [(gogoproto.jsontag) = "accounts", (gogoproto.moretags) = "yaml:\"accounts\""]; } -// TODO_MAINNET(@bryanchriswhite): Refactor morse_onchain and morse_offchain to support -// the full all migration requirements. -// This is being merged in as an interim step in #1039 but will not be the final implementation. -// Example: -// 1. Assume a Supplier in Morse with 100 staked POKT (in escrow) and 100 unstaked POKT (balance) -// 2. When ClaimPOKTMorseAsSupplier is called: -// - A single new Supplier in Shannon will be staked with 100 POKT (escrow) and 100 POKT (balance) -// - The configs (i.e. the data) staked for can vary as long as the total POKT (staked + unstaked) is equivalent -// - The following situations ARE NOT allowed: -// - Claiming different variations of total amounts (e.g. 99 unstaked POKT + 101 staked POKT) -// - Partial claiming (e.g. 1 staked POKT + 1 unstaked POKT) -// - Claiming to multiple Supplier -// 3. The above needs to be done for each actor -// 4. Caveats: edge cases like "min stake amounts" will be accounted for in the operational process to ensure they're non issues - // MorseAccount is an analog of the Morse ProtoBaseAccount type. // It encapsulates the minimum information required to import accounts. // @@ -41,15 +27,14 @@ message MorseAccount { option (gogoproto.goproto_stringer) = true; option (cosmos_proto.implements_interface) = "Account"; - // address is a binary (not hex) representation of the Account's ed25519 public key. + // A hex-encoded representation of the address corresponding to a Morse application's ed25519 public key. bytes address = 1 [(gogoproto.jsontag) = "address", (gogoproto.casttype) = "github.com/cometbft/cometbft/crypto.Address"]; // The ed25519 public key of the account. MorsePublicKey pub_key = 2 [(gogoproto.jsontag) = "public_key", (gogoproto.moretags) = "yaml:\"public_key\""]; - // The amount of uPOKT held by the account - // TODO_MAINNET(@bryanchriswhite): Refactor to another approach supporting the new requirements to claim as a staked actor. - // This could be a split to "staked_coins" + "unstaked_coins" (as an example), but any other approaches is valid. + // The total amount of uPOKT owned by the account; this is a sum of the balance and any actor stakes. + // NB: The default stake/balance proportion is derived from Morse query response(s) at the time of claiming. repeated cosmos.base.v1beta1.Coin coins = 3 [(gogoproto.nullable) = false, (gogoproto.jsontag) = "coins"]; } @@ -57,4 +42,4 @@ message MorseAccount { // NB: All Morse account public keys will be ed25519 keys by definition. message MorsePublicKey { bytes value = 2 [(gogoproto.casttype) = "crypto/ed25519.PublicKey"]; -} \ No newline at end of file +} diff --git a/x/application/types/types.pb.go b/x/application/types/types.pb.go index ec942dee4..0bc5d391a 100644 --- a/x/application/types/types.pb.go +++ b/x/application/types/types.pb.go @@ -27,7 +27,7 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// Application represents the on-chain definition and state of an application +// Application represents the onchain definition and state of an application type Application struct { // Bech32 address of the application Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` diff --git a/x/migration/types/morse_offchain.pb.go b/x/migration/types/morse_offchain.pb.go index 10b11344e..09cd6657f 100644 --- a/x/migration/types/morse_offchain.pb.go +++ b/x/migration/types/morse_offchain.pb.go @@ -8,7 +8,7 @@ // but are not completely identical to their Morse counterparts, not all of which are defined // as protobuf types in the Morse codebase. // -// Morse also leverages pb.Any types, as well as the gogoproto.casttype option in several places. +// Morse leverages pb.Any types, as well as the gogoproto.casttype option in several places. // All usages of pb.Any have been replaced with equivalent protobuf types // (i.e. an interstitial type with `type` and/or `value` field(s)). // All usages of gogoproto.casttype which previously referenced Morse data structures have been removed. @@ -16,10 +16,10 @@ // external lib type that the Morse type was wrapping (e.g. address and public key fields). // // These types are used by the migration subcommand to transform -// the Morse state export into the Shannon state import. -// Ref: `poktrolld migrate collect-morse-accounts ...` +// the Morse state export into the Shannon state import like so: +// $ poktrolld migrate collect-morse-accounts ... // -// They ARE NOT persisted on-chain (Shannon) at any point. +// CRITICAL: These types are offchain and ARE NOT persisted onchain (Shannon) at any point. package types @@ -45,10 +45,11 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// MorseStateExport is the data structure that is serialized and output when running -// `pocket utils export-genesis-for-reset`. +// MorseStateExport is the data structure that is serialized and output when running: // -// See: https://editor.swagger.io/?url=https://raw.githubusercontent.com/pokt-network/pocket-core/staging/doc/specs/rpc-spec.yaml#operations-query-post_query_state +// $ pocket utils export-genesis-for-reset ... +// +// Ref: https://editor.swagger.io/?url=https://raw.githubusercontent.com/pokt-network/pocket-core/staging/doc/specs/rpc-spec.yaml#operations-query-post_query_state type MorseStateExport struct { // app_hash is the Morse tendermint state hash. AppHash string `protobuf:"bytes,1,opt,name=app_hash,json=appHash,proto3" json:"app_hash"` @@ -204,7 +205,7 @@ func (m *MorseApplications) GetApplications() []*MorseApplication { return nil } -// A wrapper around a list of Morse accounts. +// A wrapper around a list of MorseAuthAccount. // It encapsulates the minimum information required to import Morse accounts. // // See: https://github.com/pokt-network/pocket-core/blob/staging/x/auth/types/genesis.go#L9 @@ -249,7 +250,7 @@ func (m *MorseAuth) GetAccounts() []*MorseAuthAccount { } // MorseAccount: -// * Wraps Morse account information to conform to Morse genesis structure +// * Wraps MorseAuthAccount information to conform to Morse genesis structure // * Represents only externally owned accounts (not module accounts) // * Avoids pb.Any serialization since only external accounts needed for migration type MorseAuthAccount struct { @@ -354,8 +355,9 @@ type MorseApplication struct { Address github_com_cometbft_cometbft_crypto.Address `protobuf:"bytes,1,opt,name=address,proto3,casttype=github.com/cometbft/cometbft/crypto.Address" json:"address" yaml:"address"` // PublicKey is the binary representation of a Morse application's ed25519 public key. PublicKey []byte `protobuf:"bytes,2,opt,name=public_key,json=publicKey,proto3" json:"public_key" yaml:"public_key"` - Jailed bool `protobuf:"varint,3,opt,name=jailed,proto3" json:"jailed" yaml:"jailed"` - Status int32 `protobuf:"varint,4,opt,name=status,proto3" json:"status" yaml:"status"` + // TODO_MAINNET(@Olshansk): Should status and/or jailed be considered during the migration, and if so, how? + Jailed bool `protobuf:"varint,3,opt,name=jailed,proto3" json:"jailed" yaml:"jailed"` + Status int32 `protobuf:"varint,4,opt,name=status,proto3" json:"status" yaml:"status"` // The string representation of the BigInt amount of upokt. StakedTokens string `protobuf:"bytes,6,opt,name=staked_tokens,json=stakedTokens,proto3" json:"tokens"` } @@ -398,8 +400,9 @@ type MorseValidator struct { Address github_com_cometbft_cometbft_crypto.Address `protobuf:"bytes,1,opt,name=address,proto3,casttype=github.com/cometbft/cometbft/crypto.Address" json:"address" yaml:"address"` // The binary representation of a Morse application's ed25519 public key. PublicKey []byte `protobuf:"bytes,2,opt,name=public_key,json=publicKey,proto3" json:"public_key" yaml:"public_key"` - Jailed bool `protobuf:"varint,3,opt,name=jailed,proto3" json:"jailed"` - Status int32 `protobuf:"varint,4,opt,name=status,proto3" json:"status"` + // TODO_MAINNET(@Olshansk): Should status and/or jailed be considered during the migration, and if so, how? + Jailed bool `protobuf:"varint,3,opt,name=jailed,proto3" json:"jailed"` + Status int32 `protobuf:"varint,4,opt,name=status,proto3" json:"status"` // The string representation of the BigInt amount of upokt. StakedTokens string `protobuf:"bytes,7,opt,name=staked_tokens,json=stakedTokens,proto3" json:"tokens"` } diff --git a/x/migration/types/morse_onchain.pb.go b/x/migration/types/morse_onchain.pb.go index 0ce2c7f08..3b3d7421e 100644 --- a/x/migration/types/morse_onchain.pb.go +++ b/x/migration/types/morse_onchain.pb.go @@ -28,7 +28,9 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// MorseAccountState is the on-chain representation of the imported account state from Morse. +// MorseAccountState is the onchain representation of the imported account state from Morse. +// +// TODO_UPNEXT(@bryanchriswhite): Decompose this on-chain structure. type MorseAccountState struct { AccountsIdxByAddress map[string]uint64 `protobuf:"bytes,1,rep,name=accounts_idx_by_address,json=accountsIdxByAddress,proto3" json:"accounts_idx_by_address" yaml:"accounts_idx_by_address" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` Accounts []*MorseAccount `protobuf:"bytes,2,rep,name=accounts,proto3" json:"accounts" yaml:"accounts"` @@ -82,10 +84,13 @@ func (m *MorseAccountState) GetAccounts() []*MorseAccount { // // See: https://github.com/pokt-network/pocket-core/blob/staging/proto/x/auth/auth.proto#L14. type MorseAccount struct { - // A binary representation of the address corresponding to a Morse application's ed25519 public key. + // A hex-encoded representation of the address corresponding to a Morse application's ed25519 public key. Address github_com_cometbft_cometbft_crypto.Address `protobuf:"bytes,1,opt,name=address,proto3,casttype=github.com/cometbft/cometbft/crypto.Address" json:"address"` - PubKey *MorsePublicKey `protobuf:"bytes,2,opt,name=pub_key,json=pubKey,proto3" json:"public_key" yaml:"public_key"` - Coins []types.Coin `protobuf:"bytes,3,rep,name=coins,proto3" json:"coins"` + // The ed25519 public key of the account. + PubKey *MorsePublicKey `protobuf:"bytes,2,opt,name=pub_key,json=pubKey,proto3" json:"public_key" yaml:"public_key"` + // The total amount of uPOKT owned by the account; this is a sum of the balance and any actor stakes. + // NB: The default stake/balance proportion is derived from Morse query response(s) at the time of claiming. + Coins []types.Coin `protobuf:"bytes,3,rep,name=coins,proto3" json:"coins"` } func (m *MorseAccount) Reset() { *m = MorseAccount{} }