diff --git a/api/poktroll/migration/event.pulsar.go b/api/poktroll/migration/event.pulsar.go new file mode 100644 index 000000000..07c371df5 --- /dev/null +++ b/api/poktroll/migration/event.pulsar.go @@ -0,0 +1,646 @@ +// 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" + prot + 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_height protoreflect.FieldDescriptor + fd_EventCreateMorseAccountState_state_hash protoreflect.FieldDescriptor +) + +func init() { + file_poktroll_migration_event_proto_init() + md_EventCreateMorseAccountState = File_poktroll_migration_event_proto.Messages().ByName("EventCreateMorseAccountState") + fd_EventCreateMorseAccountState_height = md_EventCreateMorseAccountState.Fields().ByName("height") + fd_EventCreateMorseAccountState_state_hash = md_EventCreateMorseAccountState.Fields().ByName("state_hash") +} + +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.Height != int64(0) { + value := protoreflect.ValueOfInt64(x.Height) + if !f(fd_EventCreateMorseAccountState_height, value) { + return + } + } + if len(x.StateHash) != 0 { + value := protoreflect.ValueOfBytes(x.StateHash) + if !f(fd_EventCreateMorseAccountState_state_hash, 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.height": + return x.Height != int64(0) + case "poktroll.migration.EventCreateMorseAccountState.state_hash": + return len(x.StateHash) != 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.height": + x.Height = int64(0) + case "poktroll.migration.EventCreateMorseAccountState.state_hash": + x.StateHash = nil + 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.height": + value := x.Height + return protoreflect.ValueOfInt64(value) + case "poktroll.migration.EventCreateMorseAccountState.state_hash": + value := x.StateHash + return protoreflect.ValueOfBytes(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.height": + x.Height = value.Int() + case "poktroll.migration.EventCreateMorseAccountState.state_hash": + x.StateHash = value.Bytes() + 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.height": + panic(fmt.Errorf("field height of message poktroll.migration.EventCreateMorseAccountState is not mutable")) + case "poktroll.migration.EventCreateMorseAccountState.state_hash": + panic(fmt.Errorf("field state_hash 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.height": + return protoreflect.ValueOfInt64(int64(0)) + case "poktroll.migration.EventCreateMorseAccountState.state_hash": + return protoreflect.ValueOfBytes(nil) + 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.Height != 0 { + n += 1 + runtime.Sov(uint64(x.Height)) + } + l = len(x.StateHash) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + 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 len(x.StateHash) > 0 { + i -= len(x.StateHash) + copy(dAtA[i:], x.StateHash) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.StateHash))) + i-- + dAtA[i] = 0x1a + } + if x.Height != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.Height)) + 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 Height", wireType) + } + x.Height = 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.Height |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field StateHash", 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.StateHash = append(x.StateHash[:0], dAtA[iNdEx:postIndex]...) + if x.StateHash == nil { + x.StateHash = []byte{} + } + iNdEx = postIndex + 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 a new state hash is uploaded. +type EventCreateMorseAccountState struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Height int64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` + StateHash []byte `protobuf:"bytes,3,opt,name=state_hash,json=stateHash,proto3" json:"state_hash,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) GetHeight() int64 { + if x != nil { + return x.Height + } + return 0 +} + +func (x *EventCreateMorseAccountState) GetStateHash() []byte { + if x != nil { + return x.StateHash + } + return nil +} + +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, 0x1e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x6d, + 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x71, 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, 0x22, 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x03, 0x42, 0x0a, 0xea, 0xde, 0x1f, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, + 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x2d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, + 0x65, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x03, 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, 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_types_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/proto/poktroll/migration/event.proto b/proto/poktroll/migration/event.proto new file mode 100644 index 000000000..d1b9cc900 --- /dev/null +++ b/proto/poktroll/migration/event.proto @@ -0,0 +1,18 @@ +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/types.proto"; + +// EventUploadMorseState is emitted when a new state hash is uploaded. +message EventCreateMorseAccountState { + int64 height = 1 [(gogoproto.jsontag) = "height"]; + bytes state_hash = 3 [(gogoproto.jsontag) = "state_hash"]; +} diff --git a/x/migration/keeper/msg_server_morse_account_state.go b/x/migration/keeper/msg_server_morse_account_state.go index 9ae9b6139..75ecfa7a6 100644 --- a/x/migration/keeper/msg_server_morse_account_state.go +++ b/x/migration/keeper/msg_server_morse_account_state.go @@ -3,25 +3,51 @@ 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" ) -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 *types.MsgCreateMorseAccountState) (*types.MsgCreateMorseAccountStateResponse, error) { + sdkCtx := sdk.UnwrapSDKContext(ctx) + + if err := msg.ValidateBasic(); err != nil { + return nil, err + } // Check if the value already exists - _, isFound := k.GetMorseAccountState(ctx) + _, isFound := k.GetMorseAccountState(sdkCtx) if isFound { - return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "already set") + return nil, status.Error( + codes.FailedPrecondition, + sdkerrors.ErrInvalidRequest.Wrap("already set").Error(), + ) } k.SetMorseAccountState( - ctx, + sdkCtx, msg.MorseAccountState, ) - return &types.MsgCreateMorseAccountStateResponse{}, nil + + stateHash, err := msg.MorseAccountState.GetHash() + if err != nil { + return nil, err + } + + if err = sdkCtx.EventManager().EmitTypedEvent( + &types.EventCreateMorseAccountState{ + Height: sdkCtx.BlockHeight(), + StateHash: stateHash, + }, + ); err != nil { + return nil, err + } + + return &types.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 c12fd49bc..a4f811b48 100644 --- a/x/migration/keeper/msg_server_morse_account_state_test.go +++ b/x/migration/keeper/msg_server_morse_account_state_test.go @@ -3,20 +3,91 @@ 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/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 := "A" - expected := &types.MsgCreateMorseAccountState{Authority: authority} - _, err := srv.CreateMorseAccountState(ctx, expected) + + numAccounts := 10 + _, accountState := testmigration.NewMorseStateExportAndAccountState(t, numAccounts) + + // Assert that the MorseAccountState is not set initially. + _, isFound := k.GetMorseAccountState(ctx) + require.False(t, isFound) + + res, err := srv.CreateMorseAccountState(ctx, &migrationtypes.MsgCreateMorseAccountState{ + Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), + MorseAccountState: *accountState, + }) + require.NoError(t, err) + + 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) + + MorseAccountState, isFound := k.GetMorseAccountState(ctx) + require.True(t, isFound) + require.NoError(t, err) + + actualStateHash, err := MorseAccountState.GetHash() require.NoError(t, err) - _, found := k.GetMorseAccountState(ctx) - require.True(t, found) + require.Equal(t, expectedRes.StateHash, actualStateHash) + require.Equal(t, int(expectedRes.NumAccounts), len(MorseAccountState.GetAccounts())) + + evts := ctx.EventManager().Events() + filteredEvts := events.FilterEvents[*migrationtypes.EventCreateMorseAccountState](t, evts) + require.Equal(t, 1, len(filteredEvts)) + + expectedEvent := &migrationtypes.EventCreateMorseAccountState{ + Height: ctx.BlockHeight(), + StateHash: expectedStateHash, + } + require.Equal(t, expectedEvent, filteredEvts[0]) +} + +func TestMorseAccountStateMsgServerCreate_Error(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. + _, err := srv.CreateMorseAccountState(ctx, &migrationtypes.MsgCreateMorseAccountState{ + Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), + MorseAccountState: *accountState, + }) + t.Log(err) + + stat := status.Convert(err) + require.Equal(t, codes.FailedPrecondition, stat.Code()) + require.ErrorContains(t, err, "already set") } diff --git a/x/migration/types/event.pb.go b/x/migration/types/event.pb.go new file mode 100644 index 000000000..4960740bc --- /dev/null +++ b/x/migration/types/event.pb.go @@ -0,0 +1,361 @@ +// 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 a new state hash is uploaded. +type EventCreateMorseAccountState struct { + Height int64 `protobuf:"varint,1,opt,name=height,proto3" json:"height"` + StateHash []byte `protobuf:"bytes,3,opt,name=state_hash,json=stateHash,proto3" json:"state_hash"` +} + +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) GetHeight() int64 { + if m != nil { + return m.Height + } + return 0 +} + +func (m *EventCreateMorseAccountState) GetStateHash() []byte { + if m != nil { + return m.StateHash + } + return nil +} + +func init() { + proto.RegisterType((*EventCreateMorseAccountState)(nil), "poktroll.migration.EventCreateMorseAccountState") +} + +func init() { proto.RegisterFile("poktroll/migration/event.proto", fileDescriptor_d5b0bc9ed37905e1) } + +var fileDescriptor_d5b0bc9ed37905e1 = []byte{ + // 290 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x8f, 0xcf, 0x4a, 0x33, 0x31, + 0x14, 0xc5, 0x1b, 0x0a, 0x85, 0x2f, 0x7c, 0xb8, 0x18, 0x5c, 0xd4, 0xa2, 0x69, 0xe9, 0xaa, 0x9b, + 0x36, 0x54, 0x9f, 0xc0, 0x8a, 0xe0, 0x46, 0x90, 0xba, 0x73, 0x53, 0x32, 0xf1, 0x32, 0x09, 0x6d, + 0xe7, 0x8e, 0xc9, 0xed, 0xa8, 0x6f, 0xe1, 0x63, 0xb9, 0xec, 0xb2, 0xab, 0x22, 0x33, 0xbb, 0x3e, + 0x85, 0xcc, 0x9f, 0x0e, 0x22, 0xae, 0x72, 0x72, 0xce, 0x09, 0xf9, 0x1d, 0x2e, 0x12, 0x5c, 0x92, + 0xc3, 0xd5, 0x4a, 0xae, 0x6d, 0xe4, 0x14, 0x59, 0x8c, 0x25, 0xa4, 0x10, 0xd3, 0x24, 0x71, 0x48, + 0x18, 0x04, 0xc7, 0x7c, 0xd2, 0xe4, 0xbd, 0x33, 0x8d, 0x7e, 0x8d, 0x7e, 0x51, 0x36, 0x64, 0x75, + 0xa9, 0xea, 0xbd, 0xd3, 0x08, 0x23, 0xac, 0xfc, 0x42, 0xd5, 0xae, 0xa8, 0x3a, 0x32, 0x54, 0x1e, + 0x64, 0x3a, 0x0d, 0x81, 0xd4, 0x54, 0x6a, 0xb4, 0x71, 0x9d, 0x5f, 0x34, 0x10, 0xde, 0x28, 0x07, + 0xcf, 0xd2, 0x83, 0x4b, 0xad, 0x86, 0xe3, 0xf3, 0x3f, 0x18, 0xe9, 0x3d, 0x81, 0xfa, 0xd3, 0xe1, + 0x0b, 0x3f, 0xbf, 0x2d, 0x90, 0x6f, 0x1c, 0x28, 0x82, 0x7b, 0x74, 0x1e, 0xae, 0xb5, 0xc6, 0x4d, + 0x4c, 0x8f, 0xa4, 0x08, 0x82, 0x21, 0xef, 0x18, 0xb0, 0x91, 0xa1, 0x2e, 0x1b, 0xb0, 0x51, 0x7b, + 0xc6, 0x0f, 0xfb, 0x7e, 0xed, 0xcc, 0xeb, 0x33, 0x18, 0x73, 0xee, 0x8b, 0xf2, 0xc2, 0x28, 0x6f, + 0xba, 0xed, 0x01, 0x1b, 0xfd, 0x9f, 0x9d, 0x1c, 0xf6, 0xfd, 0x1f, 0xee, 0xfc, 0x5f, 0xa9, 0xef, + 0x94, 0x37, 0xb3, 0x87, 0xcf, 0x4c, 0xb0, 0x6d, 0x26, 0xd8, 0x2e, 0x13, 0xec, 0x2b, 0x13, 0xec, + 0x23, 0x17, 0xad, 0x6d, 0x2e, 0x5a, 0xbb, 0x5c, 0xb4, 0x9e, 0x2e, 0x23, 0x4b, 0x66, 0x13, 0x4e, + 0x34, 0xae, 0x65, 0xc1, 0x3e, 0x8e, 0x81, 0x5e, 0xd1, 0x2d, 0x65, 0x33, 0xe4, 0xed, 0xf7, 0x94, + 0xb0, 0x53, 0x6e, 0xb9, 0xfa, 0x0e, 0x00, 0x00, 0xff, 0xff, 0x8b, 0x52, 0xd7, 0x04, 0x91, 0x01, + 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 len(m.StateHash) > 0 { + i -= len(m.StateHash) + copy(dAtA[i:], m.StateHash) + i = encodeVarintEvent(dAtA, i, uint64(len(m.StateHash))) + i-- + dAtA[i] = 0x1a + } + if m.Height != 0 { + i = encodeVarintEvent(dAtA, i, uint64(m.Height)) + 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.Height != 0 { + n += 1 + sovEvent(uint64(m.Height)) + } + l = len(m.StateHash) + if l > 0 { + n += 1 + l + sovEvent(uint64(l)) + } + 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 Height", wireType) + } + m.Height = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Height |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StateHash", 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.StateHash = append(m.StateHash[:0], dAtA[iNdEx:postIndex]...) + if m.StateHash == nil { + m.StateHash = []byte{} + } + iNdEx = postIndex + 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/morse_account_state.go b/x/migration/types/morse_account_state.go new file mode 100644 index 000000000..d1a9763fa --- /dev/null +++ b/x/migration/types/morse_account_state.go @@ -0,0 +1,17 @@ +package types + +import ( + "crypto/sha256" + + "github.com/cosmos/gogoproto/proto" +) + +func (m MorseAccountState) GetHash() ([]byte, error) { + accountStateBz, err := proto.Marshal(&m) + if err != nil { + return nil, err + } + + hash := sha256.Sum256(accountStateBz) + return hash[:], nil +}