From e111319745836bce5a2af912b08a96b029e33c1f Mon Sep 17 00:00:00 2001 From: keruch Date: Fri, 15 Nov 2024 10:19:36 +0100 Subject: [PATCH 1/2] feat(rollapp): store all rollapp revisions --- app/upgrades/v4/upgrade.go | 6 +- .../dymension/rollapp/rollapp.proto | 14 +- x/lightclient/ante/ibc_msg_update_client.go | 5 +- x/rollapp/keeper/fraud_proposal.go | 5 +- x/rollapp/keeper/hard_fork.go | 6 +- x/rollapp/keeper/hard_fork_test.go | 2 +- .../keeper/msg_server_create_rollapp_test.go | 4 + .../msg_server_mark_obsolete_rollapps_test.go | 4 +- x/rollapp/keeper/msg_server_update_state.go | 4 +- x/rollapp/keeper/rollapp_suite_test.go | 2 +- x/rollapp/types/rollapp.go | 22 +- x/rollapp/types/rollapp.pb.go | 348 ++++++++++++++---- 12 files changed, 320 insertions(+), 102 deletions(-) diff --git a/app/upgrades/v4/upgrade.go b/app/upgrades/v4/upgrade.go index 677ff49ae..acda2f9d9 100644 --- a/app/upgrades/v4/upgrade.go +++ b/app/upgrades/v4/upgrade.go @@ -335,8 +335,10 @@ func ConvertOldRollappToNew(oldRollapp rollapptypes.Rollapp) rollapptypes.Rollap PreLaunchTime: nil, // We can just let it be zero. Existing rollapps are already launched. LivenessEventHeight: 0, // Filled lazily in runtime LastStateUpdateHeight: 0, // Filled lazily in runtime - RevisionNumber: 0, - RevisionStartHeight: 0, + Revisions: []rollapptypes.Revision{{ + Number: 0, + StartHeight: 0, + }}, } } diff --git a/proto/dymensionxyz/dymension/rollapp/rollapp.proto b/proto/dymensionxyz/dymension/rollapp/rollapp.proto index 37c245e84..d1e0df4eb 100644 --- a/proto/dymensionxyz/dymension/rollapp/rollapp.proto +++ b/proto/dymensionxyz/dymension/rollapp/rollapp.proto @@ -75,10 +75,16 @@ message Rollapp { // received int64 last_state_update_height = 18; - // The revision number of the rollapp. starts always with 0 revision - uint64 revision_number = 19; - // The first height of the rollapp when the revision started - uint64 revision_start_height = 20; + // Revisions is a list of all the rollapp revisions. + repeated Revision revisions = 19 [ (gogoproto.nullable) = false ]; +} + +// Revision is a representation of the rollapp revision. +message Revision { + // Number is the revision number of the rollapp. Always start with 0 revision. + uint64 number = 19; + // StartHeight is the first height of the rollapp when the revision started. + uint64 start_height = 20; } // Rollapp summary is a compact representation of Rollapp diff --git a/x/lightclient/ante/ibc_msg_update_client.go b/x/lightclient/ante/ibc_msg_update_client.go index 719151279..4b94bbcd0 100644 --- a/x/lightclient/ante/ibc_msg_update_client.go +++ b/x/lightclient/ante/ibc_msg_update_client.go @@ -8,10 +8,11 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" + "github.com/dymensionxyz/gerr-cosmos/gerrc" + "github.com/dymensionxyz/dymension/v3/x/lightclient/types" rollapptypes "github.com/dymensionxyz/dymension/v3/x/rollapp/types" sequencertypes "github.com/dymensionxyz/dymension/v3/x/sequencer/types" - "github.com/dymensionxyz/gerr-cosmos/gerrc" ) func (i IBCMessagesDecorator) HandleMsgUpdateClient(ctx sdk.Context, msg *ibcclienttypes.MsgUpdateClient) error { @@ -69,7 +70,7 @@ func (i IBCMessagesDecorator) HandleMsgUpdateClient(ctx sdk.Context, msg *ibccli // this disallows LC updates from previous revisions but should be fine since new state roots can be used to prove // state older than the one in the current state root. - if header.Header.Version.App != rollapp.RevisionNumber { + if header.Header.Version.App != rollapp.LatestRevision().Number { return errorsmod.Wrap(gerrc.ErrFailedPrecondition, "client update revision mismatch") } diff --git a/x/rollapp/keeper/fraud_proposal.go b/x/rollapp/keeper/fraud_proposal.go index 00187be7c..45e1c66f4 100644 --- a/x/rollapp/keeper/fraud_proposal.go +++ b/x/rollapp/keeper/fraud_proposal.go @@ -6,8 +6,9 @@ import ( errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/dymensionxyz/dymension/v3/x/rollapp/types" "github.com/dymensionxyz/gerr-cosmos/gerrc" + + "github.com/dymensionxyz/dymension/v3/x/rollapp/types" ) // SubmitRollappFraud handles the submission of a fraud proposal @@ -36,7 +37,7 @@ func (k Keeper) SubmitRollappFraud(goCtx context.Context, msg *types.MsgRollappF } // check revision number - if rollapp.RevisionNumber != msg.RollappRevision { + if rollapp.LatestRevision().Number != msg.RollappRevision { err := errorsmod.Wrap(gerrc.ErrFailedPrecondition, "revision number mismatch") ctx.Logger().Error(err.Error()) return nil, err diff --git a/x/rollapp/keeper/hard_fork.go b/x/rollapp/keeper/hard_fork.go index c15b4c644..cd1ccfec3 100644 --- a/x/rollapp/keeper/hard_fork.go +++ b/x/rollapp/keeper/hard_fork.go @@ -8,9 +8,10 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/dymensionxyz/gerr-cosmos/gerrc" + common "github.com/dymensionxyz/dymension/v3/x/common/types" "github.com/dymensionxyz/dymension/v3/x/rollapp/types" - "github.com/dymensionxyz/gerr-cosmos/gerrc" ) // HardFork handles the fraud evidence submitted by the user. @@ -27,8 +28,7 @@ func (k Keeper) HardFork(ctx sdk.Context, rollappID string, newRevisionHeight ui newRevisionHeight = lastValidHeight + 1 // update revision number - rollapp.RevisionNumber += 1 - rollapp.RevisionStartHeight = newRevisionHeight + rollapp.BumpRevision(newRevisionHeight) k.SetRollapp(ctx, rollapp) // handle the sequencers, clean delayed packets, handle light client diff --git a/x/rollapp/keeper/hard_fork_test.go b/x/rollapp/keeper/hard_fork_test.go index 44ec81b7f..cae6b0a73 100644 --- a/x/rollapp/keeper/hard_fork_test.go +++ b/x/rollapp/keeper/hard_fork_test.go @@ -125,7 +125,7 @@ func (suite *RollappTestSuite) TestHardFork_AlreadyFinalized() { func (suite *RollappTestSuite) assertFraudHandled(rollappId string, height uint64) { rollapp, found := suite.App.RollappKeeper.GetRollapp(suite.Ctx, rollappId) suite.Require().True(found) - suite.Require().Equal(uint64(1), rollapp.RevisionNumber) + suite.Require().Equal(uint64(1), rollapp.LatestRevision().Number) // check states were deleted // the last state should have height less than the fraud height diff --git a/x/rollapp/keeper/msg_server_create_rollapp_test.go b/x/rollapp/keeper/msg_server_create_rollapp_test.go index 0f5ec5bf2..cff3b7b53 100644 --- a/x/rollapp/keeper/msg_server_create_rollapp_test.go +++ b/x/rollapp/keeper/msg_server_create_rollapp_test.go @@ -202,6 +202,10 @@ func (suite *RollappTestSuite) createRollappWithCreatorAndVerify( VmType: types.Rollapp_EVM, Metadata: rollapp.GetMetadata(), GenesisInfo: *rollapp.GetGenesisInfo(), + Revisions: []types.Revision{{ + Number: 0, + StartHeight: 0, + }}, } // create rollapp diff --git a/x/rollapp/keeper/msg_server_mark_obsolete_rollapps_test.go b/x/rollapp/keeper/msg_server_mark_obsolete_rollapps_test.go index 2d1c9a81f..162845702 100644 --- a/x/rollapp/keeper/msg_server_mark_obsolete_rollapps_test.go +++ b/x/rollapp/keeper/msg_server_mark_obsolete_rollapps_test.go @@ -190,9 +190,9 @@ func (s *RollappTestSuite) TestMarkObsoleteRollapps() { } func FilterForked(b types.Rollapp) bool { - return b.RevisionNumber > 0 + return b.LatestRevision().Number > 0 } func FilterNonForked(b types.Rollapp) bool { - return b.RevisionNumber == 0 + return b.LatestRevision().Number == 0 } diff --git a/x/rollapp/keeper/msg_server_update_state.go b/x/rollapp/keeper/msg_server_update_state.go index 198355997..5466e51d5 100644 --- a/x/rollapp/keeper/msg_server_update_state.go +++ b/x/rollapp/keeper/msg_server_update_state.go @@ -30,10 +30,10 @@ func (k msgServer) UpdateState(goCtx context.Context, msg *types.MsgUpdateState) } // validate correct rollapp revision number - if rollapp.RevisionNumber != msg.RollappRevision { + if rollapp.LatestRevision().Number != msg.RollappRevision { return nil, errorsmod.Wrapf(types.ErrWrongRollappRevision, "expected revision number (%d), but received (%d)", - rollapp.RevisionNumber, msg.RollappRevision) + rollapp.LatestRevision().Number, msg.RollappRevision) } // retrieve last updating index diff --git a/x/rollapp/keeper/rollapp_suite_test.go b/x/rollapp/keeper/rollapp_suite_test.go index 1708c84a1..cca0f1260 100644 --- a/x/rollapp/keeper/rollapp_suite_test.go +++ b/x/rollapp/keeper/rollapp_suite_test.go @@ -74,7 +74,7 @@ func TestRollappKeeperTestSuite(t *testing.T) { func (suite *RollappTestSuite) assertNotForked(rollappID string) { rollapp, _ := suite.App.RollappKeeper.GetRollapp(suite.Ctx, rollappID) - suite.Zero(rollapp.RevisionNumber) + suite.Zero(rollapp.LatestRevision().Number) } func (suite *RollappTestSuite) GetRollappLastHeight(rollappID string) uint64 { diff --git a/x/rollapp/types/rollapp.go b/x/rollapp/types/rollapp.go index 6b8bbc217..dc2c8d5b0 100644 --- a/x/rollapp/types/rollapp.go +++ b/x/rollapp/types/rollapp.go @@ -46,8 +46,10 @@ func NewRollapp( GenesisState: RollappGenesisState{ TransfersEnabled: transfersEnabled, }, - RevisionNumber: 0, - RevisionStartHeight: 0, + Revisions: []Revision{{ + Number: 0, + StartHeight: 0, + }}, } } @@ -101,6 +103,22 @@ func (r Rollapp) GenesisInfoFieldsAreSet() bool { return r.GenesisInfo.AllSet() } +func (r Rollapp) LatestRevision() Revision { + if len(r.Revisions) == 0 { + // Revision 0 if no revisions exist. + // Should happen only in tests. + return Revision{} + } + return r.Revisions[len(r.Revisions)-1] +} + +func (r *Rollapp) BumpRevision(nextRevisionStartHeight uint64) { + r.Revisions = append(r.Revisions, Revision{ + Number: r.LatestRevision().Number + 1, + StartHeight: nextRevisionStartHeight, + }) +} + func validateInitialSequencer(initialSequencer string) error { if initialSequencer == "" || initialSequencer == "*" { return nil diff --git a/x/rollapp/types/rollapp.pb.go b/x/rollapp/types/rollapp.pb.go index 663aae685..62f1233a5 100644 --- a/x/rollapp/types/rollapp.pb.go +++ b/x/rollapp/types/rollapp.pb.go @@ -147,10 +147,8 @@ type Rollapp struct { // The LastStateUpdateHeight HUB height when the last state update was // received LastStateUpdateHeight int64 `protobuf:"varint,18,opt,name=last_state_update_height,json=lastStateUpdateHeight,proto3" json:"last_state_update_height,omitempty"` - // The revision number of the rollapp. starts always with 0 revision - RevisionNumber uint64 `protobuf:"varint,19,opt,name=revision_number,json=revisionNumber,proto3" json:"revision_number,omitempty"` - // The first height of the rollapp when the revision started - RevisionStartHeight uint64 `protobuf:"varint,20,opt,name=revision_start_height,json=revisionStartHeight,proto3" json:"revision_start_height,omitempty"` + // Revisions is a list of all the rollapp revisions. + Revisions []Revision `protobuf:"bytes,19,rep,name=revisions,proto3" json:"revisions"` } func (m *Rollapp) Reset() { *m = Rollapp{} } @@ -270,16 +268,64 @@ func (m *Rollapp) GetLastStateUpdateHeight() int64 { return 0 } -func (m *Rollapp) GetRevisionNumber() uint64 { +func (m *Rollapp) GetRevisions() []Revision { if m != nil { - return m.RevisionNumber + return m.Revisions + } + return nil +} + +// Revision is a representation of the rollapp revision. +type Revision struct { + // Number is the revision number of the rollapp. Always start with 0 revision. + Number uint64 `protobuf:"varint,19,opt,name=number,proto3" json:"number,omitempty"` + // StartHeight is the first height of the rollapp when the revision started. + StartHeight uint64 `protobuf:"varint,20,opt,name=start_height,json=startHeight,proto3" json:"start_height,omitempty"` +} + +func (m *Revision) Reset() { *m = Revision{} } +func (m *Revision) String() string { return proto.CompactTextString(m) } +func (*Revision) ProtoMessage() {} +func (*Revision) Descriptor() ([]byte, []int) { + return fileDescriptor_d4ef2bec3aea5528, []int{2} +} +func (m *Revision) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Revision) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Revision.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 *Revision) XXX_Merge(src proto.Message) { + xxx_messageInfo_Revision.Merge(m, src) +} +func (m *Revision) XXX_Size() int { + return m.Size() +} +func (m *Revision) XXX_DiscardUnknown() { + xxx_messageInfo_Revision.DiscardUnknown(m) +} + +var xxx_messageInfo_Revision proto.InternalMessageInfo + +func (m *Revision) GetNumber() uint64 { + if m != nil { + return m.Number } return 0 } -func (m *Rollapp) GetRevisionStartHeight() uint64 { +func (m *Revision) GetStartHeight() uint64 { if m != nil { - return m.RevisionStartHeight + return m.StartHeight } return 0 } @@ -301,7 +347,7 @@ func (m *RollappSummary) Reset() { *m = RollappSummary{} } func (m *RollappSummary) String() string { return proto.CompactTextString(m) } func (*RollappSummary) ProtoMessage() {} func (*RollappSummary) Descriptor() ([]byte, []int) { - return fileDescriptor_d4ef2bec3aea5528, []int{2} + return fileDescriptor_d4ef2bec3aea5528, []int{3} } func (m *RollappSummary) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -369,6 +415,7 @@ func init() { proto.RegisterEnum("dymensionxyz.dymension.rollapp.Rollapp_VMType", Rollapp_VMType_name, Rollapp_VMType_value) proto.RegisterType((*RollappGenesisState)(nil), "dymensionxyz.dymension.rollapp.RollappGenesisState") proto.RegisterType((*Rollapp)(nil), "dymensionxyz.dymension.rollapp.Rollapp") + proto.RegisterType((*Revision)(nil), "dymensionxyz.dymension.rollapp.Revision") proto.RegisterType((*RollappSummary)(nil), "dymensionxyz.dymension.rollapp.RollappSummary") } @@ -377,55 +424,56 @@ func init() { } var fileDescriptor_d4ef2bec3aea5528 = []byte{ - // 763 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0x41, 0x6f, 0xe2, 0x46, - 0x14, 0xc6, 0xe0, 0x05, 0x33, 0x10, 0xf0, 0x0e, 0x89, 0xea, 0xa2, 0x2e, 0x41, 0x5c, 0x8a, 0xb4, - 0x5b, 0x5b, 0x9b, 0xac, 0xd4, 0x73, 0x23, 0xa5, 0x1b, 0x68, 0xd9, 0x83, 0xc9, 0x6e, 0xa5, 0x3d, - 0xd4, 0x1a, 0xf0, 0x60, 0x46, 0xb2, 0xc7, 0xae, 0x67, 0xa0, 0x61, 0x7f, 0x45, 0x7e, 0x55, 0x95, - 0x63, 0xd4, 0x53, 0x4f, 0x6d, 0x95, 0xfc, 0x91, 0x6a, 0xc6, 0x63, 0x87, 0x36, 0x49, 0x89, 0xf6, - 0x34, 0x7e, 0xef, 0x7b, 0xef, 0x7b, 0xef, 0x7b, 0x33, 0xcf, 0xe0, 0x95, 0xbf, 0x89, 0x30, 0x65, - 0x24, 0xa6, 0x17, 0x9b, 0x4f, 0x4e, 0x61, 0x38, 0x69, 0x1c, 0x86, 0x28, 0x49, 0xf2, 0xd3, 0x4e, - 0xd2, 0x98, 0xc7, 0xb0, 0xb7, 0x1d, 0x6d, 0x17, 0x86, 0xad, 0xa2, 0xba, 0xfb, 0x41, 0x1c, 0xc4, - 0x32, 0xd4, 0x11, 0x5f, 0x59, 0x56, 0xf7, 0x30, 0x88, 0xe3, 0x20, 0xc4, 0x8e, 0xb4, 0x66, 0xab, - 0x85, 0xc3, 0x49, 0x84, 0x19, 0x47, 0x91, 0xa2, 0xed, 0x7e, 0x31, 0x8f, 0x59, 0x14, 0x33, 0x27, - 0x62, 0x81, 0xb3, 0x7e, 0x2d, 0x0e, 0x05, 0x38, 0x3b, 0xba, 0x63, 0x1c, 0x71, 0xec, 0x11, 0xba, - 0xc8, 0x4b, 0x7d, 0xb3, 0x23, 0x21, 0xc2, 0x1c, 0xf9, 0x88, 0x23, 0x15, 0xfe, 0x7a, 0x47, 0x78, - 0x80, 0x29, 0x66, 0x84, 0x6d, 0x55, 0x18, 0x9c, 0x81, 0x8e, 0x9b, 0xa1, 0x6f, 0x33, 0x70, 0x2a, - 0x7a, 0x80, 0x2f, 0xc1, 0x73, 0x9e, 0x22, 0xca, 0x16, 0x38, 0x65, 0x1e, 0xa6, 0x68, 0x16, 0x62, - 0xdf, 0x2a, 0xf7, 0xb5, 0xa1, 0xe1, 0x9a, 0x05, 0x70, 0x9a, 0xf9, 0xc7, 0xba, 0xa1, 0x99, 0xe5, - 0xc1, 0x6f, 0x55, 0x50, 0x53, 0x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ef, 0x65, 0xd0, 0x52, 0x57, 0x31, 0x5d, 0x45, 0x11, 0x4a, 0x37, 0xf0, 0x2b, 0x70, - 0xb7, 0x3d, 0xf7, 0xd7, 0xe9, 0x23, 0x30, 0x43, 0xc4, 0xb1, 0x12, 0x3a, 0xa2, 0x3e, 0xbe, 0x90, - 0x9b, 0xd5, 0xd8, 0x7d, 0xe5, 0x2a, 0x63, 0x11, 0xcb, 0x2c, 0xf7, 0x1e, 0x0f, 0x0c, 0xc1, 0x97, - 0x99, 0xef, 0x7b, 0x42, 0x51, 0x48, 0x3e, 0x61, 0x7f, 0xab, 0x48, 0xe5, 0xb3, 0x8a, 0x3c, 0x4e, - 0x08, 0x07, 0xa0, 0x99, 0x81, 0xd9, 0x28, 0x2d, 0x5d, 0x4e, 0xf9, 0x5f, 0x3e, 0xf8, 0x06, 0x1c, - 0xfc, 0x87, 0x40, 0x05, 0x3f, 0x93, 0xc1, 0x0f, 0x83, 0x27, 0xef, 0xae, 0x6e, 0x7a, 0xda, 0xf5, - 0x4d, 0x4f, 0xfb, 0xfb, 0xa6, 0xa7, 0x5d, 0xde, 0xf6, 0x4a, 0xd7, 0xb7, 0xbd, 0xd2, 0x1f, 0xb7, - 0xbd, 0xd2, 0xc7, 0x37, 0x01, 0xe1, 0xcb, 0xd5, 0xcc, 0x9e, 0xc7, 0xd1, 0x63, 0xff, 0xe7, 0xf5, - 0xb1, 0x73, 0x51, 0xfc, 0x44, 0xc5, 0x46, 0xb1, 0x59, 0x55, 0xbe, 0xeb, 0xe3, 0x7f, 0x02, 0x00, - 0x00, 0xff, 0xff, 0x5c, 0xc6, 0x07, 0x2b, 0x71, 0x06, 0x00, 0x00, + // 780 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0xcd, 0x6e, 0xdb, 0x46, + 0x10, 0x16, 0x2d, 0x46, 0xa2, 0x86, 0xb2, 0xcd, 0xac, 0xed, 0x96, 0x15, 0x1a, 0x59, 0xd5, 0x89, + 0x40, 0x52, 0x12, 0xb1, 0x03, 0xf4, 0x5c, 0x03, 0x6a, 0x2c, 0x35, 0xea, 0x81, 0x72, 0x52, 0x20, + 0x87, 0x12, 0x2b, 0x71, 0x45, 0x2d, 0x40, 0x2e, 0x59, 0xee, 0x4a, 0xb5, 0xf2, 0x14, 0x79, 0x9b, + 0xbe, 0x42, 0x8e, 0x41, 0x4f, 0x3d, 0xb5, 0x85, 0xfd, 0x22, 0x05, 0x97, 0x4b, 0x59, 0x6d, 0x92, + 0xca, 0xe8, 0x69, 0x39, 0xf3, 0xcd, 0xf7, 0xcd, 0xcf, 0xee, 0x10, 0x9e, 0x84, 0xeb, 0x84, 0x30, + 0x4e, 0x53, 0x76, 0xbd, 0x7e, 0xe3, 0x6d, 0x0c, 0x2f, 0x4f, 0xe3, 0x18, 0x67, 0x59, 0x75, 0xba, + 0x59, 0x9e, 0x8a, 0x14, 0x75, 0xb7, 0xa3, 0xdd, 0x8d, 0xe1, 0xaa, 0xa8, 0xce, 0x71, 0x94, 0x46, + 0xa9, 0x0c, 0xf5, 0x8a, 0xaf, 0x92, 0xd5, 0x39, 0x8d, 0xd2, 0x34, 0x8a, 0x89, 0x27, 0xad, 0xe9, + 0x72, 0xee, 0x09, 0x9a, 0x10, 0x2e, 0x70, 0xa2, 0x64, 0x3b, 0x9f, 0xcf, 0x52, 0x9e, 0xa4, 0xdc, + 0x4b, 0x78, 0xe4, 0xad, 0x9e, 0x16, 0x87, 0x02, 0xbc, 0x1d, 0xd5, 0x71, 0x81, 0x05, 0x09, 0x28, + 0x9b, 0x57, 0xa9, 0xbe, 0xde, 0x41, 0x48, 0x88, 0xc0, 0x21, 0x16, 0x58, 0x85, 0x3f, 0xdd, 0x11, + 0x1e, 0x11, 0x46, 0x38, 0xe5, 0x5b, 0x19, 0xfa, 0x97, 0x70, 0xe4, 0x97, 0xe8, 0xf3, 0x12, 0x9c, + 0x14, 0x35, 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xef, 0x7a, 0xf3, 0xf3, 0x2d, 0x36, 0x91, 0x4f, 0x1b, 0x72, 0x1f, 0xce, 0xff, 0x0e, + 0x00, 0x00, 0xff, 0xff, 0x80, 0x31, 0xdb, 0x98, 0xa9, 0x06, 0x00, 0x00, } func (m *RollappGenesisState) Marshal() (dAtA []byte, err error) { @@ -481,19 +529,21 @@ func (m *Rollapp) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.RevisionStartHeight != 0 { - i = encodeVarintRollapp(dAtA, i, uint64(m.RevisionStartHeight)) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0xa0 - } - if m.RevisionNumber != 0 { - i = encodeVarintRollapp(dAtA, i, uint64(m.RevisionNumber)) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0x98 + if len(m.Revisions) > 0 { + for iNdEx := len(m.Revisions) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Revisions[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintRollapp(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x9a + } } if m.LastStateUpdateHeight != 0 { i = encodeVarintRollapp(dAtA, i, uint64(m.LastStateUpdateHeight)) @@ -599,6 +649,43 @@ func (m *Rollapp) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *Revision) 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 *Revision) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Revision) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.StartHeight != 0 { + i = encodeVarintRollapp(dAtA, i, uint64(m.StartHeight)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xa0 + } + if m.Number != 0 { + i = encodeVarintRollapp(dAtA, i, uint64(m.Number)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x98 + } + return len(dAtA) - i, nil +} + func (m *RollappSummary) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -732,11 +819,26 @@ func (m *Rollapp) Size() (n int) { if m.LastStateUpdateHeight != 0 { n += 2 + sovRollapp(uint64(m.LastStateUpdateHeight)) } - if m.RevisionNumber != 0 { - n += 2 + sovRollapp(uint64(m.RevisionNumber)) + if len(m.Revisions) > 0 { + for _, e := range m.Revisions { + l = e.Size() + n += 2 + l + sovRollapp(uint64(l)) + } + } + return n +} + +func (m *Revision) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Number != 0 { + n += 2 + sovRollapp(uint64(m.Number)) } - if m.RevisionStartHeight != 0 { - n += 2 + sovRollapp(uint64(m.RevisionStartHeight)) + if m.StartHeight != 0 { + n += 2 + sovRollapp(uint64(m.StartHeight)) } return n } @@ -1216,11 +1318,95 @@ func (m *Rollapp) Unmarshal(dAtA []byte) error { break } } + case 19: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Revisions", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRollapp + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthRollapp + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthRollapp + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Revisions = append(m.Revisions, Revision{}) + if err := m.Revisions[len(m.Revisions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipRollapp(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthRollapp + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Revision) 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 ErrIntOverflowRollapp + } + 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: Revision: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Revision: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { case 19: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field RevisionNumber", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Number", wireType) } - m.RevisionNumber = 0 + m.Number = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowRollapp @@ -1230,16 +1416,16 @@ func (m *Rollapp) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.RevisionNumber |= uint64(b&0x7F) << shift + m.Number |= uint64(b&0x7F) << shift if b < 0x80 { break } } case 20: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field RevisionStartHeight", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field StartHeight", wireType) } - m.RevisionStartHeight = 0 + m.StartHeight = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowRollapp @@ -1249,7 +1435,7 @@ func (m *Rollapp) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.RevisionStartHeight |= uint64(b&0x7F) << shift + m.StartHeight |= uint64(b&0x7F) << shift if b < 0x80 { break } From 81042c5f2be7a8fb3dfb1cceff3877a9ff44caa3 Mon Sep 17 00:00:00 2001 From: keruch Date: Fri, 15 Nov 2024 10:21:35 +0100 Subject: [PATCH 2/2] imports --- x/rollapp/keeper/hard_fork.go | 2 -- x/rollapp/keeper/msg_server_update_state.go | 1 - 2 files changed, 3 deletions(-) diff --git a/x/rollapp/keeper/hard_fork.go b/x/rollapp/keeper/hard_fork.go index cd1ccfec3..bada2de62 100644 --- a/x/rollapp/keeper/hard_fork.go +++ b/x/rollapp/keeper/hard_fork.go @@ -5,9 +5,7 @@ import ( "sort" errorsmod "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/dymensionxyz/gerr-cosmos/gerrc" common "github.com/dymensionxyz/dymension/v3/x/common/types" diff --git a/x/rollapp/keeper/msg_server_update_state.go b/x/rollapp/keeper/msg_server_update_state.go index 5466e51d5..e247311de 100644 --- a/x/rollapp/keeper/msg_server_update_state.go +++ b/x/rollapp/keeper/msg_server_update_state.go @@ -5,7 +5,6 @@ import ( errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/dymensionxyz/gerr-cosmos/gerrc" "github.com/dymensionxyz/dymension/v3/x/rollapp/types"