From ee76270e1ca3393c07ee66fff6b273bd9b9c6ac4 Mon Sep 17 00:00:00 2001 From: zale144 Date: Tue, 15 Oct 2024 13:45:29 +0200 Subject: [PATCH] fix(rollapp): revert state info created_at removal (#1321) --- .../dymension/rollapp/state_info.proto | 8 +- x/rollapp/keeper/msg_server_update_state.go | 2 + x/rollapp/types/state_info.go | 3 + x/rollapp/types/state_info.pb.go | 130 +++++++++++++----- 4 files changed, 106 insertions(+), 37 deletions(-) diff --git a/proto/dymensionxyz/dymension/rollapp/state_info.proto b/proto/dymensionxyz/dymension/rollapp/state_info.proto index f8a265ce7..a8ade3d99 100644 --- a/proto/dymensionxyz/dymension/rollapp/state_info.proto +++ b/proto/dymensionxyz/dymension/rollapp/state_info.proto @@ -47,8 +47,14 @@ message StateInfo { // BDs is a list of block description objects (one per block) // the list must be ordered by height, starting from startHeight to startHeight+numBlocks-1 BlockDescriptors BDs = 9 [(gogoproto.nullable) = false]; + // created_at is the timestamp at which the StateInfo was created + google.protobuf.Timestamp created_at = 10 [ + (gogoproto.stdtime) = true, + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"created_at\"" + ]; // DrsVersion is a DRS version used by the rollapp. - string drs_version = 10; + string drs_version = 11; } // StateInfoSummary is a compact representation of StateInfo diff --git a/x/rollapp/keeper/msg_server_update_state.go b/x/rollapp/keeper/msg_server_update_state.go index 8e905466e..3fd41c361 100644 --- a/x/rollapp/keeper/msg_server_update_state.go +++ b/x/rollapp/keeper/msg_server_update_state.go @@ -96,6 +96,7 @@ func (k msgServer) UpdateState(goCtx context.Context, msg *types.MsgUpdateState) }) creationHeight := uint64(ctx.BlockHeight()) + blockTime := ctx.BlockTime() stateInfo := types.NewStateInfo( msg.RollappId, newIndex, @@ -105,6 +106,7 @@ func (k msgServer) UpdateState(goCtx context.Context, msg *types.MsgUpdateState) msg.DAPath, creationHeight, msg.BDs, + blockTime, msg.DrsVersion, ) // Write new state information to the store indexed by diff --git a/x/rollapp/types/state_info.go b/x/rollapp/types/state_info.go index b9aa7d409..7f094f6e5 100644 --- a/x/rollapp/types/state_info.go +++ b/x/rollapp/types/state_info.go @@ -2,6 +2,7 @@ package types import ( "strconv" + "time" sdk "github.com/cosmos/cosmos-sdk/types" @@ -17,6 +18,7 @@ func NewStateInfo( daPath string, height uint64, BDs BlockDescriptors, + createdAt time.Time, drsVersion string, ) *StateInfo { stateInfoIndex := StateInfoIndex{RollappId: rollappId, Index: newIndex} @@ -30,6 +32,7 @@ func NewStateInfo( CreationHeight: height, Status: status, BDs: BDs, + CreatedAt: createdAt, DrsVersion: drsVersion, } } diff --git a/x/rollapp/types/state_info.pb.go b/x/rollapp/types/state_info.pb.go index 01c9d40e2..36748d303 100644 --- a/x/rollapp/types/state_info.pb.go +++ b/x/rollapp/types/state_info.pb.go @@ -7,17 +7,20 @@ import ( fmt "fmt" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" + github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types" types "github.com/dymensionxyz/dymension/v3/x/common/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. @@ -107,8 +110,10 @@ type StateInfo struct { // BDs is a list of block description objects (one per block) // the list must be ordered by height, starting from startHeight to startHeight+numBlocks-1 BDs BlockDescriptors `protobuf:"bytes,9,opt,name=BDs,proto3" json:"BDs"` + // created_at is the timestamp at which the StateInfo was created + CreatedAt time.Time `protobuf:"bytes,10,opt,name=created_at,json=createdAt,proto3,stdtime" json:"created_at" yaml:"created_at"` // DrsVersion is a DRS version used by the rollapp. - DrsVersion string `protobuf:"bytes,10,opt,name=drs_version,json=drsVersion,proto3" json:"drs_version,omitempty"` + DrsVersion string `protobuf:"bytes,11,opt,name=drs_version,json=drsVersion,proto3" json:"drs_version,omitempty"` } func (m *StateInfo) Reset() { *m = StateInfo{} } @@ -200,6 +205,13 @@ func (m *StateInfo) GetBDs() BlockDescriptors { return BlockDescriptors{} } +func (m *StateInfo) GetCreatedAt() time.Time { + if m != nil { + return m.CreatedAt + } + return time.Time{} +} + func (m *StateInfo) GetDrsVersion() string { if m != nil { return m.DrsVersion @@ -340,40 +352,43 @@ func init() { } var fileDescriptor_750f3a9f16533ec4 = []byte{ - // 519 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x94, 0x4f, 0x8b, 0xd3, 0x40, - 0x18, 0xc6, 0x3b, 0x4d, 0xb7, 0xbb, 0x99, 0x42, 0x59, 0x87, 0x45, 0xc2, 0x22, 0x69, 0x28, 0x28, - 0xc5, 0x43, 0x22, 0xbb, 0x7a, 0xf4, 0x60, 0x29, 0xb2, 0xf5, 0x20, 0x9a, 0x15, 0x0f, 0x22, 0x94, - 0xfc, 0x99, 0xa6, 0x83, 0xc9, 0x4c, 0x9c, 0x99, 0x2c, 0xed, 0x7e, 0x0a, 0x3f, 0x88, 0x77, 0xbf, - 0xc2, 0x1e, 0xf7, 0xa6, 0x27, 0x91, 0xf6, 0x8b, 0x48, 0x26, 0x21, 0xd9, 0xed, 0xb6, 0x2e, 0x14, - 0xbc, 0xf5, 0x7d, 0xfb, 0x3e, 0x0f, 0xcf, 0xfb, 0x7b, 0xc9, 0x40, 0x27, 0x5c, 0x24, 0x98, 0x0a, - 0xc2, 0xe8, 0x7c, 0x71, 0x59, 0x17, 0x0e, 0x67, 0x71, 0xec, 0xa5, 0xa9, 0x23, 0xa4, 0x27, 0xf1, - 0x84, 0xd0, 0x29, 0xb3, 0x53, 0xce, 0x24, 0x43, 0xe6, 0x4d, 0x81, 0x5d, 0x15, 0x76, 0x29, 0x38, - 0x3e, 0x8a, 0x58, 0xc4, 0xd4, 0xa8, 0x93, 0xff, 0x2a, 0x54, 0xc7, 0xbd, 0x88, 0xb1, 0x28, 0xc6, - 0x8e, 0xaa, 0xfc, 0x6c, 0xea, 0x48, 0x92, 0x60, 0x21, 0xbd, 0x24, 0x2d, 0x07, 0x5e, 0xdc, 0x93, - 0xc3, 0x8f, 0x59, 0xf0, 0x65, 0x12, 0x62, 0x11, 0x70, 0x92, 0x4a, 0xc6, 0x4b, 0xd9, 0xd3, 0x2d, - 0xb2, 0x80, 0x25, 0x09, 0xa3, 0x2a, 0x7d, 0x26, 0x8a, 0xd9, 0xfe, 0x08, 0x76, 0xcf, 0xf3, 0x6d, - 0xc6, 0x74, 0xca, 0xc6, 0x34, 0xc4, 0x73, 0xf4, 0x08, 0xea, 0xa5, 0xff, 0x38, 0x34, 0x80, 0x05, - 0x06, 0xba, 0x5b, 0x37, 0xd0, 0x11, 0xdc, 0x23, 0xf9, 0x98, 0xd1, 0xb4, 0xc0, 0xa0, 0xe5, 0x16, - 0x45, 0xff, 0x87, 0x06, 0xf5, 0xca, 0x06, 0x7d, 0x86, 0x5d, 0x71, 0xcb, 0x53, 0xd9, 0x74, 0x4e, - 0x6c, 0xfb, 0xdf, 0x98, 0xec, 0xdb, 0x49, 0x86, 0xad, 0xab, 0xdf, 0xbd, 0x86, 0xbb, 0xe6, 0x95, - 0xe7, 0x13, 0xf8, 0x6b, 0x86, 0x69, 0x80, 0xb9, 0x4a, 0xa1, 0xbb, 0x75, 0x03, 0x59, 0xb0, 0x23, - 0xa4, 0xc7, 0xe5, 0x19, 0x26, 0xd1, 0x4c, 0x1a, 0x9a, 0x4a, 0x79, 0xb3, 0x95, 0xeb, 0x69, 0x96, - 0x0c, 0x73, 0x74, 0xc2, 0x68, 0xa9, 0xff, 0xeb, 0x06, 0x7a, 0x08, 0xdb, 0xa3, 0x57, 0xef, 0x3c, - 0x39, 0x33, 0xf6, 0x94, 0x75, 0x59, 0xa1, 0x27, 0xb0, 0x1b, 0x70, 0xec, 0x49, 0xc2, 0x68, 0x69, - 0xbd, 0xaf, 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, 0xf7, 0xe9, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xe2, - 0x90, 0x6b, 0xc9, 0xcc, 0x04, 0x00, 0x00, + // 568 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x54, 0x41, 0x6a, 0xdb, 0x40, + 0x14, 0xf5, 0xd8, 0x8e, 0x13, 0x8d, 0xc1, 0x24, 0x43, 0x28, 0xc2, 0xb4, 0xb2, 0x11, 0xb4, 0x98, + 0x2e, 0xa4, 0x92, 0xb4, 0x9b, 0x42, 0x17, 0x31, 0xa6, 0xc4, 0x5d, 0x94, 0x56, 0x09, 0xa5, 0x94, + 0x82, 0x91, 0xad, 0xb1, 0x2c, 0x2a, 0xcd, 0xa8, 0x33, 0xa3, 0x60, 0xe7, 0x14, 0xe9, 0x3d, 0x7a, + 0x90, 0x2c, 0xb3, 0x6b, 0x57, 0x69, 0xb1, 0x6f, 0xd0, 0x13, 0x94, 0x19, 0x29, 0x52, 0xe2, 0xd8, + 0x0d, 0x04, 0xba, 0xd3, 0x7f, 0xfa, 0xef, 0xf1, 0xfe, 0xfb, 0x9f, 0x81, 0xb6, 0x37, 0x8b, 0x30, + 0xe1, 0x01, 0x25, 0xd3, 0xd9, 0x69, 0x51, 0xd8, 0x8c, 0x86, 0xa1, 0x1b, 0xc7, 0x36, 0x17, 0xae, + 0xc0, 0x83, 0x80, 0x8c, 0xa9, 0x15, 0x33, 0x2a, 0x28, 0x32, 0xae, 0x13, 0xac, 0xbc, 0xb0, 0x32, + 0x42, 0x73, 0xd7, 0xa7, 0x3e, 0x55, 0xad, 0xb6, 0xfc, 0x4a, 0x59, 0xcd, 0x96, 0x4f, 0xa9, 0x1f, + 0x62, 0x5b, 0x55, 0xc3, 0x64, 0x6c, 0x8b, 0x20, 0xc2, 0x5c, 0xb8, 0x51, 0x9c, 0x35, 0xbc, 0xb8, + 0xc3, 0xc7, 0x30,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9, 0xe7, 0xc2, 0x28, + 0x7d, 0x7a, 0xee, 0x07, 0x62, 0x92, 0x0c, 0x65, 0x1c, 0xeb, 0x9e, 0xbc, 0x93, 0x7d, 0x7b, 0x9a, + 0xbf, 0x37, 0x62, 0x16, 0x63, 0x3e, 0xac, 0xa9, 0xeb, 0xd9, 0xff, 0x1b, 0x00, 0x00, 0xff, 0xff, + 0x8a, 0x35, 0x1b, 0xf6, 0x26, 0x05, 0x00, 0x00, } func (m *StateInfoIndex) Marshal() (dAtA []byte, err error) { @@ -436,8 +451,16 @@ func (m *StateInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.DrsVersion) i = encodeVarintStateInfo(dAtA, i, uint64(len(m.DrsVersion))) i-- - dAtA[i] = 0x52 + dAtA[i] = 0x5a + } + n1, err1 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.CreatedAt, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.CreatedAt):]) + if err1 != nil { + return 0, err1 } + i -= n1 + i = encodeVarintStateInfo(dAtA, i, uint64(n1)) + i-- + dAtA[i] = 0x52 { size, err := m.BDs.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -637,6 +660,8 @@ func (m *StateInfo) Size() (n int) { } l = m.BDs.Size() n += 1 + l + sovStateInfo(uint64(l)) + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.CreatedAt) + n += 1 + l + sovStateInfo(uint64(l)) l = len(m.DrsVersion) if l > 0 { n += 1 + l + sovStateInfo(uint64(l)) @@ -1022,6 +1047,39 @@ func (m *StateInfo) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CreatedAt", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStateInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthStateInfo + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthStateInfo + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.CreatedAt, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 11: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field DrsVersion", wireType) }