From d28e0786198a401c6124955b7fc8524729b1ba87 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Mon, 3 Feb 2025 14:01:23 +0100 Subject: [PATCH] chore: review feedback improvements --- api/poktroll/migration/legacy.pulsar.go | 2 +- api/poktroll/migration/query.pulsar.go | 2 + api/poktroll/migration/query_grpc.pb.go | 4 +- api/poktroll/migration/tx.pulsar.go | 182 +++++++++++++----- proto/poktroll/migration/legacy.proto | 2 +- proto/poktroll/migration/query.proto | 4 +- proto/poktroll/migration/tx.proto | 14 ++ x/migration/keeper/morse_account_state.go | 18 +- .../keeper/msg_server_morse_account_state.go | 5 + .../keeper/query_morse_account_state.go | 8 +- x/migration/types/legacy.pb.go | 2 +- .../types/messages_morse_account_state.go | 23 ++- x/migration/types/query.pb.go | 6 +- x/migration/types/tx.pb.go | 139 +++++++++---- 14 files changed, 306 insertions(+), 105 deletions(-) diff --git a/api/poktroll/migration/legacy.pulsar.go b/api/poktroll/migration/legacy.pulsar.go index 4d77f6a6a..22ddc0d33 100644 --- a/api/poktroll/migration/legacy.pulsar.go +++ b/api/poktroll/migration/legacy.pulsar.go @@ -4417,7 +4417,7 @@ const ( ) // MorseStateExport is the data structure that is serialized and output when running -// `pocket utils export-genesis-for-reset`. +// `pocket util export-genesis-for-reset`. // 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 type MorseStateExport struct { state protoimpl.MessageState diff --git a/api/poktroll/migration/query.pulsar.go b/api/poktroll/migration/query.pulsar.go index a55078adb..789e3d8bd 100644 --- a/api/poktroll/migration/query.pulsar.go +++ b/api/poktroll/migration/query.pulsar.go @@ -1675,6 +1675,7 @@ func (x *QueryParamsResponse) GetParams() *Params { return nil } +// Queries the MorseAccountState which was created with MsgCreateMorseAccountState. type QueryGetMorseAccountStateRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -1701,6 +1702,7 @@ func (*QueryGetMorseAccountStateRequest) Descriptor() ([]byte, []int) { return file_poktroll_migration_query_proto_rawDescGZIP(), []int{2} } +// Returns the MorseAccountState. If it has not yet been created, an error is returned. type QueryGetMorseAccountStateResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache diff --git a/api/poktroll/migration/query_grpc.pb.go b/api/poktroll/migration/query_grpc.pb.go index 844fc9b41..cb56f319a 100644 --- a/api/poktroll/migration/query_grpc.pb.go +++ b/api/poktroll/migration/query_grpc.pb.go @@ -31,7 +31,7 @@ const ( type QueryClient interface { // Parameters queries the parameters of the module. Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) - // Queries a MorseAccountState by index. + // Queries the MorseAccountState. MorseAccountState(ctx context.Context, in *QueryGetMorseAccountStateRequest, opts ...grpc.CallOption) (*QueryGetMorseAccountStateResponse, error) } @@ -71,7 +71,7 @@ func (c *queryClient) MorseAccountState(ctx context.Context, in *QueryGetMorseAc type QueryServer interface { // Parameters queries the parameters of the module. Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) - // Queries a MorseAccountState by index. + // Queries the MorseAccountState. MorseAccountState(context.Context, *QueryGetMorseAccountStateRequest) (*QueryGetMorseAccountStateResponse, error) mustEmbedUnimplementedQueryServer() } diff --git a/api/poktroll/migration/tx.pulsar.go b/api/poktroll/migration/tx.pulsar.go index 2ef7ccf2e..3e529cf34 100644 --- a/api/poktroll/migration/tx.pulsar.go +++ b/api/poktroll/migration/tx.pulsar.go @@ -872,9 +872,10 @@ func (x *fastReflection_MsgUpdateParamsResponse) ProtoMethods() *protoiface.Meth } var ( - md_MsgCreateMorseAccountState protoreflect.MessageDescriptor - fd_MsgCreateMorseAccountState_authority protoreflect.FieldDescriptor - fd_MsgCreateMorseAccountState_morse_account_state protoreflect.FieldDescriptor + md_MsgCreateMorseAccountState protoreflect.MessageDescriptor + fd_MsgCreateMorseAccountState_authority protoreflect.FieldDescriptor + fd_MsgCreateMorseAccountState_morse_account_state protoreflect.FieldDescriptor + fd_MsgCreateMorseAccountState_morse_account_state_hash protoreflect.FieldDescriptor ) func init() { @@ -882,6 +883,7 @@ func init() { md_MsgCreateMorseAccountState = File_poktroll_migration_tx_proto.Messages().ByName("MsgCreateMorseAccountState") fd_MsgCreateMorseAccountState_authority = md_MsgCreateMorseAccountState.Fields().ByName("authority") fd_MsgCreateMorseAccountState_morse_account_state = md_MsgCreateMorseAccountState.Fields().ByName("morse_account_state") + fd_MsgCreateMorseAccountState_morse_account_state_hash = md_MsgCreateMorseAccountState.Fields().ByName("morse_account_state_hash") } var _ protoreflect.Message = (*fastReflection_MsgCreateMorseAccountState)(nil) @@ -961,6 +963,12 @@ func (x *fastReflection_MsgCreateMorseAccountState) Range(f func(protoreflect.Fi return } } + if len(x.MorseAccountStateHash) != 0 { + value := protoreflect.ValueOfBytes(x.MorseAccountStateHash) + if !f(fd_MsgCreateMorseAccountState_morse_account_state_hash, value) { + return + } + } } // Has reports whether a field is populated. @@ -980,6 +988,8 @@ func (x *fastReflection_MsgCreateMorseAccountState) Has(fd protoreflect.FieldDes return x.Authority != "" case "poktroll.migration.MsgCreateMorseAccountState.morse_account_state": return x.MorseAccountState != nil + case "poktroll.migration.MsgCreateMorseAccountState.morse_account_state_hash": + return len(x.MorseAccountStateHash) != 0 default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.migration.MsgCreateMorseAccountState")) @@ -1000,6 +1010,8 @@ func (x *fastReflection_MsgCreateMorseAccountState) Clear(fd protoreflect.FieldD x.Authority = "" case "poktroll.migration.MsgCreateMorseAccountState.morse_account_state": x.MorseAccountState = nil + case "poktroll.migration.MsgCreateMorseAccountState.morse_account_state_hash": + x.MorseAccountStateHash = nil default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.migration.MsgCreateMorseAccountState")) @@ -1022,6 +1034,9 @@ func (x *fastReflection_MsgCreateMorseAccountState) Get(descriptor protoreflect. case "poktroll.migration.MsgCreateMorseAccountState.morse_account_state": value := x.MorseAccountState return protoreflect.ValueOfMessage(value.ProtoReflect()) + case "poktroll.migration.MsgCreateMorseAccountState.morse_account_state_hash": + value := x.MorseAccountStateHash + return protoreflect.ValueOfBytes(value) default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.migration.MsgCreateMorseAccountState")) @@ -1046,6 +1061,8 @@ func (x *fastReflection_MsgCreateMorseAccountState) Set(fd protoreflect.FieldDes x.Authority = value.Interface().(string) case "poktroll.migration.MsgCreateMorseAccountState.morse_account_state": x.MorseAccountState = value.Message().Interface().(*MorseAccountState) + case "poktroll.migration.MsgCreateMorseAccountState.morse_account_state_hash": + x.MorseAccountStateHash = value.Bytes() default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.migration.MsgCreateMorseAccountState")) @@ -1073,6 +1090,8 @@ func (x *fastReflection_MsgCreateMorseAccountState) Mutable(fd protoreflect.Fiel return protoreflect.ValueOfMessage(x.MorseAccountState.ProtoReflect()) case "poktroll.migration.MsgCreateMorseAccountState.authority": panic(fmt.Errorf("field authority of message poktroll.migration.MsgCreateMorseAccountState is not mutable")) + case "poktroll.migration.MsgCreateMorseAccountState.morse_account_state_hash": + panic(fmt.Errorf("field morse_account_state_hash of message poktroll.migration.MsgCreateMorseAccountState is not mutable")) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.migration.MsgCreateMorseAccountState")) @@ -1091,6 +1110,8 @@ func (x *fastReflection_MsgCreateMorseAccountState) NewField(fd protoreflect.Fie case "poktroll.migration.MsgCreateMorseAccountState.morse_account_state": m := new(MorseAccountState) return protoreflect.ValueOfMessage(m.ProtoReflect()) + case "poktroll.migration.MsgCreateMorseAccountState.morse_account_state_hash": + return protoreflect.ValueOfBytes(nil) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.migration.MsgCreateMorseAccountState")) @@ -1168,6 +1189,10 @@ func (x *fastReflection_MsgCreateMorseAccountState) ProtoMethods() *protoiface.M l = options.Size(x.MorseAccountState) n += 1 + l + runtime.Sov(uint64(l)) } + l = len(x.MorseAccountStateHash) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } if x.unknownFields != nil { n += len(x.unknownFields) } @@ -1197,6 +1222,13 @@ func (x *fastReflection_MsgCreateMorseAccountState) ProtoMethods() *protoiface.M i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } + if len(x.MorseAccountStateHash) > 0 { + i -= len(x.MorseAccountStateHash) + copy(dAtA[i:], x.MorseAccountStateHash) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.MorseAccountStateHash))) + i-- + dAtA[i] = 0x1a + } if x.MorseAccountState != nil { encoded, err := options.Marshal(x.MorseAccountState) if err != nil { @@ -1335,6 +1367,40 @@ func (x *fastReflection_MsgCreateMorseAccountState) ProtoMethods() *protoiface.M return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err } iNdEx = postIndex + case 3: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field MorseAccountStateHash", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.MorseAccountStateHash = append(x.MorseAccountStateHash[:0], dAtA[iNdEx:postIndex]...) + if x.MorseAccountStateHash == nil { + x.MorseAccountStateHash = []byte{} + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := runtime.Skip(dAtA[iNdEx:]) @@ -1927,14 +1993,24 @@ func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { return file_poktroll_migration_tx_proto_rawDescGZIP(), []int{1} } +// MsgCreateMorseAccountState is used to create the on-chain MorseAccountState ONLY ONCE (per network / re-genesis). type MsgCreateMorseAccountState struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields // authority is the address that controls the module (defaults to x/gov unless overwritten). - Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + // the account state derived from the Morse state export and the `poktrolld migrate collect-morse-accounts` command. MorseAccountState *MorseAccountState `protobuf:"bytes,2,opt,name=morse_account_state,json=morseAccountState,proto3" json:"morse_account_state,omitempty"` + // expected sha256 hash of the morse_account_state. If this hash does not match the on-chain + // computation, the transaction will fail. Social consensus regarding the correctness of + // morse_account_state should have be achieved off-chain and can be verified on-chain by + // comparing this hash with that of a locally derived Morse state export: + // E.g., `poktrolld migrate collect-morse-accounts $<(pocket util export-genesis-for-reset)`. + // See: `pocket util export-genesis-for-migration --help` & `poktrolld migrate collect-morse-accounts --help` + // for more details. + MorseAccountStateHash []byte `protobuf:"bytes,3,opt,name=morse_account_state_hash,json=morseAccountStateHash,proto3" json:"morse_account_state_hash,omitempty"` } func (x *MsgCreateMorseAccountState) Reset() { @@ -1971,12 +2047,23 @@ func (x *MsgCreateMorseAccountState) GetMorseAccountState() *MorseAccountState { return nil } +func (x *MsgCreateMorseAccountState) GetMorseAccountStateHash() []byte { + if x != nil { + return x.MorseAccountStateHash + } + return nil +} + +// MsgCreateMorseAccountStateResponse represents an on-chain summary of the result of the corresponding MsgCreateMorseAccountState. type MsgCreateMorseAccountStateResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - StateHash []byte `protobuf:"bytes,1,opt,name=state_hash,json=stateHash,proto3" json:"state_hash,omitempty"` + // On-chain computed sha256 hash of the morse_account_state provided in the corresponding MsgCreateMorseAccountState. + StateHash []byte `protobuf:"bytes,1,opt,name=state_hash,json=stateHash,proto3" json:"state_hash,omitempty"` + // Number of accounts (EOAs) which were collected from the Morse state export, which may be claimed. + // NOTE: Application and supplier actor stakes are consolidated into their corresponding account balances. NumAccounts uint64 `protobuf:"varint,2,opt,name=num_accounts,json=numAccounts,proto3" json:"num_accounts,omitempty"` } @@ -2043,8 +2130,8 @@ var file_poktroll_migration_tx_proto_rawDesc = []byte{ 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x78, 0x2f, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x22, 0x19, 0x0a, 0x17, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, - 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0xd8, - 0x01, 0x0a, 0x1a, 0x4d, 0x73, 0x67, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4d, 0x6f, 0x72, 0x73, + 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0xaf, + 0x02, 0x0a, 0x1a, 0x4d, 0x73, 0x67, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4d, 0x6f, 0x72, 0x73, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x36, 0x0a, 0x09, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, @@ -2056,44 +2143,49 @@ var file_poktroll_migration_tx_proto_rawDesc = []byte{ 0x6f, 0x75, 0x6e, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x42, 0x1b, 0xc8, 0xde, 0x1f, 0x00, 0xea, 0xde, 0x1f, 0x13, 0x6d, 0x6f, 0x72, 0x73, 0x65, 0x5f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x52, 0x11, 0x6d, 0x6f, 0x72, 0x73, 0x65, 0x41, 0x63, 0x63, - 0x6f, 0x75, 0x6e, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x3a, 0x0e, 0x82, 0xe7, 0xb0, 0x2a, 0x09, - 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x22, 0x88, 0x01, 0x0a, 0x22, 0x4d, 0x73, - 0x67, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4d, 0x6f, 0x72, 0x73, 0x65, 0x41, 0x63, 0x63, 0x6f, - 0x75, 0x6e, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x2d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0c, 0x42, 0x0e, 0xea, 0xde, 0x1f, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, - 0x68, 0x61, 0x73, 0x68, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x65, 0x48, 0x61, 0x73, 0x68, 0x12, - 0x33, 0x0a, 0x0c, 0x6e, 0x75, 0x6d, 0x5f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x04, 0x42, 0x10, 0xea, 0xde, 0x1f, 0x0c, 0x6e, 0x75, 0x6d, 0x5f, 0x61, - 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x52, 0x0b, 0x6e, 0x75, 0x6d, 0x41, 0x63, 0x63, 0x6f, - 0x75, 0x6e, 0x74, 0x73, 0x32, 0xf2, 0x01, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x12, 0x60, 0x0a, 0x0c, - 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x23, 0x2e, 0x70, - 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, - 0x73, 0x1a, 0x2b, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x6d, 0x69, 0x67, - 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, - 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x81, - 0x01, 0x0a, 0x17, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4d, 0x6f, 0x72, 0x73, 0x65, 0x41, 0x63, - 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x2e, 0x2e, 0x70, 0x6f, 0x6b, - 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, - 0x4d, 0x73, 0x67, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4d, 0x6f, 0x72, 0x73, 0x65, 0x41, 0x63, - 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x1a, 0x36, 0x2e, 0x70, 0x6f, 0x6b, - 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, - 0x4d, 0x73, 0x67, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4d, 0x6f, 0x72, 0x73, 0x65, 0x41, 0x63, - 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x1a, 0x05, 0x80, 0xe7, 0xb0, 0x2a, 0x01, 0x42, 0xb3, 0x01, 0xd8, 0xe2, 0x1e, 0x01, - 0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x6d, - 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, - 0x6f, 0x50, 0x01, 0x5a, 0x23, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, - 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x6d, - 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0xa2, 0x02, 0x03, 0x50, 0x4d, 0x58, 0xaa, 0x02, - 0x12, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x4d, 0x69, 0x67, 0x72, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0xca, 0x02, 0x12, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x4d, - 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0xe2, 0x02, 0x1e, 0x50, 0x6f, 0x6b, 0x74, 0x72, - 0x6f, 0x6c, 0x6c, 0x5c, 0x4d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5c, 0x47, 0x50, - 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x13, 0x50, 0x6f, 0x6b, 0x74, - 0x72, 0x6f, 0x6c, 0x6c, 0x3a, 0x3a, 0x4d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6f, 0x75, 0x6e, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x55, 0x0a, 0x18, 0x6d, 0x6f, 0x72, + 0x73, 0x65, 0x5f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, + 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x1c, 0xea, 0xde, 0x1f, + 0x18, 0x6d, 0x6f, 0x72, 0x73, 0x65, 0x5f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x73, + 0x74, 0x61, 0x74, 0x65, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x52, 0x15, 0x6d, 0x6f, 0x72, 0x73, 0x65, + 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x48, 0x61, 0x73, 0x68, + 0x3a, 0x0e, 0x82, 0xe7, 0xb0, 0x2a, 0x09, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, + 0x22, 0x88, 0x01, 0x0a, 0x22, 0x4d, 0x73, 0x67, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4d, 0x6f, + 0x72, 0x73, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x65, + 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x0e, 0xea, 0xde, 0x1f, + 0x0a, 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x52, 0x09, 0x73, 0x74, 0x61, + 0x74, 0x65, 0x48, 0x61, 0x73, 0x68, 0x12, 0x33, 0x0a, 0x0c, 0x6e, 0x75, 0x6d, 0x5f, 0x61, 0x63, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x42, 0x10, 0xea, 0xde, + 0x1f, 0x0c, 0x6e, 0x75, 0x6d, 0x5f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x52, 0x0b, + 0x6e, 0x75, 0x6d, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x32, 0xf2, 0x01, 0x0a, 0x03, + 0x4d, 0x73, 0x67, 0x12, 0x60, 0x0a, 0x0c, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, + 0x61, 0x6d, 0x73, 0x12, 0x23, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x6d, + 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x1a, 0x2b, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, + 0x6f, 0x6c, 0x6c, 0x2e, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x4d, 0x73, + 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x81, 0x01, 0x0a, 0x17, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, + 0x4d, 0x6f, 0x72, 0x73, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x53, 0x74, 0x61, 0x74, + 0x65, 0x12, 0x2e, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x6d, 0x69, 0x67, + 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x4d, 0x73, 0x67, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, + 0x4d, 0x6f, 0x72, 0x73, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x53, 0x74, 0x61, 0x74, + 0x65, 0x1a, 0x36, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x6d, 0x69, 0x67, + 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x4d, 0x73, 0x67, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, + 0x4d, 0x6f, 0x72, 0x73, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x53, 0x74, 0x61, 0x74, + 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x1a, 0x05, 0x80, 0xe7, 0xb0, 0x2a, 0x01, + 0x42, 0xb3, 0x01, 0xd8, 0xe2, 0x1e, 0x01, 0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x2e, 0x70, 0x6f, 0x6b, + 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, + 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x23, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x70, 0x6f, 0x6b, + 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0xa2, + 0x02, 0x03, 0x50, 0x4d, 0x58, 0xaa, 0x02, 0x12, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, + 0x2e, 0x4d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0xca, 0x02, 0x12, 0x50, 0x6f, 0x6b, + 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x4d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0xe2, + 0x02, 0x1e, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x4d, 0x69, 0x67, 0x72, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, + 0xea, 0x02, 0x13, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x3a, 0x3a, 0x4d, 0x69, 0x67, + 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/proto/poktroll/migration/legacy.proto b/proto/poktroll/migration/legacy.proto index 23dafcbea..75c7882ae 100644 --- a/proto/poktroll/migration/legacy.proto +++ b/proto/poktroll/migration/legacy.proto @@ -17,7 +17,7 @@ option go_package = "github.com/pokt-network/poktroll/x/migration/types"; option (gogoproto.stable_marshaler_all) = true; // MorseStateExport is the data structure that is serialized and output when running -// `pocket utils export-genesis-for-reset`. +// `pocket util export-genesis-for-reset`. // 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 message MorseStateExport { // app_hash is the Morse tendermint state hash. diff --git a/proto/poktroll/migration/query.proto b/proto/poktroll/migration/query.proto index adadca6e9..09336c175 100644 --- a/proto/poktroll/migration/query.proto +++ b/proto/poktroll/migration/query.proto @@ -21,7 +21,7 @@ service Query { } - // Queries a MorseAccountState by index. + // Queries the MorseAccountState. rpc MorseAccountState (QueryGetMorseAccountStateRequest) returns (QueryGetMorseAccountStateResponse) { option (google.api.http).get = "/pokt-network/poktroll/migration/morse_account_state"; @@ -37,8 +37,10 @@ message QueryParamsResponse { Params params = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; } +// Queries the MorseAccountState which was created with MsgCreateMorseAccountState. message QueryGetMorseAccountStateRequest {} +// Returns the MorseAccountState. If it has not yet been created, an error is returned. message QueryGetMorseAccountStateResponse { MorseAccountState MorseAccountState = 1 [(gogoproto.nullable) = false]; } diff --git a/proto/poktroll/migration/tx.proto b/proto/poktroll/migration/tx.proto index 2c83f02f2..617369160 100644 --- a/proto/poktroll/migration/tx.proto +++ b/proto/poktroll/migration/tx.proto @@ -39,15 +39,29 @@ message MsgUpdateParams { // MsgUpdateParams message. message MsgUpdateParamsResponse {} +// MsgCreateMorseAccountState is used to create the on-chain MorseAccountState ONLY ONCE (per network / re-genesis). message MsgCreateMorseAccountState { option (cosmos.msg.v1.signer) = "authority"; // authority is the address that controls the module (defaults to x/gov unless overwritten). string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // the account state derived from the Morse state export and the `poktrolld migrate collect-morse-accounts` command. MorseAccountState morse_account_state = 2 [(gogoproto.jsontag) = "morse_account_state", (gogoproto.nullable) = false]; + // expected sha256 hash of the morse_account_state. If this hash does not match the on-chain + // computation, the transaction will fail. Social consensus regarding the correctness of + // morse_account_state should have be achieved off-chain and can be verified on-chain by + // comparing this hash with that of a locally derived Morse state export: + // E.g., `poktrolld migrate collect-morse-accounts $<(pocket util export-genesis-for-reset)`. + // See: `pocket util export-genesis-for-migration --help` & `poktrolld migrate collect-morse-accounts --help` + // for more details. + bytes morse_account_state_hash = 3 [(gogoproto.jsontag) = "morse_account_state_hash"]; } +// MsgCreateMorseAccountStateResponse represents an on-chain summary of the result of the corresponding MsgCreateMorseAccountState. message MsgCreateMorseAccountStateResponse { + // On-chain computed sha256 hash of the morse_account_state provided in the corresponding MsgCreateMorseAccountState. bytes state_hash = 1 [(gogoproto.jsontag) = "state_hash"]; + // Number of accounts (EOAs) which were collected from the Morse state export, which may be claimed. + // NOTE: Application and supplier actor stakes are consolidated into their corresponding account balances. uint64 num_accounts = 2 [(gogoproto.jsontag) = "num_accounts"]; } diff --git a/x/migration/keeper/morse_account_state.go b/x/migration/keeper/morse_account_state.go index b88311d16..d985e186f 100644 --- a/x/migration/keeper/morse_account_state.go +++ b/x/migration/keeper/morse_account_state.go @@ -9,26 +9,26 @@ import ( "github.com/pokt-network/poktroll/x/migration/types" ) -// SetMorseAccountState set morseAccountState in the store +// SetMorseAccountState sets morseAccountState in the store func (k Keeper) SetMorseAccountState(ctx context.Context, morseAccountState types.MorseAccountState) { storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) store := prefix.NewStore(storeAdapter, types.KeyPrefix(types.MorseAccountStateKey)) - b := k.cdc.MustMarshal(&morseAccountState) - store.Set([]byte{0}, b) + morseAccountStateBz := k.cdc.MustMarshal(&morseAccountState) + store.Set([]byte{0}, morseAccountStateBz) } // GetMorseAccountState returns morseAccountState -func (k Keeper) GetMorseAccountState(ctx context.Context) (val types.MorseAccountState, found bool) { +func (k Keeper) GetMorseAccountState(ctx context.Context) (morseAccountState types.MorseAccountState, found bool) { storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) store := prefix.NewStore(storeAdapter, types.KeyPrefix(types.MorseAccountStateKey)) - b := store.Get([]byte{0}) - if b == nil { - return val, false + morseAccountStateBz := store.Get([]byte{0}) + if morseAccountStateBz == nil { + return morseAccountState, false } - k.cdc.MustUnmarshal(b, &val) - return val, true + k.cdc.MustUnmarshal(morseAccountStateBz, &morseAccountState) + return morseAccountState, true } // RemoveMorseAccountState removes morseAccountState from the store diff --git a/x/migration/keeper/msg_server_morse_account_state.go b/x/migration/keeper/msg_server_morse_account_state.go index 9ae9b6139..cc3d91083 100644 --- a/x/migration/keeper/msg_server_morse_account_state.go +++ b/x/migration/keeper/msg_server_morse_account_state.go @@ -10,6 +10,7 @@ import ( "github.com/pokt-network/poktroll/x/migration/types" ) +// CreateMorseAccountState creates the on-chain MorseAccountState ONLY ONCE (per network / re-genesis). func (k msgServer) CreateMorseAccountState(goCtx context.Context, msg *types.MsgCreateMorseAccountState) (*types.MsgCreateMorseAccountStateResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) @@ -19,6 +20,10 @@ func (k msgServer) CreateMorseAccountState(goCtx context.Context, msg *types.Msg return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "already set") } + if err := msg.ValidateBasic(); err != nil { + return nil, err + } + k.SetMorseAccountState( ctx, msg.MorseAccountState, diff --git a/x/migration/keeper/query_morse_account_state.go b/x/migration/keeper/query_morse_account_state.go index c61fff565..0d3a0e6a9 100644 --- a/x/migration/keeper/query_morse_account_state.go +++ b/x/migration/keeper/query_morse_account_state.go @@ -10,16 +10,18 @@ import ( "github.com/pokt-network/poktroll/x/migration/types" ) +// MorseAccountState returns the morseAccountState, if one has been created; +// otherwise, an error is returned. func (k Keeper) MorseAccountState(goCtx context.Context, req *types.QueryGetMorseAccountStateRequest) (*types.QueryGetMorseAccountStateResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") } ctx := sdk.UnwrapSDKContext(goCtx) - val, found := k.GetMorseAccountState(ctx) - if !found { + morseAccountState, isFound := k.GetMorseAccountState(ctx) + if !isFound { return nil, status.Error(codes.NotFound, "not found") } - return &types.QueryGetMorseAccountStateResponse{MorseAccountState: val}, nil + return &types.QueryGetMorseAccountStateResponse{MorseAccountState: morseAccountState}, nil } diff --git a/x/migration/types/legacy.pb.go b/x/migration/types/legacy.pb.go index 302a8614a..78a752ab4 100644 --- a/x/migration/types/legacy.pb.go +++ b/x/migration/types/legacy.pb.go @@ -35,7 +35,7 @@ var _ = math.Inf 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`. +// `pocket util export-genesis-for-reset`. // 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 type MorseStateExport struct { // app_hash is the Morse tendermint state hash. diff --git a/x/migration/types/messages_morse_account_state.go b/x/migration/types/messages_morse_account_state.go index 28081eab6..75cce1c4a 100644 --- a/x/migration/types/messages_morse_account_state.go +++ b/x/migration/types/messages_morse_account_state.go @@ -1,7 +1,9 @@ package types import ( - errorsmod "cosmossdk.io/errors" + "bytes" + + "cosmossdk.io/store/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) @@ -16,9 +18,22 @@ func NewMsgCreateMorseAccountState(authority string, morseAccountState MorseAcco } func (msg *MsgCreateMorseAccountState) ValidateBasic() error { - _, err := sdk.AccAddressFromBech32(msg.Authority) + if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil { + return sdkerrors.ErrInvalidAddress.Wrapf("invalid authority address (%s)", err) + } + + actualHash, err := msg.MorseAccountState.GetHash() if err != nil { - return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + return err } - return nil + + expectedHash := msg.GetMorseAccountStateHash() + if bytes.Equal(actualHash, expectedHash) { + return nil + } + + return types.ErrInvalidRequest.Wrapf( + "Morse account state hash (%s) doesn't match expected: (%s)", + actualHash, expectedHash, + ) } diff --git a/x/migration/types/query.pb.go b/x/migration/types/query.pb.go index a9f299c3d..9b9248c9b 100644 --- a/x/migration/types/query.pb.go +++ b/x/migration/types/query.pb.go @@ -106,6 +106,7 @@ func (m *QueryParamsResponse) GetParams() Params { return Params{} } +// Queries the MorseAccountState which was created with MsgCreateMorseAccountState. type QueryGetMorseAccountStateRequest struct { } @@ -138,6 +139,7 @@ func (m *QueryGetMorseAccountStateRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryGetMorseAccountStateRequest proto.InternalMessageInfo +// Returns the MorseAccountState. If it has not yet been created, an error is returned. type QueryGetMorseAccountStateResponse struct { MorseAccountState MorseAccountState `protobuf:"bytes,1,opt,name=MorseAccountState,proto3" json:"MorseAccountState"` } @@ -232,7 +234,7 @@ const _ = grpc.SupportPackageIsVersion4 type QueryClient interface { // Parameters queries the parameters of the module. Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) - // Queries a MorseAccountState by index. + // Queries the MorseAccountState. MorseAccountState(ctx context.Context, in *QueryGetMorseAccountStateRequest, opts ...grpc.CallOption) (*QueryGetMorseAccountStateResponse, error) } @@ -266,7 +268,7 @@ func (c *queryClient) MorseAccountState(ctx context.Context, in *QueryGetMorseAc type QueryServer interface { // Parameters queries the parameters of the module. Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) - // Queries a MorseAccountState by index. + // Queries the MorseAccountState. MorseAccountState(context.Context, *QueryGetMorseAccountStateRequest) (*QueryGetMorseAccountStateResponse, error) } diff --git a/x/migration/types/tx.pb.go b/x/migration/types/tx.pb.go index dfa97537b..57d682ebc 100644 --- a/x/migration/types/tx.pb.go +++ b/x/migration/types/tx.pb.go @@ -116,10 +116,20 @@ func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo +// MsgCreateMorseAccountState is used to create the on-chain MorseAccountState ONLY ONCE (per network / re-genesis). type MsgCreateMorseAccountState struct { // authority is the address that controls the module (defaults to x/gov unless overwritten). - Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + // the account state derived from the Morse state export and the `poktrolld migrate collect-morse-accounts` command. MorseAccountState MorseAccountState `protobuf:"bytes,2,opt,name=morse_account_state,json=morseAccountState,proto3" json:"morse_account_state"` + // expected sha256 hash of the morse_account_state. If this hash does not match the on-chain + // computation, the transaction will fail. Social consensus regarding the correctness of + // morse_account_state should have be achieved off-chain and can be verified on-chain by + // comparing this hash with that of a locally derived Morse state export: + // E.g., `poktrolld migrate collect-morse-accounts $<(pocket util export-genesis-for-reset)`. + // See: `pocket util export-genesis-for-migration --help` & `poktrolld migrate collect-morse-accounts --help` + // for more details. + MorseAccountStateHash []byte `protobuf:"bytes,3,opt,name=morse_account_state_hash,json=morseAccountStateHash,proto3" json:"morse_account_state_hash"` } func (m *MsgCreateMorseAccountState) Reset() { *m = MsgCreateMorseAccountState{} } @@ -165,8 +175,19 @@ func (m *MsgCreateMorseAccountState) GetMorseAccountState() MorseAccountState { return MorseAccountState{} } +func (m *MsgCreateMorseAccountState) GetMorseAccountStateHash() []byte { + if m != nil { + return m.MorseAccountStateHash + } + return nil +} + +// MsgCreateMorseAccountStateResponse represents an on-chain summary of the result of the corresponding MsgCreateMorseAccountState. type MsgCreateMorseAccountStateResponse struct { - StateHash []byte `protobuf:"bytes,1,opt,name=state_hash,json=stateHash,proto3" json:"state_hash"` + // On-chain computed sha256 hash of the morse_account_state provided in the corresponding MsgCreateMorseAccountState. + StateHash []byte `protobuf:"bytes,1,opt,name=state_hash,json=stateHash,proto3" json:"state_hash"` + // Number of accounts (EOAs) which were collected from the Morse state export, which may be claimed. + // NOTE: Application and supplier actor stakes are consolidated into their corresponding account balances. NumAccounts uint64 `protobuf:"varint,2,opt,name=num_accounts,json=numAccounts,proto3" json:"num_accounts"` } @@ -223,40 +244,41 @@ func init() { func init() { proto.RegisterFile("poktroll/migration/tx.proto", fileDescriptor_21658240592266b6) } var fileDescriptor_21658240592266b6 = []byte{ - // 519 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x53, 0xbf, 0x6b, 0xdb, 0x40, - 0x14, 0xf6, 0xf5, 0x47, 0xc0, 0x17, 0x93, 0x36, 0x6a, 0xc0, 0x8e, 0x02, 0x52, 0x50, 0x5b, 0x08, - 0x2e, 0x96, 0xa8, 0x03, 0x29, 0x04, 0x3a, 0x44, 0x5d, 0xba, 0x18, 0x82, 0x42, 0x97, 0x2e, 0xee, - 0xc5, 0x3e, 0x4e, 0x22, 0x39, 0x9d, 0xb8, 0x3b, 0xb5, 0xc9, 0xd6, 0x76, 0x2a, 0x9d, 0xfa, 0x67, - 0x74, 0xf4, 0xd0, 0x7f, 0xa0, 0x5b, 0xc6, 0xd0, 0xc9, 0x93, 0x29, 0xf6, 0x60, 0xf0, 0xd8, 0xbf, - 0xa0, 0x48, 0x3a, 0x39, 0xb1, 0x23, 0x41, 0x9b, 0x45, 0xba, 0x7b, 0xef, 0xbb, 0xef, 0x7d, 0xdf, - 0xbb, 0x77, 0x70, 0x2b, 0x62, 0x27, 0x92, 0xb3, 0xd3, 0x53, 0x87, 0x06, 0x84, 0x23, 0x19, 0xb0, - 0xd0, 0x91, 0x67, 0x76, 0xc4, 0x99, 0x64, 0x9a, 0x96, 0x27, 0xed, 0x79, 0x52, 0x5f, 0x47, 0x34, - 0x08, 0x99, 0x93, 0x7e, 0x33, 0x98, 0x5e, 0xef, 0x31, 0x41, 0x99, 0x70, 0xa8, 0x20, 0xce, 0xfb, - 0xe7, 0xc9, 0x4f, 0x25, 0x36, 0xb3, 0x44, 0x37, 0xdd, 0x39, 0xd9, 0x46, 0xa5, 0x36, 0x08, 0x23, - 0x2c, 0x8b, 0x27, 0x2b, 0x15, 0x35, 0x0b, 0xd4, 0x44, 0x88, 0x23, 0x9a, 0x1f, 0x33, 0x8a, 0xe4, - 0x9e, 0x47, 0x58, 0xe5, 0xad, 0x9f, 0x00, 0x3e, 0xe8, 0x08, 0xf2, 0x26, 0xea, 0x23, 0x89, 0x0f, - 0xd3, 0x93, 0xda, 0x1e, 0xac, 0xa2, 0x58, 0xfa, 0x8c, 0x07, 0xf2, 0xbc, 0x01, 0xb6, 0xc1, 0x4e, - 0xd5, 0x6d, 0xfc, 0xfa, 0xd1, 0xda, 0x50, 0x7a, 0x0e, 0xfa, 0x7d, 0x8e, 0x85, 0x38, 0x92, 0x3c, - 0x08, 0x89, 0x77, 0x05, 0xd5, 0x5e, 0xc2, 0x95, 0xac, 0x76, 0xe3, 0xce, 0x36, 0xd8, 0x59, 0x6d, - 0xeb, 0xf6, 0xcd, 0x76, 0xd8, 0x59, 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, 0xbb, 0xf9, 0x04, 0x60, - 0xbd, 0xec, 0x32, 0xed, 0x12, 0xa2, 0x12, 0xbc, 0xbe, 0xf7, 0x7f, 0xf8, 0x5c, 0x83, 0x7e, 0xff, - 0x63, 0x32, 0xb6, 0xee, 0xe1, 0xc5, 0xd8, 0x00, 0x97, 0x63, 0x03, 0x0c, 0xc7, 0x06, 0xf8, 0x3d, - 0x36, 0xc0, 0xb7, 0x89, 0x51, 0xb9, 0x9c, 0x18, 0x95, 0xe1, 0xc4, 0xa8, 0xbc, 0x6d, 0x93, 0x40, - 0xfa, 0xf1, 0xb1, 0xdd, 0x63, 0xd4, 0x49, 0xca, 0xb4, 0x42, 0x2c, 0x3f, 0x30, 0x7e, 0xe2, 0x14, - 0x4e, 0x74, 0xfa, 0x22, 0x8f, 0x57, 0xd2, 0x27, 0xb9, 0xfb, 0x37, 0x00, 0x00, 0xff, 0xff, 0xeb, - 0x8c, 0x0f, 0x52, 0x63, 0x04, 0x00, 0x00, + // 541 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x53, 0x3f, 0x6f, 0xd3, 0x5e, + 0x14, 0xcd, 0x6b, 0x7f, 0xbf, 0x4a, 0x79, 0x8d, 0x0a, 0x35, 0x45, 0x71, 0x5d, 0x64, 0x47, 0x06, + 0xa4, 0x28, 0x28, 0xb6, 0x48, 0xa5, 0x22, 0x55, 0x62, 0xa8, 0x59, 0x58, 0x22, 0x55, 0xae, 0xba, + 0xb0, 0x84, 0xd7, 0xe4, 0xc9, 0xb6, 0xda, 0xe7, 0x67, 0xbd, 0xf7, 0x0c, 0xed, 0x06, 0x4c, 0x88, + 0x89, 0x8f, 0xc1, 0x46, 0x06, 0xbe, 0x00, 0x5b, 0xc7, 0x8a, 0xa9, 0x93, 0x85, 0x92, 0x21, 0x52, + 0x46, 0x3e, 0x01, 0xf2, 0xbf, 0x34, 0x69, 0x6c, 0x09, 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01, 0xac, 0x97, 0xed, 0x88, 0x51, 0x42, 0x54, 0x82, 0x57, 0xf6, 0xfe, + 0x0e, 0x9f, 0x7b, 0x50, 0xfe, 0x7f, 0x17, 0x5f, 0x83, 0x75, 0x78, 0x39, 0x52, 0xc1, 0xd5, 0x48, + 0x05, 0xd7, 0x23, 0x15, 0xfc, 0x1c, 0xa9, 0xe0, 0xf3, 0x58, 0xad, 0x5c, 0x8d, 0xd5, 0xca, 0xf5, + 0x58, 0xad, 0xbc, 0xea, 0x38, 0x9e, 0x70, 0xc3, 0x13, 0xa3, 0x4f, 0x89, 0x19, 0xcb, 0xb4, 0x7d, + 0x2c, 0xde, 0x52, 0x76, 0x6a, 0x16, 0x1e, 0x4a, 0x72, 0xe8, 0x27, 0x6b, 0xc9, 0xa5, 0xef, 0xfe, + 0x0e, 0x00, 0x00, 0xff, 0xff, 0x6c, 0x34, 0xcf, 0x74, 0xba, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -462,6 +484,13 @@ func (m *MsgCreateMorseAccountState) MarshalToSizedBuffer(dAtA []byte) (int, err _ = i var l int _ = l + if len(m.MorseAccountStateHash) > 0 { + i -= len(m.MorseAccountStateHash) + copy(dAtA[i:], m.MorseAccountStateHash) + i = encodeVarintTx(dAtA, i, uint64(len(m.MorseAccountStateHash))) + i-- + dAtA[i] = 0x1a + } { size, err := m.MorseAccountState.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -564,6 +593,10 @@ func (m *MsgCreateMorseAccountState) Size() (n int) { } l = m.MorseAccountState.Size() n += 1 + l + sovTx(uint64(l)) + l = len(m.MorseAccountStateHash) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } return n } @@ -848,6 +881,40 @@ func (m *MsgCreateMorseAccountState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MorseAccountStateHash", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MorseAccountStateHash = append(m.MorseAccountStateHash[:0], dAtA[iNdEx:postIndex]...) + if m.MorseAccountStateHash == nil { + m.MorseAccountStateHash = []byte{} + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:])