From 064c9ba6385ac5bfbc1510c316529ae5568bd1b6 Mon Sep 17 00:00:00 2001 From: cool-developer <51834436+cool-develope@users.noreply.github.com> Date: Mon, 13 Jan 2025 05:56:48 -0500 Subject: [PATCH] feat(store/v2): build the migration manager in the root store factory (#22336) Co-authored-by: marbar3778 Co-authored-by: Marko Co-authored-by: Alex | Interchain Labs --- api/cosmos/store/v2/commit_info.pulsar.go | 2048 +++++++++++++++++ client/grpc/reflection/reflection.pb.go | 2 +- proto/cosmos/store/v2/commit_info.proto | 34 + scripts/init-simapp-v2.sh | 3 +- server/v2/cometbft/abci_test.go | 2 +- .../v2/cometbft/internal/mock/mock_store.go | 4 +- server/v2/server.go | 11 +- simapp/v2/app_config.go | 12 +- simapp/v2/simdv2/cmd/testnet.go | 21 - store/v2/commitment/iavl/exporter.go | 13 + store/v2/commitment/iavl/tree.go | 18 + store/v2/commitment/metadata.go | 53 +- store/v2/commitment/store.go | 23 +- store/v2/commitment/store_test_suite.go | 6 +- store/v2/go.mod | 2 +- store/v2/migration/manager.go | 5 +- store/v2/migration/manager_test.go | 1 - store/v2/proof/commit_info.go | 155 +- store/v2/proof/commit_info.pb.go | 975 ++++++++ store/v2/proof/commit_info_test.go | 32 +- store/v2/proof/v1/types/commit_info.pb.go | 859 +++++++ store/v2/root/factory.go | 63 +- store/v2/root/factory_test.go | 17 + store/v2/root/store.go | 22 +- tests/systemtests/bankv2_test.go | 2 + 25 files changed, 4131 insertions(+), 252 deletions(-) create mode 100644 api/cosmos/store/v2/commit_info.pulsar.go create mode 100644 proto/cosmos/store/v2/commit_info.proto create mode 100644 store/v2/proof/commit_info.pb.go create mode 100644 store/v2/proof/v1/types/commit_info.pb.go diff --git a/api/cosmos/store/v2/commit_info.pulsar.go b/api/cosmos/store/v2/commit_info.pulsar.go new file mode 100644 index 000000000000..572f80f0be48 --- /dev/null +++ b/api/cosmos/store/v2/commit_info.pulsar.go @@ -0,0 +1,2048 @@ +// Code generated by protoc-gen-go-pulsar. DO NOT EDIT. +package storev2 + +import ( + fmt "fmt" + runtime "github.com/cosmos/cosmos-proto/runtime" + _ "github.com/cosmos/gogoproto/gogoproto" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoiface "google.golang.org/protobuf/runtime/protoiface" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" + io "io" + reflect "reflect" + sync "sync" +) + +var _ protoreflect.List = (*_CommitInfo_2_list)(nil) + +type _CommitInfo_2_list struct { + list *[]*StoreInfo +} + +func (x *_CommitInfo_2_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_CommitInfo_2_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfMessage((*x.list)[i].ProtoReflect()) +} + +func (x *_CommitInfo_2_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*StoreInfo) + (*x.list)[i] = concreteValue +} + +func (x *_CommitInfo_2_list) Append(value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*StoreInfo) + *x.list = append(*x.list, concreteValue) +} + +func (x *_CommitInfo_2_list) AppendMutable() protoreflect.Value { + v := new(StoreInfo) + *x.list = append(*x.list, v) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_CommitInfo_2_list) Truncate(n int) { + for i := n; i < len(*x.list); i++ { + (*x.list)[i] = nil + } + *x.list = (*x.list)[:n] +} + +func (x *_CommitInfo_2_list) NewElement() protoreflect.Value { + v := new(StoreInfo) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_CommitInfo_2_list) IsValid() bool { + return x.list != nil +} + +var ( + md_CommitInfo protoreflect.MessageDescriptor + fd_CommitInfo_version protoreflect.FieldDescriptor + fd_CommitInfo_store_infos protoreflect.FieldDescriptor + fd_CommitInfo_timestamp protoreflect.FieldDescriptor + fd_CommitInfo_commit_hash protoreflect.FieldDescriptor +) + +func init() { + file_cosmos_store_v2_commit_info_proto_init() + md_CommitInfo = File_cosmos_store_v2_commit_info_proto.Messages().ByName("CommitInfo") + fd_CommitInfo_version = md_CommitInfo.Fields().ByName("version") + fd_CommitInfo_store_infos = md_CommitInfo.Fields().ByName("store_infos") + fd_CommitInfo_timestamp = md_CommitInfo.Fields().ByName("timestamp") + fd_CommitInfo_commit_hash = md_CommitInfo.Fields().ByName("commit_hash") +} + +var _ protoreflect.Message = (*fastReflection_CommitInfo)(nil) + +type fastReflection_CommitInfo CommitInfo + +func (x *CommitInfo) ProtoReflect() protoreflect.Message { + return (*fastReflection_CommitInfo)(x) +} + +func (x *CommitInfo) slowProtoReflect() protoreflect.Message { + mi := &file_cosmos_store_v2_commit_info_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_CommitInfo_messageType fastReflection_CommitInfo_messageType +var _ protoreflect.MessageType = fastReflection_CommitInfo_messageType{} + +type fastReflection_CommitInfo_messageType struct{} + +func (x fastReflection_CommitInfo_messageType) Zero() protoreflect.Message { + return (*fastReflection_CommitInfo)(nil) +} +func (x fastReflection_CommitInfo_messageType) New() protoreflect.Message { + return new(fastReflection_CommitInfo) +} +func (x fastReflection_CommitInfo_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_CommitInfo +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_CommitInfo) Descriptor() protoreflect.MessageDescriptor { + return md_CommitInfo +} + +// 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_CommitInfo) Type() protoreflect.MessageType { + return _fastReflection_CommitInfo_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_CommitInfo) New() protoreflect.Message { + return new(fastReflection_CommitInfo) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_CommitInfo) Interface() protoreflect.ProtoMessage { + return (*CommitInfo)(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_CommitInfo) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Version != int64(0) { + value := protoreflect.ValueOfInt64(x.Version) + if !f(fd_CommitInfo_version, value) { + return + } + } + if len(x.StoreInfos) != 0 { + value := protoreflect.ValueOfList(&_CommitInfo_2_list{list: &x.StoreInfos}) + if !f(fd_CommitInfo_store_infos, value) { + return + } + } + if x.Timestamp != nil { + value := protoreflect.ValueOfMessage(x.Timestamp.ProtoReflect()) + if !f(fd_CommitInfo_timestamp, value) { + return + } + } + if len(x.CommitHash) != 0 { + value := protoreflect.ValueOfBytes(x.CommitHash) + if !f(fd_CommitInfo_commit_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_CommitInfo) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "cosmos.store.v2.CommitInfo.version": + return x.Version != int64(0) + case "cosmos.store.v2.CommitInfo.store_infos": + return len(x.StoreInfos) != 0 + case "cosmos.store.v2.CommitInfo.timestamp": + return x.Timestamp != nil + case "cosmos.store.v2.CommitInfo.commit_hash": + return len(x.CommitHash) != 0 + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.v2.CommitInfo")) + } + panic(fmt.Errorf("message cosmos.store.v2.CommitInfo 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_CommitInfo) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "cosmos.store.v2.CommitInfo.version": + x.Version = int64(0) + case "cosmos.store.v2.CommitInfo.store_infos": + x.StoreInfos = nil + case "cosmos.store.v2.CommitInfo.timestamp": + x.Timestamp = nil + case "cosmos.store.v2.CommitInfo.commit_hash": + x.CommitHash = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.v2.CommitInfo")) + } + panic(fmt.Errorf("message cosmos.store.v2.CommitInfo 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_CommitInfo) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "cosmos.store.v2.CommitInfo.version": + value := x.Version + return protoreflect.ValueOfInt64(value) + case "cosmos.store.v2.CommitInfo.store_infos": + if len(x.StoreInfos) == 0 { + return protoreflect.ValueOfList(&_CommitInfo_2_list{}) + } + listValue := &_CommitInfo_2_list{list: &x.StoreInfos} + return protoreflect.ValueOfList(listValue) + case "cosmos.store.v2.CommitInfo.timestamp": + value := x.Timestamp + return protoreflect.ValueOfMessage(value.ProtoReflect()) + case "cosmos.store.v2.CommitInfo.commit_hash": + value := x.CommitHash + return protoreflect.ValueOfBytes(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.v2.CommitInfo")) + } + panic(fmt.Errorf("message cosmos.store.v2.CommitInfo 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_CommitInfo) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "cosmos.store.v2.CommitInfo.version": + x.Version = value.Int() + case "cosmos.store.v2.CommitInfo.store_infos": + lv := value.List() + clv := lv.(*_CommitInfo_2_list) + x.StoreInfos = *clv.list + case "cosmos.store.v2.CommitInfo.timestamp": + x.Timestamp = value.Message().Interface().(*timestamppb.Timestamp) + case "cosmos.store.v2.CommitInfo.commit_hash": + x.CommitHash = value.Bytes() + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.v2.CommitInfo")) + } + panic(fmt.Errorf("message cosmos.store.v2.CommitInfo 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_CommitInfo) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.store.v2.CommitInfo.store_infos": + if x.StoreInfos == nil { + x.StoreInfos = []*StoreInfo{} + } + value := &_CommitInfo_2_list{list: &x.StoreInfos} + return protoreflect.ValueOfList(value) + case "cosmos.store.v2.CommitInfo.timestamp": + if x.Timestamp == nil { + x.Timestamp = new(timestamppb.Timestamp) + } + return protoreflect.ValueOfMessage(x.Timestamp.ProtoReflect()) + case "cosmos.store.v2.CommitInfo.version": + panic(fmt.Errorf("field version of message cosmos.store.v2.CommitInfo is not mutable")) + case "cosmos.store.v2.CommitInfo.commit_hash": + panic(fmt.Errorf("field commit_hash of message cosmos.store.v2.CommitInfo is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.v2.CommitInfo")) + } + panic(fmt.Errorf("message cosmos.store.v2.CommitInfo 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_CommitInfo) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.store.v2.CommitInfo.version": + return protoreflect.ValueOfInt64(int64(0)) + case "cosmos.store.v2.CommitInfo.store_infos": + list := []*StoreInfo{} + return protoreflect.ValueOfList(&_CommitInfo_2_list{list: &list}) + case "cosmos.store.v2.CommitInfo.timestamp": + m := new(timestamppb.Timestamp) + return protoreflect.ValueOfMessage(m.ProtoReflect()) + case "cosmos.store.v2.CommitInfo.commit_hash": + return protoreflect.ValueOfBytes(nil) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.v2.CommitInfo")) + } + panic(fmt.Errorf("message cosmos.store.v2.CommitInfo 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_CommitInfo) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in cosmos.store.v2.CommitInfo", 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_CommitInfo) 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_CommitInfo) 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_CommitInfo) 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_CommitInfo) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*CommitInfo) + 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.Version != 0 { + n += 1 + runtime.Sov(uint64(x.Version)) + } + if len(x.StoreInfos) > 0 { + for _, e := range x.StoreInfos { + l = options.Size(e) + n += 1 + l + runtime.Sov(uint64(l)) + } + } + if x.Timestamp != nil { + l = options.Size(x.Timestamp) + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.CommitHash) + 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().(*CommitInfo) + 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.CommitHash) > 0 { + i -= len(x.CommitHash) + copy(dAtA[i:], x.CommitHash) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.CommitHash))) + i-- + dAtA[i] = 0x22 + } + if x.Timestamp != nil { + encoded, err := options.Marshal(x.Timestamp) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x1a + } + if len(x.StoreInfos) > 0 { + for iNdEx := len(x.StoreInfos) - 1; iNdEx >= 0; iNdEx-- { + encoded, err := options.Marshal(x.StoreInfos[iNdEx]) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x12 + } + } + if x.Version != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.Version)) + 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().(*CommitInfo) + 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: CommitInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: CommitInfo: 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 Version", wireType) + } + x.Version = 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.Version |= 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 StoreInfos", wireType) + } + var msglen 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++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + 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.StoreInfos = append(x.StoreInfos, &StoreInfo{}) + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.StoreInfos[len(x.StoreInfos)-1]); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Timestamp", wireType) + } + var msglen 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++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + 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 + } + if x.Timestamp == nil { + x.Timestamp = ×tamppb.Timestamp{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Timestamp); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field CommitHash", 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.CommitHash = append(x.CommitHash[:0], dAtA[iNdEx:postIndex]...) + if x.CommitHash == nil { + x.CommitHash = []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, + } +} + +var ( + md_StoreInfo protoreflect.MessageDescriptor + fd_StoreInfo_name protoreflect.FieldDescriptor + fd_StoreInfo_commit_id protoreflect.FieldDescriptor + fd_StoreInfo_structure protoreflect.FieldDescriptor +) + +func init() { + file_cosmos_store_v2_commit_info_proto_init() + md_StoreInfo = File_cosmos_store_v2_commit_info_proto.Messages().ByName("StoreInfo") + fd_StoreInfo_name = md_StoreInfo.Fields().ByName("name") + fd_StoreInfo_commit_id = md_StoreInfo.Fields().ByName("commit_id") + fd_StoreInfo_structure = md_StoreInfo.Fields().ByName("structure") +} + +var _ protoreflect.Message = (*fastReflection_StoreInfo)(nil) + +type fastReflection_StoreInfo StoreInfo + +func (x *StoreInfo) ProtoReflect() protoreflect.Message { + return (*fastReflection_StoreInfo)(x) +} + +func (x *StoreInfo) slowProtoReflect() protoreflect.Message { + mi := &file_cosmos_store_v2_commit_info_proto_msgTypes[1] + 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_StoreInfo_messageType fastReflection_StoreInfo_messageType +var _ protoreflect.MessageType = fastReflection_StoreInfo_messageType{} + +type fastReflection_StoreInfo_messageType struct{} + +func (x fastReflection_StoreInfo_messageType) Zero() protoreflect.Message { + return (*fastReflection_StoreInfo)(nil) +} +func (x fastReflection_StoreInfo_messageType) New() protoreflect.Message { + return new(fastReflection_StoreInfo) +} +func (x fastReflection_StoreInfo_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_StoreInfo +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_StoreInfo) Descriptor() protoreflect.MessageDescriptor { + return md_StoreInfo +} + +// 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_StoreInfo) Type() protoreflect.MessageType { + return _fastReflection_StoreInfo_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_StoreInfo) New() protoreflect.Message { + return new(fastReflection_StoreInfo) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_StoreInfo) Interface() protoreflect.ProtoMessage { + return (*StoreInfo)(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_StoreInfo) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Name != "" { + value := protoreflect.ValueOfString(x.Name) + if !f(fd_StoreInfo_name, value) { + return + } + } + if x.CommitId != nil { + value := protoreflect.ValueOfMessage(x.CommitId.ProtoReflect()) + if !f(fd_StoreInfo_commit_id, value) { + return + } + } + if x.Structure != "" { + value := protoreflect.ValueOfString(x.Structure) + if !f(fd_StoreInfo_structure, 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_StoreInfo) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "cosmos.store.v2.StoreInfo.name": + return x.Name != "" + case "cosmos.store.v2.StoreInfo.commit_id": + return x.CommitId != nil + case "cosmos.store.v2.StoreInfo.structure": + return x.Structure != "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.v2.StoreInfo")) + } + panic(fmt.Errorf("message cosmos.store.v2.StoreInfo 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_StoreInfo) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "cosmos.store.v2.StoreInfo.name": + x.Name = "" + case "cosmos.store.v2.StoreInfo.commit_id": + x.CommitId = nil + case "cosmos.store.v2.StoreInfo.structure": + x.Structure = "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.v2.StoreInfo")) + } + panic(fmt.Errorf("message cosmos.store.v2.StoreInfo 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_StoreInfo) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "cosmos.store.v2.StoreInfo.name": + value := x.Name + return protoreflect.ValueOfString(value) + case "cosmos.store.v2.StoreInfo.commit_id": + value := x.CommitId + return protoreflect.ValueOfMessage(value.ProtoReflect()) + case "cosmos.store.v2.StoreInfo.structure": + value := x.Structure + return protoreflect.ValueOfString(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.v2.StoreInfo")) + } + panic(fmt.Errorf("message cosmos.store.v2.StoreInfo 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_StoreInfo) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "cosmos.store.v2.StoreInfo.name": + x.Name = value.Interface().(string) + case "cosmos.store.v2.StoreInfo.commit_id": + x.CommitId = value.Message().Interface().(*CommitID) + case "cosmos.store.v2.StoreInfo.structure": + x.Structure = value.Interface().(string) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.v2.StoreInfo")) + } + panic(fmt.Errorf("message cosmos.store.v2.StoreInfo 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_StoreInfo) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.store.v2.StoreInfo.commit_id": + if x.CommitId == nil { + x.CommitId = new(CommitID) + } + return protoreflect.ValueOfMessage(x.CommitId.ProtoReflect()) + case "cosmos.store.v2.StoreInfo.name": + panic(fmt.Errorf("field name of message cosmos.store.v2.StoreInfo is not mutable")) + case "cosmos.store.v2.StoreInfo.structure": + panic(fmt.Errorf("field structure of message cosmos.store.v2.StoreInfo is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.v2.StoreInfo")) + } + panic(fmt.Errorf("message cosmos.store.v2.StoreInfo 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_StoreInfo) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.store.v2.StoreInfo.name": + return protoreflect.ValueOfString("") + case "cosmos.store.v2.StoreInfo.commit_id": + m := new(CommitID) + return protoreflect.ValueOfMessage(m.ProtoReflect()) + case "cosmos.store.v2.StoreInfo.structure": + return protoreflect.ValueOfString("") + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.v2.StoreInfo")) + } + panic(fmt.Errorf("message cosmos.store.v2.StoreInfo 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_StoreInfo) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in cosmos.store.v2.StoreInfo", 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_StoreInfo) 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_StoreInfo) 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_StoreInfo) 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_StoreInfo) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*StoreInfo) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + l = len(x.Name) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.CommitId != nil { + l = options.Size(x.CommitId) + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.Structure) + 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().(*StoreInfo) + 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.Structure) > 0 { + i -= len(x.Structure) + copy(dAtA[i:], x.Structure) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Structure))) + i-- + dAtA[i] = 0x1a + } + if x.CommitId != nil { + encoded, err := options.Marshal(x.CommitId) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x12 + } + if len(x.Name) > 0 { + i -= len(x.Name) + copy(dAtA[i:], x.Name) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Name))) + i-- + dAtA[i] = 0xa + } + 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().(*StoreInfo) + 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: StoreInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: StoreInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen 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++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + 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.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field CommitId", wireType) + } + var msglen 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++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + 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 + } + if x.CommitId == nil { + x.CommitId = &CommitID{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.CommitId); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Structure", wireType) + } + var stringLen 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++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + 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.Structure = string(dAtA[iNdEx:postIndex]) + 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, + } +} + +var ( + md_CommitID protoreflect.MessageDescriptor + fd_CommitID_version protoreflect.FieldDescriptor + fd_CommitID_hash protoreflect.FieldDescriptor +) + +func init() { + file_cosmos_store_v2_commit_info_proto_init() + md_CommitID = File_cosmos_store_v2_commit_info_proto.Messages().ByName("CommitID") + fd_CommitID_version = md_CommitID.Fields().ByName("version") + fd_CommitID_hash = md_CommitID.Fields().ByName("hash") +} + +var _ protoreflect.Message = (*fastReflection_CommitID)(nil) + +type fastReflection_CommitID CommitID + +func (x *CommitID) ProtoReflect() protoreflect.Message { + return (*fastReflection_CommitID)(x) +} + +func (x *CommitID) slowProtoReflect() protoreflect.Message { + mi := &file_cosmos_store_v2_commit_info_proto_msgTypes[2] + 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_CommitID_messageType fastReflection_CommitID_messageType +var _ protoreflect.MessageType = fastReflection_CommitID_messageType{} + +type fastReflection_CommitID_messageType struct{} + +func (x fastReflection_CommitID_messageType) Zero() protoreflect.Message { + return (*fastReflection_CommitID)(nil) +} +func (x fastReflection_CommitID_messageType) New() protoreflect.Message { + return new(fastReflection_CommitID) +} +func (x fastReflection_CommitID_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_CommitID +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_CommitID) Descriptor() protoreflect.MessageDescriptor { + return md_CommitID +} + +// 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_CommitID) Type() protoreflect.MessageType { + return _fastReflection_CommitID_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_CommitID) New() protoreflect.Message { + return new(fastReflection_CommitID) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_CommitID) Interface() protoreflect.ProtoMessage { + return (*CommitID)(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_CommitID) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Version != int64(0) { + value := protoreflect.ValueOfInt64(x.Version) + if !f(fd_CommitID_version, value) { + return + } + } + if len(x.Hash) != 0 { + value := protoreflect.ValueOfBytes(x.Hash) + if !f(fd_CommitID_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_CommitID) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "cosmos.store.v2.CommitID.version": + return x.Version != int64(0) + case "cosmos.store.v2.CommitID.hash": + return len(x.Hash) != 0 + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.v2.CommitID")) + } + panic(fmt.Errorf("message cosmos.store.v2.CommitID 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_CommitID) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "cosmos.store.v2.CommitID.version": + x.Version = int64(0) + case "cosmos.store.v2.CommitID.hash": + x.Hash = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.v2.CommitID")) + } + panic(fmt.Errorf("message cosmos.store.v2.CommitID 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_CommitID) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "cosmos.store.v2.CommitID.version": + value := x.Version + return protoreflect.ValueOfInt64(value) + case "cosmos.store.v2.CommitID.hash": + value := x.Hash + return protoreflect.ValueOfBytes(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.v2.CommitID")) + } + panic(fmt.Errorf("message cosmos.store.v2.CommitID 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_CommitID) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "cosmos.store.v2.CommitID.version": + x.Version = value.Int() + case "cosmos.store.v2.CommitID.hash": + x.Hash = value.Bytes() + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.v2.CommitID")) + } + panic(fmt.Errorf("message cosmos.store.v2.CommitID 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_CommitID) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.store.v2.CommitID.version": + panic(fmt.Errorf("field version of message cosmos.store.v2.CommitID is not mutable")) + case "cosmos.store.v2.CommitID.hash": + panic(fmt.Errorf("field hash of message cosmos.store.v2.CommitID is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.v2.CommitID")) + } + panic(fmt.Errorf("message cosmos.store.v2.CommitID 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_CommitID) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.store.v2.CommitID.version": + return protoreflect.ValueOfInt64(int64(0)) + case "cosmos.store.v2.CommitID.hash": + return protoreflect.ValueOfBytes(nil) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.v2.CommitID")) + } + panic(fmt.Errorf("message cosmos.store.v2.CommitID 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_CommitID) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in cosmos.store.v2.CommitID", 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_CommitID) 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_CommitID) 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_CommitID) 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_CommitID) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*CommitID) + 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.Version != 0 { + n += 1 + runtime.Sov(uint64(x.Version)) + } + l = len(x.Hash) + 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().(*CommitID) + 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.Hash) > 0 { + i -= len(x.Hash) + copy(dAtA[i:], x.Hash) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Hash))) + i-- + dAtA[i] = 0x12 + } + if x.Version != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.Version)) + 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().(*CommitID) + 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: CommitID: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: CommitID: 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 Version", wireType) + } + x.Version = 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.Version |= 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 Hash", 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.Hash = append(x.Hash[:0], dAtA[iNdEx:postIndex]...) + if x.Hash == nil { + x.Hash = []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: cosmos/store/v2/commit_info.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) +) + +// CommitInfo defines commit information used by the multi-store when committing +// a version/height. +type CommitInfo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Version int64 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"` + StoreInfos []*StoreInfo `protobuf:"bytes,2,rep,name=store_infos,json=storeInfos,proto3" json:"store_infos,omitempty"` + Timestamp *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + CommitHash []byte `protobuf:"bytes,4,opt,name=commit_hash,json=commitHash,proto3" json:"commit_hash,omitempty"` +} + +func (x *CommitInfo) Reset() { + *x = CommitInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_store_v2_commit_info_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CommitInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CommitInfo) ProtoMessage() {} + +// Deprecated: Use CommitInfo.ProtoReflect.Descriptor instead. +func (*CommitInfo) Descriptor() ([]byte, []int) { + return file_cosmos_store_v2_commit_info_proto_rawDescGZIP(), []int{0} +} + +func (x *CommitInfo) GetVersion() int64 { + if x != nil { + return x.Version + } + return 0 +} + +func (x *CommitInfo) GetStoreInfos() []*StoreInfo { + if x != nil { + return x.StoreInfos + } + return nil +} + +func (x *CommitInfo) GetTimestamp() *timestamppb.Timestamp { + if x != nil { + return x.Timestamp + } + return nil +} + +func (x *CommitInfo) GetCommitHash() []byte { + if x != nil { + return x.CommitHash + } + return nil +} + +// StoreInfo defines store-specific commit information. It contains a reference +// between a store name and the commit ID. +type StoreInfo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + CommitId *CommitID `protobuf:"bytes,2,opt,name=commit_id,json=commitId,proto3" json:"commit_id,omitempty"` + Structure string `protobuf:"bytes,3,opt,name=structure,proto3" json:"structure,omitempty"` +} + +func (x *StoreInfo) Reset() { + *x = StoreInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_store_v2_commit_info_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *StoreInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StoreInfo) ProtoMessage() {} + +// Deprecated: Use StoreInfo.ProtoReflect.Descriptor instead. +func (*StoreInfo) Descriptor() ([]byte, []int) { + return file_cosmos_store_v2_commit_info_proto_rawDescGZIP(), []int{1} +} + +func (x *StoreInfo) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *StoreInfo) GetCommitId() *CommitID { + if x != nil { + return x.CommitId + } + return nil +} + +func (x *StoreInfo) GetStructure() string { + if x != nil { + return x.Structure + } + return "" +} + +// CommitID defines the commitment information when a specific store is +// committed. +type CommitID struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Version int64 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"` + Hash []byte `protobuf:"bytes,2,opt,name=hash,proto3" json:"hash,omitempty"` +} + +func (x *CommitID) Reset() { + *x = CommitID{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_store_v2_commit_info_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CommitID) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CommitID) ProtoMessage() {} + +// Deprecated: Use CommitID.ProtoReflect.Descriptor instead. +func (*CommitID) Descriptor() ([]byte, []int) { + return file_cosmos_store_v2_commit_info_proto_rawDescGZIP(), []int{2} +} + +func (x *CommitID) GetVersion() int64 { + if x != nil { + return x.Version + } + return 0 +} + +func (x *CommitID) GetHash() []byte { + if x != nil { + return x.Hash + } + return nil +} + +var File_cosmos_store_v2_commit_info_proto protoreflect.FileDescriptor + +var file_cosmos_store_v2_commit_info_proto_rawDesc = []byte{ + 0x0a, 0x21, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2f, 0x76, + 0x32, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x12, 0x0f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x73, 0x74, 0x6f, 0x72, + 0x65, 0x2e, 0x76, 0x32, 0x1a, 0x14, 0x67, 0x6f, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, + 0x67, 0x6f, 0x67, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, + 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xc8, 0x01, 0x0a, 0x0a, + 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, + 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x76, 0x65, 0x72, + 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x3b, 0x0a, 0x0b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x5f, 0x69, 0x6e, + 0x66, 0x6f, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x32, 0x2e, 0x53, 0x74, 0x6f, 0x72, + 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0a, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x49, 0x6e, 0x66, 0x6f, + 0x73, 0x12, 0x42, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, + 0x42, 0x08, 0xc8, 0xde, 0x1f, 0x00, 0x90, 0xdf, 0x1f, 0x01, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, + 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x1f, 0x0a, 0x0b, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x5f, + 0x68, 0x61, 0x73, 0x68, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0a, 0x63, 0x6f, 0x6d, 0x6d, + 0x69, 0x74, 0x48, 0x61, 0x73, 0x68, 0x22, 0x75, 0x0a, 0x09, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x49, + 0x6e, 0x66, 0x6f, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x36, 0x0a, 0x09, 0x63, 0x6f, 0x6d, 0x6d, 0x69, + 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x32, 0x2e, 0x43, 0x6f, 0x6d, + 0x6d, 0x69, 0x74, 0x49, 0x44, 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x49, 0x64, 0x12, + 0x1c, 0x0a, 0x09, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x75, 0x72, 0x65, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x75, 0x72, 0x65, 0x22, 0x3e, 0x0a, + 0x08, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x49, 0x44, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, + 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, + 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x61, 0x73, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0c, 0x52, 0x04, 0x68, 0x61, 0x73, 0x68, 0x3a, 0x04, 0x98, 0xa0, 0x1f, 0x00, 0x42, 0xae, 0x01, + 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x73, 0x74, 0x6f, + 0x72, 0x65, 0x2e, 0x76, 0x32, 0x42, 0x0f, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x49, 0x6e, 0x66, + 0x6f, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x28, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2f, 0x76, 0x32, 0x3b, 0x73, 0x74, 0x6f, 0x72, 0x65, + 0x76, 0x32, 0xa2, 0x02, 0x03, 0x43, 0x53, 0x58, 0xaa, 0x02, 0x0f, 0x43, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x0f, 0x43, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x5c, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x5c, 0x56, 0x32, 0xe2, 0x02, 0x1b, 0x43, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x5c, 0x56, 0x32, 0x5c, 0x47, + 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x11, 0x43, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x3a, 0x3a, 0x56, 0x32, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_cosmos_store_v2_commit_info_proto_rawDescOnce sync.Once + file_cosmos_store_v2_commit_info_proto_rawDescData = file_cosmos_store_v2_commit_info_proto_rawDesc +) + +func file_cosmos_store_v2_commit_info_proto_rawDescGZIP() []byte { + file_cosmos_store_v2_commit_info_proto_rawDescOnce.Do(func() { + file_cosmos_store_v2_commit_info_proto_rawDescData = protoimpl.X.CompressGZIP(file_cosmos_store_v2_commit_info_proto_rawDescData) + }) + return file_cosmos_store_v2_commit_info_proto_rawDescData +} + +var file_cosmos_store_v2_commit_info_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_cosmos_store_v2_commit_info_proto_goTypes = []interface{}{ + (*CommitInfo)(nil), // 0: cosmos.store.v2.CommitInfo + (*StoreInfo)(nil), // 1: cosmos.store.v2.StoreInfo + (*CommitID)(nil), // 2: cosmos.store.v2.CommitID + (*timestamppb.Timestamp)(nil), // 3: google.protobuf.Timestamp +} +var file_cosmos_store_v2_commit_info_proto_depIdxs = []int32{ + 1, // 0: cosmos.store.v2.CommitInfo.store_infos:type_name -> cosmos.store.v2.StoreInfo + 3, // 1: cosmos.store.v2.CommitInfo.timestamp:type_name -> google.protobuf.Timestamp + 2, // 2: cosmos.store.v2.StoreInfo.commit_id:type_name -> cosmos.store.v2.CommitID + 3, // [3:3] is the sub-list for method output_type + 3, // [3:3] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name +} + +func init() { file_cosmos_store_v2_commit_info_proto_init() } +func file_cosmos_store_v2_commit_info_proto_init() { + if File_cosmos_store_v2_commit_info_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_cosmos_store_v2_commit_info_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CommitInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_cosmos_store_v2_commit_info_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*StoreInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_cosmos_store_v2_commit_info_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CommitID); 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_cosmos_store_v2_commit_info_proto_rawDesc, + NumEnums: 0, + NumMessages: 3, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_cosmos_store_v2_commit_info_proto_goTypes, + DependencyIndexes: file_cosmos_store_v2_commit_info_proto_depIdxs, + MessageInfos: file_cosmos_store_v2_commit_info_proto_msgTypes, + }.Build() + File_cosmos_store_v2_commit_info_proto = out.File + file_cosmos_store_v2_commit_info_proto_rawDesc = nil + file_cosmos_store_v2_commit_info_proto_goTypes = nil + file_cosmos_store_v2_commit_info_proto_depIdxs = nil +} diff --git a/client/grpc/reflection/reflection.pb.go b/client/grpc/reflection/reflection.pb.go index 2f159025d30f..d54b1f600157 100644 --- a/client/grpc/reflection/reflection.pb.go +++ b/client/grpc/reflection/reflection.pb.go @@ -114,7 +114,7 @@ func (m *ListAllInterfacesResponse) GetInterfaceNames() []string { // ListImplementationsRequest is the request type of the ListImplementations // RPC. type ListImplementationsRequest struct { - // interface_name defines the interface to query the implementations. + // interface_name defines the interface to query the implementations for. InterfaceName string `protobuf:"bytes,1,opt,name=interface_name,json=interfaceName,proto3" json:"interface_name,omitempty"` } diff --git a/proto/cosmos/store/v2/commit_info.proto b/proto/cosmos/store/v2/commit_info.proto new file mode 100644 index 000000000000..18987f34e0ac --- /dev/null +++ b/proto/cosmos/store/v2/commit_info.proto @@ -0,0 +1,34 @@ +syntax = "proto3"; +package cosmos.store.v2; + +import "gogoproto/gogo.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "cosmossdk.io/store/v2/proof"; + +// CommitInfo defines commit information used by the multi-store when committing +// a version/height. +message CommitInfo { + int64 version = 1; + repeated StoreInfo store_infos = 2; + google.protobuf.Timestamp timestamp = 3 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; + bytes commit_hash = 4; +} + +// StoreInfo defines store-specific commit information. It contains a reference +// between a store name and the commit ID. +// +message StoreInfo { + string name = 1; + CommitID commit_id = 2; + string structure = 3; +} + +// CommitID defines the commitment information when a specific store is +// committed. +message CommitID { + option (gogoproto.goproto_stringer) = false; + + int64 version = 1; + bytes hash = 2; +} diff --git a/scripts/init-simapp-v2.sh b/scripts/init-simapp-v2.sh index 3ad1eedc41b1..71d167001fec 100755 --- a/scripts/init-simapp-v2.sh +++ b/scripts/init-simapp-v2.sh @@ -11,7 +11,6 @@ $SIMD_BIN config set client keyring-backend test $SIMD_BIN config set client keyring-default-keyname alice $SIMD_BIN config set app rest.enable true $SIMD_BIN config set app telemetry.prometheus-retention-time 600 -$SIMD_BIN config set app store.options.sc-type iavl-v2 sed -i '' 's/timeout_commit = "5s"/timeout_commit = "1s"/' "$SIMD_HOME"/config/config.toml sed -i '' 's/prometheus = false/prometheus = true/' "$SIMD_HOME"/config/config.toml @@ -19,7 +18,7 @@ $SIMD_BIN keys add alice --indiscreet $SIMD_BIN keys add bob --indiscreet aliases="" for i in $(seq 10); do - alias=$(dd if=/dev/urandom bs=16 count=24 2> /dev/null | base32 | head -c 32) + alias=$(dd if=/dev/urandom bs=16 count=24 2> /dev/null | base64 | head -c 32) $SIMD_BIN keys add "$alias" --indiscreet aliases="$aliases $alias" done diff --git a/server/v2/cometbft/abci_test.go b/server/v2/cometbft/abci_test.go index 780e50b5027d..e6bf1b26191c 100644 --- a/server/v2/cometbft/abci_test.go +++ b/server/v2/cometbft/abci_test.go @@ -913,7 +913,7 @@ func assertStoreLatestVersion(t *testing.T, store types.Store, target uint64) { require.Equal(t, target, version) commitInfo, err := store.GetStateCommitment().GetCommitInfo(version) require.NoError(t, err) - require.Equal(t, target, commitInfo.Version) + require.Equal(t, target, uint64(commitInfo.Version)) } func TestOptimisticExecution(t *testing.T) { diff --git a/server/v2/cometbft/internal/mock/mock_store.go b/server/v2/cometbft/internal/mock/mock_store.go index 8cb4542ac41e..7097aea83211 100644 --- a/server/v2/cometbft/internal/mock/mock_store.go +++ b/server/v2/cometbft/internal/mock/mock_store.go @@ -37,7 +37,7 @@ func (s *MockStore) GetLatestVersion() (uint64, error) { return 0, err } - return lastCommitID.Version, nil + return uint64(lastCommitID.Version), nil } func (s *MockStore) StateLatest() (uint64, corestore.ReaderMap, error) { @@ -99,7 +99,7 @@ func (s *MockStore) LastCommitID() (proof.CommitID, error) { v, err := s.GetStateCommitment().GetLatestVersion() bz := sha256.Sum256([]byte{}) return proof.CommitID{ - Version: v, + Version: int64(v), Hash: bz[:], }, err } diff --git a/server/v2/server.go b/server/v2/server.go index 9f4f3ee66e58..6036be1508cf 100644 --- a/server/v2/server.go +++ b/server/v2/server.go @@ -101,8 +101,15 @@ func (s *Server[T]) Start(ctx context.Context) error { }() } - if err := <-resCh; err != nil { - return fmt.Errorf("failed to start servers: %w", err) + for i := 0; i < len(s.components); i++ { + select { + case err := <-resCh: + if err != nil { + return fmt.Errorf("failed to start servers: %w", err) + } + case <-ctx.Done(): + return nil + } } <-ctx.Done() diff --git a/simapp/v2/app_config.go b/simapp/v2/app_config.go index 0681354b549e..84ed2f8fb643 100644 --- a/simapp/v2/app_config.go +++ b/simapp/v2/app_config.go @@ -37,8 +37,6 @@ import ( _ "cosmossdk.io/x/bank" // import for side-effects banktypes "cosmossdk.io/x/bank/types" _ "cosmossdk.io/x/bank/v2" // import for side-effects - bankv2types "cosmossdk.io/x/bank/v2/types" - bankmodulev2 "cosmossdk.io/x/bank/v2/types/module" _ "cosmossdk.io/x/circuit" // import for side-effects circuittypes "cosmossdk.io/x/circuit/types" _ "cosmossdk.io/x/consensus" // import for side-effects @@ -156,7 +154,7 @@ var ( accounts.ModuleName, authtypes.ModuleName, banktypes.ModuleName, - bankv2types.ModuleName, + // bankv2types.ModuleName, distrtypes.ModuleName, stakingtypes.ModuleName, slashingtypes.ModuleName, @@ -297,10 +295,10 @@ var ( Name: epochstypes.ModuleName, Config: appconfig.WrapAny(&epochsmodulev1.Module{}), }, - { - Name: bankv2types.ModuleName, - Config: appconfig.WrapAny(&bankmodulev2.Module{}), - }, + // { + // Name: bankv2types.ModuleName, + // Config: appconfig.WrapAny(&bankmodulev2.Module{}), + // }, }, } ) diff --git a/simapp/v2/simdv2/cmd/testnet.go b/simapp/v2/simdv2/cmd/testnet.go index 9453a117b54f..1b280b7161b3 100644 --- a/simapp/v2/simdv2/cmd/testnet.go +++ b/simapp/v2/simdv2/cmd/testnet.go @@ -26,7 +26,6 @@ import ( "cosmossdk.io/server/v2/cometbft" "cosmossdk.io/server/v2/store" banktypes "cosmossdk.io/x/bank/types" - bankv2types "cosmossdk.io/x/bank/v2/types" stakingtypes "cosmossdk.io/x/staking/types" "github.com/cosmos/cosmos-sdk/client" @@ -423,13 +422,6 @@ func initGenFiles[T transaction.Tx]( } appGenState[banktypes.ModuleName] = clientCtx.Codec.MustMarshalJSON(&bankGenState) - var bankV2GenState bankv2types.GenesisState - clientCtx.Codec.MustUnmarshalJSON(appGenState[bankv2types.ModuleName], &bankV2GenState) - if len(bankV2GenState.Balances) == 0 { - bankV2GenState = getBankV2GenesisFromV1(bankGenState) - } - appGenState[bankv2types.ModuleName] = clientCtx.Codec.MustMarshalJSON(&bankV2GenState) - appGenStateJSON, err := json.MarshalIndent(appGenState, "", " ") if err != nil { return err @@ -532,16 +524,3 @@ func writeFile(name, dir string, contents []byte) error { return os.WriteFile(file, contents, 0o600) } - -// getBankV2GenesisFromV1 clones bank/v1 state to bank/v2 -// since we not migrate yet -// TODO: Remove -func getBankV2GenesisFromV1(v1GenesisState banktypes.GenesisState) bankv2types.GenesisState { - var v2GenesisState bankv2types.GenesisState - for _, balance := range v1GenesisState.Balances { - v2Balance := bankv2types.Balance(balance) - v2GenesisState.Balances = append(v2GenesisState.Balances, v2Balance) - v2GenesisState.Supply = v2GenesisState.Supply.Add(balance.Coins...) - } - return v2GenesisState -} diff --git a/store/v2/commitment/iavl/exporter.go b/store/v2/commitment/iavl/exporter.go index 20f00d1a1722..7d7c1a5b75fc 100644 --- a/store/v2/commitment/iavl/exporter.go +++ b/store/v2/commitment/iavl/exporter.go @@ -38,3 +38,16 @@ func (e *Exporter) Close() error { return nil } + +// EmptyExporter is a Exporter for an empty tree. +type EmptyExporter struct{} + +// Next returns ExportDone. +func (e *EmptyExporter) Next() (*snapshotstypes.SnapshotIAVLItem, error) { + return nil, commitment.ErrorExportDone +} + +// Close does nothing. +func (e *EmptyExporter) Close() error { + return nil +} diff --git a/store/v2/commitment/iavl/tree.go b/store/v2/commitment/iavl/tree.go index 1769bc45126e..9b7d1641ab68 100644 --- a/store/v2/commitment/iavl/tree.go +++ b/store/v2/commitment/iavl/tree.go @@ -1,6 +1,7 @@ package iavl import ( + "errors" "fmt" "github.com/cosmos/iavl" @@ -21,6 +22,8 @@ var ( // IavlTree is a wrapper around iavl.MutableTree. type IavlTree struct { tree *iavl.MutableTree + // it is only used for new store key during the migration process. + initialVersion uint64 } // NewIavlTree creates a new IavlTree instance. @@ -65,6 +68,17 @@ func (t *IavlTree) WorkingHash() []byte { // LoadVersion loads the state at the given version. func (t *IavlTree) LoadVersion(version uint64) error { + if t.initialVersion > 0 { + // If the initial version is set and the tree is empty, + // we don't need to load the version. + latestVersion, err := t.tree.GetLatestVersion() + if err != nil { + return err + } + if latestVersion == 0 { + return nil + } + } _, err := t.tree.LoadVersion(int64(version)) return err } @@ -150,6 +164,7 @@ func (t *IavlTree) GetLatestVersion() (uint64, error) { // SetInitialVersion sets the initial version of the database. func (t *IavlTree) SetInitialVersion(version uint64) error { t.tree.SetInitialVersion(version) + t.initialVersion = version return nil } @@ -169,6 +184,9 @@ func (t *IavlTree) PausePruning(pause bool) { // Export exports the tree exporter at the given version. func (t *IavlTree) Export(version uint64) (commitment.Exporter, error) { + if version < t.initialVersion { + return nil, errors.New("version is less than the initial version") + } tree, err := t.tree.GetImmutable(int64(version)) if err != nil { return nil, err diff --git a/store/v2/commitment/metadata.go b/store/v2/commitment/metadata.go index a054acf26e89..62ae4a3d1655 100644 --- a/store/v2/commitment/metadata.go +++ b/store/v2/commitment/metadata.go @@ -1,19 +1,20 @@ package commitment import ( - "bytes" "errors" "fmt" + gogotypes "github.com/cosmos/gogoproto/types" + corestore "cosmossdk.io/core/store" "cosmossdk.io/store/v2/internal/encoding" "cosmossdk.io/store/v2/proof" ) const ( - commitInfoKeyFmt = "c/%d" // c/ - latestVersionKey = "c/latest" - removedStoreKeyPrefix = "c/removed/" // c/removed// + commitInfoKeyFmt = "s/%d" // s/ + latestVersionKey = "s/latest" + removedStoreKeyPrefix = "s/removed/" // s/removed// ) // MetadataStore is a store for metadata related to the commitment store. @@ -39,21 +40,20 @@ func (m *MetadataStore) GetLatestVersion() (uint64, error) { return 0, nil } - version, _, err := encoding.DecodeUvarint(value) - if err != nil { + var latestVersion int64 + if err := gogotypes.StdInt64Unmarshal(&latestVersion, value); err != nil { return 0, err } - return version, nil + return uint64(latestVersion), nil } func (m *MetadataStore) setLatestVersion(version uint64) error { - var buf bytes.Buffer - buf.Grow(encoding.EncodeUvarintSize(version)) - if err := encoding.EncodeUvarint(&buf, version); err != nil { + bz, err := gogotypes.StdInt64Marshal(int64(version)) // convert uint64 to int64 is safe since there will be no overflow or underflow + if err != nil { return err } - return m.kv.Set([]byte(latestVersionKey), buf.Bytes()) + return m.kv.Set([]byte(latestVersionKey), bz) } // GetCommitInfo returns the commit info for the given version. @@ -72,6 +72,10 @@ func (m *MetadataStore) GetCommitInfo(version uint64) (*proof.CommitInfo, error) return nil, err } + if err := migrateStoreInfo(cInfo); err != nil { + return nil, err + } + return cInfo, nil } @@ -94,12 +98,11 @@ func (m *MetadataStore) flushCommitInfo(version uint64, cInfo *proof.CommitInfo) return err } - var buf bytes.Buffer - buf.Grow(encoding.EncodeUvarintSize(version)) - if err := encoding.EncodeUvarint(&buf, version); err != nil { + bz, err := gogotypes.StdInt64Marshal(int64(version)) // convert uint64 to int64 is safe since there will be no overflow or underflow + if err != nil { return err } - if err := batch.Set([]byte(latestVersionKey), buf.Bytes()); err != nil { + if err := batch.Set([]byte(latestVersionKey), bz); err != nil { return err } @@ -172,3 +175,23 @@ func (m *MetadataStore) deleteCommitInfo(version uint64) error { cInfoKey := []byte(fmt.Sprintf(commitInfoKeyFmt, version)) return m.kv.Delete(cInfoKey) } + +// when in migration mode, we need to add new fields to the store info +// this will only be the case for the storev1 to storev2 migration +func migrateStoreInfo(cInfo *proof.CommitInfo) error { + for _, storeInfo := range cInfo.StoreInfos { + if storeInfo.Structure == "" { + storeInfo.Structure = "iavl" + } + } + + if cInfo.CommitHash == nil { + commitHash, _, err := cInfo.GetStoreProof([]byte{}) + if err != nil { + return err + } + + cInfo.CommitHash = commitHash + } + return nil +} diff --git a/store/v2/commitment/store.go b/store/v2/commitment/store.go index 757fb45851c1..08c254b1992d 100644 --- a/store/v2/commitment/store.go +++ b/store/v2/commitment/store.go @@ -229,7 +229,7 @@ func (c *CommitStore) Commit(version uint64) (*proof.CommitInfo, error) { if internal.IsMemoryStoreKey(storeKey) { continue } - si := &proof.StoreInfo{Name: []byte(storeKey)} + si := &proof.StoreInfo{Name: storeKey} storeInfos = append(storeInfos, si) if tree.IsConcurrentSafe() { @@ -248,9 +248,13 @@ func (c *CommitStore) Commit(version uint64) (*proof.CommitInfo, error) { } } + // convert storeInfos to []proof.StoreInfo + sideref := make([]*proof.StoreInfo, 0, len(c.multiTrees)) + sideref = append(sideref, storeInfos...) + cInfo := &proof.CommitInfo{ - Version: version, - StoreInfos: storeInfos, + Version: int64(version), + StoreInfos: sideref, } if err := eg.Wait(); err != nil { @@ -272,8 +276,8 @@ func (c *CommitStore) commit(tree Tree, si *proof.StoreInfo, expected uint64) er if v != expected { return fmt.Errorf("commit version %d does not match the target version %d", v, expected) } - si.CommitID = &proof.CommitID{ - Version: v, + si.CommitId = &proof.CommitID{ + Version: int64(v), Hash: h, } return nil @@ -596,18 +600,17 @@ func (c *CommitStore) GetCommitInfo(version uint64) (*proof.CommitInfo, error) { if v != version { return nil, fmt.Errorf("tree version %d does not match the target version %d", v, version) } - bz := []byte(storeKey) storeInfos = append(storeInfos, &proof.StoreInfo{ - Name: bz, - CommitID: &proof.CommitID{ - Version: v, + Name: storeKey, + CommitId: &proof.CommitID{ + Version: int64(v), Hash: tree.Hash(), }, }) } ci = &proof.CommitInfo{ - Version: version, + Version: int64(version), StoreInfos: storeInfos, } return ci, nil diff --git a/store/v2/commitment/store_test_suite.go b/store/v2/commitment/store_test_suite.go index 76d1029a74a9..955b743058a7 100644 --- a/store/v2/commitment/store_test_suite.go +++ b/store/v2/commitment/store_test_suite.go @@ -1,9 +1,9 @@ package commitment import ( - "bytes" "fmt" "io" + "strings" "github.com/stretchr/testify/suite" @@ -134,7 +134,7 @@ func (s *CommitStoreTestSuite) TestStore_Snapshotter() { for _, storeInfo := range targetCommitInfo.StoreInfos { matched := false for _, latestStoreInfo := range cInfo.StoreInfos { - if bytes.Equal(storeInfo.Name, latestStoreInfo.Name) { + if strings.EqualFold(storeInfo.Name, latestStoreInfo.Name) { s.Require().Equal(latestStoreInfo.GetHash(), storeInfo.GetHash()) matched = true } @@ -176,7 +176,7 @@ func (s *CommitStoreTestSuite) TestStore_LoadVersion() { for i := uint64(1); i <= latestVersion; i++ { commitInfo, _ := targetStore.GetCommitInfo(i) s.Require().NotNil(commitInfo) - s.Require().Equal(i, commitInfo.Version) + s.Require().Equal(i, uint64(commitInfo.Version)) } // rollback to a previous version diff --git a/store/v2/go.mod b/store/v2/go.mod index a75aadc81a94..dcb57635f47c 100644 --- a/store/v2/go.mod +++ b/store/v2/go.mod @@ -20,6 +20,7 @@ require ( github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d go.uber.org/mock v0.5.0 golang.org/x/sync v0.10.0 + google.golang.org/protobuf v1.36.2 ) require ( @@ -71,6 +72,5 @@ require ( golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect golang.org/x/sys v0.28.0 // indirect golang.org/x/text v0.21.0 // indirect - google.golang.org/protobuf v1.36.2 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/store/v2/migration/manager.go b/store/v2/migration/manager.go index 5365e8eb6a11..18bf6d4c9b7a 100644 --- a/store/v2/migration/manager.go +++ b/store/v2/migration/manager.go @@ -200,11 +200,8 @@ func (m *Manager) Sync() error { } // Close closes the manager. It should be called after the migration is done. -// It will close the db and notify the snapshotsManager that the migration is done. +// It will notify the snapshotsManager that the migration is done. func (m *Manager) Close() error { - if err := m.db.Close(); err != nil { - return fmt.Errorf("failed to close db: %w", err) - } if m.stateCommitment != nil { m.snapshotsManager.EndMigration(m.stateCommitment) } diff --git a/store/v2/migration/manager_test.go b/store/v2/migration/manager_test.go index 103b3244b650..f5382ac33011 100644 --- a/store/v2/migration/manager_test.go +++ b/store/v2/migration/manager_test.go @@ -70,7 +70,6 @@ func TestMigrateState(t *testing.T) { // expecting error for conflicting process, since Migrate trigger snapshotter create migration, // which start a snapshot process already. _, err = m.snapshotsManager.Create(toVersion - 1) - fmt.Println(1) require.Error(t, err) // check the migrated state diff --git a/store/v2/proof/commit_info.go b/store/v2/proof/commit_info.go index 0ca52bd8dd87..b42b401ae61d 100644 --- a/store/v2/proof/commit_info.go +++ b/store/v2/proof/commit_info.go @@ -1,42 +1,13 @@ package proof import ( - "bytes" "fmt" "sort" - "time" - - "cosmossdk.io/store/v2/internal/encoding" -) - -type ( - // CommitInfo defines commit information used by the multi-store when committing - // a version/height. - CommitInfo struct { - Version uint64 - StoreInfos []*StoreInfo - Timestamp time.Time - CommitHash []byte - } - - // StoreInfo defines store-specific commit information. It contains a reference - // between a store name/key and the commit ID. - StoreInfo struct { - Name []byte - CommitID *CommitID - Structure string - } - - // CommitID defines the commitment information when a specific store is - // committed. - CommitID struct { - Version uint64 - Hash []byte - } + "strings" ) func (si StoreInfo) GetHash() []byte { - return si.CommitID.Hash + return si.CommitId.Hash } // Hash returns the root hash of all committed stores represented by CommitInfo, @@ -57,8 +28,8 @@ func (ci *CommitInfo) Hash() []byte { // GetStoreCommitID returns the CommitID for the given store key. func (ci *CommitInfo) GetStoreCommitID(storeKey []byte) *CommitID { for _, si := range ci.StoreInfos { - if bytes.Equal(si.Name, storeKey) { - return si.CommitID + if strings.EqualFold(si.Name, string(storeKey)) { + return si.CommitId } } return &CommitID{} @@ -69,7 +40,7 @@ func (ci *CommitInfo) GetStoreCommitID(storeKey []byte) *CommitID { // store based on lexographical ordering will be proved. func (ci *CommitInfo) GetStoreProof(storeKey []byte) ([]byte, *CommitmentOp, error) { sort.Slice(ci.StoreInfos, func(i, j int) bool { - return bytes.Compare(ci.StoreInfos[i].Name, ci.StoreInfos[j].Name) < 0 + return strings.Compare(ci.StoreInfos[i].Name, ci.StoreInfos[j].Name) < 0 }) isEmpty := len(storeKey) == 0 @@ -77,11 +48,11 @@ func (ci *CommitInfo) GetStoreProof(storeKey []byte) ([]byte, *CommitmentOp, err leaves := make([][]byte, len(ci.StoreInfos)) for i, si := range ci.StoreInfos { var err error - leaves[i], err = LeafHash(si.Name, si.GetHash()) + leaves[i], err = LeafHash([]byte(si.Name), si.GetHash()) if err != nil { return nil, nil, err } - if !isEmpty && bytes.Equal(si.Name, storeKey) { + if !isEmpty && strings.EqualFold(si.Name, string(storeKey)) { index = i } } @@ -99,111 +70,6 @@ func (ci *CommitInfo) GetStoreProof(storeKey []byte) ([]byte, *CommitmentOp, err return rootHash, &commitmentOp, nil } -// encodedSize returns the encoded size of CommitInfo for preallocation in Marshal. -func (ci *CommitInfo) encodedSize() int { - size := encoding.EncodeUvarintSize(ci.Version) - size += encoding.EncodeVarintSize(ci.Timestamp.UnixNano()) - size += encoding.EncodeUvarintSize(uint64(len(ci.StoreInfos))) - for _, storeInfo := range ci.StoreInfos { - size += encoding.EncodeBytesSize(storeInfo.Name) - size += encoding.EncodeBytesSize(storeInfo.CommitID.Hash) - size += encoding.EncodeBytesSize([]byte(storeInfo.Structure)) - } - return size -} - -// Marshal returns the encoded byte representation of CommitInfo. -// NOTE: CommitInfo is encoded as follows: -// - version (uvarint) -// - timestamp (varint) -// - number of stores (uvarint) -// - for each store: -// - store name (bytes) -// - store hash (bytes) -// - store commit structure (bytes) -func (ci *CommitInfo) Marshal() ([]byte, error) { - var buf bytes.Buffer - buf.Grow(ci.encodedSize()) - - if err := encoding.EncodeUvarint(&buf, ci.Version); err != nil { - return nil, err - } - if err := encoding.EncodeVarint(&buf, ci.Timestamp.UnixNano()); err != nil { - return nil, err - } - if err := encoding.EncodeUvarint(&buf, uint64(len(ci.StoreInfos))); err != nil { - return nil, err - } - for _, si := range ci.StoreInfos { - if err := encoding.EncodeBytes(&buf, si.Name); err != nil { - return nil, err - } - if err := encoding.EncodeBytes(&buf, si.CommitID.Hash); err != nil { - return nil, err - } - if err := encoding.EncodeBytes(&buf, []byte(si.Structure)); err != nil { - return nil, err - } - } - - return buf.Bytes(), nil -} - -// Unmarshal unmarshals the encoded byte representation of CommitInfo. -func (ci *CommitInfo) Unmarshal(buf []byte) error { - // Version - version, n, err := encoding.DecodeUvarint(buf) - if err != nil { - return err - } - buf = buf[n:] - ci.Version = version - // Timestamp - timestamp, n, err := encoding.DecodeVarint(buf) - if err != nil { - return err - } - buf = buf[n:] - ci.Timestamp = time.Unix(timestamp/int64(time.Second), timestamp%int64(time.Second)) - // StoreInfos - storeInfosLen, n, err := encoding.DecodeUvarint(buf) - if err != nil { - return err - } - buf = buf[n:] - ci.StoreInfos = make([]*StoreInfo, storeInfosLen) - for i := 0; i < int(storeInfosLen); i++ { - ci.StoreInfos[i] = &StoreInfo{} - // Name - name, n, err := encoding.DecodeBytes(buf) - if err != nil { - return err - } - buf = buf[n:] - ci.StoreInfos[i].Name = name - // CommitID - hash, n, err := encoding.DecodeBytes(buf) - if err != nil { - return err - } - buf = buf[n:] - // Structure - structure, n, err := encoding.DecodeBytes(buf) - if err != nil { - return err - } - buf = buf[n:] - ci.StoreInfos[i].Structure = string(structure) - - ci.StoreInfos[i].CommitID = &CommitID{ - Hash: hash, - Version: ci.Version, - } - } - - return nil -} - func (ci *CommitInfo) CommitID() *CommitID { return &CommitID{ Version: ci.Version, @@ -211,13 +77,6 @@ func (ci *CommitInfo) CommitID() *CommitID { } } -func (ci *CommitInfo) GetVersion() uint64 { - if ci != nil { - return ci.Version - } - return 0 -} - func (cid *CommitID) String() string { return fmt.Sprintf("CommitID{%v:%X}", cid.Hash, cid.Version) } diff --git a/store/v2/proof/commit_info.pb.go b/store/v2/proof/commit_info.pb.go new file mode 100644 index 000000000000..26811186fd4c --- /dev/null +++ b/store/v2/proof/commit_info.pb.go @@ -0,0 +1,975 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: cosmos/store/v2/commit_info.proto + +package proof + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types" + _ "google.golang.org/protobuf/types/known/timestamppb" + io "io" + math "math" + math_bits "math/bits" + time "time" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf +var _ = time.Kitchen + +// 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 + +// CommitInfo defines commit information used by the multi-store when committing +// a version/height. +type CommitInfo struct { + Version int64 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"` + StoreInfos []*StoreInfo `protobuf:"bytes,2,rep,name=store_infos,json=storeInfos,proto3" json:"store_infos,omitempty"` + Timestamp time.Time `protobuf:"bytes,3,opt,name=timestamp,proto3,stdtime" json:"timestamp"` + CommitHash []byte `protobuf:"bytes,4,opt,name=commit_hash,json=commitHash,proto3" json:"commit_hash,omitempty"` +} + +func (m *CommitInfo) Reset() { *m = CommitInfo{} } +func (m *CommitInfo) String() string { return proto.CompactTextString(m) } +func (*CommitInfo) ProtoMessage() {} +func (*CommitInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_fae1fdc51331137e, []int{0} +} +func (m *CommitInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CommitInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CommitInfo.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *CommitInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_CommitInfo.Merge(m, src) +} +func (m *CommitInfo) XXX_Size() int { + return m.Size() +} +func (m *CommitInfo) XXX_DiscardUnknown() { + xxx_messageInfo_CommitInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_CommitInfo proto.InternalMessageInfo + +func (m *CommitInfo) GetVersion() int64 { + if m != nil { + return m.Version + } + return 0 +} + +func (m *CommitInfo) GetStoreInfos() []*StoreInfo { + if m != nil { + return m.StoreInfos + } + return nil +} + +func (m *CommitInfo) GetTimestamp() time.Time { + if m != nil { + return m.Timestamp + } + return time.Time{} +} + +func (m *CommitInfo) GetCommitHash() []byte { + if m != nil { + return m.CommitHash + } + return nil +} + +// StoreInfo defines store-specific commit information. It contains a reference +// between a store name and the commit ID. +type StoreInfo struct { + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + CommitId *CommitID `protobuf:"bytes,2,opt,name=commit_id,json=commitId,proto3" json:"commit_id,omitempty"` + Structure string `protobuf:"bytes,3,opt,name=structure,proto3" json:"structure,omitempty"` +} + +func (m *StoreInfo) Reset() { *m = StoreInfo{} } +func (m *StoreInfo) String() string { return proto.CompactTextString(m) } +func (*StoreInfo) ProtoMessage() {} +func (*StoreInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_fae1fdc51331137e, []int{1} +} +func (m *StoreInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StoreInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_StoreInfo.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *StoreInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_StoreInfo.Merge(m, src) +} +func (m *StoreInfo) XXX_Size() int { + return m.Size() +} +func (m *StoreInfo) XXX_DiscardUnknown() { + xxx_messageInfo_StoreInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_StoreInfo proto.InternalMessageInfo + +func (m *StoreInfo) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *StoreInfo) GetCommitId() *CommitID { + if m != nil { + return m.CommitId + } + return nil +} + +func (m *StoreInfo) GetStructure() string { + if m != nil { + return m.Structure + } + return "" +} + +// CommitID defines the commitment information when a specific store is +// committed. +type CommitID struct { + Version int64 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"` + Hash []byte `protobuf:"bytes,2,opt,name=hash,proto3" json:"hash,omitempty"` +} + +func (m *CommitID) Reset() { *m = CommitID{} } +func (*CommitID) ProtoMessage() {} +func (*CommitID) Descriptor() ([]byte, []int) { + return fileDescriptor_fae1fdc51331137e, []int{2} +} +func (m *CommitID) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CommitID) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CommitID.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *CommitID) XXX_Merge(src proto.Message) { + xxx_messageInfo_CommitID.Merge(m, src) +} +func (m *CommitID) XXX_Size() int { + return m.Size() +} +func (m *CommitID) XXX_DiscardUnknown() { + xxx_messageInfo_CommitID.DiscardUnknown(m) +} + +var xxx_messageInfo_CommitID proto.InternalMessageInfo + +func (m *CommitID) GetVersion() int64 { + if m != nil { + return m.Version + } + return 0 +} + +func (m *CommitID) GetHash() []byte { + if m != nil { + return m.Hash + } + return nil +} + +func init() { + proto.RegisterType((*CommitInfo)(nil), "cosmos.store.v2.CommitInfo") + proto.RegisterType((*StoreInfo)(nil), "cosmos.store.v2.StoreInfo") + proto.RegisterType((*CommitID)(nil), "cosmos.store.v2.CommitID") +} + +func init() { proto.RegisterFile("cosmos/store/v2/commit_info.proto", fileDescriptor_fae1fdc51331137e) } + +var fileDescriptor_fae1fdc51331137e = []byte{ + // 355 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x92, 0x31, 0x4f, 0xc2, 0x50, + 0x10, 0xc7, 0xfb, 0xa0, 0x51, 0x7a, 0x98, 0x98, 0xbc, 0x38, 0x54, 0x34, 0x6d, 0x65, 0x62, 0x7a, + 0x4d, 0x30, 0x3a, 0x68, 0xe2, 0x80, 0x0e, 0xb2, 0x56, 0x27, 0x17, 0x53, 0xa0, 0x2d, 0x8d, 0xb6, + 0x47, 0xfa, 0x5e, 0xf9, 0x1c, 0x8c, 0x8e, 0x7e, 0x1c, 0x46, 0x46, 0x27, 0x35, 0xf0, 0x45, 0x0c, + 0xf7, 0x28, 0x24, 0x9a, 0xb8, 0xfd, 0xdf, 0xf5, 0x7f, 0x77, 0xbf, 0xfb, 0xa7, 0x70, 0x36, 0x44, + 0x99, 0xa1, 0xf4, 0xa5, 0xc2, 0x22, 0xf2, 0xa7, 0x5d, 0x7f, 0x88, 0x59, 0x96, 0xaa, 0xe7, 0x34, + 0x8f, 0x51, 0x4c, 0x0a, 0x54, 0xc8, 0x0f, 0xb5, 0x45, 0x90, 0x45, 0x4c, 0xbb, 0xad, 0xa3, 0x04, + 0x13, 0xa4, 0x6f, 0xfe, 0x5a, 0x69, 0x5b, 0xcb, 0x4d, 0x10, 0x93, 0xd7, 0xc8, 0xa7, 0xd7, 0xa0, + 0x8c, 0x7d, 0x95, 0x66, 0x91, 0x54, 0x61, 0x36, 0xd1, 0x86, 0xf6, 0x9c, 0x01, 0xdc, 0xd2, 0xf4, + 0x7e, 0x1e, 0x23, 0xb7, 0x61, 0x7f, 0x1a, 0x15, 0x32, 0xc5, 0xdc, 0x66, 0x1e, 0xeb, 0xd4, 0x83, + 0xea, 0xc9, 0xaf, 0xa1, 0x49, 0xbb, 0x08, 0x42, 0xda, 0x35, 0xaf, 0xde, 0x69, 0x76, 0x5b, 0xe2, + 0x17, 0x86, 0x78, 0x58, 0x8b, 0xf5, 0xa8, 0x00, 0x64, 0x25, 0x25, 0xef, 0x81, 0xb5, 0x5d, 0x6c, + 0xd7, 0x3d, 0x46, 0xad, 0x1a, 0x4d, 0x54, 0x68, 0xe2, 0xb1, 0x72, 0xf4, 0x1a, 0xf3, 0x4f, 0xd7, + 0x98, 0x7d, 0xb9, 0x2c, 0xd8, 0xb5, 0x71, 0x17, 0x9a, 0x9b, 0x18, 0xc6, 0xa1, 0x1c, 0xdb, 0xa6, + 0xc7, 0x3a, 0x07, 0x01, 0xe8, 0xd2, 0x7d, 0x28, 0xc7, 0xed, 0x12, 0xac, 0xed, 0x76, 0xce, 0xc1, + 0xcc, 0xc3, 0x2c, 0xa2, 0x2b, 0xac, 0x80, 0x34, 0xbf, 0x04, 0xab, 0x0a, 0x72, 0x64, 0xd7, 0x88, + 0xe2, 0xf8, 0xcf, 0x01, 0x9b, 0x30, 0xee, 0x82, 0x86, 0xf6, 0xf6, 0x47, 0xfc, 0x14, 0x2c, 0xa9, + 0x8a, 0x72, 0xa8, 0xca, 0x22, 0x22, 0x7a, 0x2b, 0xd8, 0x15, 0xda, 0x37, 0xd0, 0xa8, 0x7a, 0xfe, + 0x89, 0x8f, 0x83, 0x49, 0xd8, 0x35, 0xc2, 0x26, 0x7d, 0x65, 0xbe, 0xbd, 0xbb, 0x46, 0xef, 0x62, + 0xbe, 0x74, 0xd8, 0x62, 0xe9, 0xb0, 0xef, 0xa5, 0xc3, 0x66, 0x2b, 0xc7, 0x58, 0xac, 0x1c, 0xe3, + 0x63, 0xe5, 0x18, 0x4f, 0x27, 0x9a, 0x4d, 0x8e, 0x5e, 0x44, 0x8a, 0xbb, 0x9f, 0x61, 0x52, 0x20, + 0xc6, 0x83, 0x3d, 0xca, 0xed, 0xfc, 0x27, 0x00, 0x00, 0xff, 0xff, 0x18, 0xd0, 0x41, 0xbe, 0x2c, + 0x02, 0x00, 0x00, +} + +func (m *CommitInfo) 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 *CommitInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CommitInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.CommitHash) > 0 { + i -= len(m.CommitHash) + copy(dAtA[i:], m.CommitHash) + i = encodeVarintCommitInfo(dAtA, i, uint64(len(m.CommitHash))) + i-- + dAtA[i] = 0x22 + } + n1, err1 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.Timestamp, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.Timestamp):]) + if err1 != nil { + return 0, err1 + } + i -= n1 + i = encodeVarintCommitInfo(dAtA, i, uint64(n1)) + i-- + dAtA[i] = 0x1a + if len(m.StoreInfos) > 0 { + for iNdEx := len(m.StoreInfos) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.StoreInfos[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintCommitInfo(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if m.Version != 0 { + i = encodeVarintCommitInfo(dAtA, i, uint64(m.Version)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *StoreInfo) 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 *StoreInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StoreInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Structure) > 0 { + i -= len(m.Structure) + copy(dAtA[i:], m.Structure) + i = encodeVarintCommitInfo(dAtA, i, uint64(len(m.Structure))) + i-- + dAtA[i] = 0x1a + } + if m.CommitId != nil { + { + size, err := m.CommitId.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintCommitInfo(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintCommitInfo(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *CommitID) 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 *CommitID) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CommitID) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Hash) > 0 { + i -= len(m.Hash) + copy(dAtA[i:], m.Hash) + i = encodeVarintCommitInfo(dAtA, i, uint64(len(m.Hash))) + i-- + dAtA[i] = 0x12 + } + if m.Version != 0 { + i = encodeVarintCommitInfo(dAtA, i, uint64(m.Version)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintCommitInfo(dAtA []byte, offset int, v uint64) int { + offset -= sovCommitInfo(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *CommitInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Version != 0 { + n += 1 + sovCommitInfo(uint64(m.Version)) + } + if len(m.StoreInfos) > 0 { + for _, e := range m.StoreInfos { + l = e.Size() + n += 1 + l + sovCommitInfo(uint64(l)) + } + } + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.Timestamp) + n += 1 + l + sovCommitInfo(uint64(l)) + l = len(m.CommitHash) + if l > 0 { + n += 1 + l + sovCommitInfo(uint64(l)) + } + return n +} + +func (m *StoreInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovCommitInfo(uint64(l)) + } + if m.CommitId != nil { + l = m.CommitId.Size() + n += 1 + l + sovCommitInfo(uint64(l)) + } + l = len(m.Structure) + if l > 0 { + n += 1 + l + sovCommitInfo(uint64(l)) + } + return n +} + +func (m *CommitID) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Version != 0 { + n += 1 + sovCommitInfo(uint64(m.Version)) + } + l = len(m.Hash) + if l > 0 { + n += 1 + l + sovCommitInfo(uint64(l)) + } + return n +} + +func sovCommitInfo(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozCommitInfo(x uint64) (n int) { + return sovCommitInfo(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *CommitInfo) 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 ErrIntOverflowCommitInfo + } + 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: CommitInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CommitInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) + } + m.Version = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCommitInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Version |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StoreInfos", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCommitInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthCommitInfo + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthCommitInfo + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.StoreInfos = append(m.StoreInfos, &StoreInfo{}) + if err := m.StoreInfos[len(m.StoreInfos)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Timestamp", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCommitInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthCommitInfo + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthCommitInfo + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.Timestamp, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CommitHash", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCommitInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthCommitInfo + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthCommitInfo + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CommitHash = append(m.CommitHash[:0], dAtA[iNdEx:postIndex]...) + if m.CommitHash == nil { + m.CommitHash = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipCommitInfo(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthCommitInfo + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *StoreInfo) 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 ErrIntOverflowCommitInfo + } + 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: StoreInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StoreInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCommitInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthCommitInfo + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCommitInfo + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CommitId", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCommitInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthCommitInfo + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthCommitInfo + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.CommitId == nil { + m.CommitId = &CommitID{} + } + if err := m.CommitId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Structure", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCommitInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthCommitInfo + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCommitInfo + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Structure = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipCommitInfo(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthCommitInfo + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CommitID) 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 ErrIntOverflowCommitInfo + } + 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: CommitID: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CommitID: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) + } + m.Version = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCommitInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Version |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCommitInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthCommitInfo + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthCommitInfo + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Hash = append(m.Hash[:0], dAtA[iNdEx:postIndex]...) + if m.Hash == nil { + m.Hash = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipCommitInfo(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthCommitInfo + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipCommitInfo(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, ErrIntOverflowCommitInfo + } + 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, ErrIntOverflowCommitInfo + } + 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, ErrIntOverflowCommitInfo + } + 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, ErrInvalidLengthCommitInfo + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupCommitInfo + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthCommitInfo + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthCommitInfo = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowCommitInfo = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupCommitInfo = fmt.Errorf("proto: unexpected end of group") +) diff --git a/store/v2/proof/commit_info_test.go b/store/v2/proof/commit_info_test.go index 1c0221fe6360..61f4f48412ab 100644 --- a/store/v2/proof/commit_info_test.go +++ b/store/v2/proof/commit_info_test.go @@ -13,27 +13,27 @@ func TestGetStoreProof(t *testing.T) { storeInfos []*StoreInfo }{ {[]*StoreInfo{ - {[]byte("key1"), &CommitID{1, []byte("value1")}, "iavl"}, + {("key1"), &CommitID{1, []byte("value1")}, "iavl"}, }}, {[]*StoreInfo{ - {[]byte("key2"), &CommitID{1, []byte("value2")}, "iavl"}, - {[]byte("key1"), &CommitID{1, []byte("value1")}, "iavl"}, + {("key2"), &CommitID{1, []byte("value2")}, "iavl"}, + {("key1"), &CommitID{1, []byte("value1")}, "iavl"}, }}, {[]*StoreInfo{ - {[]byte("key3"), &CommitID{1, []byte("value3")}, "iavl"}, - {[]byte("key2"), &CommitID{1, []byte("value2")}, "iavl"}, - {[]byte("key1"), &CommitID{1, []byte("value1")}, "iavl"}, + {("key3"), &CommitID{1, []byte("value3")}, "iavl"}, + {("key2"), &CommitID{1, []byte("value2")}, "iavl"}, + {("key1"), &CommitID{1, []byte("value1")}, "iavl"}, }}, {[]*StoreInfo{ - {[]byte("key2"), &CommitID{1, []byte("value2")}, "iavl"}, - {[]byte("key1"), &CommitID{1, []byte("value1")}, "iavl"}, - {[]byte("key3"), &CommitID{1, []byte("value3")}, "iavl"}, + {("key2"), &CommitID{1, []byte("value2")}, "iavl"}, + {("key1"), &CommitID{1, []byte("value1")}, "iavl"}, + {("key3"), &CommitID{1, []byte("value3")}, "iavl"}, }}, {[]*StoreInfo{ - {[]byte("key4"), &CommitID{1, []byte("value4")}, "iavl"}, - {[]byte("key1"), &CommitID{1, []byte("value1")}, "iavl"}, - {[]byte("key3"), &CommitID{1, []byte("value3")}, "iavl"}, - {[]byte("key2"), &CommitID{1, []byte("value2")}, "iavl"}, + {("key4"), &CommitID{1, []byte("value4")}, "iavl"}, + {("key1"), &CommitID{1, []byte("value1")}, "iavl"}, + {("key3"), &CommitID{1, []byte("value3")}, "iavl"}, + {("key2"), &CommitID{1, []byte("value2")}, "iavl"}, }}, } @@ -47,13 +47,13 @@ func TestGetStoreProof(t *testing.T) { } commitHash := ci.Hash() // make sure the store infos are sorted - require.Equal(t, ci.StoreInfos[0].Name, []byte("key1")) + require.Equal(t, ci.StoreInfos[0].Name, "key1") for _, si := range tc.storeInfos { // get the proof - _, proof, err := ci.GetStoreProof(si.Name) + _, proof, err := ci.GetStoreProof([]byte(si.Name)) require.NoError(t, err, "test case %d", i) // verify the proof - expRoots, err := proof.Run([][]byte{si.CommitID.Hash}) + expRoots, err := proof.Run([][]byte{si.CommitId.Hash}) require.NoError(t, err, "test case %d", i) require.Equal(t, commitHash, expRoots[0], "test case %d", i) diff --git a/store/v2/proof/v1/types/commit_info.pb.go b/store/v2/proof/v1/types/commit_info.pb.go new file mode 100644 index 000000000000..aa3c6788690f --- /dev/null +++ b/store/v2/proof/v1/types/commit_info.pb.go @@ -0,0 +1,859 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: cosmos/store/v1beta1/commit_info.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types" + _ "google.golang.org/protobuf/types/known/timestamppb" + io "io" + math "math" + math_bits "math/bits" + time "time" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf +var _ = time.Kitchen + +// 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 + +// CommitInfo defines commit information used by the multi-store when committing +// a version/height. +type CommitInfo struct { + Version int64 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"` + StoreInfos []StoreInfo `protobuf:"bytes,2,rep,name=store_infos,json=storeInfos,proto3" json:"store_infos"` + Timestamp time.Time `protobuf:"bytes,3,opt,name=timestamp,proto3,stdtime" json:"timestamp"` +} + +func (m *CommitInfo) Reset() { *m = CommitInfo{} } +func (m *CommitInfo) String() string { return proto.CompactTextString(m) } +func (*CommitInfo) ProtoMessage() {} +func (*CommitInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_5f8c656cdef8c524, []int{0} +} +func (m *CommitInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CommitInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CommitInfo.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *CommitInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_CommitInfo.Merge(m, src) +} +func (m *CommitInfo) XXX_Size() int { + return m.Size() +} +func (m *CommitInfo) XXX_DiscardUnknown() { + xxx_messageInfo_CommitInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_CommitInfo proto.InternalMessageInfo + +func (m *CommitInfo) GetVersion() int64 { + if m != nil { + return m.Version + } + return 0 +} + +func (m *CommitInfo) GetStoreInfos() []StoreInfo { + if m != nil { + return m.StoreInfos + } + return nil +} + +func (m *CommitInfo) GetTimestamp() time.Time { + if m != nil { + return m.Timestamp + } + return time.Time{} +} + +// StoreInfo defines store-specific commit information. It contains a reference +// between a store name and the commit ID. +type StoreInfo struct { + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + CommitId CommitID `protobuf:"bytes,2,opt,name=commit_id,json=commitId,proto3" json:"commit_id"` +} + +func (m *StoreInfo) Reset() { *m = StoreInfo{} } +func (m *StoreInfo) String() string { return proto.CompactTextString(m) } +func (*StoreInfo) ProtoMessage() {} +func (*StoreInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_5f8c656cdef8c524, []int{1} +} +func (m *StoreInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StoreInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_StoreInfo.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *StoreInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_StoreInfo.Merge(m, src) +} +func (m *StoreInfo) XXX_Size() int { + return m.Size() +} +func (m *StoreInfo) XXX_DiscardUnknown() { + xxx_messageInfo_StoreInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_StoreInfo proto.InternalMessageInfo + +func (m *StoreInfo) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *StoreInfo) GetCommitId() CommitID { + if m != nil { + return m.CommitId + } + return CommitID{} +} + +// CommitID defines the commitment information when a specific store is +// committed. +type CommitID struct { + Version int64 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"` + Hash []byte `protobuf:"bytes,2,opt,name=hash,proto3" json:"hash,omitempty"` +} + +func (m *CommitID) Reset() { *m = CommitID{} } +func (*CommitID) ProtoMessage() {} +func (m *CommitID) String() string { + return fmt.Sprintf("CommitID{%v:%X}", m.Hash, m.Version) +} +func (*CommitID) Descriptor() ([]byte, []int) { + return fileDescriptor_5f8c656cdef8c524, []int{2} +} +func (m *CommitID) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CommitID) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CommitID.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *CommitID) XXX_Merge(src proto.Message) { + xxx_messageInfo_CommitID.Merge(m, src) +} +func (m *CommitID) XXX_Size() int { + return m.Size() +} +func (m *CommitID) XXX_DiscardUnknown() { + xxx_messageInfo_CommitID.DiscardUnknown(m) +} + +var xxx_messageInfo_CommitID proto.InternalMessageInfo + +func (m *CommitID) GetVersion() int64 { + if m != nil { + return m.Version + } + return 0 +} + +func (m *CommitID) GetHash() []byte { + if m != nil { + return m.Hash + } + return nil +} + + + +var fileDescriptor_5f8c656cdef8c524 = []byte{ + // 336 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x91, 0xb1, 0x4e, 0xf2, 0x50, + 0x14, 0xc7, 0x7b, 0xa1, 0xf9, 0x3e, 0x7a, 0x70, 0xba, 0x61, 0x68, 0x18, 0x6e, 0x09, 0x83, 0x61, + 0xba, 0x0d, 0xb8, 0x39, 0x98, 0x58, 0x8d, 0x09, 0x6b, 0x75, 0x72, 0x31, 0x2d, 0x5c, 0x4a, 0xa3, + 0xed, 0x21, 0xdc, 0x2b, 0x89, 0x6f, 0xc1, 0xe8, 0xe8, 0x33, 0xf8, 0x14, 0x8c, 0x8c, 0x4e, 0x6a, + 0xe0, 0x45, 0x4c, 0x4f, 0x5b, 0x5c, 0x88, 0xdb, 0x39, 0xed, 0xef, 0x9c, 0xff, 0xaf, 0xa7, 0x70, + 0x3a, 0x41, 0x9d, 0xa1, 0xf6, 0xb5, 0xc1, 0xa5, 0xf2, 0x57, 0xc3, 0x58, 0x99, 0x68, 0xe8, 0x4f, + 0x30, 0xcb, 0x52, 0xf3, 0x90, 0xe6, 0x33, 0x94, 0x8b, 0x25, 0x1a, 0xe4, 0x9d, 0x92, 0x93, 0xc4, + 0xc9, 0x8a, 0xeb, 0x76, 0x12, 0x4c, 0x90, 0x00, 0xbf, 0xa8, 0x4a, 0xb6, 0xeb, 0x25, 0x88, 0xc9, + 0x93, 0xf2, 0xa9, 0x8b, 0x9f, 0x67, 0xbe, 0x49, 0x33, 0xa5, 0x4d, 0x94, 0x2d, 0x4a, 0xa0, 0xff, + 0xce, 0x00, 0xae, 0x28, 0x62, 0x9c, 0xcf, 0x90, 0xbb, 0xf0, 0x7f, 0xa5, 0x96, 0x3a, 0xc5, 0xdc, + 0x65, 0x3d, 0x36, 0x68, 0x86, 0x75, 0xcb, 0x6f, 0xa0, 0x4d, 0x81, 0x64, 0xa2, 0xdd, 0x46, 0xaf, + 0x39, 0x68, 0x8f, 0x3c, 0x79, 0xcc, 0x45, 0xde, 0x16, 0x5d, 0xb1, 0x2f, 0xb0, 0x37, 0x9f, 0x9e, + 0x15, 0x82, 0xae, 0x1f, 0x68, 0x1e, 0x80, 0x73, 0x70, 0x70, 0x9b, 0x3d, 0x36, 0x68, 0x8f, 0xba, + 0xb2, 0xb4, 0x94, 0xb5, 0xa5, 0xbc, 0xab, 0x89, 0xa0, 0x55, 0x2c, 0x58, 0x7f, 0x79, 0x2c, 0xfc, + 0x1d, 0xeb, 0xc7, 0xe0, 0x1c, 0x22, 0x38, 0x07, 0x3b, 0x8f, 0x32, 0x45, 0xbe, 0x4e, 0x48, 0x35, + 0xbf, 0x04, 0xa7, 0xbe, 0xdb, 0xd4, 0x6d, 0x50, 0x88, 0x38, 0xae, 0x5a, 0x7d, 0xfb, 0x75, 0x65, + 0xda, 0x2a, 0xc7, 0xc6, 0xd3, 0xfe, 0x05, 0xb4, 0xea, 0x77, 0x7f, 0x5c, 0x85, 0x83, 0x3d, 0x8f, + 0xf4, 0x9c, 0x32, 0x4e, 0x42, 0xaa, 0xcf, 0xed, 0xd7, 0x37, 0xcf, 0x0a, 0x46, 0x9b, 0x9d, 0x60, + 0xdb, 0x9d, 0x60, 0xdf, 0x3b, 0xc1, 0xd6, 0x7b, 0x61, 0x6d, 0xf7, 0xc2, 0xfa, 0xd8, 0x0b, 0xeb, + 0xde, 0x2d, 0x45, 0xf4, 0xf4, 0x51, 0xa6, 0x58, 0xfd, 0x6d, 0xf3, 0xb2, 0x50, 0x3a, 0xfe, 0x47, + 0x07, 0x38, 0xfb, 0x09, 0x00, 0x00, 0xff, 0xff, 0x67, 0xb7, 0x0d, 0x59, 0x0a, 0x02, 0x00, 0x00, +} + +func (m *CommitInfo) 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 *CommitInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CommitInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + n1, err1 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.Timestamp, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.Timestamp):]) + if err1 != nil { + return 0, err1 + } + i -= n1 + i = encodeVarintCommitInfo(dAtA, i, uint64(n1)) + i-- + dAtA[i] = 0x1a + if len(m.StoreInfos) > 0 { + for iNdEx := len(m.StoreInfos) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.StoreInfos[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintCommitInfo(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if m.Version != 0 { + i = encodeVarintCommitInfo(dAtA, i, uint64(m.Version)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *StoreInfo) 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 *StoreInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StoreInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.CommitId.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintCommitInfo(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintCommitInfo(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *CommitID) 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 *CommitID) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CommitID) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Hash) > 0 { + i -= len(m.Hash) + copy(dAtA[i:], m.Hash) + i = encodeVarintCommitInfo(dAtA, i, uint64(len(m.Hash))) + i-- + dAtA[i] = 0x12 + } + if m.Version != 0 { + i = encodeVarintCommitInfo(dAtA, i, uint64(m.Version)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintCommitInfo(dAtA []byte, offset int, v uint64) int { + offset -= sovCommitInfo(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *CommitInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Version != 0 { + n += 1 + sovCommitInfo(uint64(m.Version)) + } + if len(m.StoreInfos) > 0 { + for _, e := range m.StoreInfos { + l = e.Size() + n += 1 + l + sovCommitInfo(uint64(l)) + } + } + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.Timestamp) + n += 1 + l + sovCommitInfo(uint64(l)) + return n +} + +func (m *StoreInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovCommitInfo(uint64(l)) + } + l = m.CommitId.Size() + n += 1 + l + sovCommitInfo(uint64(l)) + return n +} + +func (m *CommitID) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Version != 0 { + n += 1 + sovCommitInfo(uint64(m.Version)) + } + l = len(m.Hash) + if l > 0 { + n += 1 + l + sovCommitInfo(uint64(l)) + } + return n +} + +func sovCommitInfo(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozCommitInfo(x uint64) (n int) { + return sovCommitInfo(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *CommitInfo) 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 ErrIntOverflowCommitInfo + } + 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: CommitInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CommitInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) + } + m.Version = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCommitInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Version |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StoreInfos", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCommitInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthCommitInfo + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthCommitInfo + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.StoreInfos = append(m.StoreInfos, StoreInfo{}) + if err := m.StoreInfos[len(m.StoreInfos)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Timestamp", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCommitInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthCommitInfo + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthCommitInfo + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.Timestamp, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipCommitInfo(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthCommitInfo + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *StoreInfo) 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 ErrIntOverflowCommitInfo + } + 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: StoreInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StoreInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCommitInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthCommitInfo + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCommitInfo + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CommitId", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCommitInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthCommitInfo + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthCommitInfo + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.CommitId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipCommitInfo(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthCommitInfo + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CommitID) 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 ErrIntOverflowCommitInfo + } + 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: CommitID: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CommitID: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) + } + m.Version = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCommitInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Version |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCommitInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthCommitInfo + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthCommitInfo + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Hash = append(m.Hash[:0], dAtA[iNdEx:postIndex]...) + if m.Hash == nil { + m.Hash = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipCommitInfo(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthCommitInfo + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipCommitInfo(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, ErrIntOverflowCommitInfo + } + 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, ErrIntOverflowCommitInfo + } + 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, ErrIntOverflowCommitInfo + } + 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, ErrInvalidLengthCommitInfo + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupCommitInfo + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthCommitInfo + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthCommitInfo = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowCommitInfo = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupCommitInfo = fmt.Errorf("proto: unexpected end of group") +) diff --git a/store/v2/root/factory.go b/store/v2/root/factory.go index b568792641ad..fb90c575e783 100644 --- a/store/v2/root/factory.go +++ b/store/v2/root/factory.go @@ -16,7 +16,9 @@ import ( "cosmossdk.io/store/v2/db" "cosmossdk.io/store/v2/internal" "cosmossdk.io/store/v2/metrics" + "cosmossdk.io/store/v2/migration" "cosmossdk.io/store/v2/pruning" + "cosmossdk.io/store/v2/snapshots" ) type ( @@ -28,6 +30,8 @@ const ( SCTypeIavlV2 SCType = "iavl-v2" ) +const storePrefixTpl = "s/k:%s/" // s/k: + // Options are the options for creating a root store. type Options struct { SCType SCType `mapstructure:"sc-type" toml:"sc-type" comment:"State commitment database type. Currently we support: \"iavl\" and \"iavl-v2\""` @@ -86,7 +90,7 @@ func CreateRootStore(opts *FactoryOptions) (store.RootStore, error) { return nil, fmt.Errorf("tried to construct a root store with no store keys specified but no commit info found for version %d", latestVersion) } for _, si := range lastCommitInfo.StoreInfos { - opts.StoreKeys = append(opts.StoreKeys, string(si.Name)) + opts.StoreKeys = append(opts.StoreKeys, si.Name) } } removedStoreKeys, err := metadata.GetRemovedStoreKeys(latestVersion) @@ -94,13 +98,13 @@ func CreateRootStore(opts *FactoryOptions) (store.RootStore, error) { return nil, err } - newTreeFn := func(key string) (commitment.Tree, error) { + newTreeFn := func(key string, scType SCType) (commitment.Tree, error) { if internal.IsMemoryStoreKey(key) { return mem.New(), nil } else { - switch storeOpts.SCType { + switch scType { case SCTypeIavl: - return iavl.NewIavlTree(db.NewPrefixDB(opts.SCRawDB, []byte(key)), opts.Logger, storeOpts.IavlConfig), nil + return iavl.NewIavlTree(db.NewPrefixDB(opts.SCRawDB, []byte(fmt.Sprintf(storePrefixTpl, key))), opts.Logger, storeOpts.IavlConfig), nil case SCTypeIavlV2: dir := fmt.Sprintf("%s/data/iavl-v2/%s", opts.RootDir, key) return iavlv2.NewTree(opts.Options.IavlV2Config, iavl_v2.SqliteDbOptions{Path: dir}, opts.Logger) @@ -110,17 +114,37 @@ func CreateRootStore(opts *FactoryOptions) (store.RootStore, error) { } } + // check if we need to migrate the store + isMigrating := false + scType := storeOpts.SCType + + if scType != SCTypeIavl { + isMigrating = true // need to migrate + scType = SCTypeIavl // only support iavl v1 for migration + } + trees := make(map[string]commitment.Tree, len(opts.StoreKeys)) for _, key := range opts.StoreKeys { - tree, err := newTreeFn(key) + tree, err := newTreeFn(key, scType) if err != nil { return nil, err } + if isMigrating { + v, err := tree.GetLatestVersion() + if err != nil { + return nil, err + } + if v == 0 && latestVersion > 0 { + if err := tree.SetInitialVersion(latestVersion + 1); err != nil { + return nil, err + } + } + } trees[key] = tree } oldTrees := make(map[string]commitment.Tree, len(opts.StoreKeys)) for _, key := range removedStoreKeys { - tree, err := newTreeFn(string(key)) + tree, err := newTreeFn(string(key), scType) if err != nil { return nil, err } @@ -132,6 +156,31 @@ func CreateRootStore(opts *FactoryOptions) (store.RootStore, error) { return nil, err } + var mm *migration.Manager + if isMigrating { + snapshotDB, err := snapshots.NewStore(fmt.Sprintf("%s/data/snapshots/store.db", opts.RootDir)) + if err != nil { + return nil, err + } + snapshotMgr := snapshots.NewManager(snapshotDB, snapshots.SnapshotOptions{}, sc, nil, opts.Logger) + var newSC *commitment.CommitStore + if scType != storeOpts.SCType { + newTrees := make(map[string]commitment.Tree, len(opts.StoreKeys)) + for _, key := range opts.StoreKeys { + tree, err := newTreeFn(key, storeOpts.SCType) + if err != nil { + return nil, err + } + newTrees[key] = tree + } + newSC, err = commitment.NewCommitStore(newTrees, nil, opts.SCRawDB, opts.Logger) + if err != nil { + return nil, err + } + } + mm = migration.NewManager(opts.SCRawDB, snapshotMgr, newSC, opts.Logger) + } + pm := pruning.NewManager(sc, storeOpts.SCPruningOption) - return New(opts.SCRawDB, opts.Logger, sc, pm, nil, metrics.NoOpMetrics{}) + return New(opts.SCRawDB, opts.Logger, sc, pm, mm, metrics.NoOpMetrics{}) } diff --git a/store/v2/root/factory_test.go b/store/v2/root/factory_test.go index 1da5e4309ab8..031ccd0adfa1 100644 --- a/store/v2/root/factory_test.go +++ b/store/v2/root/factory_test.go @@ -3,8 +3,10 @@ package root import ( "testing" + gogotypes "github.com/cosmos/gogoproto/types" "github.com/stretchr/testify/require" + corestore "cosmossdk.io/core/store" coretesting "cosmossdk.io/core/testing" "cosmossdk.io/store/v2/db" ) @@ -26,4 +28,19 @@ func TestFactory(t *testing.T) { f, err = CreateRootStore(&fop) require.NoError(t, err) require.NotNil(t, f) + + require.NoError(t, setLatestVersion(fop.SCRawDB, 1)) + fop.Options.SCType = SCTypeIavl + f, err = CreateRootStore(&fop) + require.NoError(t, err) + require.NotNil(t, f) + require.False(t, f.(*Store).isMigrating) +} + +func setLatestVersion(db corestore.KVStoreWithBatch, version int64) error { + bz, err := gogotypes.StdInt64Marshal(version) + if err != nil { + panic(err) + } + return db.Set([]byte("s/latest"), bz) } diff --git a/store/v2/root/store.go b/store/v2/root/store.go index 3104260d11b3..c0d06420a7c6 100644 --- a/store/v2/root/store.go +++ b/store/v2/root/store.go @@ -152,7 +152,7 @@ func (s *Store) LastCommitID() (proof.CommitID, error) { // if the latest version is 0, we return a CommitID with version 0 and a hash of an empty byte slice bz := sha256.Sum256([]byte{}) - return proof.CommitID{Version: latestVersion, Hash: bz[:]}, nil + return proof.CommitID{Version: int64(latestVersion), Hash: bz[:]}, nil } // GetLatestVersion returns the latest version based on the latest internal @@ -164,7 +164,7 @@ func (s *Store) GetLatestVersion() (uint64, error) { return 0, err } - return lastCommitID.Version, nil + return uint64(lastCommitID.Version), nil } func (s *Store) Query(storeKey []byte, version uint64, key []byte, prove bool) (store.QueryResult, error) { @@ -312,13 +312,13 @@ func (s *Store) Commit(cs *corestore.Changeset) ([]byte, error) { } s.logger.Warn(fmt.Sprintf("commit version %d write=%s commit=%s", cs.Version, writeDur, time.Since(st))) - if cInfo.Version != cs.Version { + if cInfo.Version != int64(cs.Version) { return nil, fmt.Errorf("commit version mismatch: got %d, expected %d", cInfo.Version, cs.Version) } s.lastCommitInfo = cInfo // signal to the pruning manager that the commit is done - if err := s.pruningManager.ResumePruning(s.lastCommitInfo.Version); err != nil { + if err := s.pruningManager.ResumePruning(uint64(s.lastCommitInfo.Version)); err != nil { s.logger.Error("failed to signal commit done to pruning manager", "err", err) } @@ -344,7 +344,7 @@ func (s *Store) startMigration() { version := s.lastCommitInfo.Version s.logger.Info("starting migration", "version", version) mtx.Unlock() - if err := s.migrationManager.Start(version, s.chChangeset, s.chDone); err != nil { + if err := s.migrationManager.Start(uint64(version), s.chChangeset, s.chDone); err != nil { s.logger.Error("failed to start migration", "err", err) } }() @@ -358,16 +358,16 @@ func (s *Store) handleMigration(cs *corestore.Changeset) error { if s.isMigrating { // if the migration manager has already migrated to the version, close the // channels and replace the state commitment - if s.migrationManager.GetMigratedVersion() == s.lastCommitInfo.Version { + if s.migrationManager.GetMigratedVersion() == uint64(s.lastCommitInfo.Version) { close(s.chDone) close(s.chChangeset) s.isMigrating = false - // close the old state commitment and replace it with the new one - if err := s.stateCommitment.Close(); err != nil { - return fmt.Errorf("failed to close the old SC store: %w", err) - } newStateCommitment := s.migrationManager.GetStateCommitment() if newStateCommitment != nil { + // close the old state commitment and replace it with the new one + if err := s.stateCommitment.Close(); err != nil { + return fmt.Errorf("failed to close the old SC store: %w", err) + } s.stateCommitment = newStateCommitment } if err := s.migrationManager.Close(); err != nil { @@ -376,7 +376,7 @@ func (s *Store) handleMigration(cs *corestore.Changeset) error { s.logger.Info("migration completed", "version", s.lastCommitInfo.Version) } else { // queue the next changeset to the migration manager - s.chChangeset <- &migration.VersionedChangeset{Version: s.lastCommitInfo.Version + 1, Changeset: cs} + s.chChangeset <- &migration.VersionedChangeset{Version: uint64(s.lastCommitInfo.Version + 1), Changeset: cs} } } return nil diff --git a/tests/systemtests/bankv2_test.go b/tests/systemtests/bankv2_test.go index cc7145f8741f..9d4d60914a5b 100644 --- a/tests/systemtests/bankv2_test.go +++ b/tests/systemtests/bankv2_test.go @@ -13,6 +13,8 @@ import ( ) func TestBankV2SendTxCmd(t *testing.T) { + // bankv2 was removed from simapp + t.Skip() // scenario: test bank send command // given a running chain