diff --git a/api/poktroll/migration/event.pulsar.go b/api/poktroll/migration/event.pulsar.go new file mode 100644 index 000000000..5e22ebcfe --- /dev/null +++ b/api/poktroll/migration/event.pulsar.go @@ -0,0 +1,713 @@ +// Code generated by protoc-gen-go-pulsar. DO NOT EDIT. +package migration + +import ( + _ "cosmossdk.io/api/cosmos/base/v1beta1" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + runtime "github.com/cosmos/cosmos-proto/runtime" + _ "github.com/cosmos/gogoproto/gogoproto" + _ "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" + io "io" + reflect "reflect" + sync "sync" +) + +var ( + md_EventCreateMorseAccountState protoreflect.MessageDescriptor + fd_EventCreateMorseAccountState_created_at_height protoreflect.FieldDescriptor + fd_EventCreateMorseAccountState_morse_account_state_hash protoreflect.FieldDescriptor + fd_EventCreateMorseAccountState_num_accounts protoreflect.FieldDescriptor +) + +func init() { + file_poktroll_migration_event_proto_init() + md_EventCreateMorseAccountState = File_poktroll_migration_event_proto.Messages().ByName("EventCreateMorseAccountState") + fd_EventCreateMorseAccountState_created_at_height = md_EventCreateMorseAccountState.Fields().ByName("created_at_height") + fd_EventCreateMorseAccountState_morse_account_state_hash = md_EventCreateMorseAccountState.Fields().ByName("morse_account_state_hash") + fd_EventCreateMorseAccountState_num_accounts = md_EventCreateMorseAccountState.Fields().ByName("num_accounts") +} + +var _ protoreflect.Message = (*fastReflection_EventCreateMorseAccountState)(nil) + +type fastReflection_EventCreateMorseAccountState EventCreateMorseAccountState + +func (x *EventCreateMorseAccountState) ProtoReflect() protoreflect.Message { + return (*fastReflection_EventCreateMorseAccountState)(x) +} + +func (x *EventCreateMorseAccountState) slowProtoReflect() protoreflect.Message { + mi := &file_poktroll_migration_event_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_EventCreateMorseAccountState_messageType fastReflection_EventCreateMorseAccountState_messageType +var _ protoreflect.MessageType = fastReflection_EventCreateMorseAccountState_messageType{} + +type fastReflection_EventCreateMorseAccountState_messageType struct{} + +func (x fastReflection_EventCreateMorseAccountState_messageType) Zero() protoreflect.Message { + return (*fastReflection_EventCreateMorseAccountState)(nil) +} +func (x fastReflection_EventCreateMorseAccountState_messageType) New() protoreflect.Message { + return new(fastReflection_EventCreateMorseAccountState) +} +func (x fastReflection_EventCreateMorseAccountState_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_EventCreateMorseAccountState +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_EventCreateMorseAccountState) Descriptor() protoreflect.MessageDescriptor { + return md_EventCreateMorseAccountState +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_EventCreateMorseAccountState) Type() protoreflect.MessageType { + return _fastReflection_EventCreateMorseAccountState_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_EventCreateMorseAccountState) New() protoreflect.Message { + return new(fastReflection_EventCreateMorseAccountState) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_EventCreateMorseAccountState) Interface() protoreflect.ProtoMessage { + return (*EventCreateMorseAccountState)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_EventCreateMorseAccountState) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.CreatedAtHeight != int64(0) { + value := protoreflect.ValueOfInt64(x.CreatedAtHeight) + if !f(fd_EventCreateMorseAccountState_created_at_height, value) { + return + } + } + if len(x.MorseAccountStateHash) != 0 { + value := protoreflect.ValueOfBytes(x.MorseAccountStateHash) + if !f(fd_EventCreateMorseAccountState_morse_account_state_hash, value) { + return + } + } + if x.NumAccounts != uint64(0) { + value := protoreflect.ValueOfUint64(x.NumAccounts) + if !f(fd_EventCreateMorseAccountState_num_accounts, value) { + return + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_EventCreateMorseAccountState) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "poktroll.migration.EventCreateMorseAccountState.created_at_height": + return x.CreatedAtHeight != int64(0) + case "poktroll.migration.EventCreateMorseAccountState.morse_account_state_hash": + return len(x.MorseAccountStateHash) != 0 + case "poktroll.migration.EventCreateMorseAccountState.num_accounts": + return x.NumAccounts != uint64(0) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.migration.EventCreateMorseAccountState")) + } + panic(fmt.Errorf("message poktroll.migration.EventCreateMorseAccountState does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_EventCreateMorseAccountState) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "poktroll.migration.EventCreateMorseAccountState.created_at_height": + x.CreatedAtHeight = int64(0) + case "poktroll.migration.EventCreateMorseAccountState.morse_account_state_hash": + x.MorseAccountStateHash = nil + case "poktroll.migration.EventCreateMorseAccountState.num_accounts": + x.NumAccounts = uint64(0) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.migration.EventCreateMorseAccountState")) + } + panic(fmt.Errorf("message poktroll.migration.EventCreateMorseAccountState does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_EventCreateMorseAccountState) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "poktroll.migration.EventCreateMorseAccountState.created_at_height": + value := x.CreatedAtHeight + return protoreflect.ValueOfInt64(value) + case "poktroll.migration.EventCreateMorseAccountState.morse_account_state_hash": + value := x.MorseAccountStateHash + return protoreflect.ValueOfBytes(value) + case "poktroll.migration.EventCreateMorseAccountState.num_accounts": + value := x.NumAccounts + return protoreflect.ValueOfUint64(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.migration.EventCreateMorseAccountState")) + } + panic(fmt.Errorf("message poktroll.migration.EventCreateMorseAccountState does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_EventCreateMorseAccountState) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "poktroll.migration.EventCreateMorseAccountState.created_at_height": + x.CreatedAtHeight = value.Int() + case "poktroll.migration.EventCreateMorseAccountState.morse_account_state_hash": + x.MorseAccountStateHash = value.Bytes() + case "poktroll.migration.EventCreateMorseAccountState.num_accounts": + x.NumAccounts = value.Uint() + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.migration.EventCreateMorseAccountState")) + } + panic(fmt.Errorf("message poktroll.migration.EventCreateMorseAccountState does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_EventCreateMorseAccountState) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "poktroll.migration.EventCreateMorseAccountState.created_at_height": + panic(fmt.Errorf("field created_at_height of message poktroll.migration.EventCreateMorseAccountState is not mutable")) + case "poktroll.migration.EventCreateMorseAccountState.morse_account_state_hash": + panic(fmt.Errorf("field morse_account_state_hash of message poktroll.migration.EventCreateMorseAccountState is not mutable")) + case "poktroll.migration.EventCreateMorseAccountState.num_accounts": + panic(fmt.Errorf("field num_accounts of message poktroll.migration.EventCreateMorseAccountState is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.migration.EventCreateMorseAccountState")) + } + panic(fmt.Errorf("message poktroll.migration.EventCreateMorseAccountState does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_EventCreateMorseAccountState) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "poktroll.migration.EventCreateMorseAccountState.created_at_height": + return protoreflect.ValueOfInt64(int64(0)) + case "poktroll.migration.EventCreateMorseAccountState.morse_account_state_hash": + return protoreflect.ValueOfBytes(nil) + case "poktroll.migration.EventCreateMorseAccountState.num_accounts": + return protoreflect.ValueOfUint64(uint64(0)) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.migration.EventCreateMorseAccountState")) + } + panic(fmt.Errorf("message poktroll.migration.EventCreateMorseAccountState does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_EventCreateMorseAccountState) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in poktroll.migration.EventCreateMorseAccountState", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_EventCreateMorseAccountState) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_EventCreateMorseAccountState) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_EventCreateMorseAccountState) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_EventCreateMorseAccountState) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*EventCreateMorseAccountState) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + if x.CreatedAtHeight != 0 { + n += 1 + runtime.Sov(uint64(x.CreatedAtHeight)) + } + l = len(x.MorseAccountStateHash) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.NumAccounts != 0 { + n += 1 + runtime.Sov(uint64(x.NumAccounts)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*EventCreateMorseAccountState) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if x.NumAccounts != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.NumAccounts)) + i-- + dAtA[i] = 0x18 + } + 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] = 0x12 + } + if x.CreatedAtHeight != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.CreatedAtHeight)) + i-- + dAtA[i] = 0x8 + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*EventCreateMorseAccountState) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + 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++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: EventCreateMorseAccountState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: EventCreateMorseAccountState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field CreatedAtHeight", wireType) + } + x.CreatedAtHeight = 0 + 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++ + x.CreatedAtHeight |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + 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 + case 3: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field NumAccounts", wireType) + } + x.NumAccounts = 0 + 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++ + x.NumAccounts |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.27.0 +// protoc (unknown) +// source: poktroll/migration/event.proto + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// EventUploadMorseState is emitted when the MorseAccountState is created on-chain. +type EventCreateMorseAccountState struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The height (on Shannon) at which the MorseAccountState was created on-chain. + CreatedAtHeight int64 `protobuf:"varint,1,opt,name=created_at_height,json=createdAtHeight,proto3" json:"created_at_height,omitempty"` + // The sha256 has of the MorseAccountState. + MorseAccountStateHash []byte `protobuf:"bytes,2,opt,name=morse_account_state_hash,json=morseAccountStateHash,proto3" json:"morse_account_state_hash,omitempty"` + // The 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,3,opt,name=num_accounts,json=numAccounts,proto3" json:"num_accounts,omitempty"` +} + +func (x *EventCreateMorseAccountState) Reset() { + *x = EventCreateMorseAccountState{} + if protoimpl.UnsafeEnabled { + mi := &file_poktroll_migration_event_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *EventCreateMorseAccountState) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EventCreateMorseAccountState) ProtoMessage() {} + +// Deprecated: Use EventCreateMorseAccountState.ProtoReflect.Descriptor instead. +func (*EventCreateMorseAccountState) Descriptor() ([]byte, []int) { + return file_poktroll_migration_event_proto_rawDescGZIP(), []int{0} +} + +func (x *EventCreateMorseAccountState) GetCreatedAtHeight() int64 { + if x != nil { + return x.CreatedAtHeight + } + return 0 +} + +func (x *EventCreateMorseAccountState) GetMorseAccountStateHash() []byte { + if x != nil { + return x.MorseAccountStateHash + } + return nil +} + +func (x *EventCreateMorseAccountState) GetNumAccounts() uint64 { + if x != nil { + return x.NumAccounts + } + return 0 +} + +var File_poktroll_migration_event_proto protoreflect.FileDescriptor + +var file_poktroll_migration_event_proto_rawDesc = []byte{ + 0x0a, 0x1e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x6d, 0x69, 0x67, 0x72, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x12, 0x12, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x6d, 0x69, 0x67, 0x72, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x1a, 0x19, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5f, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, + 0x14, 0x67, 0x6f, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x67, 0x6f, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, + 0x73, 0x65, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x63, 0x6f, 0x69, 0x6e, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1d, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, + 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x26, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x6d, + 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x6d, 0x6f, 0x72, 0x73, 0x65, 0x5f, 0x6f, + 0x6e, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xed, 0x01, 0x0a, + 0x1c, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4d, 0x6f, 0x72, 0x73, + 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x41, 0x0a, + 0x11, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x5f, 0x68, 0x65, 0x69, 0x67, + 0x68, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x42, 0x15, 0xea, 0xde, 0x1f, 0x11, 0x63, 0x72, + 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x5f, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x52, + 0x0f, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, + 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, 0x02, 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, 0x12, 0x33, 0x0a, 0x0c, 0x6e, 0x75, 0x6d, 0x5f, 0x61, + 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x18, 0x03, 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, 0x42, 0xb6, 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, 0x0a, 0x45, 0x76, 0x65, + 0x6e, 0x74, 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 ( + file_poktroll_migration_event_proto_rawDescOnce sync.Once + file_poktroll_migration_event_proto_rawDescData = file_poktroll_migration_event_proto_rawDesc +) + +func file_poktroll_migration_event_proto_rawDescGZIP() []byte { + file_poktroll_migration_event_proto_rawDescOnce.Do(func() { + file_poktroll_migration_event_proto_rawDescData = protoimpl.X.CompressGZIP(file_poktroll_migration_event_proto_rawDescData) + }) + return file_poktroll_migration_event_proto_rawDescData +} + +var file_poktroll_migration_event_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_poktroll_migration_event_proto_goTypes = []interface{}{ + (*EventCreateMorseAccountState)(nil), // 0: poktroll.migration.EventCreateMorseAccountState +} +var file_poktroll_migration_event_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_poktroll_migration_event_proto_init() } +func file_poktroll_migration_event_proto_init() { + if File_poktroll_migration_event_proto != nil { + return + } + file_poktroll_migration_morse_onchain_proto_init() + if !protoimpl.UnsafeEnabled { + file_poktroll_migration_event_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*EventCreateMorseAccountState); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_poktroll_migration_event_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_poktroll_migration_event_proto_goTypes, + DependencyIndexes: file_poktroll_migration_event_proto_depIdxs, + MessageInfos: file_poktroll_migration_event_proto_msgTypes, + }.Build() + File_poktroll_migration_event_proto = out.File + file_poktroll_migration_event_proto_rawDesc = nil + file_poktroll_migration_event_proto_goTypes = nil + file_poktroll_migration_event_proto_depIdxs = nil +} diff --git a/cmd/poktrolld/cmd/migrate/migrate_test.go b/cmd/poktrolld/cmd/migrate/migrate_test.go index 5b2aa5696..f6370a066 100644 --- a/cmd/poktrolld/cmd/migrate/migrate_test.go +++ b/cmd/poktrolld/cmd/migrate/migrate_test.go @@ -1,23 +1,18 @@ package migrate import ( - "encoding/binary" "fmt" "math" - "math/rand" "os" "path/filepath" "strings" "testing" - cometcrypto "github.com/cometbft/cometbft/crypto/ed25519" cmtjson "github.com/cometbft/cometbft/libs/json" - cosmostypes "github.com/cosmos/cosmos-sdk/types" - "github.com/regen-network/gocuke" "github.com/stretchr/testify/require" - "github.com/pokt-network/poktroll/app/volatile" "github.com/pokt-network/poktroll/pkg/polylog/polyzero" + "github.com/pokt-network/poktroll/testutil/testmigration" migrationtypes "github.com/pokt-network/poktroll/x/migration/types" ) @@ -32,7 +27,7 @@ func TestCollectMorseAccounts(t *testing.T) { inputFile, err := os.CreateTemp(tmpDir, "morse-state-input.json") require.NoError(t, err) - morseStateExportBz, morseAccountStateBz := newMorseStateExportAndAccountState(t, 10) + morseStateExportBz, morseAccountStateBz := testmigration.NewMorseStateExportAndAccountStateBytes(t, 10) _, err = inputFile.Write(morseStateExportBz) require.NoError(t, err) @@ -61,7 +56,7 @@ func TestNewTestMorseStateExport(t *testing.T) { for i := 1; i < 10; i++ { t.Run(fmt.Sprintf("num_accounts=%d", i), func(t *testing.T) { morseStateExport := new(migrationtypes.MorseStateExport) - stateExportBz, _ := newMorseStateExportAndAccountState(t, i) + stateExportBz, _ := testmigration.NewMorseStateExportAndAccountStateBytes(t, i) err := cmtjson.Unmarshal(stateExportBz, morseStateExport) require.NoError(t, err) @@ -83,7 +78,7 @@ func BenchmarkTransformMorseState(b *testing.B) { for i := 0; i < 5; i++ { numAccounts := int(math.Pow10(i + 1)) morseStateExport := new(migrationtypes.MorseStateExport) - morseStateExportBz, _ := newMorseStateExportAndAccountState(b, numAccounts) + morseStateExportBz, _ := testmigration.NewMorseStateExportAndAccountStateBytes(b, numAccounts) err := cmtjson.Unmarshal(morseStateExportBz, morseStateExport) require.NoError(b, err) @@ -99,91 +94,3 @@ func BenchmarkTransformMorseState(b *testing.B) { }) } } - -// TODO_CONSIDERATION: Test/benchmark execution speed can be optimized by refactoring this to a pre-generate fixture. -func newMorseStateExportAndAccountState( - t gocuke.TestingT, - numAccounts int, -) (morseStateExportBz []byte, morseAccountStateBz []byte) { - morseStateExport := &migrationtypes.MorseStateExport{ - AppHash: "", - AppState: &migrationtypes.MorseTendermintAppState{ - Application: &migrationtypes.MorseApplications{}, - Auth: &migrationtypes.MorseAuth{}, - Pos: &migrationtypes.MorsePos{}, - }, - } - - morseAccountState := &migrationtypes.MorseAccountState{ - Accounts: make([]*migrationtypes.MorseAccount, numAccounts), - } - - for i := 1; i < numAccounts+1; i++ { - seedUint := rand.Uint64() - seedBz := make([]byte, 8) - binary.LittleEndian.PutUint64(seedBz, seedUint) - privKey := cometcrypto.GenPrivKeyFromSecret(seedBz) - pubKey := privKey.PubKey() - balanceAmount := int64(1e6*i + i) // i_000_00i - appStakeAmount := int64(1e5*i + (i * 10)) // i00_0i0 - supplierStakeAmount := int64(1e4*i + (i * 100)) // i0_i00 - sumAmount := balanceAmount + appStakeAmount + supplierStakeAmount // i_ii0_iii - - // Add an account. - morseStateExport.AppState.Auth.Accounts = append( - morseStateExport.AppState.Auth.Accounts, - &migrationtypes.MorseAuthAccount{ - Type: "posmint/Account", - Value: &migrationtypes.MorseAccount{ - Address: pubKey.Address(), - Coins: cosmostypes.NewCoins(cosmostypes.NewInt64Coin(volatile.DenomuPOKT, balanceAmount)), - PubKey: &migrationtypes.MorsePublicKey{ - Value: pubKey.Bytes(), - }, - }, - }, - ) - - // Add an application. - morseStateExport.AppState.Application.Applications = append( - morseStateExport.AppState.Application.Applications, - &migrationtypes.MorseApplication{ - Address: pubKey.Address(), - PublicKey: pubKey.Bytes(), - Jailed: false, - Status: 2, - StakedTokens: fmt.Sprintf("%d", appStakeAmount), - }, - ) - - // Add a supplier. - morseStateExport.AppState.Pos.Validators = append( - morseStateExport.AppState.Pos.Validators, - &migrationtypes.MorseValidator{ - Address: pubKey.Address(), - PublicKey: pubKey.Bytes(), - Jailed: false, - Status: 2, - StakedTokens: fmt.Sprintf("%d", supplierStakeAmount), - }, - ) - - // Add the account to the morseAccountState. - morseAccountState.Accounts[i-1] = &migrationtypes.MorseAccount{ - Address: pubKey.Address(), - Coins: cosmostypes.NewCoins(cosmostypes.NewInt64Coin(volatile.DenomuPOKT, sumAmount)), - PubKey: &migrationtypes.MorsePublicKey{ - Value: pubKey.Bytes(), - }, - } - } - - var err error - morseStateExportBz, err = cmtjson.Marshal(morseStateExport) - require.NoError(t, err) - - morseAccountStateBz, err = cmtjson.Marshal(morseAccountState) - require.NoError(t, err) - - return morseStateExportBz, morseAccountStateBz -} diff --git a/proto/poktroll/migration/event.proto b/proto/poktroll/migration/event.proto new file mode 100644 index 000000000..142abf6fc --- /dev/null +++ b/proto/poktroll/migration/event.proto @@ -0,0 +1,25 @@ +syntax = "proto3"; +package poktroll.migration; + +option go_package = "github.com/pokt-network/poktroll/x/migration/types"; +option (gogoproto.stable_marshaler_all) = true; + +import "cosmos_proto/cosmos.proto"; +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; + +import "poktroll/shared/service.proto"; +import "poktroll/migration/morse_onchain.proto"; + +// EventUploadMorseState is emitted when the MorseAccountState is created on-chain. +message EventCreateMorseAccountState { + // The height (on Shannon) at which the MorseAccountState was created on-chain. + int64 created_at_height = 1 [(gogoproto.jsontag) = "created_at_height"]; + + // The sha256 has of the MorseAccountState. + bytes morse_account_state_hash = 2 [(gogoproto.jsontag) = "morse_account_state_hash"]; + + // The 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 = 3 [(gogoproto.jsontag) = "num_accounts"]; +} diff --git a/testutil/testmigration/fixtures.go b/testutil/testmigration/fixtures.go new file mode 100644 index 000000000..a9ee7f96a --- /dev/null +++ b/testutil/testmigration/fixtures.go @@ -0,0 +1,132 @@ +package testmigration + +import ( + "encoding/binary" + "fmt" + "math/rand" + + cometcrypto "github.com/cometbft/cometbft/crypto/ed25519" + cmtjson "github.com/cometbft/cometbft/libs/json" + cosmostypes "github.com/cosmos/cosmos-sdk/types" + "github.com/regen-network/gocuke" + "github.com/stretchr/testify/require" + + "github.com/pokt-network/poktroll/app/volatile" + migrationtypes "github.com/pokt-network/poktroll/x/migration/types" +) + +// NewMorseStateExportAndAccountStateBytes returns: +// - A serialized MorseStateExport. +// This is the JSON output of `pocket util export-genesis-for-reset`. +// It is used to generate the MorseAccountState. +// - Its corresponding MorseAccountState. +// This is the JSON output of `poktrolld migrate collect-morse-accounts`. +// It is used to persist the canonical Morse migration state from on Shannon. +// +// The states are populated with: +// - Random account addresses +// - Monotonically increasing balances/stakes +// - One application per account +// - One supplier per account +func NewMorseStateExportAndAccountStateBytes( + t gocuke.TestingT, + numAccounts int, +) (morseStateExportBz []byte, morseAccountStateBz []byte) { + morseStateExport, morseAccountState := NewMorseStateExportAndAccountState(t, numAccounts) + + var err error + morseStateExportBz, err = cmtjson.Marshal(morseStateExport) + require.NoError(t, err) + + morseAccountStateBz, err = cmtjson.Marshal(morseAccountState) + require.NoError(t, err) + + return morseStateExportBz, morseAccountStateBz +} + +// NewMorseStateExportAndAccountState returns MorseStateExport and MorseAccountState +// structs populated with: +// - Random account addresses +// - Monotonically increasing balances/stakes +// - One application per account +// - One supplier per account +func NewMorseStateExportAndAccountState( + t gocuke.TestingT, numAccounts int, +) (export *migrationtypes.MorseStateExport, state *migrationtypes.MorseAccountState) { + t.Helper() + + morseStateExport := &migrationtypes.MorseStateExport{ + AppHash: "", + AppState: &migrationtypes.MorseTendermintAppState{ + Application: &migrationtypes.MorseApplications{}, + Auth: &migrationtypes.MorseAuth{}, + Pos: &migrationtypes.MorsePos{}, + }, + } + + morseAccountState := &migrationtypes.MorseAccountState{ + Accounts: make([]*migrationtypes.MorseAccount, numAccounts), + } + + for i := 1; i < numAccounts+1; i++ { + seedUint := rand.Uint64() + seedBz := make([]byte, 8) + binary.LittleEndian.PutUint64(seedBz, seedUint) + privKey := cometcrypto.GenPrivKeyFromSecret(seedBz) + pubKey := privKey.PubKey() + balanceAmount := int64(1e6*i + i) // i_000_00i + appStakeAmount := int64(1e5*i + (i * 10)) // i00_0i0 + supplierStakeAmount := int64(1e4*i + (i * 100)) // i0_i00 + sumAmount := balanceAmount + appStakeAmount + supplierStakeAmount // i_ii0_iii + + // Add an account. + morseStateExport.AppState.Auth.Accounts = append( + morseStateExport.AppState.Auth.Accounts, + &migrationtypes.MorseAuthAccount{ + Type: "posmint/Account", + Value: &migrationtypes.MorseAccount{ + Address: pubKey.Address(), + Coins: cosmostypes.NewCoins(cosmostypes.NewInt64Coin(volatile.DenomuPOKT, balanceAmount)), + PubKey: &migrationtypes.MorsePublicKey{ + Value: pubKey.Bytes(), + }, + }, + }, + ) + + // Add an application. + morseStateExport.AppState.Application.Applications = append( + morseStateExport.AppState.Application.Applications, + &migrationtypes.MorseApplication{ + Address: pubKey.Address(), + PublicKey: pubKey.Bytes(), + Jailed: false, + Status: 2, + StakedTokens: fmt.Sprintf("%d", appStakeAmount), + }, + ) + + // Add a supplier. + morseStateExport.AppState.Pos.Validators = append( + morseStateExport.AppState.Pos.Validators, + &migrationtypes.MorseValidator{ + Address: pubKey.Address(), + PublicKey: pubKey.Bytes(), + Jailed: false, + Status: 2, + StakedTokens: fmt.Sprintf("%d", supplierStakeAmount), + }, + ) + + // Add the account to the morseAccountState. + morseAccountState.Accounts[i-1] = &migrationtypes.MorseAccount{ + Address: pubKey.Address(), + Coins: cosmostypes.NewCoins(cosmostypes.NewInt64Coin(volatile.DenomuPOKT, sumAmount)), + PubKey: &migrationtypes.MorsePublicKey{ + Value: pubKey.Bytes(), + }, + } + } + + return morseStateExport, morseAccountState +} diff --git a/x/migration/keeper/msg_server_morse_account_state.go b/x/migration/keeper/msg_server_morse_account_state.go index 4c30c9f6b..e562138a7 100644 --- a/x/migration/keeper/msg_server_morse_account_state.go +++ b/x/migration/keeper/msg_server_morse_account_state.go @@ -3,34 +3,54 @@ package keeper import ( "context" - errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" - "github.com/pokt-network/poktroll/x/migration/types" + migrationtypes "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) +func (k msgServer) CreateMorseAccountState( + ctx context.Context, + msg *migrationtypes.MsgCreateMorseAccountState, +) (*migrationtypes.MsgCreateMorseAccountStateResponse, error) { + sdkCtx := sdk.UnwrapSDKContext(ctx) + logger := sdkCtx.Logger().With("method", "CreateMorseAccountState") - // Check if the value already exists - _, isFound := k.GetMorseAccountState(ctx) - if isFound { - return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "already set") + if err := msg.ValidateBasic(); err != nil { + logger.Info(err.Error()) + return nil, status.Error(codes.InvalidArgument, err.Error()) } - if err := msg.ValidateBasic(); err != nil { - return nil, err + // Check if the value already exists + if _, isFound := k.GetMorseAccountState(sdkCtx); isFound { + err := migrationtypes.ErrMorseAccountState.Wrap("already set") + logger.Info(err.Error()) + return nil, status.Error(codes.FailedPrecondition, err.Error()) } - k.SetMorseAccountState( - ctx, - msg.MorseAccountState, - ) + k.SetMorseAccountState(sdkCtx, msg.MorseAccountState) - // TODO_UPNEXT(@bryanchriswhite#1034): Emit an event... + stateHash, err := msg.MorseAccountState.GetHash() + if err != nil { + logger.Info(err.Error()) + return nil, status.Error(codes.Internal, err.Error()) + } + + if err = sdkCtx.EventManager().EmitTypedEvent( + &migrationtypes.EventCreateMorseAccountState{ + CreatedAtHeight: sdkCtx.BlockHeight(), + MorseAccountStateHash: stateHash, + NumAccounts: uint64(len(msg.MorseAccountState.Accounts)), + }, + ); err != nil { + logger.Info(err.Error()) + return nil, err + } - // TODO_UPNEXT(@bryanchriswhite#1034): Populate the response... - return &types.MsgCreateMorseAccountStateResponse{}, nil + return &migrationtypes.MsgCreateMorseAccountStateResponse{ + StateHash: stateHash, + NumAccounts: uint64(len(msg.MorseAccountState.Accounts)), + }, nil } diff --git a/x/migration/keeper/msg_server_morse_account_state_test.go b/x/migration/keeper/msg_server_morse_account_state_test.go index cf2e2b70c..5c45c28fa 100644 --- a/x/migration/keeper/msg_server_morse_account_state_test.go +++ b/x/migration/keeper/msg_server_morse_account_state_test.go @@ -3,23 +3,100 @@ package keeper_test import ( "testing" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/stretchr/testify/require" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "github.com/pokt-network/poktroll/testutil/events" keepertest "github.com/pokt-network/poktroll/testutil/keeper" - "github.com/pokt-network/poktroll/testutil/sample" + "github.com/pokt-network/poktroll/testutil/testmigration" "github.com/pokt-network/poktroll/x/migration/keeper" - "github.com/pokt-network/poktroll/x/migration/types" + migrationtypes "github.com/pokt-network/poktroll/x/migration/types" ) -func TestMorseAccountStateMsgServerCreate(t *testing.T) { +func TestMorseAccountStateMsgServerCreate_Success(t *testing.T) { k, ctx := keepertest.MigrationKeeper(t) srv := keeper.NewMsgServerImpl(k) - authority := sample.AccAddress() - expected, err := types.NewMsgCreateMorseAccountState(authority, types.MorseAccountState{}) + + numAccounts := 10 + _, accountState := testmigration.NewMorseStateExportAndAccountState(t, numAccounts) + + // Assert that the MorseAccountState is not set initially. + _, isFound := k.GetMorseAccountState(ctx) + require.False(t, isFound) + + // Create the on-chain MorseAccountState. + msgCreateMorseAccountState, err := migrationtypes.NewMsgCreateMorseAccountState( + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + *accountState, + ) require.NoError(t, err) - _, err = srv.CreateMorseAccountState(ctx, expected) + res, err := srv.CreateMorseAccountState(ctx, msgCreateMorseAccountState) require.NoError(t, err) - _, found := k.GetMorseAccountState(ctx) - require.True(t, found) + + // Assert that the response matches expectations. + expectedUploadMsg := &migrationtypes.MsgCreateMorseAccountState{ + Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), + MorseAccountState: *accountState, + } + expectedStateHash, err := expectedUploadMsg.MorseAccountState.GetHash() + require.NoError(t, err) + require.NotEmpty(t, expectedStateHash) + require.Len(t, expectedStateHash, 32) + + expectedRes := &migrationtypes.MsgCreateMorseAccountStateResponse{ + StateHash: expectedStateHash, + NumAccounts: uint64(numAccounts), + } + require.Equal(t, expectedRes, res) + + // Assert that the MorseAccountState was created and matches expectations. + morseAccountState, isFound := k.GetMorseAccountState(ctx) + require.True(t, isFound) + require.NoError(t, err) + + actualStateHash, err := morseAccountState.GetHash() + require.NoError(t, err) + require.Equal(t, expectedRes.StateHash, actualStateHash) + require.Equal(t, int(expectedRes.NumAccounts), len(morseAccountState.GetAccounts())) + + // Assert that the EventCreateMorseAccountState event was emitted. + evts := ctx.EventManager().Events() + filteredEvts := events.FilterEvents[*migrationtypes.EventCreateMorseAccountState](t, evts) + require.Equal(t, 1, len(filteredEvts)) + + expectedEvent := &migrationtypes.EventCreateMorseAccountState{ + CreatedAtHeight: ctx.BlockHeight(), + MorseAccountStateHash: expectedStateHash, + NumAccounts: uint64(numAccounts), + } + require.Equal(t, expectedEvent, filteredEvts[0]) +} + +func TestMorseAccountStateMsgServerCreate_ErrorAlreadySet(t *testing.T) { + k, ctx := keepertest.MigrationKeeper(t) + srv := keeper.NewMsgServerImpl(k) + + numAccounts := 10 + _, accountState := testmigration.NewMorseStateExportAndAccountState(t, numAccounts) + k.SetMorseAccountState(ctx, *accountState) + + // Assert that the MorseAccountState is set initially. + _, isFound := k.GetMorseAccountState(ctx) + require.True(t, isFound) + + // Assert that the MorseAccountState can ONLY be set once. + msgCreateMorseAccountState, err := migrationtypes.NewMsgCreateMorseAccountState( + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + *accountState, + ) + require.NoError(t, err) + + _, err = srv.CreateMorseAccountState(ctx, msgCreateMorseAccountState) + stat := status.Convert(err) + require.Equal(t, codes.FailedPrecondition, stat.Code()) + require.ErrorContains(t, err, "already set") } diff --git a/x/migration/module/autocli.go b/x/migration/module/autocli.go index ce8e01995..7bfa46165 100644 --- a/x/migration/module/autocli.go +++ b/x/migration/module/autocli.go @@ -23,9 +23,8 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { }, { RpcMethod: "MorseAccountState", - Use: "show-morse-account-state", + Use: "morse-account-state", Short: "show morse_account_state", - Skip: true, }, // this line is used by ignite scaffolding # autocli/query }, diff --git a/x/migration/types/event.pb.go b/x/migration/types/event.pb.go new file mode 100644 index 000000000..7b37e6b2c --- /dev/null +++ b/x/migration/types/event.pb.go @@ -0,0 +1,403 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: poktroll/migration/event.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + _ "github.com/pokt-network/poktroll/x/shared/types" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// EventUploadMorseState is emitted when the MorseAccountState is created on-chain. +type EventCreateMorseAccountState struct { + // The height (on Shannon) at which the MorseAccountState was created on-chain. + CreatedAtHeight int64 `protobuf:"varint,1,opt,name=created_at_height,json=createdAtHeight,proto3" json:"created_at_height"` + // The sha256 has of the MorseAccountState. + MorseAccountStateHash []byte `protobuf:"bytes,2,opt,name=morse_account_state_hash,json=morseAccountStateHash,proto3" json:"morse_account_state_hash"` + // The 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,3,opt,name=num_accounts,json=numAccounts,proto3" json:"num_accounts"` +} + +func (m *EventCreateMorseAccountState) Reset() { *m = EventCreateMorseAccountState{} } +func (m *EventCreateMorseAccountState) String() string { return proto.CompactTextString(m) } +func (*EventCreateMorseAccountState) ProtoMessage() {} +func (*EventCreateMorseAccountState) Descriptor() ([]byte, []int) { + return fileDescriptor_d5b0bc9ed37905e1, []int{0} +} +func (m *EventCreateMorseAccountState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventCreateMorseAccountState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *EventCreateMorseAccountState) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventCreateMorseAccountState.Merge(m, src) +} +func (m *EventCreateMorseAccountState) XXX_Size() int { + return m.Size() +} +func (m *EventCreateMorseAccountState) XXX_DiscardUnknown() { + xxx_messageInfo_EventCreateMorseAccountState.DiscardUnknown(m) +} + +var xxx_messageInfo_EventCreateMorseAccountState proto.InternalMessageInfo + +func (m *EventCreateMorseAccountState) GetCreatedAtHeight() int64 { + if m != nil { + return m.CreatedAtHeight + } + return 0 +} + +func (m *EventCreateMorseAccountState) GetMorseAccountStateHash() []byte { + if m != nil { + return m.MorseAccountStateHash + } + return nil +} + +func (m *EventCreateMorseAccountState) GetNumAccounts() uint64 { + if m != nil { + return m.NumAccounts + } + return 0 +} + +func init() { + proto.RegisterType((*EventCreateMorseAccountState)(nil), "poktroll.migration.EventCreateMorseAccountState") +} + +func init() { proto.RegisterFile("poktroll/migration/event.proto", fileDescriptor_d5b0bc9ed37905e1) } + +var fileDescriptor_d5b0bc9ed37905e1 = []byte{ + // 350 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x90, 0xcd, 0x6a, 0x22, 0x41, + 0x14, 0x85, 0xad, 0x71, 0x98, 0x45, 0x8f, 0x30, 0x33, 0xcd, 0x08, 0x3d, 0xe2, 0x94, 0x92, 0x45, + 0x70, 0x13, 0x0b, 0xe3, 0x13, 0xd8, 0x21, 0xe0, 0x26, 0x10, 0x0c, 0xd9, 0x64, 0xd3, 0x54, 0x97, + 0x45, 0x57, 0xa3, 0x5d, 0x57, 0xaa, 0x6e, 0x9b, 0xe4, 0x2d, 0xf2, 0x58, 0x59, 0xba, 0x74, 0x25, + 0xa1, 0xdd, 0x09, 0x79, 0x87, 0xd0, 0x3f, 0x4a, 0x7e, 0x77, 0xdd, 0xe7, 0x3b, 0xf7, 0xd4, 0xe1, + 0x38, 0x74, 0x01, 0x33, 0x34, 0x30, 0x9f, 0xb3, 0x24, 0x8e, 0x0c, 0xc7, 0x18, 0x34, 0x93, 0x4b, + 0xa9, 0xb1, 0xbf, 0x30, 0x80, 0xe0, 0xba, 0x7b, 0xde, 0x3f, 0xf0, 0xd6, 0x3f, 0x01, 0x36, 0x01, + 0x1b, 0x14, 0x0e, 0x56, 0xfe, 0x94, 0xf6, 0xd6, 0xdf, 0x08, 0x22, 0x28, 0xf5, 0xfc, 0xab, 0x52, + 0x69, 0xe9, 0x61, 0x21, 0xb7, 0x92, 0x2d, 0x07, 0xa1, 0x44, 0x3e, 0x60, 0x02, 0x62, 0x5d, 0xf1, + 0xff, 0x87, 0x12, 0x56, 0x71, 0x23, 0xa7, 0xcc, 0x4a, 0xb3, 0x8c, 0x85, 0xac, 0xf0, 0xf1, 0x27, + 0x1d, 0x13, 0x30, 0x56, 0x06, 0xa0, 0x85, 0xe2, 0xfb, 0x98, 0xa3, 0x67, 0xe2, 0xb4, 0xcf, 0xf3, + 0xee, 0x67, 0x46, 0x72, 0x94, 0x17, 0xb9, 0x65, 0x24, 0x04, 0xa4, 0x1a, 0xaf, 0x90, 0xa3, 0x74, + 0x47, 0xce, 0x1f, 0x51, 0xa0, 0x69, 0xc0, 0x31, 0x50, 0x32, 0x8e, 0x14, 0x7a, 0xa4, 0x4b, 0x7a, + 0x75, 0xbf, 0xb9, 0xdb, 0x74, 0x3e, 0xc2, 0xc9, 0xaf, 0x4a, 0x1a, 0xe1, 0xb8, 0x10, 0xdc, 0x6b, + 0xc7, 0x2b, 0x9f, 0xe6, 0x65, 0x70, 0x60, 0xf3, 0xe4, 0x40, 0x71, 0xab, 0xbc, 0x6f, 0x5d, 0xd2, + 0x6b, 0xf8, 0xed, 0xdd, 0xa6, 0xf3, 0xa5, 0x67, 0xd2, 0x4c, 0xde, 0xb7, 0x1a, 0x73, 0xab, 0xdc, + 0xa1, 0xd3, 0xd0, 0x69, 0xb2, 0x3f, 0xb0, 0x5e, 0xbd, 0x4b, 0x7a, 0xdf, 0xfd, 0xdf, 0xbb, 0x4d, + 0xe7, 0x8d, 0x3e, 0xf9, 0xa9, 0xd3, 0xa4, 0x3a, 0xb6, 0xfe, 0xe5, 0x63, 0x46, 0xc9, 0x2a, 0xa3, + 0x64, 0x9d, 0x51, 0xf2, 0x94, 0x51, 0xf2, 0xb0, 0xa5, 0xb5, 0xd5, 0x96, 0xd6, 0xd6, 0x5b, 0x5a, + 0xbb, 0x39, 0x8d, 0x62, 0x54, 0x69, 0xd8, 0x17, 0x90, 0xb0, 0x7c, 0xc0, 0x13, 0x2d, 0xf1, 0x16, + 0xcc, 0x8c, 0x1d, 0xd6, 0xbc, 0x7b, 0xb5, 0x27, 0xde, 0x2f, 0xa4, 0x0d, 0x7f, 0x14, 0x43, 0x0e, + 0x5f, 0x02, 0x00, 0x00, 0xff, 0xff, 0xca, 0xdd, 0x3d, 0xd8, 0x16, 0x02, 0x00, 0x00, +} + +func (m *EventCreateMorseAccountState) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *EventCreateMorseAccountState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventCreateMorseAccountState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.NumAccounts != 0 { + i = encodeVarintEvent(dAtA, i, uint64(m.NumAccounts)) + i-- + dAtA[i] = 0x18 + } + if len(m.MorseAccountStateHash) > 0 { + i -= len(m.MorseAccountStateHash) + copy(dAtA[i:], m.MorseAccountStateHash) + i = encodeVarintEvent(dAtA, i, uint64(len(m.MorseAccountStateHash))) + i-- + dAtA[i] = 0x12 + } + if m.CreatedAtHeight != 0 { + i = encodeVarintEvent(dAtA, i, uint64(m.CreatedAtHeight)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintEvent(dAtA []byte, offset int, v uint64) int { + offset -= sovEvent(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *EventCreateMorseAccountState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.CreatedAtHeight != 0 { + n += 1 + sovEvent(uint64(m.CreatedAtHeight)) + } + l = len(m.MorseAccountStateHash) + if l > 0 { + n += 1 + l + sovEvent(uint64(l)) + } + if m.NumAccounts != 0 { + n += 1 + sovEvent(uint64(m.NumAccounts)) + } + return n +} + +func sovEvent(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozEvent(x uint64) (n int) { + return sovEvent(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *EventCreateMorseAccountState) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: EventCreateMorseAccountState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventCreateMorseAccountState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CreatedAtHeight", wireType) + } + m.CreatedAtHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CreatedAtHeight |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + 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 ErrIntOverflowEvent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthEvent + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MorseAccountStateHash = append(m.MorseAccountStateHash[:0], dAtA[iNdEx:postIndex]...) + if m.MorseAccountStateHash == nil { + m.MorseAccountStateHash = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NumAccounts", wireType) + } + m.NumAccounts = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NumAccounts |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipEvent(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvent + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipEvent(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowEvent + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowEvent + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowEvent + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthEvent + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupEvent + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthEvent + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthEvent = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowEvent = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupEvent = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/migration/types/messages_morse_account_state.go b/x/migration/types/messages_morse_account_state.go index 2edd6b63e..fe8b1fd36 100644 --- a/x/migration/types/messages_morse_account_state.go +++ b/x/migration/types/messages_morse_account_state.go @@ -30,8 +30,6 @@ func (msg *MsgCreateMorseAccountState) ValidateBasic() error { return sdkerrors.ErrInvalidAddress.Wrapf("invalid authority address (%s)", err) } - // TODO_UPNEXT(@bryanchriswhite): add validation. - actualHash, err := msg.MorseAccountState.GetHash() if err != nil { return err