From 2b83cb7fe37b569ec8f786c26d7a47edcce3d4af Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 28 Mar 2023 18:05:41 -0300 Subject: [PATCH] feat: auto-set block timestamp for historical queries (backport #15448) (#15573) Co-authored-by: Aleksandr Bezobchuk Co-authored-by: Aleksandr Bezobchuk --- CHANGELOG.md | 4 + .../base/store/v1beta1/commit_info.pulsar.go | 188 +++++++++++++----- baseapp/abci.go | 16 ++ .../base/store/v1beta1/commit_info.proto | 7 +- store/rootmulti/store.go | 70 ++++--- store/rootmulti/store_test.go | 12 +- store/types/commit_info.pb.go | 99 +++++++-- 7 files changed, 293 insertions(+), 103 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bfc68759eca..c8c80ca680d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,10 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## [Unreleased] +## Improvements + +* [#15448](https://github.com/cosmos/cosmos-sdk/pull/15448) Automatically populate the block timestamp for historical queries. In contexts where the block timestamp is needed for previous states, the timestamp will now be set. Note, when querying against a node it must be re-synced in order to be able to automatically populate the block timestamp. Otherwise, the block timestamp will be populated for heights going forward once upgraded. + ## [v0.47.1](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.47.1) - 2023-03-23 ### Features diff --git a/api/cosmos/base/store/v1beta1/commit_info.pulsar.go b/api/cosmos/base/store/v1beta1/commit_info.pulsar.go index 4e259d85870..3f9381e5188 100644 --- a/api/cosmos/base/store/v1beta1/commit_info.pulsar.go +++ b/api/cosmos/base/store/v1beta1/commit_info.pulsar.go @@ -8,6 +8,7 @@ import ( 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" @@ -68,6 +69,7 @@ var ( md_CommitInfo protoreflect.MessageDescriptor fd_CommitInfo_version protoreflect.FieldDescriptor fd_CommitInfo_store_infos protoreflect.FieldDescriptor + fd_CommitInfo_timestamp protoreflect.FieldDescriptor ) func init() { @@ -75,6 +77,7 @@ func init() { md_CommitInfo = File_cosmos_base_store_v1beta1_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") } var _ protoreflect.Message = (*fastReflection_CommitInfo)(nil) @@ -154,6 +157,12 @@ func (x *fastReflection_CommitInfo) Range(f func(protoreflect.FieldDescriptor, p return } } + if x.Timestamp != nil { + value := protoreflect.ValueOfMessage(x.Timestamp.ProtoReflect()) + if !f(fd_CommitInfo_timestamp, value) { + return + } + } } // Has reports whether a field is populated. @@ -173,6 +182,8 @@ func (x *fastReflection_CommitInfo) Has(fd protoreflect.FieldDescriptor) bool { return x.Version != int64(0) case "cosmos.base.store.v1beta1.CommitInfo.store_infos": return len(x.StoreInfos) != 0 + case "cosmos.base.store.v1beta1.CommitInfo.timestamp": + return x.Timestamp != nil default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.store.v1beta1.CommitInfo")) @@ -193,6 +204,8 @@ func (x *fastReflection_CommitInfo) Clear(fd protoreflect.FieldDescriptor) { x.Version = int64(0) case "cosmos.base.store.v1beta1.CommitInfo.store_infos": x.StoreInfos = nil + case "cosmos.base.store.v1beta1.CommitInfo.timestamp": + x.Timestamp = nil default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.store.v1beta1.CommitInfo")) @@ -218,6 +231,9 @@ func (x *fastReflection_CommitInfo) Get(descriptor protoreflect.FieldDescriptor) } listValue := &_CommitInfo_2_list{list: &x.StoreInfos} return protoreflect.ValueOfList(listValue) + case "cosmos.base.store.v1beta1.CommitInfo.timestamp": + value := x.Timestamp + return protoreflect.ValueOfMessage(value.ProtoReflect()) default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.store.v1beta1.CommitInfo")) @@ -244,6 +260,8 @@ func (x *fastReflection_CommitInfo) Set(fd protoreflect.FieldDescriptor, value p lv := value.List() clv := lv.(*_CommitInfo_2_list) x.StoreInfos = *clv.list + case "cosmos.base.store.v1beta1.CommitInfo.timestamp": + x.Timestamp = value.Message().Interface().(*timestamppb.Timestamp) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.store.v1beta1.CommitInfo")) @@ -270,6 +288,11 @@ func (x *fastReflection_CommitInfo) Mutable(fd protoreflect.FieldDescriptor) pro } value := &_CommitInfo_2_list{list: &x.StoreInfos} return protoreflect.ValueOfList(value) + case "cosmos.base.store.v1beta1.CommitInfo.timestamp": + if x.Timestamp == nil { + x.Timestamp = new(timestamppb.Timestamp) + } + return protoreflect.ValueOfMessage(x.Timestamp.ProtoReflect()) case "cosmos.base.store.v1beta1.CommitInfo.version": panic(fmt.Errorf("field version of message cosmos.base.store.v1beta1.CommitInfo is not mutable")) default: @@ -290,6 +313,9 @@ func (x *fastReflection_CommitInfo) NewField(fd protoreflect.FieldDescriptor) pr case "cosmos.base.store.v1beta1.CommitInfo.store_infos": list := []*StoreInfo{} return protoreflect.ValueOfList(&_CommitInfo_2_list{list: &list}) + case "cosmos.base.store.v1beta1.CommitInfo.timestamp": + m := new(timestamppb.Timestamp) + return protoreflect.ValueOfMessage(m.ProtoReflect()) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.store.v1beta1.CommitInfo")) @@ -368,6 +394,10 @@ func (x *fastReflection_CommitInfo) ProtoMethods() *protoiface.Methods { n += 1 + l + runtime.Sov(uint64(l)) } } + if x.Timestamp != nil { + l = options.Size(x.Timestamp) + n += 1 + l + runtime.Sov(uint64(l)) + } if x.unknownFields != nil { n += len(x.unknownFields) } @@ -397,6 +427,20 @@ func (x *fastReflection_CommitInfo) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } + 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]) @@ -520,6 +564,42 @@ func (x *fastReflection_CommitInfo) ProtoMethods() *protoiface.Methods { 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 default: iNdEx = preIndex skippy, err := runtime.Skip(dAtA[iNdEx:]) @@ -1544,8 +1624,9 @@ type CommitInfo struct { 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"` + 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"` } func (x *CommitInfo) Reset() { @@ -1582,6 +1663,13 @@ func (x *CommitInfo) GetStoreInfos() []*StoreInfo { return nil } +func (x *CommitInfo) GetTimestamp() *timestamppb.Timestamp { + if x != nil { + return x.Timestamp + } + return nil +} + // StoreInfo defines store-specific commit information. It contains a reference // between a store name and the commit ID. type StoreInfo struct { @@ -1680,41 +1768,47 @@ var file_cosmos_base_store_v1beta1_commit_info_proto_rawDesc = []byte{ 0x69, 0x74, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x19, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x1a, 0x14, 0x67, 0x6f, 0x67, 0x6f, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x67, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x73, - 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, 0x4b, 0x0a, 0x0b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x5f, - 0x69, 0x6e, 0x66, 0x6f, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x63, 0x6f, - 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, - 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x49, 0x6e, 0x66, - 0x6f, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x0a, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x49, 0x6e, - 0x66, 0x6f, 0x73, 0x22, 0x67, 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, 0x46, 0x0a, 0x09, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x5f, 0x69, - 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, - 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x49, 0x44, 0x42, 0x04, 0xc8, 0xde, - 0x1f, 0x00, 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x49, 0x64, 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, 0xf0, 0x01, 0x0a, - 0x1d, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, - 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0f, - 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, - 0x01, 0x5a, 0x37, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, - 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2f, - 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x73, 0x74, - 0x6f, 0x72, 0x65, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x42, 0x53, - 0xaa, 0x02, 0x19, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x2e, 0x53, - 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xca, 0x02, 0x19, 0x43, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x42, 0x61, 0x73, 0x65, 0x5c, 0x53, 0x74, 0x6f, 0x72, 0x65, - 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xe2, 0x02, 0x25, 0x43, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x5c, 0x42, 0x61, 0x73, 0x65, 0x5c, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x5c, 0x56, 0x31, 0x62, - 0x65, 0x74, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, - 0xea, 0x02, 0x1c, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x42, 0x61, 0x73, 0x65, 0x3a, - 0x3a, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 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, + 0xb7, 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, 0x4b, 0x0a, 0x0b, 0x73, 0x74, 0x6f, 0x72, + 0x65, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, + 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x73, 0x74, 0x6f, 0x72, + 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x49, + 0x6e, 0x66, 0x6f, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 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, 0x22, 0x67, 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, 0x46, 0x0a, 0x09, 0x63, 0x6f, + 0x6d, 0x6d, 0x69, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, + 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x73, 0x74, 0x6f, 0x72, + 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, + 0x49, 0x44, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, + 0x49, 0x64, 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, 0xf0, 0x01, 0x0a, 0x1d, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x62, + 0x65, 0x74, 0x61, 0x31, 0x42, 0x0f, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x49, 0x6e, 0x66, 0x6f, + 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x37, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, + 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2f, 0x76, 0x31, 0x62, 0x65, + 0x74, 0x61, 0x31, 0x3b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, + 0xa2, 0x02, 0x03, 0x43, 0x42, 0x53, 0xaa, 0x02, 0x19, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, + 0x42, 0x61, 0x73, 0x65, 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x56, 0x31, 0x62, 0x65, 0x74, + 0x61, 0x31, 0xca, 0x02, 0x19, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x42, 0x61, 0x73, 0x65, + 0x5c, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xe2, 0x02, + 0x25, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x42, 0x61, 0x73, 0x65, 0x5c, 0x53, 0x74, 0x6f, + 0x72, 0x65, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, + 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1c, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, + 0x3a, 0x42, 0x61, 0x73, 0x65, 0x3a, 0x3a, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x3a, 0x3a, 0x56, 0x31, + 0x62, 0x65, 0x74, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1731,18 +1825,20 @@ func file_cosmos_base_store_v1beta1_commit_info_proto_rawDescGZIP() []byte { var file_cosmos_base_store_v1beta1_commit_info_proto_msgTypes = make([]protoimpl.MessageInfo, 3) var file_cosmos_base_store_v1beta1_commit_info_proto_goTypes = []interface{}{ - (*CommitInfo)(nil), // 0: cosmos.base.store.v1beta1.CommitInfo - (*StoreInfo)(nil), // 1: cosmos.base.store.v1beta1.StoreInfo - (*CommitID)(nil), // 2: cosmos.base.store.v1beta1.CommitID + (*CommitInfo)(nil), // 0: cosmos.base.store.v1beta1.CommitInfo + (*StoreInfo)(nil), // 1: cosmos.base.store.v1beta1.StoreInfo + (*CommitID)(nil), // 2: cosmos.base.store.v1beta1.CommitID + (*timestamppb.Timestamp)(nil), // 3: google.protobuf.Timestamp } var file_cosmos_base_store_v1beta1_commit_info_proto_depIdxs = []int32{ 1, // 0: cosmos.base.store.v1beta1.CommitInfo.store_infos:type_name -> cosmos.base.store.v1beta1.StoreInfo - 2, // 1: cosmos.base.store.v1beta1.StoreInfo.commit_id:type_name -> cosmos.base.store.v1beta1.CommitID - 2, // [2:2] is the sub-list for method output_type - 2, // [2:2] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name + 3, // 1: cosmos.base.store.v1beta1.CommitInfo.timestamp:type_name -> google.protobuf.Timestamp + 2, // 2: cosmos.base.store.v1beta1.StoreInfo.commit_id:type_name -> cosmos.base.store.v1beta1.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_base_store_v1beta1_commit_info_proto_init() } diff --git a/baseapp/abci.go b/baseapp/abci.go index b9586969f30..cf46b8bef83 100644 --- a/baseapp/abci.go +++ b/baseapp/abci.go @@ -18,6 +18,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types" + "github.com/cosmos/cosmos-sdk/store/rootmulti" "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -473,6 +474,11 @@ func (app *BaseApp) Commit() abci.ResponseCommit { header := app.deliverState.ctx.BlockHeader() retainHeight := app.GetBlockRetentionHeight(header.Height) + rms, ok := app.cms.(*rootmulti.Store) + if ok { + rms.SetCommitHeader(header) + } + // Write the DeliverTx state into branched storage and commit the MultiStore. // The write to the DeliverTx state writes all state transitions to the root // MultiStore (app.cms) so when Commit() is called is persists those values. @@ -840,6 +846,16 @@ func (app *BaseApp) CreateQueryContext(height int64, prove bool) (sdk.Context, e WithMinGasPrices(app.minGasPrices). WithBlockHeight(height) + if height != lastBlockHeight { + rms, ok := app.cms.(*rootmulti.Store) + if ok { + cInfo, err := rms.GetCommitInfo(height) + if cInfo != nil && err == nil { + ctx = ctx.WithBlockTime(cInfo.Timestamp) + } + } + } + return ctx, nil } diff --git a/proto/cosmos/base/store/v1beta1/commit_info.proto b/proto/cosmos/base/store/v1beta1/commit_info.proto index b7b6a1972fa..4625cdab222 100644 --- a/proto/cosmos/base/store/v1beta1/commit_info.proto +++ b/proto/cosmos/base/store/v1beta1/commit_info.proto @@ -2,14 +2,17 @@ syntax = "proto3"; package cosmos.base.store.v1beta1; import "gogoproto/gogo.proto"; +import "google/protobuf/timestamp.proto"; option go_package = "github.com/cosmos/cosmos-sdk/store/types"; // CommitInfo defines commit information used by the multi-store when committing // a version/height. message CommitInfo { - int64 version = 1; - repeated StoreInfo store_infos = 2 [(gogoproto.nullable) = false]; + int64 version = 1; + repeated StoreInfo store_infos = 2 [(gogoproto.nullable) = false]; + google.protobuf.Timestamp timestamp = 3 + [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; } // StoreInfo defines store-specific commit information. It contains a reference diff --git a/store/rootmulti/store.go b/store/rootmulti/store.go index 0cbf655db1b..ce08464c03b 100644 --- a/store/rootmulti/store.go +++ b/store/rootmulti/store.go @@ -11,6 +11,7 @@ import ( dbm "github.com/cometbft/cometbft-db" abci "github.com/cometbft/cometbft/abci/types" "github.com/cometbft/cometbft/libs/log" + cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" protoio "github.com/cosmos/gogoproto/io" gogotypes "github.com/cosmos/gogoproto/types" iavltree "github.com/cosmos/iavl" @@ -66,14 +67,12 @@ type Store struct { lazyLoading bool initialVersion int64 removalMap map[types.StoreKey]bool - - traceWriter io.Writer - traceContext types.TraceContext - traceContextMutex sync.Mutex - - interBlockCache types.MultiStorePersistentCache - - listeners map[types.StoreKey][]types.WriteListener + traceWriter io.Writer + traceContext types.TraceContext + traceContextMutex sync.Mutex + interBlockCache types.MultiStorePersistentCache + listeners map[types.StoreKey][]types.WriteListener + commitHeader cmtproto.Header } var ( @@ -208,7 +207,7 @@ func (rs *Store) loadVersion(ver int64, upgrades *types.StoreUpgrades) error { // load old data if we are not version 0 if ver != 0 { var err error - cInfo, err = getCommitInfo(rs.db, ver) + cInfo, err = rs.GetCommitInfo(ver) if err != nil { return err } @@ -440,7 +439,12 @@ func (rs *Store) Commit() types.CommitID { version = previousHeight + 1 } + if rs.commitHeader.Height != version { + rs.logger.Debug("commit header and version mismatch", "header_height", rs.commitHeader.Height, "version", version) + } + rs.lastCommitInfo = commitStores(version, rs.stores, rs.removalMap) + rs.lastCommitInfo.Timestamp = rs.commitHeader.Time defer rs.flushMetadata(rs.db, version, rs.lastCommitInfo) // remove remnants of removed stores @@ -451,6 +455,7 @@ func (rs *Store) Commit() types.CommitID { delete(rs.keysByName, sk.Name()) } } + // reset the removalMap rs.removalMap = make(map[types.StoreKey]bool) @@ -676,7 +681,7 @@ func (rs *Store) Query(req abci.RequestQuery) abci.ResponseQuery { if res.Height == rs.lastCommitInfo.Version { commitInfo = rs.lastCommitInfo } else { - commitInfo, err = getCommitInfo(rs.db, res.Height) + commitInfo, err = rs.GetCommitInfo(res.Height) if err != nil { return sdkerrors.QueryResult(err, false) } @@ -1010,6 +1015,32 @@ func (rs *Store) RollbackToVersion(target int64) error { return rs.LoadLatestVersion() } +// SetCommitHeader sets the commit block header of the store. +func (rs *Store) SetCommitHeader(h cmtproto.Header) { + rs.commitHeader = h +} + +// GetCommitInfo attempts to retrieve CommitInfo for a given version/height. It +// will return an error if no CommitInfo exists, we fail to unmarshal the record +// or if we cannot retrieve the object from the DB. +func (rs *Store) GetCommitInfo(ver int64) (*types.CommitInfo, error) { + cInfoKey := fmt.Sprintf(commitInfoKeyFmt, ver) + + bz, err := rs.db.Get([]byte(cInfoKey)) + if err != nil { + return nil, errors.Wrap(err, "failed to get commit info") + } else if bz == nil { + return nil, errors.New("no commit info found") + } + + cInfo := &types.CommitInfo{} + if err = cInfo.Unmarshal(bz); err != nil { + return nil, errors.Wrap(err, "failed unmarshal commit info") + } + + return cInfo, nil +} + func (rs *Store) flushMetadata(db dbm.DB, version int64, cInfo *types.CommitInfo) { rs.logger.Debug("flushing metadata", "height", version) batch := db.NewBatch() @@ -1106,25 +1137,6 @@ func commitStores(version int64, storeMap map[types.StoreKey]types.CommitKVStore } } -// Gets commitInfo from disk. -func getCommitInfo(db dbm.DB, ver int64) (*types.CommitInfo, error) { - cInfoKey := fmt.Sprintf(commitInfoKeyFmt, ver) - - bz, err := db.Get([]byte(cInfoKey)) - if err != nil { - return nil, errors.Wrap(err, "failed to get commit info") - } else if bz == nil { - return nil, errors.New("no commit info found") - } - - cInfo := &types.CommitInfo{} - if err = cInfo.Unmarshal(bz); err != nil { - return nil, errors.Wrap(err, "failed unmarshal commit info") - } - - return cInfo, nil -} - func flushCommitInfo(batch dbm.Batch, version int64, cInfo *types.CommitInfo) { bz, err := cInfo.Marshal() if err != nil { diff --git a/store/rootmulti/store_test.go b/store/rootmulti/store_test.go index 86196d9d187..78e56e9acfb 100644 --- a/store/rootmulti/store_test.go +++ b/store/rootmulti/store_test.go @@ -207,7 +207,7 @@ func TestMultistoreLoadWithUpgrade(t *testing.T) { expectedCommitID := getExpectedCommitID(store, 1) checkStore(t, store, expectedCommitID, commitID) - ci, err := getCommitInfo(db, 1) + ci, err := store.GetCommitInfo(1) require.NoError(t, err) require.Equal(t, int64(1), ci.Version) require.Equal(t, 3, len(ci.StoreInfos)) @@ -297,7 +297,7 @@ func TestMultistoreLoadWithUpgrade(t *testing.T) { require.Equal(t, v4, rl4.Get(k4)) // check commitInfo in storage - ci, err = getCommitInfo(db, 2) + ci, err = reload.GetCommitInfo(2) require.NoError(t, err) require.Equal(t, int64(2), ci.Version) require.Equal(t, 3, len(ci.StoreInfos), ci.StoreInfos) @@ -352,7 +352,7 @@ func TestMultiStoreRestart(t *testing.T) { multi.Commit() - cinfo, err := getCommitInfo(multi.db, int64(i)) + cinfo, err := multi.GetCommitInfo(int64(i)) require.NoError(t, err) require.Equal(t, int64(i), cinfo.Version) } @@ -367,7 +367,7 @@ func TestMultiStoreRestart(t *testing.T) { multi.Commit() - flushedCinfo, err := getCommitInfo(multi.db, 3) + flushedCinfo, err := multi.GetCommitInfo(3) require.Nil(t, err) require.NotEqual(t, initCid, flushedCinfo, "CID is different after flush to disk") @@ -377,7 +377,7 @@ func TestMultiStoreRestart(t *testing.T) { multi.Commit() - postFlushCinfo, err := getCommitInfo(multi.db, 4) + postFlushCinfo, err := multi.GetCommitInfo(4) require.NoError(t, err) require.Equal(t, int64(4), postFlushCinfo.Version, "Commit changed after in-memory commit") @@ -850,7 +850,7 @@ func TestCommitOrdered(t *testing.T) { typeID := multi.Commit() require.Equal(t, int64(1), typeID.Version) - ci, err := getCommitInfo(db, 1) + ci, err := multi.GetCommitInfo(1) require.NoError(t, err) require.Equal(t, int64(1), ci.Version) require.Equal(t, 3, len(ci.StoreInfos)) diff --git a/store/types/commit_info.pb.go b/store/types/commit_info.pb.go index eb91c1a87a1..58111754b43 100644 --- a/store/types/commit_info.pb.go +++ b/store/types/commit_info.pb.go @@ -7,15 +7,19 @@ 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. @@ -28,6 +32,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package 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{} } @@ -77,6 +82,13 @@ func (m *CommitInfo) GetStoreInfos() []StoreInfo { 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 { @@ -195,26 +207,30 @@ func init() { } var fileDescriptor_83f4097f6265b52f = []byte{ - // 301 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x4e, 0xce, 0x2f, 0xce, - 0xcd, 0x2f, 0xd6, 0x4f, 0x4a, 0x2c, 0x4e, 0xd5, 0x2f, 0x2e, 0xc9, 0x2f, 0x4a, 0xd5, 0x2f, 0x33, - 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x4f, 0xce, 0xcf, 0xcd, 0xcd, 0x2c, 0x89, 0xcf, 0xcc, 0x4b, - 0xcb, 0xd7, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x84, 0x28, 0xd6, 0x03, 0x29, 0xd6, 0x03, - 0x2b, 0xd6, 0x83, 0x2a, 0x96, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0xab, 0xd2, 0x07, 0xb1, 0x20, - 0x1a, 0x94, 0x8a, 0xb9, 0xb8, 0x9c, 0xc1, 0xa6, 0x78, 0xe6, 0xa5, 0xe5, 0x0b, 0x49, 0x70, 0xb1, - 0x97, 0xa5, 0x16, 0x15, 0x67, 0xe6, 0xe7, 0x49, 0x30, 0x2a, 0x30, 0x6a, 0x30, 0x07, 0xc1, 0xb8, - 0x42, 0xde, 0x5c, 0xdc, 0x60, 0xe3, 0xc0, 0x96, 0x15, 0x4b, 0x30, 0x29, 0x30, 0x6b, 0x70, 0x1b, - 0xa9, 0xe8, 0xe1, 0xb4, 0x4e, 0x2f, 0x18, 0xc4, 0x03, 0x19, 0xea, 0xc4, 0x72, 0xe2, 0x9e, 0x3c, - 0x43, 0x10, 0x57, 0x31, 0x4c, 0xa0, 0x58, 0x29, 0x9d, 0x8b, 0x13, 0x2e, 0x2d, 0x24, 0xc4, 0xc5, - 0x92, 0x97, 0x98, 0x9b, 0x0a, 0xb6, 0x90, 0x33, 0x08, 0xcc, 0x16, 0x72, 0xe3, 0xe2, 0x84, 0xf9, - 0x2d, 0x45, 0x82, 0x49, 0x81, 0x51, 0x83, 0xdb, 0x48, 0x19, 0x8f, 0x5d, 0x50, 0x1f, 0xb8, 0x40, - 0xad, 0xe2, 0x80, 0xe8, 0xf5, 0x4c, 0x51, 0xb2, 0xe3, 0xe2, 0x80, 0xc9, 0xe1, 0xf1, 0x9b, 0x10, - 0x17, 0x4b, 0x46, 0x62, 0x71, 0x06, 0xd8, 0x22, 0x9e, 0x20, 0x30, 0xdb, 0x8a, 0x65, 0xc6, 0x02, - 0x79, 0x06, 0x27, 0xa7, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, - 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, 0xd2, 0x48, - 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x87, 0x46, 0x10, 0x84, 0xd2, 0x2d, - 0x4e, 0xc9, 0x86, 0x46, 0x53, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0x38, 0xa0, 0x8d, 0x01, - 0x01, 0x00, 0x00, 0xff, 0xff, 0x00, 0xc0, 0xc7, 0x12, 0xc8, 0x01, 0x00, 0x00, + // 354 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x92, 0xb1, 0x4e, 0xfb, 0x30, + 0x10, 0xc6, 0xe3, 0x36, 0xfa, 0xff, 0x1b, 0x97, 0xc9, 0x62, 0x08, 0x1d, 0x92, 0xaa, 0x30, 0x44, + 0x42, 0xd8, 0x6a, 0xd9, 0x18, 0x18, 0x02, 0x42, 0xaa, 0xd8, 0x02, 0x13, 0x0b, 0x4a, 0x5a, 0x37, + 0x8d, 0xc0, 0xb9, 0xaa, 0x76, 0x2b, 0xf1, 0x16, 0x1d, 0x19, 0x79, 0x0b, 0x5e, 0xa1, 0x63, 0x47, + 0x26, 0x40, 0xcd, 0x8b, 0xa0, 0x38, 0x71, 0x99, 0xe8, 0x94, 0xbb, 0xf8, 0xbb, 0xfb, 0x7e, 0xfa, + 0x74, 0xf8, 0x74, 0x04, 0x52, 0x80, 0x64, 0x49, 0x2c, 0x39, 0x93, 0x0a, 0xe6, 0x9c, 0x2d, 0xfb, + 0x09, 0x57, 0x71, 0x9f, 0x8d, 0x40, 0x88, 0x4c, 0x3d, 0x66, 0xf9, 0x04, 0xe8, 0x6c, 0x0e, 0x0a, + 0xc8, 0x51, 0x25, 0xa6, 0xa5, 0x98, 0x6a, 0x31, 0xad, 0xc5, 0x9d, 0xc3, 0x14, 0x52, 0xd0, 0x2a, + 0x56, 0x56, 0xd5, 0x40, 0xc7, 0x4f, 0x01, 0xd2, 0x67, 0xce, 0x74, 0x97, 0x2c, 0x26, 0x4c, 0x65, + 0x82, 0x4b, 0x15, 0x8b, 0x59, 0x25, 0xe8, 0xbd, 0x23, 0x8c, 0xaf, 0xb4, 0xcf, 0x30, 0x9f, 0x00, + 0x71, 0xf1, 0xff, 0x25, 0x9f, 0xcb, 0x0c, 0x72, 0x17, 0x75, 0x51, 0xd0, 0x8c, 0x4c, 0x4b, 0x6e, + 0x71, 0x5b, 0x1b, 0x6a, 0x1c, 0xe9, 0x36, 0xba, 0xcd, 0xa0, 0x3d, 0x38, 0xa1, 0x7f, 0x02, 0xd1, + 0xbb, 0xb2, 0x2b, 0x97, 0x86, 0xf6, 0xfa, 0xd3, 0xb7, 0x22, 0x2c, 0xcd, 0x0f, 0x49, 0x42, 0xec, + 0xec, 0x40, 0xdc, 0x66, 0x17, 0x05, 0xed, 0x41, 0x87, 0x56, 0xa8, 0xd4, 0xa0, 0xd2, 0x7b, 0xa3, + 0x08, 0x5b, 0xe5, 0x82, 0xd5, 0x97, 0x8f, 0xa2, 0xdf, 0xb1, 0x5e, 0x8a, 0x9d, 0x9d, 0x05, 0x21, + 0xd8, 0xce, 0x63, 0xc1, 0x35, 0xb4, 0x13, 0xe9, 0x9a, 0xdc, 0x60, 0xc7, 0x24, 0x38, 0x76, 0x1b, + 0xda, 0xe4, 0x78, 0x0f, 0x6f, 0x9d, 0xc2, 0x75, 0x8d, 0xdb, 0xaa, 0x66, 0x87, 0xe3, 0xde, 0x25, + 0x6e, 0x99, 0xb7, 0x3d, 0xf9, 0x10, 0x6c, 0x4f, 0x63, 0x39, 0xd5, 0x46, 0x07, 0x91, 0xae, 0x2f, + 0xec, 0xd7, 0x37, 0xdf, 0x0a, 0xc3, 0xf5, 0xd6, 0x43, 0x9b, 0xad, 0x87, 0xbe, 0xb7, 0x1e, 0x5a, + 0x15, 0x9e, 0xb5, 0x29, 0x3c, 0xeb, 0xa3, 0xf0, 0xac, 0x87, 0x20, 0xcd, 0xd4, 0x74, 0x91, 0xd0, + 0x11, 0x08, 0x56, 0x9f, 0x41, 0xf5, 0x39, 0x93, 0xe3, 0xa7, 0xfa, 0x18, 0xd4, 0xcb, 0x8c, 0xcb, + 0xe4, 0x9f, 0x4e, 0xe5, 0xfc, 0x27, 0x00, 0x00, 0xff, 0xff, 0x46, 0x0e, 0x24, 0xd4, 0x2e, 0x02, + 0x00, 0x00, } func (m *CommitInfo) Marshal() (dAtA []byte, err error) { @@ -237,6 +253,14 @@ func (m *CommitInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = 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-- { { @@ -360,6 +384,8 @@ func (m *CommitInfo) Size() (n int) { n += 1 + l + sovCommitInfo(uint64(l)) } } + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.Timestamp) + n += 1 + l + sovCommitInfo(uint64(l)) return n } @@ -482,6 +508,39 @@ func (m *CommitInfo) Unmarshal(dAtA []byte) error { 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:])