diff --git a/CHANGELOG.md b/CHANGELOG.md index 125763ba0..c2221ee5e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,7 +52,9 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Features +- (rollapp) [#999](https://github.com/dymensionxyz/dymension/issues/999) Handle sequencer information updates. - (rollapp) [#996](https://github.com/dymensionxyz/dymension/issues/996) Handle rollapp information updates. +- (sequencer) [#955](https://github.com/dymensionxyz/dymension/issues/979) Rework the sequencer registration flow. - (app) [#972](https://github.com/dymensionxyz/dymension/pull/972) Refactor upgrade handlers. - (delayedack) [#972](https://github.com/dymensionxyz/dymension/pull/972) Use pagination when deleting rollapp packets. - (denommetadata) [#955](https://github.com/dymensionxyz/dymension/issues/955) Add IBC middleware to create denom metadata from rollapp, on IBC transfer. diff --git a/app/apptesting/test_suite.go b/app/apptesting/test_suite.go index 9f7f547c0..63929fc1b 100644 --- a/app/apptesting/test_suite.go +++ b/app/apptesting/test_suite.go @@ -4,16 +4,15 @@ import ( "strings" "github.com/cometbft/cometbft/libs/rand" + "github.com/cosmos/cosmos-sdk/crypto/types" codectypes "github.com/cosmos/cosmos-sdk/codec/types" - "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" bankutil "github.com/cosmos/cosmos-sdk/x/bank/testutil" "github.com/stretchr/testify/suite" "github.com/dymensionxyz/dymension/v3/app" - "github.com/dymensionxyz/dymension/v3/testutil/sample" - rollappkeeper "github.com/dymensionxyz/dymension/v3/x/rollapp/keeper" rollapptypes "github.com/dymensionxyz/dymension/v3/x/rollapp/types" sequencerkeeper "github.com/dymensionxyz/dymension/v3/x/sequencer/keeper" @@ -31,16 +30,19 @@ type KeeperTestHelper struct { Ctx sdk.Context } -func (s *KeeperTestHelper) CreateDefaultRollapp() string { - return s.CreateRollappWithName(rand.Str(8)) +func (s *KeeperTestHelper) CreateDefaultRollappWithProposer() (string, string) { + return s.CreateRollappWithNameWithProposer(rand.Str(8)) } -func (s *KeeperTestHelper) CreateRollappWithName(name string) string { +func (s *KeeperTestHelper) CreateRollappWithNameWithProposer(name string) (string, string) { + pubkey := ed25519.GenPrivKey().PubKey() + addr := sdk.AccAddress(pubkey.Address()) + alias := strings.NewReplacer("_", "", "-", "").Replace(name) // base it on rollappID to avoid alias conflicts msgCreateRollapp := rollapptypes.MsgCreateRollapp{ Creator: alice, RollappId: name, - InitialSequencerAddress: sample.AccAddress(), + InitialSequencerAddress: addr.String(), Bech32Prefix: strings.ToLower(rand.Str(3)), GenesisChecksum: "1234567890abcdefg", Alias: alias, @@ -60,31 +62,37 @@ func (s *KeeperTestHelper) CreateRollappWithName(name string) string { msgServer := rollappkeeper.NewMsgServerImpl(*s.App.RollappKeeper) _, err := msgServer.CreateRollapp(s.Ctx, &msgCreateRollapp) s.Require().NoError(err) - return name + + err = s.CreateSequencer(s.Ctx, name, pubkey) + s.Require().NoError(err) + return name, addr.String() } -func (s *KeeperTestHelper) CreateDefaultSequencer(ctx sdk.Context, rollappId string) string { - pubkey1 := secp256k1.GenPrivKey().PubKey() - addr1 := sdk.AccAddress(pubkey1.Address()) - pkAny1, err := codectypes.NewAnyWithValue(pubkey1) - s.Require().Nil(err) +func (s *KeeperTestHelper) CreateDefaultSequencer(ctx sdk.Context, rollappId string) (string, error) { + pubkey := ed25519.GenPrivKey().PubKey() + return sdk.AccAddress(pubkey.Address()).String(), s.CreateSequencer(ctx, rollappId, pubkey) +} +func (s *KeeperTestHelper) CreateSequencer(ctx sdk.Context, rollappId string, pubKey types.PubKey) error { + addr := sdk.AccAddress(pubKey.Address()) // fund account - err = bankutil.FundAccount(s.App.BankKeeper, ctx, addr1, sdk.NewCoins(bond)) + err := bankutil.FundAccount(s.App.BankKeeper, ctx, addr, sdk.NewCoins(bond)) + s.Require().Nil(err) + + pkAny, err := codectypes.NewAnyWithValue(pubKey) s.Require().Nil(err) sequencerMsg1 := sequencertypes.MsgCreateSequencer{ - Creator: addr1.String(), - DymintPubKey: pkAny1, + Creator: addr.String(), + DymintPubKey: pkAny, Bond: bond, RollappId: rollappId, - Description: sequencertypes.Description{}, + Metadata: sequencertypes.SequencerMetadata{}, } msgServer := sequencerkeeper.NewMsgServerImpl(s.App.SequencerKeeper) _, err = msgServer.CreateSequencer(ctx, &sequencerMsg1) - s.Require().Nil(err) - return addr1.String() + return err } func (s *KeeperTestHelper) PostStateUpdate(ctx sdk.Context, rollappId, seqAddr string, startHeight, numOfBlocks uint64) (lastHeight uint64, err error) { @@ -114,15 +122,15 @@ func (s *KeeperTestHelper) FundAcc(acc sdk.AccAddress, amounts sdk.Coins) { } // FundModuleAcc funds target modules with specified amount. -func (suite *KeeperTestHelper) FundModuleAcc(moduleName string, amounts sdk.Coins) { - err := bankutil.FundModuleAccount(suite.App.BankKeeper, suite.Ctx, moduleName, amounts) - suite.Require().NoError(err) +func (s *KeeperTestHelper) FundModuleAcc(moduleName string, amounts sdk.Coins) { + err := bankutil.FundModuleAccount(s.App.BankKeeper, s.Ctx, moduleName, amounts) + s.Require().NoError(err) } // StateNotAltered validates that app state is not altered. Fails if it is. -func (suite *KeeperTestHelper) StateNotAltered() { - oldState := suite.App.ExportState(suite.Ctx) - suite.App.Commit() - newState := suite.App.ExportState(suite.Ctx) - suite.Require().Equal(oldState, newState) +func (s *KeeperTestHelper) StateNotAltered() { + oldState := s.App.ExportState(s.Ctx) + s.App.Commit() + newState := s.App.ExportState(s.Ctx) + s.Require().Equal(oldState, newState) } diff --git a/x/sequencer/types/description.pb.go b/app/upgrades/v4/types/description.pb.go similarity index 98% rename from x/sequencer/types/description.pb.go rename to app/upgrades/v4/types/description.pb.go index ab8b77da1..1c0a501b3 100644 --- a/x/sequencer/types/description.pb.go +++ b/app/upgrades/v4/types/description.pb.go @@ -5,10 +5,11 @@ package types import ( fmt "fmt" - proto "github.com/cosmos/gogoproto/proto" io "io" math "math" math_bits "math/bits" + + proto "github.com/cosmos/gogoproto/proto" ) // Reference imports to suppress errors if they are not otherwise used. @@ -104,14 +105,6 @@ func (m *Description) GetDetails() string { return "" } -func init() { - proto.RegisterType((*Description)(nil), "dymensionxyz.dymension.sequencer.Description") -} - -func init() { - proto.RegisterFile("dymensionxyz/dymension/sequencer/description.proto", fileDescriptor_51488ae6fd653edd) -} - var fileDescriptor_51488ae6fd653edd = []byte{ // 238 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x90, 0x3f, 0x4e, 0xc3, 0x30, diff --git a/app/upgrades/v4/types/operating_status.pb.go b/app/upgrades/v4/types/operating_status.pb.go new file mode 100644 index 000000000..ddb6d9ac0 --- /dev/null +++ b/app/upgrades/v4/types/operating_status.pb.go @@ -0,0 +1,76 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: dymensionxyz/dymension/sequencer/operating_status.proto + +package types + +import ( + fmt "fmt" + math "math" + + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// OperatingStatus defines the operating status of a sequencer +type OperatingStatus int32 + +const ( + // OPERATING_STATUS_UNBONDED defines a sequencer that is not active and won't be scheduled + Unbonded OperatingStatus = 0 + // UNBONDING defines a sequencer that is currently unbonding. + Unbonding OperatingStatus = 1 + // OPERATING_STATUS_BONDED defines a sequencer that is bonded and can be scheduled + Bonded OperatingStatus = 2 +) + +var OperatingStatus_name = map[int32]string{ + 0: "OPERATING_STATUS_UNBONDED", + 1: "OPERATING_STATUS_UNBONDING", + 2: "OPERATING_STATUS_BONDED", +} + +var OperatingStatus_value = map[string]int32{ + "OPERATING_STATUS_UNBONDED": 0, + "OPERATING_STATUS_UNBONDING": 1, + "OPERATING_STATUS_BONDED": 2, +} + +func (x OperatingStatus) String() string { + return proto.EnumName(OperatingStatus_name, int32(x)) +} + +func (OperatingStatus) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_4d19c29067c09de2, []int{0} +} + +var fileDescriptor_4d19c29067c09de2 = []byte{ + // 260 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x32, 0x4f, 0xa9, 0xcc, 0x4d, + 0xcd, 0x2b, 0xce, 0xcc, 0xcf, 0xab, 0xa8, 0xac, 0xd2, 0x87, 0x73, 0xf4, 0x8b, 0x53, 0x0b, 0x4b, + 0x53, 0xf3, 0x92, 0x53, 0x8b, 0xf4, 0xf3, 0x0b, 0x52, 0x8b, 0x12, 0x4b, 0x32, 0xf3, 0xd2, 0xe3, + 0x8b, 0x4b, 0x12, 0x4b, 0x4a, 0x8b, 0xf5, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0x14, 0x90, 0x35, + 0xea, 0xc1, 0x39, 0x7a, 0x70, 0x8d, 0x52, 0x22, 0xe9, 0xf9, 0xe9, 0xf9, 0x60, 0xc5, 0xfa, 0x20, + 0x16, 0x44, 0x9f, 0xd6, 0x1c, 0x46, 0x2e, 0x7e, 0x7f, 0x98, 0x91, 0xc1, 0x60, 0x13, 0x85, 0xb4, + 0xb9, 0x24, 0xfd, 0x03, 0x5c, 0x83, 0x1c, 0x43, 0x3c, 0xfd, 0xdc, 0xe3, 0x83, 0x43, 0x1c, 0x43, + 0x42, 0x83, 0xe3, 0x43, 0xfd, 0x9c, 0xfc, 0xfd, 0x5c, 0x5c, 0x5d, 0x04, 0x18, 0xa4, 0x78, 0xba, + 0xe6, 0x2a, 0x70, 0x84, 0xe6, 0x25, 0xe5, 0xe7, 0xa5, 0xa4, 0xa6, 0x08, 0xe9, 0x72, 0x49, 0xe1, + 0x50, 0xec, 0xe9, 0xe7, 0x2e, 0xc0, 0x28, 0xc5, 0xdb, 0x35, 0x57, 0x81, 0x13, 0xa2, 0x3a, 0x33, + 0x2f, 0x5d, 0x48, 0x9d, 0x4b, 0x1c, 0x43, 0x39, 0xd4, 0x64, 0x26, 0x29, 0xae, 0xae, 0xb9, 0x0a, + 0x6c, 0x4e, 0x60, 0x73, 0xa5, 0x58, 0x3a, 0x16, 0xcb, 0x31, 0x38, 0x05, 0x9c, 0x78, 0x24, 0xc7, + 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, + 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x59, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, + 0x7e, 0xae, 0x3e, 0x8e, 0x40, 0x2b, 0x33, 0xd6, 0xaf, 0x40, 0x0a, 0xb9, 0x92, 0xca, 0x82, 0xd4, + 0xe2, 0x24, 0x36, 0xb0, 0xbf, 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0xc4, 0x80, 0x47, 0x58, + 0x6a, 0x01, 0x00, 0x00, +} diff --git a/app/upgrades/v4/types/params.pb.go b/app/upgrades/v4/types/params.pb.go index 898d3260d..2a39d36f6 100644 --- a/app/upgrades/v4/types/params.pb.go +++ b/app/upgrades/v4/types/params.pb.go @@ -136,15 +136,6 @@ func (m *Params) GetRollappsEnabled() bool { return false } -func init() { - proto.RegisterType((*DeployerParams)(nil), "dymensionxyz.dymension.rollapp.DeployerParams") - proto.RegisterType((*Params)(nil), "dymensionxyz.dymension.rollapp.Params") -} - -func init() { - proto.RegisterFile("dymensionxyz/dymension/rollapp/params.proto", fileDescriptor_75a44aa904ae1ba5) -} - var fileDescriptor_75a44aa904ae1ba5 = []byte{ // 356 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x4e, 0xa9, 0xcc, 0x4d, diff --git a/app/upgrades/v4/types/rollapp.pb.go b/app/upgrades/v4/types/rollapp.pb.go index b098c2b76..90250430c 100644 --- a/app/upgrades/v4/types/rollapp.pb.go +++ b/app/upgrades/v4/types/rollapp.pb.go @@ -262,16 +262,6 @@ func (m *RollappSummary) GetLatestFinalizedStateIndex() *StateInfoIndex { return nil } -func init() { - proto.RegisterType((*RollappGenesisState)(nil), "dymensionxyz.dymension.rollapp.RollappGenesisState") - proto.RegisterType((*Rollapp)(nil), "dymensionxyz.dymension.rollapp.Rollapp") - proto.RegisterType((*RollappSummary)(nil), "dymensionxyz.dymension.rollapp.RollappSummary") -} - -func init() { - proto.RegisterFile("dymensionxyz/dymension/rollapp/rollapp.proto", fileDescriptor_d4ef2bec3aea5528) -} - var fileDescriptor_d4ef2bec3aea5528 = []byte{ // 498 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x53, 0xcd, 0x6e, 0x13, 0x31, diff --git a/app/upgrades/v4/types/sequencer.pb.go b/app/upgrades/v4/types/sequencer.pb.go new file mode 100644 index 000000000..6be335695 --- /dev/null +++ b/app/upgrades/v4/types/sequencer.pb.go @@ -0,0 +1,785 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: dymensionxyz/dymension/sequencer/sequencer.proto + +package types + +import ( + fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + time "time" + + _ "github.com/cosmos/cosmos-proto" + types "github.com/cosmos/cosmos-sdk/codec/types" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + types1 "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" + _ "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" +) + +// 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 + +// Sequencer defines a sequencer identified by its' address (sequencerAddress). +// The sequencer could be attached to only one rollapp (rollappId). +type Sequencer struct { + // sequencerAddress is the bech32-encoded address of the sequencer account which is the account that the message was sent from. + SequencerAddress string `protobuf:"bytes,1,opt,name=sequencerAddress,proto3" json:"sequencerAddress,omitempty"` + // pubkey is the public key of the sequencers' dymint client, as a Protobuf Any. + DymintPubKey *types.Any `protobuf:"bytes,2,opt,name=dymintPubKey,proto3" json:"dymintPubKey,omitempty"` + // rollappId defines the rollapp to which the sequencer belongs. + RollappId string `protobuf:"bytes,3,opt,name=rollappId,proto3" json:"rollappId,omitempty"` + // description defines the descriptive terms for the sequencer. + Description Description `protobuf:"bytes,4,opt,name=description,proto3" json:"description"` + // jailed defined whether the sequencer has been jailed from bonded status or not. + Jailed bool `protobuf:"varint,5,opt,name=jailed,proto3" json:"jailed,omitempty"` + // proposer defines whether the sequencer is a proposer or not. + Proposer bool `protobuf:"varint,6,opt,name=proposer,proto3" json:"proposer,omitempty"` + // status is the sequencer status (bonded/unbonding/unbonded). + Status OperatingStatus `protobuf:"varint,7,opt,name=status,proto3,enum=dymensionxyz.dymension.sequencer.OperatingStatus" json:"status,omitempty"` + // tokens define the delegated tokens (incl. self-delegation). + Tokens github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,8,rep,name=tokens,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"tokens"` + // unbonding_height defines, if unbonding, the height at which this sequencer has begun unbonding. + UnbondingHeight int64 `protobuf:"varint,9,opt,name=unbonding_height,json=unbondingHeight,proto3" json:"unbonding_height,omitempty"` + // unbond_time defines, if unbonding, the min time for the sequencer to complete unbonding. + UnbondTime time.Time `protobuf:"bytes,10,opt,name=unbond_time,json=unbondTime,proto3,stdtime" json:"unbond_time"` +} + +func (m *Sequencer) Reset() { *m = Sequencer{} } +func (m *Sequencer) String() string { return proto.CompactTextString(m) } +func (*Sequencer) ProtoMessage() {} +func (*Sequencer) Descriptor() ([]byte, []int) { + return fileDescriptor_997b8663a5fc0f58, []int{0} +} +func (m *Sequencer) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Sequencer) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Sequencer.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 *Sequencer) XXX_Merge(src proto.Message) { + xxx_messageInfo_Sequencer.Merge(m, src) +} +func (m *Sequencer) XXX_Size() int { + return m.Size() +} +func (m *Sequencer) XXX_DiscardUnknown() { + xxx_messageInfo_Sequencer.DiscardUnknown(m) +} + +var xxx_messageInfo_Sequencer proto.InternalMessageInfo + +func (m *Sequencer) GetSequencerAddress() string { + if m != nil { + return m.SequencerAddress + } + return "" +} + +func (m *Sequencer) GetDymintPubKey() *types.Any { + if m != nil { + return m.DymintPubKey + } + return nil +} + +func (m *Sequencer) GetRollappId() string { + if m != nil { + return m.RollappId + } + return "" +} + +func (m *Sequencer) GetDescription() Description { + if m != nil { + return m.Description + } + return Description{} +} + +func (m *Sequencer) GetJailed() bool { + if m != nil { + return m.Jailed + } + return false +} + +func (m *Sequencer) GetProposer() bool { + if m != nil { + return m.Proposer + } + return false +} + +func (m *Sequencer) GetStatus() OperatingStatus { + if m != nil { + return m.Status + } + return Unbonded +} + +func (m *Sequencer) GetTokens() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.Tokens + } + return nil +} + +func (m *Sequencer) GetUnbondingHeight() int64 { + if m != nil { + return m.UnbondingHeight + } + return 0 +} + +func (m *Sequencer) GetUnbondTime() time.Time { + if m != nil { + return m.UnbondTime + } + return time.Time{} +} + +var fileDescriptor_997b8663a5fc0f58 = []byte{ + // 545 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x53, 0x4f, 0x6f, 0xd3, 0x30, + 0x14, 0x6f, 0x68, 0x29, 0xad, 0x8b, 0x60, 0xb2, 0x2a, 0xf0, 0x2a, 0x94, 0x46, 0x9c, 0x02, 0x52, + 0xed, 0xb5, 0x93, 0xe0, 0xbc, 0x02, 0x12, 0x13, 0x07, 0xa6, 0x0c, 0x2e, 0x5c, 0xaa, 0xfc, 0x31, + 0x69, 0x58, 0x63, 0x87, 0xd8, 0xa9, 0x16, 0x3e, 0xc5, 0x3e, 0x07, 0x67, 0x3e, 0xc4, 0xc4, 0x69, + 0x27, 0xc4, 0x89, 0xa1, 0xf6, 0x8b, 0xa0, 0x38, 0x4e, 0x5a, 0x98, 0x50, 0x4f, 0xf6, 0xef, 0x3d, + 0xff, 0x7e, 0x7e, 0xcf, 0xbf, 0x67, 0x70, 0x10, 0xe4, 0x31, 0x65, 0x22, 0xe2, 0xec, 0x3c, 0xff, + 0x42, 0x6a, 0x40, 0x04, 0xfd, 0x9c, 0x51, 0xe6, 0xd3, 0x74, 0xb3, 0xc3, 0x49, 0xca, 0x25, 0x87, + 0xd6, 0x36, 0x03, 0xd7, 0x00, 0xd7, 0xe7, 0x06, 0x93, 0x9d, 0x9a, 0x01, 0x15, 0x7e, 0x1a, 0x25, + 0xb2, 0xe0, 0x29, 0xd5, 0xc1, 0xf3, 0x9d, 0x1c, 0x9e, 0xd0, 0xd4, 0x95, 0x11, 0x0b, 0x67, 0x42, + 0xba, 0x32, 0x13, 0x9a, 0xb8, 0xef, 0x73, 0x11, 0x73, 0x31, 0x53, 0x88, 0x94, 0xa0, 0x4a, 0x85, + 0x9c,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 0x23, 0xaf, + 0xad, 0xee, 0x3e, 0xfc, 0x13, 0x00, 0x00, 0xff, 0xff, 0x7b, 0xb4, 0x65, 0x96, 0x1a, 0x04, 0x00, + 0x00, +} + +func (m *Sequencer) 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 *Sequencer) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Sequencer) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + n1, err1 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.UnbondTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.UnbondTime):]) + if err1 != nil { + return 0, err1 + } + i -= n1 + i = encodeVarintSequencer(dAtA, i, uint64(n1)) + i-- + dAtA[i] = 0x52 + if m.UnbondingHeight != 0 { + i = encodeVarintSequencer(dAtA, i, uint64(m.UnbondingHeight)) + i-- + dAtA[i] = 0x48 + } + if len(m.Tokens) > 0 { + for iNdEx := len(m.Tokens) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Tokens[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSequencer(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x42 + } + } + if m.Status != 0 { + i = encodeVarintSequencer(dAtA, i, uint64(m.Status)) + i-- + dAtA[i] = 0x38 + } + if m.Proposer { + i-- + if m.Proposer { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x30 + } + if m.Jailed { + i-- + if m.Jailed { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x28 + } + { + size, err := m.Description.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSequencer(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + if len(m.RollappId) > 0 { + i -= len(m.RollappId) + copy(dAtA[i:], m.RollappId) + i = encodeVarintSequencer(dAtA, i, uint64(len(m.RollappId))) + i-- + dAtA[i] = 0x1a + } + if m.DymintPubKey != nil { + { + size, err := m.DymintPubKey.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSequencer(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.SequencerAddress) > 0 { + i -= len(m.SequencerAddress) + copy(dAtA[i:], m.SequencerAddress) + i = encodeVarintSequencer(dAtA, i, uint64(len(m.SequencerAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintSequencer(dAtA []byte, offset int, v uint64) int { + offset -= sovSequencer(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Sequencer) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.SequencerAddress) + if l > 0 { + n += 1 + l + sovSequencer(uint64(l)) + } + if m.DymintPubKey != nil { + l = m.DymintPubKey.Size() + n += 1 + l + sovSequencer(uint64(l)) + } + l = len(m.RollappId) + if l > 0 { + n += 1 + l + sovSequencer(uint64(l)) + } + l = m.Description.Size() + n += 1 + l + sovSequencer(uint64(l)) + if m.Jailed { + n += 2 + } + if m.Proposer { + n += 2 + } + if m.Status != 0 { + n += 1 + sovSequencer(uint64(m.Status)) + } + if len(m.Tokens) > 0 { + for _, e := range m.Tokens { + l = e.Size() + n += 1 + l + sovSequencer(uint64(l)) + } + } + if m.UnbondingHeight != 0 { + n += 1 + sovSequencer(uint64(m.UnbondingHeight)) + } + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.UnbondTime) + n += 1 + l + sovSequencer(uint64(l)) + return n +} + +func sovSequencer(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozSequencer(x uint64) (n int) { + return sovSequencer(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Sequencer) 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 ErrIntOverflowSequencer + } + 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: Sequencer: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Sequencer: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SequencerAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSequencer + } + 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 ErrInvalidLengthSequencer + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthSequencer + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SequencerAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DymintPubKey", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSequencer + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSequencer + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSequencer + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.DymintPubKey == nil { + m.DymintPubKey = &types.Any{} + } + if err := m.DymintPubKey.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RollappId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSequencer + } + 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 ErrInvalidLengthSequencer + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthSequencer + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RollappId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSequencer + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSequencer + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSequencer + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Description.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Jailed", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSequencer + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Jailed = bool(v != 0) + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Proposer", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSequencer + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Proposer = bool(v != 0) + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + m.Status = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSequencer + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Status |= OperatingStatus(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Tokens", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSequencer + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSequencer + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSequencer + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Tokens = append(m.Tokens, types1.Coin{}) + if err := m.Tokens[len(m.Tokens)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 9: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field UnbondingHeight", wireType) + } + m.UnbondingHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSequencer + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.UnbondingHeight |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UnbondTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSequencer + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSequencer + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSequencer + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.UnbondTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSequencer(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSequencer + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipSequencer(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, ErrIntOverflowSequencer + } + 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, ErrIntOverflowSequencer + } + 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, ErrIntOverflowSequencer + } + 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, ErrInvalidLengthSequencer + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupSequencer + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthSequencer + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthSequencer = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowSequencer = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupSequencer = fmt.Errorf("proto: unexpected end of group") +) diff --git a/app/upgrades/v4/types/state_info.pb.go b/app/upgrades/v4/types/state_info.pb.go index 0694c3d61..92b70d53b 100644 --- a/app/upgrades/v4/types/state_info.pb.go +++ b/app/upgrades/v4/types/state_info.pb.go @@ -329,17 +329,6 @@ func (m *BlockHeightToFinalizationQueue) GetFinalizationQueue() []StateInfoIndex return nil } -func init() { - proto.RegisterType((*StateInfoIndex)(nil), "dymensionxyz.dymension.rollapp.StateInfoIndex") - proto.RegisterType((*StateInfo)(nil), "dymensionxyz.dymension.rollapp.StateInfo") - proto.RegisterType((*StateInfoSummary)(nil), "dymensionxyz.dymension.rollapp.StateInfoSummary") - proto.RegisterType((*BlockHeightToFinalizationQueue)(nil), "dymensionxyz.dymension.rollapp.BlockHeightToFinalizationQueue") -} - -func init() { - proto.RegisterFile("dymensionxyz/dymension/rollapp/state_info.proto", fileDescriptor_750f3a9f16533ec4) -} - var fileDescriptor_750f3a9f16533ec4 = []byte{ // 487 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x94, 0x4f, 0x6b, 0x13, 0x41, diff --git a/app/upgrades/v4/upgrade.go b/app/upgrades/v4/upgrade.go index 53ba74f3c..8ce9977bc 100644 --- a/app/upgrades/v4/upgrade.go +++ b/app/upgrades/v4/upgrade.go @@ -34,6 +34,8 @@ import ( delayedacktypes "github.com/dymensionxyz/dymension/v3/x/delayedack/types" rollappkeeper "github.com/dymensionxyz/dymension/v3/x/rollapp/keeper" rollapptypes "github.com/dymensionxyz/dymension/v3/x/rollapp/types" + sequencerkeeper "github.com/dymensionxyz/dymension/v3/x/sequencer/keeper" + sequencertypes "github.com/dymensionxyz/dymension/v3/x/sequencer/types" ) // CreateUpgradeHandler creates an SDK upgrade handler for v4 @@ -53,6 +55,7 @@ func CreateUpgradeHandler( if err := migrateRollapps(ctx, keepers.GetKey(rollapptypes.ModuleName), appCodec, keepers.RollappKeeper); err != nil { return nil, err } + migrateSequencers(ctx, keepers.GetKey(sequencertypes.ModuleName), appCodec, keepers.SequencerKeeper) // TODO: create rollapp gauges for each existing rollapp @@ -126,6 +129,14 @@ func migrateRollapps(ctx sdk.Context, rollappStoreKey *storetypes.KVStoreKey, ap return nil } +func migrateSequencers(ctx sdk.Context, sequencerStoreKey *storetypes.KVStoreKey, appCodec codec.Codec, sequencerkeeper sequencerkeeper.Keeper) { + list := getAllOldSequencers(ctx, sequencerStoreKey, appCodec) + for _, oldSequencer := range list { + newSequencer := ConvertOldSequencerToNew(oldSequencer) + sequencerkeeper.SetSequencer(ctx, newSequencer) + } +} + func ConvertOldRollappToNew(oldRollapp types.Rollapp) rollapptypes.Rollapp { bech32Prefix := oldRollapp.RollappId[:5] return rollapptypes.Rollapp{ @@ -152,6 +163,37 @@ func ConvertOldRollappToNew(oldRollapp types.Rollapp) rollapptypes.Rollapp { } } +var defaultGasPrice, _ = sdk.NewIntFromString("10000000000") + +func ConvertOldSequencerToNew(old types.Sequencer) sequencertypes.Sequencer { + return sequencertypes.Sequencer{ + Address: old.SequencerAddress, + DymintPubKey: old.DymintPubKey, + RollappId: old.RollappId, + Status: sequencertypes.OperatingStatus(old.Status), + Proposer: old.Proposer, + Tokens: old.Tokens, + Metadata: sequencertypes.SequencerMetadata{ + Moniker: old.Description.Moniker, + Details: old.Description.Details, + P2PSeeds: nil, // TODO + Rpcs: nil, // TODO + EvmRpcs: nil, // TODO + RestApiUrl: "", // TODO + ExplorerUrl: "", // TODO + GenesisUrls: []string{}, // TODO + ContactDetails: &sequencertypes.ContactDetails{ // TODO + Website: "", // TODO + Telegram: "", // TODO + X: "", // TODO + }, // TODO + ExtraData: nil, // TODO + Snapshots: []*sequencertypes.SnapshotInfo{}, // TODO + GasPrice: &defaultGasPrice, + }, + } +} + func getAllOldRollapps(ctx sdk.Context, storeKey *storetypes.KVStoreKey, appCodec codec.Codec) (list []types.Rollapp) { store := prefix.NewStore(ctx.KVStore(storeKey), rollapptypes.KeyPrefix(rollapptypes.RollappKeyPrefix)) iterator := sdk.KVStorePrefixIterator(store, []byte{}) @@ -167,3 +209,19 @@ func getAllOldRollapps(ctx sdk.Context, storeKey *storetypes.KVStoreKey, appCode return } + +func getAllOldSequencers(ctx sdk.Context, storeKey *storetypes.KVStoreKey, appCodec codec.Codec) (list []types.Sequencer) { + store := prefix.NewStore(ctx.KVStore(storeKey), sequencertypes.SequencersKeyPrefix) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + + defer iterator.Close() // nolint: errcheck + + for ; iterator.Valid(); iterator.Next() { + var val types.Sequencer + bz := iterator.Value() + appCodec.MustUnmarshalJSON(bz, &val) + list = append(list, val) + } + + return +} diff --git a/app/upgrades/v4/upgrade_test.go b/app/upgrades/v4/upgrade_test.go index 9ce732b32..97a4e7642 100644 --- a/app/upgrades/v4/upgrade_test.go +++ b/app/upgrades/v4/upgrade_test.go @@ -3,11 +3,14 @@ package v4_test import ( "fmt" "reflect" + "sort" "testing" "time" abci "github.com/cometbft/cometbft/abci/types" cometbftproto "github.com/cometbft/cometbft/proto/tendermint/types" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" @@ -19,6 +22,7 @@ import ( "github.com/dymensionxyz/dymension/v3/app/upgrades/v4/types" "github.com/dymensionxyz/dymension/v3/testutil/sample" rollapptypes "github.com/dymensionxyz/dymension/v3/x/rollapp/types" + sequencertypes "github.com/dymensionxyz/dymension/v3/x/sequencer/types" ) // UpgradeTestSuite defines the structure for the upgrade test suite @@ -64,7 +68,10 @@ func (s *UpgradeTestSuite) TestUpgrade() { preUpgrade: func() error { // Create and store old rollapps numRollapps := 5 - s.createAndStoreOldRollapps(numRollapps) + rollappIDs := s.createAndStoreOldRollapps(numRollapps) + + // Create and store old sequencers + s.createAndStoreOldSequencers(rollappIDs) return nil }, upgrade: func() { @@ -106,6 +113,11 @@ func (s *UpgradeTestSuite) TestUpgrade() { return } + // Check Sequencers + if err = s.validateSequencersMigration(); err != nil { + return + } + return }, expPass: true, @@ -174,6 +186,35 @@ func (s *UpgradeTestSuite) validateRollappsMigration() error { return nil } +func (s *UpgradeTestSuite) validateSequencersMigration() error { + sequencers := s.App.SequencerKeeper.GetAllSequencers(s.Ctx) + s.Require().Len(sequencers, len(newSequencers)) + + sort.Slice(sequencers, func(i, j int) bool { + return sequencers[i].Address < sequencers[j].Address + }) + + for i, sequencer := range sequencers { + // check that the sequencer can be retrieved by address + _, ok := s.App.SequencerKeeper.GetSequencer(s.Ctx, sequencer.Address) + if !ok { + return fmt.Errorf("sequencer by address not migrated") + } + + // check that the sequencer can be retrieved by rollapp and status + sequencer, ok = s.App.SequencerKeeper.GetSequencerByRollappByStatus(s.Ctx, sequencer.RollappId, sequencer.Address, sequencer.Status) + if !ok { + return fmt.Errorf("sequencer by rollapp and status not migrated") + } + + seq := s.App.AppCodec().MustMarshalJSON(&sequencer) + nSeq := s.App.AppCodec().MustMarshalJSON(&newSequencers[i]) + + s.Require().JSONEq(string(seq), string(nSeq)) + } + return nil +} + var ( oldRollapps []types.Rollapp newRollapps []rollapptypes.Rollapp @@ -225,3 +266,62 @@ func createMockOldAndNewRollapps(nRollapps int) { newRollapps[i] = v4.ConvertOldRollappToNew(oldRollapp) } } + +var ( + oldSequencers []types.Sequencer + newSequencers []sequencertypes.Sequencer +) + +func (s *UpgradeTestSuite) createAndStoreOldSequencers(rollappIDs []string) { + storeKey := s.App.GetKey(sequencertypes.StoreKey) + store := s.Ctx.KVStore(storeKey) + createMockOldAndNewSequencers(rollappIDs) + + for _, sequencer := range oldSequencers { + bz := s.App.AppCodec().MustMarshalJSON(&sequencer) + store.Set(sequencertypes.SequencerKey( + sequencer.SequencerAddress, + ), bz) + + seqByRollappKey := sequencertypes.SequencerByRollappByStatusKey( + sequencer.RollappId, + sequencer.SequencerAddress, + sequencertypes.OperatingStatus(sequencer.Status), + ) + store.Set(seqByRollappKey, bz) + } +} + +func createMockOldAndNewSequencers(rollappIDs []string) { + numSeq := len(rollappIDs) + oldSequencers = make([]types.Sequencer, numSeq) + newSequencers = make([]sequencertypes.Sequencer, numSeq) + + for i := 0; i < numSeq; i++ { + pk := ed25519.GenPrivKey().PubKey() + pkAny, _ := codectypes.NewAnyWithValue(pk) + oldSequencer := types.Sequencer{ + SequencerAddress: sample.AccAddress(), + DymintPubKey: pkAny, + RollappId: rollappIDs[i], + Description: types.Description{ + Moniker: "moniker", + Identity: "keybase:username", + Website: "http://example.com", + SecurityContact: "security@example.com", + Details: "Additional details about the validator.", + }, + Status: types.Bonded, + Proposer: true, + Tokens: sdk.NewCoins(sdk.NewInt64Coin("dym", 100)), + } + oldSequencers[i] = oldSequencer + newSequencers[i] = v4.ConvertOldSequencerToNew(oldSequencer) + } + sort.Slice(oldSequencers, func(i, j int) bool { + return oldSequencers[i].SequencerAddress < oldSequencers[j].SequencerAddress + }) + sort.Slice(newSequencers, func(i, j int) bool { + return newSequencers[i].Address < newSequencers[j].Address + }) +} diff --git a/go.mod b/go.mod index 8f7207b9f..03ed36d77 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( github.com/decred/dcrd/dcrec/edwards v1.0.0 github.com/dustin/go-humanize v1.0.1 github.com/dymensionxyz/gerr-cosmos v1.0.0 - github.com/dymensionxyz/sdk-utils v0.2.0 + github.com/dymensionxyz/sdk-utils v0.2.2 github.com/ethereum/go-ethereum v1.10.26 github.com/evmos/ethermint v0.22.0 github.com/golang/protobuf v1.5.4 diff --git a/go.sum b/go.sum index e578b1c37..ec2d7283b 100644 --- a/go.sum +++ b/go.sum @@ -505,8 +505,8 @@ github.com/dymensionxyz/osmosis/osmomath v0.0.6-dym-v0.0.1 h1:59ZE3Ocrn04MUpb5VJ github.com/dymensionxyz/osmosis/osmomath v0.0.6-dym-v0.0.1/go.mod h1:2idySYJxP5YfMAEeSeqD8e7fSchfsI4jn7XFHJgNUsM= github.com/dymensionxyz/osmosis/v15 v15.2.1-0.20240627111157-f2243f47cdb3 h1:4VD23Jv5d8hqXEhLNNcLXlpSDJCWAGYJLF0kisJtkIk= github.com/dymensionxyz/osmosis/v15 v15.2.1-0.20240627111157-f2243f47cdb3/go.mod h1:2rsnXAdjYfXtyEw0mNwAdOiAccALYjAPvINGUf9Qg7Y= -github.com/dymensionxyz/sdk-utils v0.2.0 h1:7nmP3CZ9w0XkSGaIKh3xuAw2Ah/Gc5ENwM46+AALyy8= -github.com/dymensionxyz/sdk-utils v0.2.0/go.mod h1:ywr7+EEhHyuXCPUyLsktF3R4Mr31uCiviIjqwWNbQ84= +github.com/dymensionxyz/sdk-utils v0.2.2 h1:RoANEXbR4nkEMaRGWCLT1P9A7KBCmzJ2U9wAZnNbszo= +github.com/dymensionxyz/sdk-utils v0.2.2/go.mod h1:ywr7+EEhHyuXCPUyLsktF3R4Mr31uCiviIjqwWNbQ84= github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= diff --git a/ibctesting/utils_test.go b/ibctesting/utils_test.go index cbbf98a1a..bf0b33220 100644 --- a/ibctesting/utils_test.go +++ b/ibctesting/utils_test.go @@ -23,7 +23,6 @@ import ( "github.com/dymensionxyz/dymension/v3/app" "github.com/dymensionxyz/dymension/v3/app/apptesting" - "github.com/dymensionxyz/dymension/v3/testutil/sample" common "github.com/dymensionxyz/dymension/v3/x/common/types" eibctypes "github.com/dymensionxyz/dymension/v3/x/eibc/types" rollappkeeper "github.com/dymensionxyz/dymension/v3/x/rollapp/keeper" @@ -124,7 +123,7 @@ func (s *utilSuite) createRollapp(transfersEnabled bool, channelID *string) { msgCreateRollapp := rollapptypes.NewMsgCreateRollapp( s.hubChain().SenderAccount.GetAddress().String(), rollappChainID(), - sample.AccAddress(), + s.hubChain().SenderAccount.GetAddress().String(), "eth", "somechecksum", "Rollapp", @@ -163,7 +162,7 @@ func (s *utilSuite) registerSequencer() { s.hubChain().SenderAccount.GetAddress().String(), pk, rollappChainID(), - &sequencertypes.Description{}, + sequencertypes.SequencerMetadata{}, bond, ) s.Require().NoError(err) // message committed diff --git a/proto/dymensionxyz/dymension/rollapp/rollapp.proto b/proto/dymensionxyz/dymension/rollapp/rollapp.proto index 0c5e78c7e..f0056d768 100644 --- a/proto/dymensionxyz/dymension/rollapp/rollapp.proto +++ b/proto/dymensionxyz/dymension/rollapp/rollapp.proto @@ -48,6 +48,8 @@ message Rollapp { repeated string registered_denoms = 10; // metadata is the rollapp metadata RollappMetadata metadata = 11; + // sealed is a boolean that indicates if the immutable fields are no longer updatable. + bool sealed = 12; } // UpdateRollappInformation updates the rollapp information. diff --git a/proto/dymensionxyz/dymension/sequencer/description.proto b/proto/dymensionxyz/dymension/sequencer/description.proto deleted file mode 100644 index b79cd5dc5..000000000 --- a/proto/dymensionxyz/dymension/sequencer/description.proto +++ /dev/null @@ -1,19 +0,0 @@ -syntax = "proto3"; -package dymensionxyz.dymension.sequencer; - -option go_package = "github.com/dymensionxyz/dymension/v3/x/sequencer/types"; - -// Description defines a sequencer description. -message Description { - - // moniker defines a human-readable name for the sequencer. - string moniker = 1; - // identity defines an optional identity signature (ex. UPort or Keybase). - string identity = 2; - // website defines an optional website link. - string website = 3; - // securityContact defines an optional email for security contact. - string securityContact = 4; - // details define other optional details. - string details = 5; -} diff --git a/proto/dymensionxyz/dymension/sequencer/genesis.proto b/proto/dymensionxyz/dymension/sequencer/genesis.proto index 225ec35f1..81418122e 100644 --- a/proto/dymensionxyz/dymension/sequencer/genesis.proto +++ b/proto/dymensionxyz/dymension/sequencer/genesis.proto @@ -4,7 +4,6 @@ package dymensionxyz.dymension.sequencer; import "gogoproto/gogo.proto"; import "dymensionxyz/dymension/sequencer/params.proto"; import "dymensionxyz/dymension/sequencer/sequencer.proto"; -// this line is used by starport scaffolding # genesis/proto/import option go_package = "github.com/dymensionxyz/dymension/v3/x/sequencer/types"; @@ -12,5 +11,4 @@ option go_package = "github.com/dymensionxyz/dymension/v3/x/sequencer/types"; message GenesisState { Params params = 1 [(gogoproto.nullable) = false]; repeated Sequencer sequencerList = 2 [(gogoproto.nullable) = false]; - // this line is used by starport scaffolding # genesis/proto/state } diff --git a/proto/dymensionxyz/dymension/sequencer/metadata.proto b/proto/dymensionxyz/dymension/sequencer/metadata.proto new file mode 100644 index 000000000..c0b170414 --- /dev/null +++ b/proto/dymensionxyz/dymension/sequencer/metadata.proto @@ -0,0 +1,52 @@ +syntax = "proto3"; +package dymensionxyz.dymension.sequencer; + +option go_package = "github.com/dymensionxyz/dymension/v3/x/sequencer/types"; + +import "gogoproto/gogo.proto"; + +// Metadata defines rollapp/sequencer extra information. +message SequencerMetadata { + // moniker defines a human-readable name for the sequencer. + string moniker = 1; + // details define other optional details. + string details = 2; + // bootstrap nodes list + repeated string p2p_seeds = 3; + // RPCs list + repeated string rpcs = 4; + // evm RPCs list + repeated string evm_rpcs = 5; + // REST API URL + string rest_api_url = 6; + // block explorer URL + string explorer_url = 7; + // genesis URLs + repeated string genesis_urls = 8; + // contact details + ContactDetails contact_details = 9; + // json dump the sequencer can add (limited by size) + bytes extra_data = 10; + // snapshots of the sequencer + repeated SnapshotInfo snapshots = 11; + // gas_price defines the value for each gas unit + string gas_price = 12 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int"]; +} + +message ContactDetails { + // website URL + string website = 11; + // telegram handle + string telegram = 1; + // twitter handle + string x = 2; +} + +message SnapshotInfo { + // the snapshot url + string snapshot_url = 1; + // The snapshot height + uint64 height = 2; + // sha-256 checksum value for the snapshot file + string checksum=3; +} diff --git a/proto/dymensionxyz/dymension/sequencer/query.proto b/proto/dymensionxyz/dymension/sequencer/query.proto index 8350e1c0a..fac2d7110 100644 --- a/proto/dymensionxyz/dymension/sequencer/query.proto +++ b/proto/dymensionxyz/dymension/sequencer/query.proto @@ -6,7 +6,6 @@ import "google/api/annotations.proto"; import "cosmos/base/query/v1beta1/pagination.proto"; import "dymensionxyz/dymension/sequencer/params.proto"; import "dymensionxyz/dymension/sequencer/sequencer.proto"; -// this line is used by starport scaffolding # 1 import "dymensionxyz/dymension/sequencer/operating_status.proto"; option go_package = "github.com/dymensionxyz/dymension/v3/x/sequencer/types"; @@ -17,6 +16,7 @@ service Query { rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { option (google.api.http).get = "/dymensionxyz/dymension/sequencer/params"; } + // Queries a Sequencer by address. rpc Sequencer(QueryGetSequencerRequest) returns (QueryGetSequencerResponse) { option (google.api.http).get = "/dymensionxyz/dymension/sequencer/sequencer/{sequencerAddress}"; @@ -36,10 +36,6 @@ service Query { rpc SequencersByRollappByStatus(QueryGetSequencersByRollappByStatusRequest) returns (QueryGetSequencersByRollappByStatusResponse) { option (google.api.http).get = "/dymensionxyz/dymension/sequencer/sequencers_by_rollapp/{rollappId}/{status}"; } - - - -// this line is used by starport scaffolding # 2 } // QueryParamsRequest is request type for the Query/Params RPC method. @@ -84,5 +80,3 @@ message QueryGetSequencersByRollappByStatusRequest { message QueryGetSequencersByRollappByStatusResponse { repeated Sequencer sequencers = 1 [(gogoproto.nullable) = false]; } - -// this line is used by starport scaffolding # 3 diff --git a/proto/dymensionxyz/dymension/sequencer/sequencer.proto b/proto/dymensionxyz/dymension/sequencer/sequencer.proto index da6deace9..4b7b2b568 100644 --- a/proto/dymensionxyz/dymension/sequencer/sequencer.proto +++ b/proto/dymensionxyz/dymension/sequencer/sequencer.proto @@ -2,46 +2,39 @@ syntax = "proto3"; package dymensionxyz.dymension.sequencer; option go_package = "github.com/dymensionxyz/dymension/v3/x/sequencer/types"; -import "dymensionxyz/dymension/sequencer/description.proto"; -import "dymensionxyz/dymension/sequencer/operating_status.proto"; import "cosmos_proto/cosmos.proto"; import "google/protobuf/any.proto"; import "gogoproto/gogo.proto"; import "google/protobuf/timestamp.proto"; import "cosmos/base/v1beta1/coin.proto"; - import "cosmos/msg/v1/msg.proto"; +import "dymensionxyz/dymension/sequencer/metadata.proto"; +import "dymensionxyz/dymension/sequencer/operating_status.proto"; + // Sequencer defines a sequencer identified by its' address (sequencerAddress). // The sequencer could be attached to only one rollapp (rollappId). message Sequencer { - // sequencerAddress is the bech32-encoded address of the sequencer account which is the account that the message was sent from. - string sequencerAddress = 1; + // address is the bech32-encoded address of the sequencer account which is the account that the message was sent from. + string address = 1; // pubkey is the public key of the sequencers' dymint client, as a Protobuf Any. google.protobuf.Any dymintPubKey = 2 [(cosmos_proto.accepts_interface) = "cosmos.crypto.PubKey"]; // rollappId defines the rollapp to which the sequencer belongs. - string rollappId = 3; - // description defines the descriptive terms for the sequencer. - Description description = 4 [(gogoproto.nullable) = false]; - + string rollapp_id = 3; + // metadata defines the extra information for the sequencer. + SequencerMetadata metadata = 4 [(gogoproto.nullable) = false]; // jailed defined whether the sequencer has been jailed from bonded status or not. bool jailed = 5; - -// proposer defines whether the sequencer is a proposer or not. - bool proposer = 6; - + // proposer defines whether the sequencer is a proposer or not. + bool proposer = 6; // status is the sequencer status (bonded/unbonding/unbonded). OperatingStatus status = 7; - // tokens define the delegated tokens (incl. self-delegation). repeated cosmos.base.v1beta1.Coin tokens = 8 [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; - - // unbonding_height defines, if unbonding, the height at which this sequencer has begun unbonding. + // unbonding_height defines, if unbonding, the height at which this sequencer has begun unbonding. int64 unbonding_height = 9; // unbond_time defines, if unbonding, the min time for the sequencer to complete unbonding. google.protobuf.Timestamp unbond_time = 10 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; - } - diff --git a/proto/dymensionxyz/dymension/sequencer/tx.proto b/proto/dymensionxyz/dymension/sequencer/tx.proto index 0666b9d6c..24b44be46 100644 --- a/proto/dymensionxyz/dymension/sequencer/tx.proto +++ b/proto/dymensionxyz/dymension/sequencer/tx.proto @@ -1,10 +1,8 @@ syntax = "proto3"; - package dymensionxyz.dymension.sequencer; +option go_package = "github.com/dymensionxyz/dymension/v3/x/sequencer/types"; -// this line is used by starport scaffolding # proto/tx/import -import "dymensionxyz/dymension/sequencer/description.proto"; import "google/protobuf/any.proto"; import "cosmos_proto/cosmos.proto"; import "gogoproto/gogo.proto"; @@ -12,36 +10,46 @@ import "cosmos/base/v1beta1/coin.proto"; import "google/protobuf/timestamp.proto"; import "cosmos/msg/v1/msg.proto"; -option go_package = "github.com/dymensionxyz/dymension/v3/x/sequencer/types"; +import "dymensionxyz/dymension/sequencer/metadata.proto"; // Msg defines the Msg service. service Msg { - // CreateSequencer defines a method for creating a new sequencer. rpc CreateSequencer (MsgCreateSequencer) returns (MsgCreateSequencerResponse); - + // UpdateSequencerInformation defines a method for updating the sequencer's metadata. + rpc UpdateSequencerInformation (MsgUpdateSequencerInformation) returns (MsgUpdateSequencerInformationResponse); // Unbond defines a method for removing coins from sequencer's bond rpc Unbond (MsgUnbond) returns (MsgUnbondResponse); } -// MsgCreateSequencer defines a SDK message for creating a new sequencer. + message MsgCreateSequencer { option (cosmos.msg.v1.signer) = "creator"; // creator is the bech32-encoded address of the sequencer account which is the account that the message was sent from. string creator = 1; - // pubkey is the public key of the sequencers' dymint client, as a Protobuf Any. google.protobuf.Any dymintPubKey = 2 [(cosmos_proto.accepts_interface) = "cosmos.crypto.PubKey"]; - - // rollappId defines the rollapp to which the sequencer belongs. - string rollappId = 3; - - // description defines the descriptive terms for the sequencer. - Description description = 4 [(gogoproto.nullable) = false]; - cosmos.base.v1beta1.Coin bond = 5 [(gogoproto.nullable) = false]; + // rollapp_id defines the rollapp to which the sequencer belongs. + string rollapp_id = 3; + // metadata defines the extra information for the sequencer. + SequencerMetadata metadata = 4 [(gogoproto.nullable) = false]; + // entry bond for the sequencer. + cosmos.base.v1beta1.Coin bond = 5 [(gogoproto.nullable) = false]; } message MsgCreateSequencerResponse {} +message MsgUpdateSequencerInformation { + option (cosmos.msg.v1.signer) = "creator"; + // creator is the bech32-encoded address of the sequencer account which is the account that the message was sent from. + string creator = 1; + // rollapp_id defines the rollapp to which the sequencer belongs. + string rollapp_id = 2; + // metadata defines the extra information for the sequencer. + SequencerMetadata metadata = 3 [(gogoproto.nullable) = false]; +} + +message MsgUpdateSequencerInformationResponse {} + // MsgUnbond defines a SDK message for performing an undelegation from a // bond and a sequencer. message MsgUnbond { diff --git a/x/delayedack/keeper/invariants_test.go b/x/delayedack/keeper/invariants_test.go index f4730a068..1d8d18564 100644 --- a/x/delayedack/keeper/invariants_test.go +++ b/x/delayedack/keeper/invariants_test.go @@ -31,8 +31,7 @@ func (suite *DelayedAckTestSuite) TestInvariants() { rollappBlocks := make(map[string]uint64) for i := 0; i < numOfRollapps; i++ { - rollapp := suite.CreateDefaultRollapp() - seqaddr := suite.CreateDefaultSequencer(suite.Ctx, rollapp) + rollapp, seqaddr := suite.CreateDefaultRollappWithProposer() // skip one of the rollapps so it won't have any state updates if i == 0 { @@ -237,8 +236,7 @@ func (suite *DelayedAckTestSuite) TestRollappPacketsCasesInvariant() { // create rollapp suite.SetupTest() ctx := suite.Ctx - suite.CreateRollappWithName(rollapp) - proposer := suite.CreateDefaultSequencer(ctx, rollapp) + _, proposer := suite.CreateRollappWithNameWithProposer(rollapp) // update state infos stateInfo := rollapptypes.StateInfo{ diff --git a/x/incentives/keeper/gauge_rollapp.go b/x/incentives/keeper/gauge_rollapp.go index 1c5b65b05..87f041da3 100644 --- a/x/incentives/keeper/gauge_rollapp.go +++ b/x/incentives/keeper/gauge_rollapp.go @@ -50,7 +50,7 @@ func (k Keeper) distributeToRollappGauge(ctx sdk.Context, gauge types.Gauge) (to var addr sdk.AccAddress for _, seq := range seqs { if seq.Proposer { - addr, _ = sdk.AccAddressFromBech32(seq.SequencerAddress) + addr, _ = sdk.AccAddressFromBech32(seq.Address) break } } diff --git a/x/incentives/keeper/gauge_rollapp_test.go b/x/incentives/keeper/gauge_rollapp_test.go index 6850b3988..4f2437600 100644 --- a/x/incentives/keeper/gauge_rollapp_test.go +++ b/x/incentives/keeper/gauge_rollapp_test.go @@ -1,8 +1,10 @@ package keeper_test import ( + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" - types "github.com/dymensionxyz/dymension/v3/x/incentives/types" + + "github.com/dymensionxyz/dymension/v3/x/incentives/types" ) // TestDistributeToRollappGauges tests distributing rewards to rollapp gauges. @@ -32,8 +34,11 @@ func (suite *KeeperTestSuite) TestDistributeToRollappGauges() { suite.Run(tc.name, func() { suite.SetupTest() + pubkey := ed25519.GenPrivKey().PubKey() + addr := sdk.AccAddress(pubkey.Address()) + // create rollapp and check rollapp gauge created - rollapp := suite.CreateDefaultRollapp() + rollapp := suite.CreateDefaultRollapp(addr) res, err := suite.querier.RollappGauges(sdk.WrapSDKContext(suite.Ctx), &types.GaugesRequest{}) suite.Require().NoError(err) suite.Require().Len(res.Data, 1) @@ -42,8 +47,9 @@ func (suite *KeeperTestSuite) TestDistributeToRollappGauges() { var proposerAddr sdk.AccAddress if !tc.noSequencer { - addr := suite.CreateDefaultSequencer(suite.Ctx, rollapp) - proposerAddr, _ = sdk.AccAddressFromBech32(addr) + err = suite.CreateSequencer(suite.Ctx, rollapp, pubkey) + suite.Require().NoError(err) + proposerAddr = addr } if tc.rewards.Len() > 0 { diff --git a/x/incentives/keeper/suite_test.go b/x/incentives/keeper/suite_test.go index d366f16be..10f82b3c2 100644 --- a/x/incentives/keeper/suite_test.go +++ b/x/incentives/keeper/suite_test.go @@ -206,14 +206,16 @@ func (suite *KeeperTestSuite) SetupLockAndGauge(isPerpetual bool) (sdk.AccAddres } // SetupLockAndGauge creates both a lock and a gauge. -func (suite *KeeperTestSuite) CreateDefaultRollapp() string { - alice := sdk.AccAddress("addr1---------------") - suite.FundAcc(alice, sdk.NewCoins(rollapptypes.DefaultRegistrationFee)) +func (suite *KeeperTestSuite) CreateDefaultRollapp(addr sdk.AccAddress) string { + suite.FundAcc(addr, sdk.NewCoins(rollapptypes.DefaultRegistrationFee)) msgCreateRollapp := rollapptypes.MsgCreateRollapp{ - Creator: alice.String(), - RollappId: tmrand.Str(8), - Bech32Prefix: strings.ToLower(tmrand.Str(3)), + Creator: addr.String(), + RollappId: tmrand.Str(8), + Bech32Prefix: strings.ToLower(tmrand.Str(3)), + GenesisChecksum: "checksum", + InitialSequencerAddress: addr.String(), + Alias: "alias", } msgServer := rollapp.NewMsgServerImpl(*suite.App.RollappKeeper) diff --git a/x/rollapp/client/cli/tx_update_rollapp.go b/x/rollapp/client/cli/tx_update_rollapp.go index 59022e630..bf9f0e9b0 100644 --- a/x/rollapp/client/cli/tx_update_rollapp.go +++ b/x/rollapp/client/cli/tx_update_rollapp.go @@ -1,11 +1,11 @@ package cli import ( + "github.com/cometbft/cometbft/libs/json" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" "github.com/spf13/cobra" - "github.com/tendermint/tendermint/libs/json" "github.com/dymensionxyz/dymension/v3/x/rollapp/types" ) diff --git a/x/rollapp/keeper/block_height_to_finalization_queue_test.go b/x/rollapp/keeper/block_height_to_finalization_queue_test.go index c8528ae12..710b5dc7a 100644 --- a/x/rollapp/keeper/block_height_to_finalization_queue_test.go +++ b/x/rollapp/keeper/block_height_to_finalization_queue_test.go @@ -26,8 +26,7 @@ func (suite *RollappTestSuite) TestGetAllFinalizationQueueUntilHeight() { ctx := &suite.Ctx k := suite.App.RollappKeeper - rollapp := suite.CreateDefaultRollapp() - proposer := suite.CreateDefaultSequencer(*ctx, rollapp) + rollapp, proposer := suite.CreateDefaultRollappWithProposer() // Create 2 state updates _, err := suite.PostStateUpdate(*ctx, rollapp, proposer, 1, uint64(10)) suite.Require().Nil(err) @@ -224,8 +223,7 @@ func (suite *RollappTestSuite) TestFinalizeRollapps() { for _, rf := range tt.fields.rollappStateUpdates { // Create a rollapp - rollapp := suite.CreateDefaultRollapp() - proposer := suite.CreateDefaultSequencer(*ctx, rollapp) + rollapp, proposer := suite.CreateDefaultRollappWithProposer() // Create state update su := rf.stateUpdate @@ -266,8 +264,7 @@ func (suite *RollappTestSuite) TestFinalize() { k := suite.App.RollappKeeper // Create a rollapp - rollapp := suite.CreateDefaultRollapp() - proposer := suite.CreateDefaultSequencer(*ctx, rollapp) + rollapp, proposer := suite.CreateDefaultRollappWithProposer() // Create 2 state updates _, err := suite.PostStateUpdate(*ctx, rollapp, proposer, 1, uint64(10)) diff --git a/x/rollapp/keeper/fraud_handler_test.go b/x/rollapp/keeper/fraud_handler_test.go index 320500396..1fa705ffa 100644 --- a/x/rollapp/keeper/fraud_handler_test.go +++ b/x/rollapp/keeper/fraud_handler_test.go @@ -19,20 +19,19 @@ func (suite *RollappTestSuite) TestHandleFraud() { initialheight := uint64(10) suite.Ctx = suite.Ctx.WithBlockHeight(int64(initialheight)) - numOfSequencers := uint64(3) + numOfSequencers := uint64(3) - 1 // already created one with rollapp numOfStates := uint64(100) numOfBlocks := uint64(10) fraudHeight := uint64(300) // unrelated rollapp just to validate it's unaffected - rollapp_2 := suite.CreateDefaultRollapp() - proposer_2 := suite.CreateDefaultSequencer(*ctx, rollapp_2) + rollapp2, proposer2 := suite.CreateDefaultRollappWithProposer() // create rollapp and sequencers before fraud evidence - rollapp := suite.CreateDefaultRollapp() - proposer := suite.CreateDefaultSequencer(*ctx, rollapp) + rollapp, proposer := suite.CreateDefaultRollappWithProposer() for i := uint64(0); i < numOfSequencers-1; i++ { - suite.CreateDefaultSequencer(*ctx, rollapp) + _, err = suite.CreateDefaultSequencer(*ctx, rollapp) + suite.Require().Nil(err) } // send state updates @@ -42,7 +41,7 @@ func (suite *RollappTestSuite) TestHandleFraud() { _, err = suite.PostStateUpdate(*ctx, rollapp, proposer, lastHeight, numOfBlocks) suite.Require().Nil(err) - lastHeight, err = suite.PostStateUpdate(*ctx, rollapp_2, proposer_2, lastHeight, numOfBlocks) + lastHeight, err = suite.PostStateUpdate(*ctx, rollapp2, proposer2, lastHeight, numOfBlocks) suite.Require().Nil(err) suite.Ctx = suite.Ctx.WithBlockHeight(suite.Ctx.BlockHeader().Height + 1) @@ -66,8 +65,7 @@ func (suite *RollappTestSuite) TestHandleFraud_InvalidRollapp() { ctx := &suite.Ctx keeper := suite.App.RollappKeeper - rollapp := suite.CreateDefaultRollapp() - proposer := suite.CreateDefaultSequencer(*ctx, rollapp) + rollapp, proposer := suite.CreateDefaultRollappWithProposer() _, err := suite.PostStateUpdate(*ctx, rollapp, proposer, 1, uint64(10)) suite.Require().Nil(err) @@ -81,8 +79,7 @@ func (suite *RollappTestSuite) TestHandleFraud_WrongHeight() { ctx := &suite.Ctx keeper := suite.App.RollappKeeper - rollapp := suite.CreateDefaultRollapp() - proposer := suite.CreateDefaultSequencer(*ctx, rollapp) + rollapp, proposer := suite.CreateDefaultRollappWithProposer() _, err := suite.PostStateUpdate(*ctx, rollapp, proposer, 1, uint64(10)) suite.Require().Nil(err) @@ -96,8 +93,7 @@ func (suite *RollappTestSuite) TestHandleFraud_WrongSequencer() { ctx := &suite.Ctx keeper := suite.App.RollappKeeper - rollapp := suite.CreateDefaultRollapp() - proposer := suite.CreateDefaultSequencer(*ctx, rollapp) + rollapp, proposer := suite.CreateDefaultRollappWithProposer() _, err := suite.PostStateUpdate(*ctx, rollapp, proposer, 1, uint64(10)) suite.Require().Nil(err) @@ -111,8 +107,7 @@ func (suite *RollappTestSuite) TestHandleFraud_WrongChannelID() { ctx := &suite.Ctx keeper := suite.App.RollappKeeper - rollapp := suite.CreateDefaultRollapp() - proposer := suite.CreateDefaultSequencer(*ctx, rollapp) + rollapp, proposer := suite.CreateDefaultRollappWithProposer() _, err := suite.PostStateUpdate(*ctx, rollapp, proposer, 1, uint64(10)) suite.Require().Nil(err) @@ -126,13 +121,13 @@ func (suite *RollappTestSuite) TestHandleFraud_AlreadyReverted() { var err error ctx := &suite.Ctx keeper := suite.App.RollappKeeper - numOfSequencers := uint64(3) + numOfSequencers := uint64(3) - 1 // already created one with rollapp numOfStates := uint64(10) - rollapp := suite.CreateDefaultRollapp() - proposer := suite.CreateDefaultSequencer(*ctx, rollapp) + rollapp, proposer := suite.CreateDefaultRollappWithProposer() for i := uint64(0); i < numOfSequencers-1; i++ { - suite.CreateDefaultSequencer(*ctx, rollapp) + _, err = suite.CreateDefaultSequencer(*ctx, rollapp) + suite.Require().Nil(err) } // send state updates @@ -157,8 +152,7 @@ func (suite *RollappTestSuite) TestHandleFraud_AlreadyFinalized() { ctx := &suite.Ctx keeper := suite.App.RollappKeeper - rollapp := suite.CreateDefaultRollapp() - proposer := suite.CreateDefaultSequencer(*ctx, rollapp) + rollapp, proposer := suite.CreateDefaultRollappWithProposer() _, err := suite.PostStateUpdate(*ctx, rollapp, proposer, 1, uint64(10)) suite.Require().Nil(err) diff --git a/x/rollapp/keeper/invariants_test.go b/x/rollapp/keeper/invariants_test.go index fe189a13c..96e91422c 100644 --- a/x/rollapp/keeper/invariants_test.go +++ b/x/rollapp/keeper/invariants_test.go @@ -19,8 +19,7 @@ func (suite *RollappTestSuite) TestInvariants() { // create rollapps seqPerRollapp := make(map[string]string) for i := 0; i < numOfRollapps; i++ { - rollapp := suite.CreateDefaultRollapp() - seqaddr := suite.CreateDefaultSequencer(suite.Ctx, rollapp) + rollapp, seqaddr := suite.CreateDefaultRollappWithProposer() // skip one of the rollapps so it won't have any state updates if i == 0 { @@ -29,12 +28,10 @@ func (suite *RollappTestSuite) TestInvariants() { seqPerRollapp[rollapp] = seqaddr } - rollapp := suite.CreateRollappWithName("dym_1100-1") - seqaddr := suite.CreateDefaultSequencer(suite.Ctx, rollapp) + rollapp, seqaddr := suite.CreateRollappWithNameWithProposer("dym_1100-1") seqPerRollapp[rollapp] = seqaddr - rollapp = suite.CreateRollappWithName("dym_1100") - seqaddr = suite.CreateDefaultSequencer(suite.Ctx, rollapp) + rollapp, seqaddr = suite.CreateRollappWithNameWithProposer("dym_1100") seqPerRollapp[rollapp] = seqaddr // send state updates @@ -147,7 +144,7 @@ func (suite *RollappTestSuite) TestRollappFinalizedStateInvariant() { for _, tc := range cases { suite.Run(tc.name, func() { // create rollapp - suite.CreateRollappWithName(tc.rollappId) + suite.CreateRollappWithNameWithProposer(tc.rollappId) // update state infos if tc.stateInfo != nil { suite.App.RollappKeeper.SetStateInfo(ctx, *tc.stateInfo) diff --git a/x/rollapp/keeper/keeper.go b/x/rollapp/keeper/keeper.go index cb011419a..565da90a4 100644 --- a/x/rollapp/keeper/keeper.go +++ b/x/rollapp/keeper/keeper.go @@ -22,7 +22,6 @@ type Keeper struct { ibcClientKeeper types.IBCClientKeeper channelKeeper types.ChannelKeeper bankKeeper types.BankKeeper - sequencerKeeper types.SequencerKeeper finalizePending func(ctx sdk.Context, stateInfoIndex types.StateInfoIndex) error } @@ -57,10 +56,6 @@ func (k *Keeper) SetFinalizePendingFn(fn func(ctx sdk.Context, stateInfoIndex ty k.finalizePending = fn } -func (k *Keeper) SetSequencerKeeper(sequencerKeeper types.SequencerKeeper) { - k.sequencerKeeper = sequencerKeeper -} - func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } diff --git a/x/rollapp/keeper/msg_server_create_rollapp.go b/x/rollapp/keeper/msg_server_create_rollapp.go index 6f2a1af84..923648f51 100644 --- a/x/rollapp/keeper/msg_server_create_rollapp.go +++ b/x/rollapp/keeper/msg_server_create_rollapp.go @@ -9,6 +9,10 @@ import ( ) func (k msgServer) CreateRollapp(goCtx context.Context, msg *types.MsgCreateRollapp) (*types.MsgCreateRollappResponse, error) { + if msg == nil { + return nil, types.ErrInvalidRequest + } + ctx := sdk.UnwrapSDKContext(goCtx) if err := k.RegisterRollapp(ctx, msg.GetRollapp()); err != nil { diff --git a/x/rollapp/keeper/msg_server_update_rollapp_test.go b/x/rollapp/keeper/msg_server_update_rollapp_test.go index 7538969b2..082d1ddff 100644 --- a/x/rollapp/keeper/msg_server_update_rollapp_test.go +++ b/x/rollapp/keeper/msg_server_update_rollapp_test.go @@ -1,19 +1,27 @@ package keeper_test import ( + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/dymensionxyz/gerr-cosmos/gerrc" + "github.com/dymensionxyz/sdk-utils/utils/uptr" "github.com/dymensionxyz/dymension/v3/x/rollapp/types" sequencertypes "github.com/dymensionxyz/dymension/v3/x/sequencer/types" ) func (suite *RollappTestSuite) TestUpdateRollapp() { + const ( + rollappId = "rollapp_1234-1" + initialSequencerAddress = "dym10l6edrf9gjv02um5kp7cmy4zgd26tafz6eqajz" + ) + tests := []struct { name string update *types.MsgUpdateRollappInformation - malleate func(types.Rollapp) types.Rollapp + sealed bool + frozen bool expError error expRollapp types.Rollapp }{ @@ -22,8 +30,8 @@ func (suite *RollappTestSuite) TestUpdateRollapp() { update: &types.MsgUpdateRollappInformation{ Update: &types.UpdateRollappInformation{ Creator: alice, - RollappId: "rollapp_1234-1", - InitialSequencerAddress: "dym10l6edrf9gjv02um5kp7cmy4zgd26tafz6eqajz", + RollappId: rollappId, + InitialSequencerAddress: initialSequencerAddress, Alias: "rolly", GenesisChecksum: "new_checksum", Metadata: &mockRollappMetadata, @@ -32,8 +40,8 @@ func (suite *RollappTestSuite) TestUpdateRollapp() { expError: nil, expRollapp: types.Rollapp{ Creator: alice, - RollappId: "rollapp_1234-1", - InitialSequencerAddress: "dym10l6edrf9gjv02um5kp7cmy4zgd26tafz6eqajz", + RollappId: rollappId, + InitialSequencerAddress: initialSequencerAddress, Bech32Prefix: "rol", GenesisChecksum: "new_checksum", Alias: "rolly", @@ -45,7 +53,7 @@ func (suite *RollappTestSuite) TestUpdateRollapp() { Update: &types.UpdateRollappInformation{ Creator: alice, RollappId: "somerollapp_1235-1", - InitialSequencerAddress: "dym10l6edrf9gjv02um5kp7cmy4zgd26tafz6eqajz", + InitialSequencerAddress: initialSequencerAddress, }, }, expError: gerrc.ErrNotFound, @@ -54,8 +62,8 @@ func (suite *RollappTestSuite) TestUpdateRollapp() { update: &types.MsgUpdateRollappInformation{ Update: &types.UpdateRollappInformation{ Creator: bob, - RollappId: "rollapp_1234-1", - InitialSequencerAddress: "dym10l6edrf9gjv02um5kp7cmy4zgd26tafz6eqajz", + RollappId: rollappId, + InitialSequencerAddress: initialSequencerAddress, }, }, expError: sdkerrors.ErrUnauthorized, @@ -64,171 +72,58 @@ func (suite *RollappTestSuite) TestUpdateRollapp() { update: &types.MsgUpdateRollappInformation{ Update: &types.UpdateRollappInformation{ Creator: alice, - RollappId: "rollapp_1234-1", - InitialSequencerAddress: "dym10l6edrf9gjv02um5kp7cmy4zgd26tafz6eqajz", + RollappId: rollappId, + InitialSequencerAddress: initialSequencerAddress, }, }, - malleate: func(r types.Rollapp) types.Rollapp { - r.Frozen = true - return r - }, + frozen: true, expError: types.ErrRollappFrozen, }, { - name: "Update rollapp: fail - try to update using another rollapp's alias", + name: "Update rollapp: fail - try to update InitialSequencerAddress when sealed", update: &types.MsgUpdateRollappInformation{ Update: &types.UpdateRollappInformation{ Creator: alice, - RollappId: "rollapp_1234-1", - InitialSequencerAddress: "dym10l6edrf9gjv02um5kp7cmy4zgd26tafz6eqajz", - Alias: "rolly", - }, - }, - malleate: func(r types.Rollapp) types.Rollapp { - // create another rollapp with the same InitialSequencerAddress - suite.App.RollappKeeper.SetRollapp(suite.Ctx, types.Rollapp{ - RollappId: "somerollapp_1235-1", - Alias: "rolly", - }) - return r - }, - expError: gerrc.ErrAlreadyExists, - }, { - name: "Update rollapp: fail - try to update InitialSequencerAddress with existing state", - update: &types.MsgUpdateRollappInformation{ - Update: &types.UpdateRollappInformation{ - Creator: alice, - RollappId: "rollapp_1234-1", - InitialSequencerAddress: "dym10l6edrf9gjv02um5kp7cmy4zgd26tafz6eqajz", - }, - }, - malleate: func(r types.Rollapp) types.Rollapp { - // create state for the rollapp - suite.App.RollappKeeper.SetLatestStateInfoIndex(suite.Ctx, types.StateInfoIndex{ - RollappId: r.RollappId, - Index: 1, - }) - return r - }, - expError: types.ErrImmutableFieldUpdateAfterState, - }, { - name: "Update rollapp: fail - try to update InitialSequencerAddress with bonded initial sequencer", - update: &types.MsgUpdateRollappInformation{ - Update: &types.UpdateRollappInformation{ - Creator: alice, - RollappId: "rollapp_1234-1", - InitialSequencerAddress: "dym10l6edrf9gjv02um5kp7cmy4zgd26tafz6eqajz", - }, - }, - malleate: func(r types.Rollapp) types.Rollapp { - // create initial bonded sequencer - initialSequencer := "dym10l6edrf9gjv02um5kp7cmy4zgd26tafz6eqajz" - suite.App.SequencerKeeper.SetSequencer(suite.Ctx, sequencertypes.Sequencer{ - SequencerAddress: initialSequencer, - RollappId: r.RollappId, - Status: sequencertypes.Bonded, - }) - r.InitialSequencerAddress = initialSequencer - return r - }, - expError: types.ErrImmutableFieldUpdateAfterInitialSequencerBonded, - }, { - name: "Update rollapp: fail - try to update alias with existing state", - update: &types.MsgUpdateRollappInformation{ - Update: &types.UpdateRollappInformation{ - Creator: alice, - RollappId: "rollapp_1234-1", - Alias: "rolly", + RollappId: rollappId, + InitialSequencerAddress: initialSequencerAddress, }, }, - malleate: func(r types.Rollapp) types.Rollapp { - // create state for the rollapp - suite.App.RollappKeeper.SetLatestStateInfoIndex(suite.Ctx, types.StateInfoIndex{ - RollappId: r.RollappId, - Index: 1, - }) - return r - }, - expError: types.ErrImmutableFieldUpdateAfterState, + sealed: true, + expError: types.ErrImmutableFieldUpdateAfterSealed, }, { - name: "Update rollapp: fail - try to update alias with bonded initial sequencer", + name: "Update rollapp: fail - try to update alias when sealed", update: &types.MsgUpdateRollappInformation{ Update: &types.UpdateRollappInformation{ Creator: alice, - RollappId: "rollapp_1234-1", + RollappId: rollappId, Alias: "rolly", }, }, - malleate: func(r types.Rollapp) types.Rollapp { - // create initial bonded sequencer - initialSequencer := "dym10l6edrf9gjv02um5kp7cmy4zgd26tafz6eqajz" - suite.App.SequencerKeeper.SetSequencer(suite.Ctx, sequencertypes.Sequencer{ - SequencerAddress: initialSequencer, - RollappId: r.RollappId, - Status: sequencertypes.Bonded, - }) - r.InitialSequencerAddress = initialSequencer - return r - }, - expError: types.ErrImmutableFieldUpdateAfterInitialSequencerBonded, + sealed: true, + expError: types.ErrImmutableFieldUpdateAfterSealed, }, { - name: "Update rollapp: fail - try to update genesis checksum with existing state", + name: "Update rollapp: fail - try to update genesis checksum when sealed", update: &types.MsgUpdateRollappInformation{ Update: &types.UpdateRollappInformation{ Creator: alice, - RollappId: "rollapp_1234-1", + RollappId: rollappId, GenesisChecksum: "new_checksum", }, }, - malleate: func(r types.Rollapp) types.Rollapp { - // create state for the rollapp - suite.App.RollappKeeper.SetLatestStateInfoIndex(suite.Ctx, types.StateInfoIndex{ - RollappId: "rollapp_1234-1", - Index: 1, - }) - return r - }, - expError: types.ErrImmutableFieldUpdateAfterState, + sealed: true, + expError: types.ErrImmutableFieldUpdateAfterSealed, }, { - name: "Update rollapp: fail - try to update genesis checksum with bonded initial sequencer", - update: &types.MsgUpdateRollappInformation{ - Update: &types.UpdateRollappInformation{ - Creator: alice, - RollappId: "rollapp_1234-1", - GenesisChecksum: "new_checksum", - }, - }, - malleate: func(r types.Rollapp) types.Rollapp { - // create initial bonded sequencer - initialSequencer := "dym10l6edrf9gjv02um5kp7cmy4zgd26tafz6eqajz" - suite.App.SequencerKeeper.SetSequencer(suite.Ctx, sequencertypes.Sequencer{ - SequencerAddress: initialSequencer, - RollappId: r.RollappId, - Status: sequencertypes.Bonded, - }) - r.InitialSequencerAddress = initialSequencer - return r - }, - expError: types.ErrImmutableFieldUpdateAfterInitialSequencerBonded, - }, { - name: "Update rollapp: success - update metadata with existing state", + name: "Update rollapp: success - update metadata when sealed", update: &types.MsgUpdateRollappInformation{ Update: &types.UpdateRollappInformation{ Creator: alice, - RollappId: "rollapp_1234-1", + RollappId: rollappId, Metadata: &mockRollappMetadata, }, }, - malleate: func(r types.Rollapp) types.Rollapp { - // create state for the rollapp - suite.App.RollappKeeper.SetLatestStateInfoIndex(suite.Ctx, types.StateInfoIndex{ - RollappId: "rollapp_1234-1", - Index: 1, - }) - return r - }, + sealed: true, expError: nil, expRollapp: types.Rollapp{ - RollappId: "rollapp_1234-1", + RollappId: rollappId, Creator: alice, InitialSequencerAddress: "", GenesisChecksum: "checksum1", @@ -237,39 +132,7 @@ func (suite *RollappTestSuite) TestUpdateRollapp() { Bech32Prefix: "rol", Alias: "Rollapp2", RegisteredDenoms: nil, - Metadata: &mockRollappMetadata, - }, - }, { - name: "Update rollapp: success - update metadata with bonded initial sequencer", - update: &types.MsgUpdateRollappInformation{ - Update: &types.UpdateRollappInformation{ - Creator: alice, - RollappId: "rollapp_1234-1", - Metadata: &mockRollappMetadata, - }, - }, - malleate: func(r types.Rollapp) types.Rollapp { - // create initial bonded sequencer - initialSequencer := "dym10l6edrf9gjv02um5kp7cmy4zgd26tafz6eqajz" - suite.App.SequencerKeeper.SetSequencer(suite.Ctx, sequencertypes.Sequencer{ - SequencerAddress: initialSequencer, - RollappId: r.RollappId, - Status: sequencertypes.Bonded, - }) - r.InitialSequencerAddress = initialSequencer - return r - }, - expError: nil, - expRollapp: types.Rollapp{ - RollappId: "rollapp_1234-1", - Creator: alice, - InitialSequencerAddress: "dym10l6edrf9gjv02um5kp7cmy4zgd26tafz6eqajz", - GenesisChecksum: "checksum1", - ChannelId: "", - Frozen: false, - Bech32Prefix: "rol", - Alias: "Rollapp2", - RegisteredDenoms: nil, + Sealed: true, Metadata: &mockRollappMetadata, }, }, @@ -281,12 +144,13 @@ func (suite *RollappTestSuite) TestUpdateRollapp() { goCtx := sdk.WrapSDKContext(suite.Ctx) rollapp := types.Rollapp{ - RollappId: "rollapp_1234-1", + RollappId: rollappId, Creator: alice, InitialSequencerAddress: "", GenesisChecksum: "checksum1", ChannelId: "", - Frozen: false, + Frozen: tc.frozen, + Sealed: tc.sealed, Bech32Prefix: "rol", Alias: "Rollapp2", RegisteredDenoms: nil, @@ -300,10 +164,6 @@ func (suite *RollappTestSuite) TestUpdateRollapp() { }, } - if tc.malleate != nil { - rollapp = tc.malleate(rollapp) - } - suite.App.RollappKeeper.SetRollapp(suite.Ctx, rollapp) _, err := suite.msgServer.UpdateRollappInformation(goCtx, tc.update) @@ -318,3 +178,104 @@ func (suite *RollappTestSuite) TestUpdateRollapp() { }) } } + +func (suite *RollappTestSuite) TestCreateAndUpdateRollapp() { + suite.SetupTest() + + const rollappId = "rollapp_1234-1" + + // 1. register rollapp + err := suite.App.RollappKeeper.RegisterRollapp(suite.Ctx, types.Rollapp{ + RollappId: rollappId, + Creator: alice, + GenesisChecksum: "", + InitialSequencerAddress: "", + Alias: "", + Bech32Prefix: "rol", + }) + suite.Require().NoError(err) + + // 2. try to register sequencer (not initial) - should fail because rollapp is not sealed + _, err = suite.CreateDefaultSequencer(suite.Ctx, rollappId) + suite.Require().ErrorIs(err, sequencertypes.ErrRollappNotSealed) + + // 3. update rollapp immutable fields, set InitialSequencerAddress, Alias and GenesisChecksum + initSeqPubKey := ed25519.GenPrivKey().PubKey() + addrInit := sdk.AccAddress(initSeqPubKey.Address()).String() + + err = suite.App.RollappKeeper.UpdateRollapp(suite.Ctx, types.UpdateRollappInformation{ + Creator: alice, + RollappId: rollappId, + InitialSequencerAddress: addrInit, + GenesisChecksum: "checksum1", + Alias: "alias", + }) + suite.Require().NoError(err) + + // 4. register sequencer (initial) - should be proposer; rollapp should be sealed + // from this point on, the rollapp is sealed and immutable fields cannot be updated + err = suite.CreateSequencer(suite.Ctx, rollappId, initSeqPubKey) + suite.Require().NoError(err) + initSeq, ok := suite.App.SequencerKeeper.GetSequencer(suite.Ctx, addrInit) + suite.Require().True(ok) + suite.Require().True(initSeq.Proposer) + rollapp, ok := suite.App.RollappKeeper.GetRollapp(suite.Ctx, rollappId) + suite.Require().True(ok) + suite.Require().True(rollapp.Sealed) + + // 5. try to update rollapp immutable fields - should fail because rollapp is sealed + err = suite.App.RollappKeeper.UpdateRollapp(suite.Ctx, types.UpdateRollappInformation{ + Creator: alice, + RollappId: rollappId, + Alias: "rolly", + }) + suite.Require().ErrorIs(err, types.ErrImmutableFieldUpdateAfterSealed) + + // 6. register another sequencer - should not be proposer + newSeqAddr, err := suite.CreateDefaultSequencer(suite.Ctx, rollappId) + suite.Require().NoError(err) + newSequencer, ok := suite.App.SequencerKeeper.GetSequencer(suite.Ctx, newSeqAddr) + suite.Require().True(ok) + suite.Require().False(newSequencer.Proposer) + + // 7. create state update + suite.App.RollappKeeper.SetLatestStateInfoIndex(suite.Ctx, types.StateInfoIndex{ + RollappId: rollappId, + Index: 1, + }) + + // 8. update initial sequencer + metadata := sequencertypes.SequencerMetadata{ + Moniker: "new_moniker", + Details: "something", + P2PSeeds: []string{"seed1", "seed2"}, + Rpcs: []string{"rpc1", "rpc2"}, + EvmRpcs: []string{"evm1", "evm2"}, + RestApiUrl: "http://localhost:1317", + ExplorerUrl: "http://localhost:8000", + GenesisUrls: []string{"http://localhost:26657"}, + ContactDetails: &sequencertypes.ContactDetails{ + Website: "https://dymension.xyz", + Telegram: "sequencer", + X: "sequencer", + }, + ExtraData: []byte("extra"), + Snapshots: []*sequencertypes.SnapshotInfo{ + { + SnapshotUrl: "http://localhost:1317/snapshot", + Height: 123, + Checksum: "checksum", + }, + }, + GasPrice: uptr.To(sdk.NewInt(100)), + } + _, err = suite.seqMsgServer.UpdateSequencerInformation(suite.Ctx, &sequencertypes.MsgUpdateSequencerInformation{ + Creator: addrInit, + RollappId: rollappId, + Metadata: metadata, + }) + suite.Require().NoError(err) + initSeq, ok = suite.App.SequencerKeeper.GetSequencer(suite.Ctx, addrInit) + suite.Require().True(ok) + suite.Require().Equal(metadata, initSeq.Metadata) +} diff --git a/x/rollapp/keeper/msg_server_update_state_test.go b/x/rollapp/keeper/msg_server_update_state_test.go index a50e9ac7c..d3de99a78 100644 --- a/x/rollapp/keeper/msg_server_update_state_test.go +++ b/x/rollapp/keeper/msg_server_update_state_test.go @@ -38,10 +38,10 @@ func (suite *RollappTestSuite) TestFirstUpdateState() { // set sequencer sequencer := sequencertypes.Sequencer{ - SequencerAddress: bob, - RollappId: rollapp.GetRollappId(), - Status: sequencertypes.Bonded, - Proposer: true, + Address: bob, + RollappId: rollapp.GetRollappId(), + Status: sequencertypes.Bonded, + Proposer: true, } suite.App.SequencerKeeper.SetSequencer(suite.Ctx, sequencer) @@ -87,10 +87,10 @@ func (suite *RollappTestSuite) TestUpdateState() { // set sequencer sequencer := sequencertypes.Sequencer{ - SequencerAddress: bob, - RollappId: rollapp.GetRollappId(), - Status: sequencertypes.Bonded, - Proposer: true, + Address: bob, + RollappId: rollapp.GetRollappId(), + Status: sequencertypes.Bonded, + Proposer: true, } suite.App.SequencerKeeper.SetSequencer(suite.Ctx, sequencer) @@ -243,10 +243,10 @@ func (suite *RollappTestSuite) TestUpdateStateSequencerRollappMismatch() { // set sequencer sequencer := sequencertypes.Sequencer{ - SequencerAddress: bob, - RollappId: "rollapp2", - Status: sequencertypes.Bonded, - Proposer: true, + Address: bob, + RollappId: "rollapp2", + Status: sequencertypes.Bonded, + Proposer: true, } suite.App.SequencerKeeper.SetSequencer(suite.Ctx, sequencer) @@ -280,10 +280,10 @@ func (suite *RollappTestSuite) TestUpdateStateErrLogicUnpermissioned() { // set unpermissioned sequencer sequencer := sequencertypes.Sequencer{ - SequencerAddress: rollapp.InitialSequencerAddress, - RollappId: "rollapp1", - Status: sequencertypes.Bonded, - Proposer: true, + Address: rollapp.InitialSequencerAddress, + RollappId: "rollapp1", + Status: sequencertypes.Bonded, + Proposer: true, } suite.App.SequencerKeeper.SetSequencer(suite.Ctx, sequencer) @@ -317,10 +317,10 @@ func (suite *RollappTestSuite) TestFirstUpdateStateGensisHightGreaterThanZero() // set sequencer sequencer := sequencertypes.Sequencer{ - SequencerAddress: bob, - RollappId: "rollapp1", - Status: sequencertypes.Bonded, - Proposer: true, + Address: bob, + RollappId: "rollapp1", + Status: sequencertypes.Bonded, + Proposer: true, } suite.App.SequencerKeeper.SetSequencer(suite.Ctx, sequencer) @@ -354,10 +354,10 @@ func (suite *RollappTestSuite) TestUpdateStateErrWrongBlockHeight() { // set sequencer sequencer := sequencertypes.Sequencer{ - SequencerAddress: bob, - RollappId: "rollapp1", - Status: sequencertypes.Bonded, - Proposer: true, + Address: bob, + RollappId: "rollapp1", + Status: sequencertypes.Bonded, + Proposer: true, } suite.App.SequencerKeeper.SetSequencer(suite.Ctx, sequencer) @@ -368,7 +368,7 @@ func (suite *RollappTestSuite) TestUpdateStateErrWrongBlockHeight() { } stateInfo := types.StateInfo{ StateInfoIndex: types.StateInfoIndex{RollappId: "rollapp1", Index: 1}, - Sequencer: sequencer.SequencerAddress, + Sequencer: sequencer.Address, StartHeight: 1, NumBlocks: 3, DAPath: "", @@ -413,10 +413,10 @@ func (suite *RollappTestSuite) TestUpdateStateErrLogicMissingStateInfo() { // set sequencer sequencer := sequencertypes.Sequencer{ - SequencerAddress: bob, - RollappId: "rollapp1", - Status: sequencertypes.Bonded, - Proposer: true, + Address: bob, + RollappId: "rollapp1", + Status: sequencertypes.Bonded, + Proposer: true, } suite.App.SequencerKeeper.SetSequencer(suite.Ctx, sequencer) @@ -458,9 +458,9 @@ func (suite *RollappTestSuite) TestUpdateStateErrNotActiveSequencer() { // set sequencer sequencer := sequencertypes.Sequencer{ - SequencerAddress: bob, - RollappId: "rollapp1", - Status: sequencertypes.Bonded, + Address: bob, + RollappId: "rollapp1", + Status: sequencertypes.Bonded, } suite.App.SequencerKeeper.SetSequencer(suite.Ctx, sequencer) diff --git a/x/rollapp/keeper/rollapp.go b/x/rollapp/keeper/rollapp.go index dc30b8f29..9697e2bfd 100644 --- a/x/rollapp/keeper/rollapp.go +++ b/x/rollapp/keeper/rollapp.go @@ -82,15 +82,9 @@ func (k Keeper) canUpdateRollapp(ctx sdk.Context, update types.UpdateRollappInfo return current, types.ErrRollappFrozen } - if update.UpdatingImutableValues() { - // initial sequencer address cannot be updated after the initial sequencer has bonded - if k.sequencerKeeper.IsSequencerBonded(ctx, current.InitialSequencerAddress) { - return current, types.ErrImmutableFieldUpdateAfterInitialSequencerBonded - } - // initial sequencer address cannot be updated after the first state update - if _, hasState := k.GetLatestStateInfoIndex(ctx, current.RollappId); hasState { - return current, types.ErrImmutableFieldUpdateAfterState - } + // immutable values cannot be updated when the rollapp is sealed + if update.UpdatingImutableValues() && current.Sealed { + return current, types.ErrImmutableFieldUpdateAfterSealed } var err error @@ -196,6 +190,22 @@ func (k Keeper) SetRollapp(ctx sdk.Context, rollapp types.Rollapp) { ), []byte(rollapp.RollappId)) } +func (k Keeper) SealRollapp(ctx sdk.Context, rollappId string) error { + rollapp, found := k.GetRollapp(ctx, rollappId) + if !found { + return types.ErrNotFound + } + + if rollapp.GenesisChecksum == "" || rollapp.Alias == "" || rollapp.InitialSequencerAddress == "" { + return types.ErrSealWithImmutableFieldsNotSet + } + + rollapp.Sealed = true + k.SetRollapp(ctx, rollapp) + + return nil +} + // GetRollappByEIP155 returns a rollapp from its EIP155 id (https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md) for EVM compatible rollapps func (k Keeper) GetRollappByEIP155(ctx sdk.Context, eip155 uint64) (val types.Rollapp, found bool) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.RollappByEIP155KeyPrefix)) @@ -279,3 +289,8 @@ func (k Keeper) IsRollappStarted(ctx sdk.Context, rollappId string) bool { _, found := k.GetLatestStateInfoIndex(ctx, rollappId) return found } + +func (k Keeper) IsRollappSealed(ctx sdk.Context, rollappId string) bool { + rollapp, found := k.GetRollapp(ctx, rollappId) + return found && rollapp.Sealed +} diff --git a/x/rollapp/keeper/rollapp_suite_test.go b/x/rollapp/keeper/rollapp_suite_test.go index 61f9b521c..a8df7f803 100644 --- a/x/rollapp/keeper/rollapp_suite_test.go +++ b/x/rollapp/keeper/rollapp_suite_test.go @@ -14,6 +14,8 @@ import ( "github.com/dymensionxyz/dymension/v3/app/apptesting" "github.com/dymensionxyz/dymension/v3/x/rollapp/keeper" "github.com/dymensionxyz/dymension/v3/x/rollapp/types" + sequencerkeeper "github.com/dymensionxyz/dymension/v3/x/sequencer/keeper" + sequencertypes "github.com/dymensionxyz/dymension/v3/x/sequencer/types" ) // Prevent strconv unused error @@ -27,8 +29,9 @@ const ( type RollappTestSuite struct { apptesting.KeeperTestHelper - msgServer types.MsgServer - queryClient types.QueryClient + msgServer types.MsgServer + seqMsgServer sequencertypes.MsgServer + queryClient types.QueryClient } func (suite *RollappTestSuite) SetupTest() { @@ -51,6 +54,7 @@ func (suite *RollappTestSuite) SetupTest() { suite.App = app suite.msgServer = keeper.NewMsgServerImpl(*app.RollappKeeper) + suite.seqMsgServer = sequencerkeeper.NewMsgServerImpl(app.SequencerKeeper) suite.Ctx = ctx suite.queryClient = queryClient } diff --git a/x/rollapp/types/errors.go b/x/rollapp/types/errors.go index d1325cf1c..170735830 100644 --- a/x/rollapp/types/errors.go +++ b/x/rollapp/types/errors.go @@ -9,39 +9,38 @@ import ( // x/rollapp module sentinel errors var ( - ErrRollappExists = errorsmod.Register(ModuleName, 1000, "rollapp already exists for this rollapp-id; must use new rollapp-id") - ErrInvalidInitialSequencerAddress = errorsmod.Register(ModuleName, 1001, "empty initial sequencer address") - ErrInvalidCreatorAddress = errorsmod.Register(ModuleName, 1002, "invalid creator address") - ErrInvalidBech32Prefix = errorsmod.Register(ModuleName, 1003, "invalid Bech32 prefix") - ErrRollappFrozen = errorsmod.Register(ModuleName, 1004, "rollapp is frozen") - ErrInvalidNumBlocks = errorsmod.Register(ModuleName, 1005, "invalid number of blocks") - ErrInvalidBlockSequence = errorsmod.Register(ModuleName, 1006, "invalid block sequence") - ErrUnknownRollappID = errorsmod.Register(ModuleName, 1007, "rollapp does not exist") - ErrWrongBlockHeight = errorsmod.Register(ModuleName, 1009, "start-height does not match rollapps state") - ErrInvalidGenesisChecksum = errorsmod.Register(ModuleName, 1010, "invalid genesis checksum") - ErrInvalidStateRoot = errorsmod.Register(ModuleName, 1011, "invalid blocks state root") - ErrFeePayment = errorsmod.Register(ModuleName, 1013, "rollapp creation fee payment error") - ErrStateNotExists = errorsmod.Register(ModuleName, 1017, "state of this height doesn't exist") - ErrInvalidHeight = errorsmod.Register(ModuleName, 1018, "invalid rollapp height") - ErrInvalidRollappID = errorsmod.Register(ModuleName, 1020, "invalid rollapp-id") - ErrNoFinalizedStateYetForRollapp = errorsmod.Register(ModuleName, 1024, "no finalized state yet for rollapp") - ErrInvalidClientState = errorsmod.Register(ModuleName, 1025, "invalid client state") - ErrRollappNotRegistered = errorsmod.Register(ModuleName, 1035, "rollapp not registered") - ErrUnknownRequest = errorsmod.Register(ModuleName, 1036, "unknown request") - ErrNotFound = errorsmod.Register(ModuleName, 1037, "not found") - ErrLogic = errorsmod.Register(ModuleName, 1038, "internal logic error") - ErrInvalidAddress = errorsmod.Register(ModuleName, 1040, "invalid address") - ErrInitialSequencerAddressTaken = errorsmod.Wrap(gerrc.ErrAlreadyExists, "initial sequencer address") - ErrInvalidAlias = errorsmod.Wrap(gerrc.ErrInvalidArgument, "alias") - ErrInvalidWebsiteURL = errorsmod.Wrap(gerrc.ErrInvalidArgument, "website url") - ErrInvalidDescription = errorsmod.Wrap(gerrc.ErrInvalidArgument, "description") - ErrInvalidLogoURI = errorsmod.Wrap(gerrc.ErrInvalidArgument, "logo uri") - ErrInvalidTokenLogoURI = errorsmod.Wrap(gerrc.ErrInvalidArgument, "token logo uri") - ErrInvalidMetadata = errorsmod.Wrap(gerrc.ErrInvalidArgument, "metadata") - ErrImmutableFieldUpdateAfterState = errorsmod.Wrap(gerrc.ErrInvalidArgument, "update immutable field after state created") - ErrImmutableFieldUpdateAfterInitialSequencerBonded = errorsmod.Wrap(gerrc.ErrFailedPrecondition, "update immutable field after initial sequencer already bonded") - ErrInvalidHandle = errorsmod.Wrap(gerrc.ErrInvalidArgument, "handle") - ErrInvalidRequest = errorsmod.Wrap(gerrc.ErrInvalidArgument, "invalid request") + ErrRollappExists = errorsmod.Register(ModuleName, 1000, "rollapp already exists for this rollapp-id; must use new rollapp-id") + ErrInvalidInitialSequencerAddress = errorsmod.Register(ModuleName, 1001, "empty initial sequencer address") + ErrInvalidCreatorAddress = errorsmod.Register(ModuleName, 1002, "invalid creator address") + ErrInvalidBech32Prefix = errorsmod.Register(ModuleName, 1003, "invalid Bech32 prefix") + ErrRollappFrozen = errorsmod.Register(ModuleName, 1004, "rollapp is frozen") + ErrInvalidNumBlocks = errorsmod.Register(ModuleName, 1005, "invalid number of blocks") + ErrInvalidBlockSequence = errorsmod.Register(ModuleName, 1006, "invalid block sequence") + ErrUnknownRollappID = errorsmod.Register(ModuleName, 1007, "rollapp does not exist") + ErrWrongBlockHeight = errorsmod.Register(ModuleName, 1009, "start-height does not match rollapps state") + ErrInvalidGenesisChecksum = errorsmod.Register(ModuleName, 1010, "invalid genesis checksum") + ErrInvalidStateRoot = errorsmod.Register(ModuleName, 1011, "invalid blocks state root") + ErrFeePayment = errorsmod.Register(ModuleName, 1013, "rollapp creation fee payment error") + ErrStateNotExists = errorsmod.Register(ModuleName, 1017, "state of this height doesn't exist") + ErrInvalidHeight = errorsmod.Register(ModuleName, 1018, "invalid rollapp height") + ErrInvalidRollappID = errorsmod.Register(ModuleName, 1020, "invalid rollapp-id") + ErrNoFinalizedStateYetForRollapp = errorsmod.Register(ModuleName, 1024, "no finalized state yet for rollapp") + ErrInvalidClientState = errorsmod.Register(ModuleName, 1025, "invalid client state") + ErrRollappNotRegistered = errorsmod.Register(ModuleName, 1035, "rollapp not registered") + ErrUnknownRequest = errorsmod.Register(ModuleName, 1036, "unknown request") + ErrNotFound = errorsmod.Register(ModuleName, 1037, "not found") + ErrLogic = errorsmod.Register(ModuleName, 1038, "internal logic error") + ErrInvalidAddress = errorsmod.Register(ModuleName, 1040, "invalid address") + ErrInvalidAlias = errorsmod.Wrap(gerrc.ErrInvalidArgument, "alias") + ErrInvalidWebsiteURL = errorsmod.Wrap(gerrc.ErrInvalidArgument, "website url") + ErrInvalidDescription = errorsmod.Wrap(gerrc.ErrInvalidArgument, "description") + ErrInvalidLogoURI = errorsmod.Wrap(gerrc.ErrInvalidArgument, "logo uri") + ErrInvalidTokenLogoURI = errorsmod.Wrap(gerrc.ErrInvalidArgument, "token logo uri") + ErrInvalidMetadata = errorsmod.Wrap(gerrc.ErrInvalidArgument, "metadata") + ErrImmutableFieldUpdateAfterSealed = errorsmod.Wrap(gerrc.ErrInvalidArgument, "update immutable field after rollapp sealed") + ErrSealWithImmutableFieldsNotSet = errorsmod.Wrap(gerrc.ErrInvalidArgument, "seal with immutable fields not set") + ErrInvalidHandle = errorsmod.Wrap(gerrc.ErrInvalidArgument, "handle") + ErrInvalidRequest = errorsmod.Wrap(gerrc.ErrInvalidArgument, "invalid request") /* ------------------------------ fraud related ----------------------------- */ ErrDisputeAlreadyFinalized = errorsmod.Register(ModuleName, 2000, "disputed height already finalized") diff --git a/x/rollapp/types/expected_keepers.go b/x/rollapp/types/expected_keepers.go index 8af499c1c..3d708334f 100644 --- a/x/rollapp/types/expected_keepers.go +++ b/x/rollapp/types/expected_keepers.go @@ -18,7 +18,3 @@ type BankKeeper interface { SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error BurnCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error } - -type SequencerKeeper interface { - IsSequencerBonded(ctx sdk.Context, address string) bool -} diff --git a/x/rollapp/types/rollapp.pb.go b/x/rollapp/types/rollapp.pb.go index dd93ef892..1c11f3339 100644 --- a/x/rollapp/types/rollapp.pb.go +++ b/x/rollapp/types/rollapp.pb.go @@ -102,6 +102,8 @@ type Rollapp struct { RegisteredDenoms []string `protobuf:"bytes,10,rep,name=registered_denoms,json=registeredDenoms,proto3" json:"registered_denoms,omitempty"` // metadata is the rollapp metadata Metadata *RollappMetadata `protobuf:"bytes,11,opt,name=metadata,proto3" json:"metadata,omitempty"` + // sealed is a boolean that indicates if the immutable fields are no longer updatable. + Sealed bool `protobuf:"varint,12,opt,name=sealed,proto3" json:"sealed,omitempty"` } func (m *Rollapp) Reset() { *m = Rollapp{} } @@ -214,6 +216,13 @@ func (m *Rollapp) GetMetadata() *RollappMetadata { return nil } +func (m *Rollapp) GetSealed() bool { + if m != nil { + return m.Sealed + } + return false +} + // UpdateRollappInformation updates the rollapp information. type UpdateRollappInformation struct { // creator is the bech32-encoded address of the rollapp creator @@ -383,48 +392,48 @@ func init() { } var fileDescriptor_d4ef2bec3aea5528 = []byte{ - // 645 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0xcd, 0x6e, 0xd3, 0x4a, - 0x14, 0x8e, 0x93, 0x34, 0x4d, 0xa6, 0xed, 0xbd, 0xb9, 0xbe, 0x15, 0x75, 0x2b, 0x30, 0x51, 0xd8, - 0x84, 0x3f, 0x5b, 0x6d, 0x58, 0x75, 0x47, 0xf9, 0x0d, 0x08, 0x84, 0x5c, 0xb1, 0xe9, 0x02, 0x6b, - 0xe2, 0x39, 0x71, 0x46, 0xd8, 0x33, 0x61, 0x66, 0x52, 0x25, 0x5d, 0x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ea, 0x0f, 0xbb, 0x5e, 0xc4, 0xd3, 0xf3, 0xde, 0xbb, 0xdd, 0xb6, 0x3f, 0x9a, 0xbe, 0x61, 0x6a, - 0x3c, 0x00, 0xd9, 0xad, 0xe8, 0x17, 0xac, 0xfd, 0x33, 0x00, 0x00, 0xff, 0xff, 0xe7, 0x69, 0x97, - 0xc5, 0xc0, 0x05, 0x00, 0x00, + // 653 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0x4d, 0x6f, 0xd3, 0x40, + 0x10, 0x8d, 0x93, 0x34, 0x4d, 0xb6, 0x29, 0x04, 0x53, 0x51, 0xb7, 0x02, 0x13, 0x85, 0x4b, 0xf8, + 0xb2, 0xd5, 0x86, 0x53, 0x6f, 0x94, 0xcf, 0x80, 0x40, 0xc8, 0x15, 0x97, 0x1e, 0xb0, 0x36, 0xf6, + 0xc4, 0x59, 0x61, 0xef, 0x86, 0xdd, 0x4d, 0x95, 0xf4, 0xc8, 0x1d, 0x89, 0xff, 0xc1, 0x85, 0x9f, + 0xd1, 0x63, 0x8f, 0x9c, 0x10, 0x6a, 0x0f, 0xfc, 0x05, 0x8e, 0xc8, 0xeb, 0x75, 0x9a, 0xd2, 0x2f, + 0x04, 0x27, 0x67, 0xde, 0x9b, 0x99, 0xdd, 0x79, 0xf3, 0xb2, 0xe8, 0x5e, 0x38, 0x49, 0x80, 0x0a, + 0xc2, 0xe8, 0x78, 0xb2, 0xeb, 0x4e, 0x03, 0x97, 0xb3, 0x38, 0xc6, 0xc3, 0x61, 0xfe, 0x75, 0x86, + 0x9c, 0x49, 0x66, 0xda, 0xb3, 0xd9, 0xce, 0x34, 0x70, 0x74, 0xd6, 0xea, 0x52, 0xc4, 0x22, 0xa6, + 0x52, 0xdd, 0xf4, 0x57, 0x56, 0xb5, 0x6a, 0x07, 0x4c, 0x24, 0x4c, 0xb8, 0x3d, 0x2c, 0xc0, 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0xb3, 0xba, 0x55, 0xfe, + 0x53, 0xb7, 0x8d, 0xfa, 0xc7, 0x9f, 0x5f, 0xef, 0xe4, 0x63, 0xb7, 0x7e, 0x19, 0xe8, 0x92, 0xce, + 0xdd, 0x1a, 0x25, 0x09, 0xe6, 0x13, 0xf3, 0x3a, 0x3a, 0x9a, 0xfb, 0xe4, 0x7f, 0x68, 0x1b, 0x35, + 0x62, 0x2c, 0x41, 0x48, 0xe5, 0xd6, 0x2e, 0x0d, 0x61, 0xac, 0xd4, 0x5a, 0x58, 0x77, 0x2e, 0xba, + 0x93, 0xae, 0xe8, 0x33, 0x55, 0xe5, 0x9d, 0xe8, 0x63, 0xc6, 0x68, 0x25, 0xc3, 0x9e, 0x12, 0x8a, + 0x63, 0xb2, 0x0b, 0xe1, 0xcc, 0x21, 0xa5, 0x7f, 0x3a, 0xe4, 0xec, 0x86, 0x9b, 0xaf, 0xf7, 0x0e, + 0x6c, 0x63, 0xff, 0xc0, 0x36, 0x7e, 0x1c, 0xd8, 0xc6, 0xe7, 0x43, 0xbb, 0xb0, 0x7f, 0x68, 0x17, + 0xbe, 0x1d, 0xda, 0x85, 0xed, 0x07, 0x11, 0x91, 0x83, 0x51, 0xcf, 0x09, 0x58, 0x72, 0xd6, 0x3b, + 0xb8, 0xd3, 0x71, 0xc7, 0xd3, 0xb7, 0x4d, 0x4e, 0x86, 0x20, 0x7a, 0x15, 0xf5, 0xb2, 0x75, 0x7e, + 0x07, 0x00, 0x00, 0xff, 0xff, 0xef, 0xa9, 0xe0, 0xe8, 0xd8, 0x05, 0x00, 0x00, } func (m *RollappGenesisState) Marshal() (dAtA []byte, err error) { @@ -480,6 +489,16 @@ func (m *Rollapp) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.Sealed { + i-- + if m.Sealed { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x60 + } if m.Metadata != nil { { size, err := m.Metadata.MarshalToSizedBuffer(dAtA[:i]) @@ -769,6 +788,9 @@ func (m *Rollapp) Size() (n int) { l = m.Metadata.Size() n += 1 + l + sovRollapp(uint64(l)) } + if m.Sealed { + n += 2 + } return n } @@ -1276,6 +1298,26 @@ func (m *Rollapp) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 12: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Sealed", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRollapp + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Sealed = bool(v != 0) default: iNdEx = preIndex skippy, err := skipRollapp(dAtA[iNdEx:]) diff --git a/x/sequencer/client/cli/query.go b/x/sequencer/client/cli/query.go index 05503d05c..e8583f215 100644 --- a/x/sequencer/client/cli/query.go +++ b/x/sequencer/client/cli/query.go @@ -2,13 +2,9 @@ package cli import ( "fmt" - // "strings" - - "github.com/spf13/cobra" "github.com/cosmos/cosmos-sdk/client" - // "github.com/cosmos/cosmos-sdk/client/flags" - // sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/spf13/cobra" "github.com/dymensionxyz/dymension/v3/x/sequencer/types" ) @@ -28,7 +24,6 @@ func GetQueryCmd(queryRoute string) *cobra.Command { cmd.AddCommand(CmdListSequencer()) cmd.AddCommand(CmdShowSequencer()) cmd.AddCommand(CmdShowSequencersByRollapp()) - // this line is used by starport scaffolding # 1 return cmd } diff --git a/x/sequencer/client/cli/query_params.go b/x/sequencer/client/cli/query_params.go index 6178bea71..f69293b74 100644 --- a/x/sequencer/client/cli/query_params.go +++ b/x/sequencer/client/cli/query_params.go @@ -5,8 +5,9 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/dymensionxyz/dymension/v3/x/sequencer/types" "github.com/spf13/cobra" + + "github.com/dymensionxyz/dymension/v3/x/sequencer/types" ) func CmdQueryParams() *cobra.Command { diff --git a/x/sequencer/client/cli/query_sequencer.go b/x/sequencer/client/cli/query_sequencer.go index 54b677746..0a2f1e818 100644 --- a/x/sequencer/client/cli/query_sequencer.go +++ b/x/sequencer/client/cli/query_sequencer.go @@ -5,8 +5,9 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/dymensionxyz/dymension/v3/x/sequencer/types" "github.com/spf13/cobra" + + "github.com/dymensionxyz/dymension/v3/x/sequencer/types" ) func CmdListSequencer() *cobra.Command { diff --git a/x/sequencer/client/cli/query_sequencers_by_rollapp.go b/x/sequencer/client/cli/query_sequencers_by_rollapp.go index a8c298f6b..4fa180599 100644 --- a/x/sequencer/client/cli/query_sequencers_by_rollapp.go +++ b/x/sequencer/client/cli/query_sequencers_by_rollapp.go @@ -5,8 +5,9 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/dymensionxyz/dymension/v3/x/sequencer/types" "github.com/spf13/cobra" + + "github.com/dymensionxyz/dymension/v3/x/sequencer/types" ) func CmdShowSequencersByRollapp() *cobra.Command { diff --git a/x/sequencer/client/cli/tx.go b/x/sequencer/client/cli/tx.go index 488afd739..a6919d334 100644 --- a/x/sequencer/client/cli/tx.go +++ b/x/sequencer/client/cli/tx.go @@ -3,25 +3,15 @@ package cli import ( "encoding/json" "fmt" - "strconv" - "time" - - "github.com/spf13/cobra" "github.com/cosmos/cosmos-sdk/client" - - "github.com/dymensionxyz/dymension/v3/x/sequencer/types" - "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" -) + "github.com/spf13/cobra" -var ( - DefaultRelativePacketTimeoutTimestamp = uint64((time.Duration(10) * time.Minute).Nanoseconds()) - _ = strconv.Itoa(0) + "github.com/dymensionxyz/dymension/v3/x/sequencer/types" ) // GetTxCmd returns the transaction commands for this module @@ -35,26 +25,27 @@ func GetTxCmd() *cobra.Command { } cmd.AddCommand(CmdCreateSequencer()) + cmd.AddCommand(CmdUpdateSequencer()) cmd.AddCommand(CmdUnbond()) - // this line is used by starport scaffolding # 1 return cmd } func CmdCreateSequencer() *cobra.Command { cmd := &cobra.Command{ - Use: "create-sequencer [pubkey] [rollapp-id] [description] [bond]", + Use: "create-sequencer [pubkey] [rollapp-id] [metadata] [bond]", Short: "Create a new sequencer for a rollapp", Args: cobra.ExactArgs(4), RunE: func(cmd *cobra.Command, args []string) (err error) { argPubkey := args[0] argRollappId := args[1] bond := args[3] - argDescription := new(types.Description) - err = json.Unmarshal([]byte(args[2]), argDescription) + argMetadata := types.SequencerMetadata{} + err = json.Unmarshal([]byte(args[2]), &argMetadata) if err != nil { return err } + clientCtx, err := client.GetClientTxContext(cmd) if err != nil { return err @@ -62,7 +53,7 @@ func CmdCreateSequencer() *cobra.Command { var pk cryptotypes.PubKey - if err := clientCtx.Codec.UnmarshalInterfaceJSON([]byte(argPubkey), &pk); err != nil { + if err = clientCtx.Codec.UnmarshalInterfaceJSON([]byte(argPubkey), &pk); err != nil { return err } @@ -75,7 +66,7 @@ func CmdCreateSequencer() *cobra.Command { clientCtx.GetFromAddress().String(), pk, argRollappId, - argDescription, + argMetadata, bondCoin, ) if err != nil { @@ -91,6 +82,42 @@ func CmdCreateSequencer() *cobra.Command { return cmd } +func CmdUpdateSequencer() *cobra.Command { + cmd := &cobra.Command{ + Use: "update-sequencer [rollapp-id] [metadata]", + Short: "Update a sequencer", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) (err error) { + argRollappId := args[0] + argMetadata := types.SequencerMetadata{} + + if err = json.Unmarshal([]byte(args[2]), &argMetadata); err != nil { + return err + } + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg, err := types.NewMsgUpdateSequencerInformation( + clientCtx.GetFromAddress().String(), + argRollappId, + argMetadata, + ) + if err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + func CmdUnbond() *cobra.Command { cmd := &cobra.Command{ Use: "unbond", diff --git a/x/sequencer/genesis_test.go b/x/sequencer/genesis_test.go index 0522f5f3c..a640f5002 100644 --- a/x/sequencer/genesis_test.go +++ b/x/sequencer/genesis_test.go @@ -4,11 +4,12 @@ import ( "testing" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + keepertest "github.com/dymensionxyz/dymension/v3/testutil/keeper" "github.com/dymensionxyz/dymension/v3/testutil/nullify" "github.com/dymensionxyz/dymension/v3/x/sequencer" "github.com/dymensionxyz/dymension/v3/x/sequencer/types" - "github.com/stretchr/testify/require" ) func TestInitGenesis(t *testing.T) { @@ -17,13 +18,13 @@ func TestInitGenesis(t *testing.T) { SequencerList: []types.Sequencer{ { - SequencerAddress: "0", - Status: types.Bonded, - Proposer: true, + Address: "0", + Status: types.Bonded, + Proposer: true, }, { - SequencerAddress: "1", - Status: types.Bonded, + Address: "1", + Status: types.Bonded, }, }, // this line is used by starport scaffolding # genesis/test/state @@ -48,13 +49,13 @@ func TestExportGenesis(t *testing.T) { } sequencerList := []types.Sequencer{ { - SequencerAddress: "0", - Status: types.Bonded, - Proposer: true, + Address: "0", + Status: types.Bonded, + Proposer: true, }, { - SequencerAddress: "1", - Status: types.Bonded, + Address: "1", + Status: types.Bonded, }, } k, ctx := keepertest.SequencerKeeper(t) diff --git a/x/sequencer/handler.go b/x/sequencer/handler.go index 9b042b16c..740e0102e 100644 --- a/x/sequencer/handler.go +++ b/x/sequencer/handler.go @@ -5,6 +5,7 @@ import ( errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/dymensionxyz/dymension/v3/x/sequencer/keeper" "github.com/dymensionxyz/dymension/v3/x/sequencer/types" ) @@ -20,6 +21,9 @@ func NewHandler(k keeper.Keeper) sdk.Handler { case *types.MsgCreateSequencer: res, err := msgServer.CreateSequencer(sdk.WrapSDKContext(ctx), msg) return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgUpdateSequencerInformation: + res, err := msgServer.UpdateSequencerInformation(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) case *types.MsgUnbond: res, err := msgServer.Unbond(sdk.WrapSDKContext(ctx), msg) return sdk.WrapServiceResult(ctx, res, err) diff --git a/x/sequencer/keeper/grpc_query_params.go b/x/sequencer/keeper/grpc_query_params.go index 53f90b1b3..06a79511f 100644 --- a/x/sequencer/keeper/grpc_query_params.go +++ b/x/sequencer/keeper/grpc_query_params.go @@ -4,9 +4,10 @@ import ( "context" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/dymensionxyz/dymension/v3/x/sequencer/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + + "github.com/dymensionxyz/dymension/v3/x/sequencer/types" ) func (k Keeper) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { diff --git a/x/sequencer/keeper/grpc_query_params_test.go b/x/sequencer/keeper/grpc_query_params_test.go index 4331d7f34..f1ce68fdc 100644 --- a/x/sequencer/keeper/grpc_query_params_test.go +++ b/x/sequencer/keeper/grpc_query_params_test.go @@ -4,9 +4,10 @@ import ( "testing" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + testkeeper "github.com/dymensionxyz/dymension/v3/testutil/keeper" "github.com/dymensionxyz/dymension/v3/x/sequencer/types" - "github.com/stretchr/testify/require" ) func TestParamsQuery(t *testing.T) { diff --git a/x/sequencer/keeper/grpc_query_sequencer.go b/x/sequencer/keeper/grpc_query_sequencer.go index 7bdf30a0d..0480ce187 100644 --- a/x/sequencer/keeper/grpc_query_sequencer.go +++ b/x/sequencer/keeper/grpc_query_sequencer.go @@ -6,9 +6,10 @@ import ( "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" - "github.com/dymensionxyz/dymension/v3/x/sequencer/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + + "github.com/dymensionxyz/dymension/v3/x/sequencer/types" ) func (k Keeper) Sequencers(c context.Context, req *types.QuerySequencersRequest) (*types.QuerySequencersResponse, error) { diff --git a/x/sequencer/keeper/grpc_query_sequencer_test.go b/x/sequencer/keeper/grpc_query_sequencer_test.go index cd0abb75a..de4ef0579 100644 --- a/x/sequencer/keeper/grpc_query_sequencer_test.go +++ b/x/sequencer/keeper/grpc_query_sequencer_test.go @@ -28,7 +28,7 @@ func TestSequencerQuerySingle(t *testing.T) { { desc: "First", request: &types.QueryGetSequencerRequest{ - SequencerAddress: sequencers[0].SequencerAddress, + SequencerAddress: sequencers[0].Address, }, response: &types.QueryGetSequencerResponse{ Sequencer: sequencers[0], @@ -37,7 +37,7 @@ func TestSequencerQuerySingle(t *testing.T) { { desc: "Second", request: &types.QueryGetSequencerRequest{ - SequencerAddress: sequencers[1].SequencerAddress, + SequencerAddress: sequencers[1].Address, }, response: &types.QueryGetSequencerResponse{ Sequencer: sequencers[1], diff --git a/x/sequencer/keeper/grpc_query_sequencers_by_rollapp.go b/x/sequencer/keeper/grpc_query_sequencers_by_rollapp.go index 82a0a9dd2..cc61e7ef9 100644 --- a/x/sequencer/keeper/grpc_query_sequencers_by_rollapp.go +++ b/x/sequencer/keeper/grpc_query_sequencers_by_rollapp.go @@ -4,9 +4,10 @@ import ( "context" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/dymensionxyz/dymension/v3/x/sequencer/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + + "github.com/dymensionxyz/dymension/v3/x/sequencer/types" ) func (k Keeper) SequencersByRollapp(c context.Context, req *types.QueryGetSequencersByRollappRequest) (*types.QueryGetSequencersByRollappResponse, error) { diff --git a/x/sequencer/keeper/grpc_query_sequencers_by_rollapp_test.go b/x/sequencer/keeper/grpc_query_sequencers_by_rollapp_test.go index 79dfaf170..58d0ecdd6 100644 --- a/x/sequencer/keeper/grpc_query_sequencers_by_rollapp_test.go +++ b/x/sequencer/keeper/grpc_query_sequencers_by_rollapp_test.go @@ -4,6 +4,7 @@ import ( "strconv" "testing" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/stretchr/testify/require" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -16,25 +17,27 @@ import ( func (suite *SequencerTestSuite) TestSequencersByRollappQuery3() { suite.SetupTest() - rollappId := suite.CreateDefaultRollapp() - rollappId2 := suite.CreateDefaultRollapp() + rollappId, pk11 := suite.CreateDefaultRollapp() + pk12 := ed25519.GenPrivKey().PubKey() + rollappId2, pk21 := suite.CreateDefaultRollapp() + pk22 := ed25519.GenPrivKey().PubKey() // create 2 sequencer - addr1_1 := suite.CreateDefaultSequencer(suite.Ctx, rollappId) - addr2_1 := suite.CreateDefaultSequencer(suite.Ctx, rollappId) - seq1, found := suite.App.SequencerKeeper.GetSequencer(suite.Ctx, addr1_1) + addr11 := suite.CreateDefaultSequencer(suite.Ctx, rollappId, pk11) + addr21 := suite.CreateDefaultSequencer(suite.Ctx, rollappId, pk12) + seq1, found := suite.App.SequencerKeeper.GetSequencer(suite.Ctx, addr11) require.True(suite.T(), found) - seq2, found := suite.App.SequencerKeeper.GetSequencer(suite.Ctx, addr2_1) + seq2, found := suite.App.SequencerKeeper.GetSequencer(suite.Ctx, addr21) require.True(suite.T(), found) seq1Response := types.QueryGetSequencersByRollappResponse{ Sequencers: []types.Sequencer{seq1, seq2}, } - addr1_2 := suite.CreateDefaultSequencer(suite.Ctx, rollappId2) - addr2_2 := suite.CreateDefaultSequencer(suite.Ctx, rollappId2) - seq3, found := suite.App.SequencerKeeper.GetSequencer(suite.Ctx, addr1_2) + addr12 := suite.CreateDefaultSequencer(suite.Ctx, rollappId2, pk21) + addr22 := suite.CreateDefaultSequencer(suite.Ctx, rollappId2, pk22) + seq3, found := suite.App.SequencerKeeper.GetSequencer(suite.Ctx, addr12) require.True(suite.T(), found) - seq4, found := suite.App.SequencerKeeper.GetSequencer(suite.Ctx, addr2_2) + seq4, found := suite.App.SequencerKeeper.GetSequencer(suite.Ctx, addr22) require.True(suite.T(), found) seq2Response := types.QueryGetSequencersByRollappResponse{ Sequencers: []types.Sequencer{seq3, seq4}, @@ -92,19 +95,21 @@ func (suite *SequencerTestSuite) TestSequencersByRollappByStatusQuery() { msgserver := keeper.NewMsgServerImpl(suite.App.SequencerKeeper) - rollappId := suite.CreateDefaultRollapp() + rollappId, pk11 := suite.CreateDefaultRollapp() + pk12 := ed25519.GenPrivKey().PubKey() // create 2 sequencers on rollapp1 - addr1_1 := suite.CreateDefaultSequencer(suite.Ctx, rollappId) - addr2_1 := suite.CreateDefaultSequencer(suite.Ctx, rollappId) + addr11 := suite.CreateDefaultSequencer(suite.Ctx, rollappId, pk11) + addr21 := suite.CreateDefaultSequencer(suite.Ctx, rollappId, pk12) _, err := msgserver.Unbond(suite.Ctx, &types.MsgUnbond{ - Creator: addr2_1, + Creator: addr21, }) require.NoError(suite.T(), err) // create 2 sequencers on rollapp2 - rollappId2 := suite.CreateDefaultRollapp() - addr1_2 := suite.CreateDefaultSequencer(suite.Ctx, rollappId2) - addr2_2 := suite.CreateDefaultSequencer(suite.Ctx, rollappId2) + rollappId2, pk21 := suite.CreateDefaultRollapp() + pk22 := ed25519.GenPrivKey().PubKey() + addr12 := suite.CreateDefaultSequencer(suite.Ctx, rollappId2, pk21) + addr22 := suite.CreateDefaultSequencer(suite.Ctx, rollappId2, pk22) for _, tc := range []struct { desc string @@ -118,7 +123,7 @@ func (suite *SequencerTestSuite) TestSequencersByRollappByStatusQuery() { RollappId: rollappId, Status: types.Bonded, }, - response_addr: []string{addr1_1}, + response_addr: []string{addr11}, }, { desc: "First - Unbonding", @@ -126,7 +131,7 @@ func (suite *SequencerTestSuite) TestSequencersByRollappByStatusQuery() { RollappId: rollappId, Status: types.Unbonding, }, - response_addr: []string{addr2_1}, + response_addr: []string{addr21}, }, { desc: "First - Unbonded", @@ -142,7 +147,7 @@ func (suite *SequencerTestSuite) TestSequencersByRollappByStatusQuery() { RollappId: rollappId2, Status: types.Bonded, }, - response_addr: []string{addr1_2, addr2_2}, + response_addr: []string{addr12, addr22}, }, { desc: "KeyNotFound", diff --git a/x/sequencer/keeper/hook_listener.go b/x/sequencer/keeper/hook_listener.go index 8e17d2426..8e751f77f 100644 --- a/x/sequencer/keeper/hook_listener.go +++ b/x/sequencer/keeper/hook_listener.go @@ -2,6 +2,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" + rollapptypes "github.com/dymensionxyz/dymension/v3/x/rollapp/types" "github.com/dymensionxyz/dymension/v3/x/sequencer/types" ) @@ -58,7 +59,7 @@ func (hook rollappHook) FraudSubmitted(ctx sdk.Context, rollappID string, height // unbond all other bonded sequencers sequencers := hook.k.GetSequencersByRollappByStatus(ctx, rollappID, types.Bonded) for _, sequencer := range sequencers { - err := hook.k.forceUnbondSequencer(ctx, sequencer.SequencerAddress) + err := hook.k.forceUnbondSequencer(ctx, sequencer.Address) if err != nil { return err } diff --git a/x/sequencer/keeper/hooks_test.go b/x/sequencer/keeper/hooks_test.go index 5e468de50..d1c952ac1 100644 --- a/x/sequencer/keeper/hooks_test.go +++ b/x/sequencer/keeper/hooks_test.go @@ -3,6 +3,8 @@ package keeper_test import ( "time" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + "github.com/dymensionxyz/dymension/v3/x/sequencer/types" ) @@ -13,14 +15,17 @@ func (suite *SequencerTestSuite) TestFraudSubmittedHook() { keeper := suite.App.SequencerKeeper - rollappId := suite.CreateDefaultRollapp() + rollappId, pk := suite.CreateDefaultRollapp() numOfSequencers := 5 // create 5 sequencers for rollapp1 seqAddrs := make([]string, numOfSequencers) - for i := 0; i < numOfSequencers; i++ { - seqAddrs[i] = suite.CreateDefaultSequencer(suite.Ctx, rollappId) + seqAddrs[0] = suite.CreateDefaultSequencer(suite.Ctx, rollappId, pk) + + for i := 1; i < numOfSequencers; i++ { + pki := ed25519.GenPrivKey().PubKey() + seqAddrs[i] = suite.CreateDefaultSequencer(suite.Ctx, rollappId, pki) } proposer := seqAddrs[0] diff --git a/x/sequencer/keeper/invariants_test.go b/x/sequencer/keeper/invariants_test.go index dcb805602..5729df2e3 100644 --- a/x/sequencer/keeper/invariants_test.go +++ b/x/sequencer/keeper/invariants_test.go @@ -3,6 +3,8 @@ package keeper_test import ( "time" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + "github.com/dymensionxyz/dymension/v3/x/sequencer/keeper" "github.com/dymensionxyz/dymension/v3/x/sequencer/types" ) @@ -17,12 +19,14 @@ func (suite *SequencerTestSuite) TestInvariants() { // create rollapps and sequencers for i := 0; i < numOfRollapps; i++ { - rollapp := suite.CreateDefaultRollapp() + rollapp, pk := suite.CreateDefaultRollapp() // create sequencers seqAddr := make([]string, numOfSequencers) - for j := 0; j < numOfSequencers; j++ { - seqAddr[j] = suite.CreateDefaultSequencer(suite.Ctx, rollapp) + seqAddr[0] = suite.CreateDefaultSequencer(suite.Ctx, rollapp, pk) + for j := 1; j < numOfSequencers; j++ { + pki := ed25519.GenPrivKey().PubKey() + seqAddr[j] = suite.CreateDefaultSequencer(suite.Ctx, rollapp, pki) } // unbonding some sequencers @@ -46,7 +50,7 @@ func (suite *SequencerTestSuite) TestInvariants() { suite.T().Fatal("Test setup failed") } // additional rollapp with no sequencers - _ = suite.CreateDefaultRollapp() + suite.CreateDefaultRollapp() msg, ok := keeper.AllInvariants(suite.App.SequencerKeeper)(suite.Ctx) suite.Require().False(ok, msg) diff --git a/x/sequencer/keeper/keeper.go b/x/sequencer/keeper/keeper.go index e44ba9b60..7a6b8de97 100644 --- a/x/sequencer/keeper/keeper.go +++ b/x/sequencer/keeper/keeper.go @@ -5,9 +5,8 @@ import ( "github.com/cometbft/cometbft/libs/log" - storetypes "github.com/cosmos/cosmos-sdk/store/types" - "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" @@ -38,17 +37,14 @@ func NewKeeper( ps = ps.WithKeyTable(types.ParamKeyTable()) } - k := &Keeper{ - cdc: cdc, - storeKey: storeKey, - memKey: memKey, - paramstore: ps, - bankKeeper: bankKeeper, + return &Keeper{ + cdc: cdc, + storeKey: storeKey, + memKey: memKey, + paramstore: ps, + bankKeeper: bankKeeper, + rollappKeeper: rollappKeeper, } - rollappKeeper.SetSequencerKeeper(k) - k.rollappKeeper = rollappKeeper - - return k } func (k Keeper) Logger(ctx sdk.Context) log.Logger { diff --git a/x/sequencer/keeper/msg_server_create_sequencer.go b/x/sequencer/keeper/msg_server_create_sequencer.go index 80bd1828e..be127980f 100644 --- a/x/sequencer/keeper/msg_server_create_sequencer.go +++ b/x/sequencer/keeper/msg_server_create_sequencer.go @@ -14,8 +14,8 @@ import ( func (k msgServer) CreateSequencer(goCtx context.Context, msg *types.MsgCreateSequencer) (*types.MsgCreateSequencerResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - if msg.DymintPubKey == nil { - return nil, errorsmod.Wrapf(types.ErrInvalidPubKey, "sequencer pubkey can not be empty") + if err := msg.ValidateBasic(); err != nil { + return nil, errorsmod.Wrapf(types.ErrInvalidRequest, "validate basic: %v", err) } // check to see if the sequencer has been registered before @@ -28,19 +28,30 @@ func (k msgServer) CreateSequencer(goCtx context.Context, msg *types.MsgCreateSe if !found { return nil, types.ErrUnknownRollappID } + if rollapp.Frozen { return nil, types.ErrRollappJailed } - // check to see if the sequencer has enough balance and deduct the bond - seqAcc, err := sdk.AccAddressFromBech32(msg.Creator) - if err != nil { - return nil, err + // Only the initial sequencer can be the first to register, and is automatically selected as the first proposer, + // allowing the Rollapp to be sealed (provided that all the immutable fields are set in the Rollapp). + // This limitation prevents scenarios such as: + // a) any non-initial sequencer getting registered before the immutable fields are set in the Rollapp. + // b) situation when sequencer "X" is registered prior to the initial sequencer, + // after which the initial sequencer's address is set to sequencer X's address, effectively preventing: + // 1. the initial sequencer from getting selected as the first proposer, + // 2. the rollapp from getting sealed + isInitial := msg.Creator == rollapp.InitialSequencerAddress + if isInitial { + if err := k.rollappKeeper.SealRollapp(ctx, msg.RollappId); err != nil { + return nil, err + } + } else if !rollapp.Sealed { + return nil, types.ErrRollappNotSealed } bond := sdk.Coins{} - minBond := k.GetParams(ctx).MinBond - if !minBond.IsNil() && !minBond.IsZero() { + if minBond := k.GetParams(ctx).MinBond; !(minBond.IsNil() || minBond.IsZero()) { if msg.Bond.Denom != minBond.Denom { return nil, errorsmod.Wrapf( types.ErrInvalidCoinDenom, "got %s, expected %s", msg.Bond.Denom, minBond.Denom, @@ -53,7 +64,8 @@ func (k msgServer) CreateSequencer(goCtx context.Context, msg *types.MsgCreateSe ) } - err = k.bankKeeper.SendCoinsFromAccountToModule(ctx, seqAcc, types.ModuleName, sdk.NewCoins(msg.Bond)) + seqAcc, _ := sdk.AccAddressFromBech32(msg.Creator) + err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, seqAcc, types.ModuleName, sdk.NewCoins(msg.Bond)) if err != nil { return nil, err } @@ -61,20 +73,13 @@ func (k msgServer) CreateSequencer(goCtx context.Context, msg *types.MsgCreateSe } sequencer := types.Sequencer{ - SequencerAddress: msg.Creator, - DymintPubKey: msg.DymintPubKey, - RollappId: msg.RollappId, - Description: msg.Description, - Status: types.Bonded, - Proposer: false, - Tokens: bond, - } - - bondedSequencers := k.GetSequencersByRollappByStatus(ctx, msg.RollappId, types.Bonded) - - // this is the first sequencer, make it a PROPOSER - if len(bondedSequencers) == 0 { - sequencer.Proposer = true + Address: msg.Creator, + DymintPubKey: msg.DymintPubKey, + RollappId: msg.RollappId, + Metadata: msg.Metadata, + Status: types.Bonded, + Proposer: isInitial, + Tokens: bond, } k.SetSequencer(ctx, sequencer) diff --git a/x/sequencer/keeper/msg_server_create_sequencer_test.go b/x/sequencer/keeper/msg_server_create_sequencer_test.go index d926c3496..0c9ecd7c5 100644 --- a/x/sequencer/keeper/msg_server_create_sequencer_test.go +++ b/x/sequencer/keeper/msg_server_create_sequencer_test.go @@ -2,9 +2,10 @@ package keeper_test import ( "fmt" + "reflect" codectypes "github.com/cosmos/cosmos-sdk/codec/types" - "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" bankutil "github.com/cosmos/cosmos-sdk/x/bank/testutil" @@ -21,9 +22,6 @@ const ( var bond = types.DefaultParams().MinBond func (suite *SequencerTestSuite) TestMinBond() { - suite.SetupTest() - rollappId := suite.CreateDefaultRollapp() - testCases := []struct { name string requiredBond sdk.Coin @@ -57,27 +55,28 @@ func (suite *SequencerTestSuite) TestMinBond() { } for _, tc := range testCases { + suite.SetupTest() seqParams := types.Params{ MinBond: tc.requiredBond, UnbondingTime: 100, } suite.App.SequencerKeeper.SetParams(suite.Ctx, seqParams) - pubkey1 := secp256k1.GenPrivKey().PubKey() - addr1 := sdk.AccAddress(pubkey1.Address()) - pkAny1, err := codectypes.NewAnyWithValue(pubkey1) - suite.Require().Nil(err) + rollappId, pk := suite.CreateDefaultRollapp() // fund account - err = bankutil.FundAccount(suite.App.BankKeeper, suite.Ctx, addr1, sdk.NewCoins(tc.bond)) + addr := sdk.AccAddress(pk.Address()) + pkAny, err := codectypes.NewAnyWithValue(pk) + suite.Require().Nil(err) + err = bankutil.FundAccount(suite.App.BankKeeper, suite.Ctx, addr, sdk.NewCoins(tc.bond)) suite.Require().Nil(err) sequencerMsg1 := types.MsgCreateSequencer{ - Creator: addr1.String(), - DymintPubKey: pkAny1, + Creator: addr.String(), + DymintPubKey: pkAny, Bond: bond, RollappId: rollappId, - Description: types.Description{}, + Metadata: types.SequencerMetadata{}, } _, err = suite.msgServer.CreateSequencer(suite.Ctx, &sequencerMsg1) if tc.expectedError != nil { @@ -85,7 +84,7 @@ func (suite *SequencerTestSuite) TestMinBond() { suite.Require().ErrorAs(err, &tc.expectedError, tc.name) } else { suite.Require().NoError(err) - sequencer, found := suite.App.SequencerKeeper.GetSequencer(suite.Ctx, addr1.String()) + sequencer, found := suite.App.SequencerKeeper.GetSequencer(suite.Ctx, addr.String()) suite.Require().True(found, tc.name) if tc.requiredBond.IsNil() { suite.Require().True(sequencer.Tokens.IsZero(), tc.name) @@ -117,6 +116,7 @@ func (suite *SequencerTestSuite) TestCreateSequencer() { Bech32Prefix: bech32Prefix, GenesisChecksum: "1234567890abcdefg", Alias: "Rollapp", + Sealed: true, Metadata: &rollapptypes.RollappMetadata{ Website: "https://dymension.xyz", Description: "Sample description", @@ -131,7 +131,7 @@ func (suite *SequencerTestSuite) TestCreateSequencer() { rollappId := rollapp.GetRollappId() for i := 0; i < 10; i++ { - pubkey := secp256k1.GenPrivKey().PubKey() + pubkey := ed25519.GenPrivKey().PubKey() addr := sdk.AccAddress(pubkey.Address()) err := bankutil.FundAccount(suite.App.BankKeeper, suite.Ctx, addr, sdk.NewCoins(bond)) suite.Require().NoError(err) @@ -144,16 +144,16 @@ func (suite *SequencerTestSuite) TestCreateSequencer() { DymintPubKey: pkAny, Bond: bond, RollappId: rollappId, - Description: types.Description{}, + Metadata: types.SequencerMetadata{}, } // sequencerExpect is the expected result of creating a sequencer sequencerExpect := types.Sequencer{ - SequencerAddress: sequencerMsg.GetCreator(), - DymintPubKey: sequencerMsg.GetDymintPubKey(), - Status: types.Bonded, - RollappId: rollappId, - Tokens: sdk.NewCoins(bond), - Description: sequencerMsg.GetDescription(), + Address: sequencerMsg.GetCreator(), + DymintPubKey: sequencerMsg.GetDymintPubKey(), + Status: types.Bonded, + RollappId: rollappId, + Tokens: sdk.NewCoins(bond), + Metadata: sequencerMsg.GetMetadata(), } if i == 0 { sequencerExpect.Status = types.Bonded @@ -169,7 +169,7 @@ func (suite *SequencerTestSuite) TestCreateSequencer() { SequencerAddress: sequencerMsg.GetCreator(), }) suite.Require().Nil(err) - equalSequencer(suite, &sequencerExpect, &queryResponse.Sequencer) + suite.equalSequencer(&sequencerExpect, &queryResponse.Sequencer) // add the sequencer to the list of get all expected list sequencersExpect = append(sequencersExpect, &sequencerExpect) @@ -177,10 +177,10 @@ func (suite *SequencerTestSuite) TestCreateSequencer() { sequencersRes, totalRes := getAll(suite) suite.Require().EqualValues(len(sequencersExpect), totalRes) // verify that query all contains all the sequencers that were created - verifyAll(suite, sequencersExpect, sequencersRes) + suite.verifyAll(sequencersExpect, sequencersRes) // add the sequencer to the list of spesific rollapp - rollappSequencersExpect[rollappSequencersExpectKey{rollappId, sequencerExpect.SequencerAddress}] = sequencerExpect.SequencerAddress + rollappSequencersExpect[rollappSequencersExpectKey{rollappId, sequencerExpect.Address}] = sequencerExpect.Address } } @@ -193,34 +193,32 @@ func (suite *SequencerTestSuite) TestCreateSequencer() { suite.Require().Nil(err) // verify that all the addresses of the rollapp are found for _, sequencer := range queryAllResponse.Sequencers { - suite.Require().EqualValues(rollappSequencersExpect[rollappSequencersExpectKey{rollappId, sequencer.SequencerAddress}], - sequencer.SequencerAddress) + suite.Require().EqualValues(rollappSequencersExpect[rollappSequencersExpectKey{rollappId, sequencer.Address}], + sequencer.Address) } totalFound += len(queryAllResponse.Sequencers) } suite.Require().EqualValues(totalFound, len(rollappSequencersExpect)) } -// TODO: test with different sequencer status func (suite *SequencerTestSuite) TestCreateSequencerAlreadyExists() { suite.SetupTest() goCtx := sdk.WrapSDKContext(suite.Ctx) - rollappId := suite.CreateDefaultRollapp() + rollappId, pk := suite.CreateDefaultRollapp() + addr := sdk.AccAddress(pk.Address()) - pubkey := secp256k1.GenPrivKey().PubKey() - addr := sdk.AccAddress(pubkey.Address()) err := bankutil.FundAccount(suite.App.BankKeeper, suite.Ctx, addr, sdk.NewCoins(bond)) suite.Require().NoError(err) - pkAny, err := codectypes.NewAnyWithValue(pubkey) + pkAny, err := codectypes.NewAnyWithValue(pk) suite.Require().Nil(err) sequencerMsg := types.MsgCreateSequencer{ Creator: addr.String(), DymintPubKey: pkAny, Bond: bond, RollappId: rollappId, - Description: types.Description{}, + Metadata: types.SequencerMetadata{}, } _, err = suite.msgServer.CreateSequencer(goCtx, &sequencerMsg) suite.Require().Nil(err) @@ -229,11 +227,72 @@ func (suite *SequencerTestSuite) TestCreateSequencerAlreadyExists() { suite.EqualError(err, types.ErrSequencerExists.Error()) } +func (suite *SequencerTestSuite) TestCreateSequencerInitialSequencerAsFirstProposer() { + suite.SetupTest() + goCtx := sdk.WrapSDKContext(suite.Ctx) + + // 1. create rollapp with immutable fields set + rollappId, initSeqPubkey := suite.CreateDefaultRollapp() + initSeqAddr := sdk.AccAddress(initSeqPubkey.Address()) + + err := bankutil.FundAccount(suite.App.BankKeeper, suite.Ctx, initSeqAddr, sdk.NewCoins(bond)) + suite.Require().NoError(err) + + // 2. try to create sequencer - not initial rollapp's sequencer; fails as rollapp is not sealed + pubkey := ed25519.GenPrivKey().PubKey() + addr := sdk.AccAddress(pubkey.Address()) + err = bankutil.FundAccount(suite.App.BankKeeper, suite.Ctx, addr, sdk.NewCoins(bond)) + suite.Require().NoError(err) + pkAny, err := codectypes.NewAnyWithValue(pubkey) + suite.Require().NoError(err) + + _, err = suite.msgServer.CreateSequencer(goCtx, &types.MsgCreateSequencer{ + Creator: addr.String(), + DymintPubKey: pkAny, + Bond: bond, + RollappId: rollappId, + Metadata: types.SequencerMetadata{}, + }) + suite.Require().ErrorIs(err, types.ErrRollappNotSealed) + + // 3. create initial sequencer + initSeqPKAny, err := codectypes.NewAnyWithValue(initSeqPubkey) + suite.Require().NoError(err) + _, err = suite.msgServer.CreateSequencer(goCtx, &types.MsgCreateSequencer{ + Creator: initSeqAddr.String(), + DymintPubKey: initSeqPKAny, + Bond: bond, + RollappId: rollappId, + Metadata: types.SequencerMetadata{}, + }) + suite.Require().NoError(err) + + // 4. create sequencer - not initial rollapp's sequencer; passes as rollapp is sealed + _, err = suite.msgServer.CreateSequencer(goCtx, &types.MsgCreateSequencer{ + Creator: addr.String(), + DymintPubKey: pkAny, + Bond: bond, + RollappId: rollappId, + Metadata: types.SequencerMetadata{}, + }) + suite.Require().NoError(err) + + // check that the initial sequencer is the proposer + initSequencer, ok := suite.App.SequencerKeeper.GetSequencer(suite.Ctx, initSeqAddr.String()) + suite.Require().True(ok) + suite.Require().True(initSequencer.Proposer) + + // check that the second sequencer is not the proposer + sequencer, ok := suite.App.SequencerKeeper.GetSequencer(suite.Ctx, addr.String()) + suite.Require().True(ok) + suite.Require().False(sequencer.Proposer) +} + func (suite *SequencerTestSuite) TestCreateSequencerUnknownRollappId() { suite.SetupTest() goCtx := sdk.WrapSDKContext(suite.Ctx) - pubkey := secp256k1.GenPrivKey().PubKey() + pubkey := ed25519.GenPrivKey().PubKey() addr := sdk.AccAddress(pubkey.Address()) err := bankutil.FundAccount(suite.App.BankKeeper, suite.Ctx, addr, sdk.NewCoins(bond)) suite.Require().NoError(err) @@ -245,7 +304,7 @@ func (suite *SequencerTestSuite) TestCreateSequencerUnknownRollappId() { DymintPubKey: pkAny, Bond: bond, RollappId: "rollappId", - Description: types.Description{}, + Metadata: types.SequencerMetadata{}, } _, err = suite.msgServer.CreateSequencer(goCtx, &sequencerMsg) @@ -255,13 +314,14 @@ func (suite *SequencerTestSuite) TestCreateSequencerUnknownRollappId() { func (suite *SequencerTestSuite) TestUpdateStateSecondSeqErrNotActiveSequencer() { suite.SetupTest() - rollappId := suite.CreateDefaultRollapp() + rollappId, pk1 := suite.CreateDefaultRollapp() // create first sequencer - addr1 := suite.CreateDefaultSequencer(suite.Ctx, rollappId) + addr1 := suite.CreateDefaultSequencer(suite.Ctx, rollappId, pk1) + pk2 := ed25519.GenPrivKey().PubKey() // create second sequencer - addr2 := suite.CreateDefaultSequencer(suite.Ctx, rollappId) + addr2 := suite.CreateDefaultSequencer(suite.Ctx, rollappId, pk2) // check scheduler operating status scheduler, found := suite.App.SequencerKeeper.GetSequencer(suite.Ctx, addr1) @@ -279,13 +339,13 @@ func (suite *SequencerTestSuite) TestUpdateStateSecondSeqErrNotActiveSequencer() // --------------------------------------- // verifyAll receives a list of expected results and a map of sequencerAddress->sequencer // the function verifies that the map contains all the sequencers that are in the list and only them -func verifyAll(suite *SequencerTestSuite, sequencersExpect []*types.Sequencer, sequencersRes map[string]*types.Sequencer) { +func (suite *SequencerTestSuite) verifyAll(sequencersExpect []*types.Sequencer, sequencersRes map[string]*types.Sequencer) { // check number of items are equal suite.Require().EqualValues(len(sequencersExpect), len(sequencersRes)) for i := 0; i < len(sequencersExpect); i++ { sequencerExpect := sequencersExpect[i] - sequencerRes := sequencersRes[sequencerExpect.GetSequencerAddress()] - equalSequencer(suite, sequencerExpect, sequencerRes) + sequencerRes := sequencersRes[sequencerExpect.GetAddress()] + suite.equalSequencer(sequencerExpect, sequencerRes) } } @@ -315,7 +375,7 @@ func getAll(suite *SequencerTestSuite) (map[string]*types.Sequencer, int) { for i := 0; i < len(queryAllResponse.Sequencers); i++ { sequencerRes := queryAllResponse.Sequencers[i] - sequencersRes[sequencerRes.GetSequencerAddress()] = &sequencerRes + sequencersRes[sequencerRes.GetAddress()] = &sequencerRes } totalChecked += len(queryAllResponse.Sequencers) nextKey = queryAllResponse.GetPagination().GetNextKey() @@ -329,13 +389,13 @@ func getAll(suite *SequencerTestSuite) (map[string]*types.Sequencer, int) { } // equalSequencer receives two sequencers and compares them. If there they not equal, fails the test -func equalSequencer(suite *SequencerTestSuite, s1 *types.Sequencer, s2 *types.Sequencer) { - eq := CompareSequencers(s1, s2) +func (suite *SequencerTestSuite) equalSequencer(s1 *types.Sequencer, s2 *types.Sequencer) { + eq := compareSequencers(s1, s2) suite.Require().True(eq, "expected: %v\nfound: %v", *s1, *s2) } -func CompareSequencers(s1, s2 *types.Sequencer) bool { - if s1.SequencerAddress != s2.SequencerAddress { +func compareSequencers(s1, s2 *types.Sequencer) bool { + if s1.Address != s2.Address { return false } @@ -365,5 +425,9 @@ func CompareSequencers(s1, s2 *types.Sequencer) bool { if !s1.UnbondTime.Equal(s2.UnbondTime) { return false } + + if !reflect.DeepEqual(s1.Metadata, s2.Metadata) { + return false + } return true } diff --git a/x/sequencer/keeper/msg_server_unbond.go b/x/sequencer/keeper/msg_server_unbond.go index e35008513..b6a2ed5ce 100644 --- a/x/sequencer/keeper/msg_server_unbond.go +++ b/x/sequencer/keeper/msg_server_unbond.go @@ -4,9 +4,9 @@ import ( "context" "time" + errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" - errorsmod "cosmossdk.io/errors" "github.com/dymensionxyz/dymension/v3/x/sequencer/types" ) diff --git a/x/sequencer/keeper/msg_server_unbond_test.go b/x/sequencer/keeper/msg_server_unbond_test.go index f5e2eb3f9..c4502d7f0 100644 --- a/x/sequencer/keeper/msg_server_unbond_test.go +++ b/x/sequencer/keeper/msg_server_unbond_test.go @@ -4,17 +4,20 @@ import ( "sort" "time" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + "github.com/dymensionxyz/dymension/v3/x/sequencer/types" ) func (suite *SequencerTestSuite) TestUnbondingStatusChange() { suite.SetupTest() - rollappId := suite.CreateDefaultRollapp() + rollappId, pk1 := suite.CreateDefaultRollapp() - addr1 := suite.CreateDefaultSequencer(suite.Ctx, rollappId) + addr1 := suite.CreateDefaultSequencer(suite.Ctx, rollappId, pk1) seqAddrs := make([]string, 2) - seqAddrs[0] = suite.CreateDefaultSequencer(suite.Ctx, rollappId) - seqAddrs[1] = suite.CreateDefaultSequencer(suite.Ctx, rollappId) + pk2, pk3 := ed25519.GenPrivKey().PubKey(), ed25519.GenPrivKey().PubKey() + seqAddrs[0] = suite.CreateDefaultSequencer(suite.Ctx, rollappId, pk2) + seqAddrs[1] = suite.CreateDefaultSequencer(suite.Ctx, rollappId, pk3) // sort the non proposer sequencers by address sort.Strings(seqAddrs) addr2 := seqAddrs[0] @@ -74,8 +77,8 @@ func (suite *SequencerTestSuite) TestUnbondingStatusChange() { func (suite *SequencerTestSuite) TestUnbondingNotBondedSequencer() { suite.SetupTest() - rollappId := suite.CreateDefaultRollapp() - addr1 := suite.CreateDefaultSequencer(suite.Ctx, rollappId) + rollappId, pk1 := suite.CreateDefaultRollapp() + addr1 := suite.CreateDefaultSequencer(suite.Ctx, rollappId, pk1) unbondMsg := types.MsgUnbond{Creator: addr1} _, err := suite.msgServer.Unbond(suite.Ctx, &unbondMsg) diff --git a/x/sequencer/keeper/msg_server_update_sequencer.go b/x/sequencer/keeper/msg_server_update_sequencer.go new file mode 100644 index 000000000..f3905495a --- /dev/null +++ b/x/sequencer/keeper/msg_server_update_sequencer.go @@ -0,0 +1,48 @@ +package keeper + +import ( + "context" + "fmt" + + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/dymensionxyz/dymension/v3/x/sequencer/types" +) + +// UpdateSequencerInformation defines a method for creating a new sequencer +func (k msgServer) UpdateSequencerInformation(goCtx context.Context, msg *types.MsgUpdateSequencerInformation) (*types.MsgUpdateSequencerInformationResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + if err := msg.ValidateBasic(); err != nil { + return nil, errorsmod.Wrapf(types.ErrInvalidRequest, "validate basic: %v", err) + } + + sequencer, found := k.GetSequencer(ctx, msg.Creator) + if !found { + return nil, types.ErrUnknownSequencer + } + + if sequencer.Jailed { + return nil, types.ErrSequencerJailed + } + + rollapp, found := k.rollappKeeper.GetRollapp(ctx, msg.RollappId) + if !found { + return nil, types.ErrUnknownRollappID + } + + if rollapp.Frozen { + return nil, types.ErrRollappJailed + } + + sequencer.Metadata = msg.Metadata + + k.SetSequencer(ctx, sequencer) + + if err := ctx.EventManager().EmitTypedEvent(&sequencer); err != nil { + return nil, fmt.Errorf("emit event: %w", err) + } + + return &types.MsgUpdateSequencerInformationResponse{}, nil +} diff --git a/x/sequencer/keeper/msg_server_update_sequencer_test.go b/x/sequencer/keeper/msg_server_update_sequencer_test.go new file mode 100644 index 000000000..f6aca7667 --- /dev/null +++ b/x/sequencer/keeper/msg_server_update_sequencer_test.go @@ -0,0 +1,173 @@ +package keeper_test + +import ( + "time" + + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/dymensionxyz/sdk-utils/utils/uptr" + + rollapptypes "github.com/dymensionxyz/dymension/v3/x/rollapp/types" + "github.com/dymensionxyz/dymension/v3/x/sequencer/types" +) + +func (suite *SequencerTestSuite) TestUpdateSequencer() { + pubkey := ed25519.GenPrivKey().PubKey() + addr := sdk.AccAddress(pubkey.Address()) + pkAny, err := codectypes.NewAnyWithValue(pubkey) + suite.Require().Nil(err) + + tests := []struct { + name string + update *types.MsgUpdateSequencerInformation + malleate func(sequencer types.Sequencer) types.Sequencer + expError error + expSequencer types.Sequencer + }{ + { + name: "Update sequencer: success", + update: &types.MsgUpdateSequencerInformation{ + Creator: addr.String(), + RollappId: "rollapp_1234-1", + Metadata: types.SequencerMetadata{ + Moniker: "Sequencer", + Details: "Details and such", + P2PSeeds: []string{"seed1", "seed2"}, + Rpcs: []string{"rpc1", "rpc2"}, + EvmRpcs: []string{"evm1", "evm2"}, + RestApiUrl: "rest1", + GenesisUrls: []string{"genesis1", "genesis2"}, + ExplorerUrl: "explorer", + ContactDetails: &types.ContactDetails{ + Website: "https://dymension.xyz", + Telegram: "rolly", + X: "rolly", + }, + ExtraData: []byte("extra"), + Snapshots: []*types.SnapshotInfo{ + { + SnapshotUrl: "snapshot", + Height: 1234, + Checksum: "checksum", + }, + }, + GasPrice: uptr.To(sdk.NewInt(100)), + }, + }, + expError: nil, + expSequencer: types.Sequencer{ + Address: addr.String(), + DymintPubKey: pkAny, + RollappId: "rollapp_1234-1", + Metadata: types.SequencerMetadata{ + Moniker: "Sequencer", + Details: "Details and such", + P2PSeeds: []string{"seed1", "seed2"}, + Rpcs: []string{"rpc1", "rpc2"}, + EvmRpcs: []string{"evm1", "evm2"}, + RestApiUrl: "rest1", + GenesisUrls: []string{"genesis1", "genesis2"}, + ExplorerUrl: "explorer", + ContactDetails: &types.ContactDetails{ + Website: "https://dymension.xyz", + Telegram: "rolly", + X: "rolly", + }, + ExtraData: []byte("extra"), + Snapshots: []*types.SnapshotInfo{ + { + SnapshotUrl: "snapshot", + Height: 1234, + Checksum: "checksum", + }, + }, + GasPrice: uptr.To(sdk.NewInt(100)), + }, + Jailed: false, + Proposer: false, + Status: 0, + Tokens: nil, + UnbondingHeight: 0, + UnbondTime: time.Time{}, + }, + }, { + name: "Update rollapp: fail - try to update a non-existing rollapp", + update: &types.MsgUpdateSequencerInformation{ + Creator: addr.String(), + RollappId: "somerollapp_1235-1", + }, + expError: types.ErrUnknownRollappID, + }, { + name: "Update rollapp: fail - try to update a frozen rollapp", + update: &types.MsgUpdateSequencerInformation{ + Creator: addr.String(), + RollappId: "rollapp_1235-1", + }, + malleate: func(r types.Sequencer) types.Sequencer { + suite.App.RollappKeeper.SetRollapp(suite.Ctx, rollapptypes.Rollapp{ + RollappId: "rollapp_1235-1", + Frozen: true, + }) + return r + }, + expError: types.ErrRollappJailed, + }, { + name: "Update rollapp: fail - try to update a jailed sequencer", + update: &types.MsgUpdateSequencerInformation{ + Creator: addr.String(), + RollappId: "rollapp_1234-1", + }, + malleate: func(r types.Sequencer) types.Sequencer { + r.Jailed = true + return r + }, + expError: types.ErrSequencerJailed, + }, + } + + for _, tc := range tests { + suite.Run(tc.name, func() { + suite.SetupTest() + + goCtx := sdk.WrapSDKContext(suite.Ctx) + rollapp := rollapptypes.Rollapp{ + RollappId: "rollapp_1234-1", + Creator: addr.String(), + InitialSequencerAddress: addr.String(), + } + + suite.App.RollappKeeper.SetRollapp(suite.Ctx, rollapp) + + sequencer := types.Sequencer{ + Address: addr.String(), + DymintPubKey: pkAny, + RollappId: "rollapp_1234-1", + Metadata: types.SequencerMetadata{}, + Jailed: false, + Proposer: false, + Status: 0, + Tokens: nil, + UnbondingHeight: 0, + UnbondTime: time.Time{}, + } + + if tc.malleate != nil { + sequencer = tc.malleate(sequencer) + } + + suite.App.RollappKeeper.SetRollapp(suite.Ctx, rollapp) + suite.App.SequencerKeeper.SetSequencer(suite.Ctx, sequencer) + + _, err = suite.msgServer.UpdateSequencerInformation(goCtx, tc.update) + if tc.expError == nil { + suite.Require().NoError(err) + resp, err := suite.queryClient.Sequencer(goCtx, &types.QueryGetSequencerRequest{SequencerAddress: tc.update.Creator}) + suite.Require().NoError(err) + suite.equalSequencer(&tc.expSequencer, &resp.Sequencer) + } else { + suite.ErrorIs(err, tc.expError) + } + }) + } +} diff --git a/x/sequencer/keeper/params.go b/x/sequencer/keeper/params.go index 5fbc749ac..9dd0c7dac 100644 --- a/x/sequencer/keeper/params.go +++ b/x/sequencer/keeper/params.go @@ -4,6 +4,7 @@ import ( "time" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/dymensionxyz/dymension/v3/x/sequencer/types" ) diff --git a/x/sequencer/keeper/params_test.go b/x/sequencer/keeper/params_test.go index 5cdc22e98..a4c91708c 100644 --- a/x/sequencer/keeper/params_test.go +++ b/x/sequencer/keeper/params_test.go @@ -4,9 +4,10 @@ import ( "testing" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + testkeeper "github.com/dymensionxyz/dymension/v3/testutil/keeper" "github.com/dymensionxyz/dymension/v3/x/sequencer/types" - "github.com/stretchr/testify/require" ) func TestGetParams(t *testing.T) { diff --git a/x/sequencer/keeper/sequencer.go b/x/sequencer/keeper/sequencer.go index b3037708a..6057d8d14 100644 --- a/x/sequencer/keeper/sequencer.go +++ b/x/sequencer/keeper/sequencer.go @@ -15,10 +15,10 @@ func (k Keeper) SetSequencer(ctx sdk.Context, sequencer types.Sequencer) { store := ctx.KVStore(k.storeKey) b := k.cdc.MustMarshal(&sequencer) store.Set(types.SequencerKey( - sequencer.SequencerAddress, + sequencer.Address, ), b) - seqByRollappKey := types.SequencerByRollappByStatusKey(sequencer.RollappId, sequencer.SequencerAddress, sequencer.Status) + seqByRollappKey := types.SequencerByRollappByStatusKey(sequencer.RollappId, sequencer.Address, sequencer.Status) store.Set(seqByRollappKey, b) // To support InitGenesis scenario @@ -30,14 +30,14 @@ func (k Keeper) SetSequencer(ctx sdk.Context, sequencer types.Sequencer) { func (k Keeper) UpdateSequencer(ctx sdk.Context, sequencer types.Sequencer, oldStatus types.OperatingStatus) { store := ctx.KVStore(k.storeKey) b := k.cdc.MustMarshal(&sequencer) - store.Set(types.SequencerKey(sequencer.SequencerAddress), b) + store.Set(types.SequencerKey(sequencer.Address), b) - seqByRollappKey := types.SequencerByRollappByStatusKey(sequencer.RollappId, sequencer.SequencerAddress, sequencer.Status) + seqByRollappKey := types.SequencerByRollappByStatusKey(sequencer.RollappId, sequencer.Address, sequencer.Status) store.Set(seqByRollappKey, b) // status changed, need to remove old status key if sequencer.Status != oldStatus { - oldKey := types.SequencerByRollappByStatusKey(sequencer.RollappId, sequencer.SequencerAddress, oldStatus) + oldKey := types.SequencerByRollappByStatusKey(sequencer.RollappId, sequencer.Address, oldStatus) store.Delete(oldKey) } } @@ -70,7 +70,7 @@ func (k Keeper) RotateProposer(ctx sdk.Context, rollappId string) { sdk.NewEvent( types.EventTypeProposerRotated, sdk.NewAttribute(types.AttributeKeyRollappId, rollappId), - sdk.NewAttribute(types.AttributeKeySequencer, seq.SequencerAddress), + sdk.NewAttribute(types.AttributeKeySequencer, seq.Address), ), ) } @@ -89,9 +89,19 @@ func (k Keeper) GetSequencer(ctx sdk.Context, sequencerAddress string) (val type return val, true } -func (k Keeper) IsSequencerBonded(ctx sdk.Context, address string) bool { - seq, found := k.GetSequencer(ctx, address) - return found && seq.IsBonded() +func (k Keeper) GetSequencerByRollappByStatus(ctx sdk.Context, rollappId, seqAddress string, status types.OperatingStatus) (val types.Sequencer, found bool) { + store := ctx.KVStore(k.storeKey) + b := store.Get(types.SequencerByRollappByStatusKey( + rollappId, + seqAddress, + status, + )) + if b == nil { + return val, false + } + + k.cdc.MustUnmarshal(b, &val) + return val, true } // GetAllSequencers returns all sequencer @@ -167,13 +177,13 @@ func (k Keeper) setUnbondingSequencerQueue(ctx sdk.Context, sequencer types.Sequ store := ctx.KVStore(k.storeKey) b := k.cdc.MustMarshal(&sequencer) - unbondingQueueKey := types.UnbondingSequencerKey(sequencer.SequencerAddress, sequencer.UnbondTime) + unbondingQueueKey := types.UnbondingSequencerKey(sequencer.Address, sequencer.UnbondTime) store.Set(unbondingQueueKey, b) } // remove unbonding sequencer from the queue func (k Keeper) removeUnbondingSequencer(ctx sdk.Context, sequencer types.Sequencer) { store := ctx.KVStore(k.storeKey) - unbondingQueueKey := types.UnbondingSequencerKey(sequencer.SequencerAddress, sequencer.UnbondTime) + unbondingQueueKey := types.UnbondingSequencerKey(sequencer.Address, sequencer.UnbondTime) store.Delete(unbondingQueueKey) } diff --git a/x/sequencer/keeper/sequencer_suite_test.go b/x/sequencer/keeper/sequencer_suite_test.go index a0f13ad24..e747a154b 100644 --- a/x/sequencer/keeper/sequencer_suite_test.go +++ b/x/sequencer/keeper/sequencer_suite_test.go @@ -3,22 +3,20 @@ package keeper_test import ( "testing" - "github.com/dymensionxyz/dymension/v3/app/apptesting" - rollapptypes "github.com/dymensionxyz/dymension/v3/x/rollapp/types" - "github.com/dymensionxyz/dymension/v3/x/sequencer/keeper" - "github.com/dymensionxyz/dymension/v3/x/sequencer/types" - - bankutil "github.com/cosmos/cosmos-sdk/x/bank/testutil" - + "github.com/cometbft/cometbft/libs/rand" + cometbftproto "github.com/cometbft/cometbft/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/baseapp" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" + bankutil "github.com/cosmos/cosmos-sdk/x/bank/testutil" "github.com/stretchr/testify/suite" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" - - "github.com/cometbft/cometbft/libs/rand" - cometbftproto "github.com/cometbft/cometbft/proto/tendermint/types" + "github.com/dymensionxyz/dymension/v3/app/apptesting" + rollapptypes "github.com/dymensionxyz/dymension/v3/x/rollapp/types" + "github.com/dymensionxyz/dymension/v3/x/sequencer/keeper" + "github.com/dymensionxyz/dymension/v3/x/sequencer/types" ) type SequencerTestSuite struct { @@ -45,37 +43,42 @@ func (suite *SequencerTestSuite) SetupTest() { suite.queryClient = queryClient } -func (suite *SequencerTestSuite) CreateDefaultRollapp() string { +func (suite *SequencerTestSuite) CreateDefaultRollapp() (string, cryptotypes.PubKey) { + pubkey := ed25519.GenPrivKey().PubKey() + addr := sdk.AccAddress(pubkey.Address()) + rollapp := rollapptypes.Rollapp{ - RollappId: rand.Str(8), - Creator: alice, + RollappId: rand.Str(8), + Creator: addr.String(), + GenesisChecksum: "checksum", + InitialSequencerAddress: addr.String(), + Alias: "alias", } suite.App.RollappKeeper.SetRollapp(suite.Ctx, rollapp) - return rollapp.GetRollappId() + return rollapp.GetRollappId(), pubkey } -func (suite *SequencerTestSuite) CreateDefaultSequencer(ctx sdk.Context, rollappId string) string { - return suite.CreateSequencerWithBond(ctx, rollappId, bond) +func (suite *SequencerTestSuite) CreateDefaultSequencer(ctx sdk.Context, rollappId string, pk cryptotypes.PubKey) string { + return suite.CreateSequencerWithBond(ctx, rollappId, bond, pk) } -func (suite *SequencerTestSuite) CreateSequencerWithBond(ctx sdk.Context, rollappId string, bond sdk.Coin) string { - pubkey1 := secp256k1.GenPrivKey().PubKey() - addr1 := sdk.AccAddress(pubkey1.Address()) - pkAny1, err := codectypes.NewAnyWithValue(pubkey1) +func (suite *SequencerTestSuite) CreateSequencerWithBond(ctx sdk.Context, rollappId string, bond sdk.Coin, pk cryptotypes.PubKey) string { + pkAny, err := codectypes.NewAnyWithValue(pk) suite.Require().Nil(err) + addr := sdk.AccAddress(pk.Address()) // fund account - err = bankutil.FundAccount(suite.App.BankKeeper, ctx, addr1, sdk.NewCoins(bond)) + err = bankutil.FundAccount(suite.App.BankKeeper, ctx, addr, sdk.NewCoins(bond)) suite.Require().Nil(err) sequencerMsg1 := types.MsgCreateSequencer{ - Creator: addr1.String(), - DymintPubKey: pkAny1, + Creator: addr.String(), + DymintPubKey: pkAny, Bond: bond, RollappId: rollappId, - Description: types.Description{}, + Metadata: types.SequencerMetadata{}, } _, err = suite.msgServer.CreateSequencer(ctx, &sequencerMsg1) suite.Require().Nil(err) - return addr1.String() + return addr.String() } diff --git a/x/sequencer/keeper/sequencer_test.go b/x/sequencer/keeper/sequencer_test.go index 1e2ffe875..ac3585f4d 100644 --- a/x/sequencer/keeper/sequencer_test.go +++ b/x/sequencer/keeper/sequencer_test.go @@ -4,12 +4,14 @@ import ( "strconv" "testing" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + keepertest "github.com/dymensionxyz/dymension/v3/testutil/keeper" "github.com/dymensionxyz/dymension/v3/testutil/nullify" "github.com/dymensionxyz/dymension/v3/x/sequencer/keeper" "github.com/dymensionxyz/dymension/v3/x/sequencer/types" - "github.com/stretchr/testify/require" ) // Prevent strconv unused error @@ -19,8 +21,8 @@ func createNSequencer(keeper *keeper.Keeper, ctx sdk.Context, n int) []types.Seq items := make([]types.Sequencer, n) for i := range items { seq := types.Sequencer{ - SequencerAddress: strconv.Itoa(i), - Status: types.Bonded, + Address: strconv.Itoa(i), + Status: types.Bonded, } items[i] = seq @@ -35,7 +37,7 @@ func TestSequencerGet(t *testing.T) { for _, item := range items { item := item rst, found := keeper.GetSequencer(ctx, - item.SequencerAddress, + item.Address, ) require.True(t, found) require.Equal(t, @@ -46,18 +48,18 @@ func TestSequencerGet(t *testing.T) { } func TestSequencerGetAll(t *testing.T) { - keeper, ctx := keepertest.SequencerKeeper(t) - items := createNSequencer(keeper, ctx, 10) + k, ctx := keepertest.SequencerKeeper(t) + items := createNSequencer(k, ctx, 10) require.ElementsMatch(t, nullify.Fill(items), - nullify.Fill(keeper.GetAllSequencers(ctx)), + nullify.Fill(k.GetAllSequencers(ctx)), ) } func TestSequencersByRollappGet(t *testing.T) { - keeper, ctx := keepertest.SequencerKeeper(t) - items := createNSequencer(keeper, ctx, 10) - rst := keeper.GetSequencersByRollapp(ctx, + k, ctx := keepertest.SequencerKeeper(t) + items := createNSequencer(k, ctx, 10) + rst := k.GetSequencersByRollapp(ctx, items[0].RollappId, ) @@ -70,17 +72,19 @@ func TestSequencersByRollappGet(t *testing.T) { func (suite *SequencerTestSuite) TestRotatingSequencerByBond() { suite.SetupTest() - rollappId := suite.CreateDefaultRollapp() + rollappId, pk := suite.CreateDefaultRollapp() numOfSequencers := 5 // create sequencers seqAddrs := make([]string, numOfSequencers) - for j := 0; j < len(seqAddrs)-1; j++ { - seqAddrs[j] = suite.CreateDefaultSequencer(suite.Ctx, rollappId) + seqAddrs[0] = suite.CreateDefaultSequencer(suite.Ctx, rollappId, pk) + for j := 1; j < len(seqAddrs)-1; j++ { + seqAddrs[j] = suite.CreateDefaultSequencer(suite.Ctx, rollappId, ed25519.GenPrivKey().PubKey()) } // last one with high bond is the expected new proposer - seqAddrs[len(seqAddrs)-1] = suite.CreateSequencerWithBond(suite.Ctx, rollappId, sdk.NewCoin(bond.Denom, bond.Amount.MulRaw(2))) + pkx := ed25519.GenPrivKey().PubKey() + seqAddrs[len(seqAddrs)-1] = suite.CreateSequencerWithBond(suite.Ctx, rollappId, sdk.NewCoin(bond.Denom, bond.Amount.MulRaw(2)), pkx) expecetedProposer := seqAddrs[len(seqAddrs)-1] // check starting proposer and unbond diff --git a/x/sequencer/keeper/slashing.go b/x/sequencer/keeper/slashing.go index f7833da2f..f23ae73c9 100644 --- a/x/sequencer/keeper/slashing.go +++ b/x/sequencer/keeper/slashing.go @@ -3,6 +3,7 @@ package keeper import ( errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/dymensionxyz/dymension/v3/x/sequencer/types" ) @@ -28,7 +29,7 @@ func (k Keeper) Slashing(ctx sdk.Context, seqAddr string) error { return err } } else { - k.Logger(ctx).Error("sequencer has no tokens to slash", "sequencer", seq.SequencerAddress) + k.Logger(ctx).Error("sequencer has no tokens to slash", "sequencer", seq.Address) } seq.Tokens = sdk.Coins{} diff --git a/x/sequencer/keeper/slashing_test.go b/x/sequencer/keeper/slashing_test.go index 87f68e4b0..961f8e7bc 100644 --- a/x/sequencer/keeper/slashing_test.go +++ b/x/sequencer/keeper/slashing_test.go @@ -3,7 +3,9 @@ package keeper_test import ( "time" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/dymensionxyz/dymension/v3/x/sequencer/types" ) @@ -16,14 +18,14 @@ func (suite *SequencerTestSuite) assertSlashed(seqAddr string) { sequencers := suite.App.SequencerKeeper.GetMatureUnbondingSequencers(suite.Ctx, suite.Ctx.BlockTime()) for _, s := range sequencers { - suite.NotEqual(s.SequencerAddress, seqAddr) + suite.NotEqual(s.Address, seqAddr) } } func (suite *SequencerTestSuite) TestSlashingUnknownSequencer() { suite.SetupTest() - _ = suite.CreateDefaultRollapp() + suite.CreateDefaultRollapp() keeper := suite.App.SequencerKeeper err := keeper.Slashing(suite.Ctx, "unknown_sequencer") @@ -34,8 +36,8 @@ func (suite *SequencerTestSuite) TestSlashingUnbondedSequencer() { suite.SetupTest() keeper := suite.App.SequencerKeeper - rollappId := suite.CreateDefaultRollapp() - seqAddr := suite.CreateDefaultSequencer(suite.Ctx, rollappId) + rollappId, pk := suite.CreateDefaultRollapp() + seqAddr := suite.CreateDefaultSequencer(suite.Ctx, rollappId, pk) suite.Ctx = suite.Ctx.WithBlockHeight(20) suite.Ctx = suite.Ctx.WithBlockTime(time.Now()) @@ -50,7 +52,7 @@ func (suite *SequencerTestSuite) TestSlashingUnbondedSequencer() { seq, found := keeper.GetSequencer(suite.Ctx, seqAddr) suite.Require().True(found) - suite.Equal(seq.SequencerAddress, seqAddr) + suite.Equal(seq.Address, seqAddr) suite.Equal(seq.Status, types.Unbonded) err = keeper.Slashing(suite.Ctx, seqAddr) suite.ErrorIs(err, types.ErrInvalidSequencerStatus) @@ -60,8 +62,8 @@ func (suite *SequencerTestSuite) TestSlashingUnbondingSequencer() { suite.SetupTest() keeper := suite.App.SequencerKeeper - rollappId := suite.CreateDefaultRollapp() - seqAddr := suite.CreateDefaultSequencer(suite.Ctx, rollappId) + rollappId, pk := suite.CreateDefaultRollapp() + seqAddr := suite.CreateDefaultSequencer(suite.Ctx, rollappId, pk) suite.Ctx = suite.Ctx.WithBlockHeight(20) suite.Ctx = suite.Ctx.WithBlockTime(time.Now()) @@ -83,9 +85,10 @@ func (suite *SequencerTestSuite) TestSlashingPropserSequencer() { suite.SetupTest() keeper := suite.App.SequencerKeeper - rollappId := suite.CreateDefaultRollapp() - seqAddr := suite.CreateDefaultSequencer(suite.Ctx, rollappId) - seqAddr2 := suite.CreateDefaultSequencer(suite.Ctx, rollappId) + rollappId, pk1 := suite.CreateDefaultRollapp() + pk2 := ed25519.GenPrivKey().PubKey() + seqAddr := suite.CreateDefaultSequencer(suite.Ctx, rollappId, pk1) + seqAddr2 := suite.CreateDefaultSequencer(suite.Ctx, rollappId, pk2) suite.Ctx = suite.Ctx.WithBlockHeight(20) suite.Ctx = suite.Ctx.WithBlockTime(time.Now()) diff --git a/x/sequencer/keeper/unbond.go b/x/sequencer/keeper/unbond.go index e1b3daea0..64bb13868 100644 --- a/x/sequencer/keeper/unbond.go +++ b/x/sequencer/keeper/unbond.go @@ -5,8 +5,9 @@ import ( errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/dymensionxyz/dymension/v3/x/sequencer/types" "github.com/osmosis-labs/osmosis/v15/osmoutils" + + "github.com/dymensionxyz/dymension/v3/x/sequencer/types" ) // UnbondAllMatureSequencers unbonds all the mature unbonding sequencers that @@ -15,11 +16,11 @@ func (k Keeper) UnbondAllMatureSequencers(ctx sdk.Context, currTime time.Time) { sequencers := k.GetMatureUnbondingSequencers(ctx, currTime) for _, seq := range sequencers { wrapFn := func(ctx sdk.Context) error { - return k.unbondUnbondingSequencer(ctx, seq.SequencerAddress) + return k.unbondUnbondingSequencer(ctx, seq.Address) } err := osmoutils.ApplyFuncIfNoError(ctx, wrapFn) if err != nil { - k.Logger(ctx).Error("unbond sequencer", "error", err, "sequencer", seq.SequencerAddress) + k.Logger(ctx).Error("unbond sequencer", "error", err, "sequencer", seq.Address) continue } } @@ -42,7 +43,7 @@ func (k Keeper) forceUnbondSequencer(ctx sdk.Context, seqAddr string) error { seqTokens := seq.Tokens if !seqTokens.Empty() { - seqAcc, err := sdk.AccAddressFromBech32(seq.SequencerAddress) + seqAcc, err := sdk.AccAddressFromBech32(seq.Address) if err != nil { return err } @@ -52,7 +53,7 @@ func (k Keeper) forceUnbondSequencer(ctx sdk.Context, seqAddr string) error { return err } } else { - k.Logger(ctx).Error("sequencer has no tokens to unbond", "sequencer", seq.SequencerAddress) + k.Logger(ctx).Error("sequencer has no tokens to unbond", "sequencer", seq.Address) } // set the status to unbonded and remove from the unbonding queue if needed @@ -93,7 +94,7 @@ func (k Keeper) unbondUnbondingSequencer(ctx sdk.Context, seqAddr string) error } seqTokens := seq.Tokens if !seqTokens.Empty() { - seqAcc, err := sdk.AccAddressFromBech32(seq.SequencerAddress) + seqAcc, err := sdk.AccAddressFromBech32(seq.Address) if err != nil { return err } @@ -103,7 +104,7 @@ func (k Keeper) unbondUnbondingSequencer(ctx sdk.Context, seqAddr string) error return err } } else { - k.Logger(ctx).Error("sequencer has no tokens to unbond", "sequencer", seq.SequencerAddress) + k.Logger(ctx).Error("sequencer has no tokens to unbond", "sequencer", seq.Address) } // set the status to unbonded and remove from the unbonding queue diff --git a/x/sequencer/keeper/unbond_test.go b/x/sequencer/keeper/unbond_test.go index c930bc32d..3c8406ea2 100644 --- a/x/sequencer/keeper/unbond_test.go +++ b/x/sequencer/keeper/unbond_test.go @@ -3,7 +3,9 @@ package keeper_test import ( "time" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/dymensionxyz/dymension/v3/x/sequencer/types" ) @@ -14,8 +16,8 @@ func (suite *SequencerTestSuite) TestUnbondingMultiple() { keeper := suite.App.SequencerKeeper - rollappId := suite.CreateDefaultRollapp() - rollappId2 := suite.CreateDefaultRollapp() + rollappId, pk1 := suite.CreateDefaultRollapp() + rollappId2, pk2 := suite.CreateDefaultRollapp() numOfSequencers := 5 numOfSequencers2 := 3 @@ -25,13 +27,15 @@ func (suite *SequencerTestSuite) TestUnbondingMultiple() { seqAddr2 := make([]string, numOfSequencers2) // create 5 sequencers for rollapp1 - for i := 0; i < numOfSequencers; i++ { - seqAddr1[i] = suite.CreateDefaultSequencer(suite.Ctx, rollappId) + seqAddr1[0] = suite.CreateDefaultSequencer(suite.Ctx, rollappId, pk1) + for i := 1; i < numOfSequencers; i++ { + seqAddr1[i] = suite.CreateDefaultSequencer(suite.Ctx, rollappId, ed25519.GenPrivKey().PubKey()) } // create 3 sequencers for rollapp2 - for i := 0; i < numOfSequencers2; i++ { - seqAddr2[i] = suite.CreateDefaultSequencer(suite.Ctx, rollappId2) + seqAddr2[0] = suite.CreateDefaultSequencer(suite.Ctx, rollappId2, pk2) + for i := 1; i < numOfSequencers2; i++ { + seqAddr2[i] = suite.CreateDefaultSequencer(suite.Ctx, rollappId2, ed25519.GenPrivKey().PubKey()) } // start unbonding for 2 sequencers in each rollapp @@ -67,15 +71,16 @@ func (suite *SequencerTestSuite) TestTokensRefundOnUnbond() { blockheight := 20 var err error - rollappId := suite.CreateDefaultRollapp() - addr1 := suite.CreateDefaultSequencer(suite.Ctx, rollappId) + rollappId, pk1 := suite.CreateDefaultRollapp() + addr1 := suite.CreateDefaultSequencer(suite.Ctx, rollappId, pk1) sequencer1, _ := suite.App.SequencerKeeper.GetSequencer(suite.Ctx, addr1) suite.Require().True(sequencer1.Status == types.Bonded) suite.Require().True(sequencer1.Proposer) suite.Require().False(sequencer1.Tokens.IsZero()) - addr2 := suite.CreateDefaultSequencer(suite.Ctx, rollappId) + pk2 := ed25519.GenPrivKey().PubKey() + addr2 := suite.CreateDefaultSequencer(suite.Ctx, rollappId, pk2) sequencer2, _ := suite.App.SequencerKeeper.GetSequencer(suite.Ctx, addr2) suite.Require().True(sequencer2.Status == types.Bonded) suite.Require().False(sequencer2.Proposer) diff --git a/x/sequencer/module.go b/x/sequencer/module.go index 6b7d5546b..b5e350ed9 100644 --- a/x/sequencer/module.go +++ b/x/sequencer/module.go @@ -5,17 +5,16 @@ import ( "encoding/json" "fmt" - "github.com/gorilla/mux" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/spf13/cobra" - abci "github.com/cometbft/cometbft/abci/types" - "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + "github.com/gorilla/mux" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + "github.com/dymensionxyz/dymension/v3/x/sequencer/client/cli" "github.com/dymensionxyz/dymension/v3/x/sequencer/keeper" "github.com/dymensionxyz/dymension/v3/x/sequencer/types" diff --git a/x/sequencer/module_simulation.go b/x/sequencer/module_simulation.go index 6ddb3ea84..392827fc2 100644 --- a/x/sequencer/module_simulation.go +++ b/x/sequencer/module_simulation.go @@ -8,6 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/simulation" + "github.com/dymensionxyz/dymension/v3/app/params" "github.com/dymensionxyz/dymension/v3/testutil/sample" sequencersimulation "github.com/dymensionxyz/dymension/v3/x/sequencer/simulation" @@ -64,7 +65,7 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp ) operations = append(operations, simulation.NewWeightedOperation( weightMsgCreateSequencer, - sequencersimulation.SimulateMsgCreateSequencer(am.accountKeeper, am.bankKeeper, am.keeper), + sequencersimulation.SimulateMsgCreateSequencer(am.accountKeeper, am.bankKeeper), )) // this line is used by starport scaffolding # simapp/module/operation diff --git a/x/sequencer/simulation/create_sequencer.go b/x/sequencer/simulation/create_sequencer.go index 91f1a24cd..85210ed2a 100644 --- a/x/sequencer/simulation/create_sequencer.go +++ b/x/sequencer/simulation/create_sequencer.go @@ -10,14 +10,12 @@ import ( "github.com/dymensionxyz/dymension/v3/simulation" simulationtypes "github.com/dymensionxyz/dymension/v3/simulation/types" - "github.com/dymensionxyz/dymension/v3/x/sequencer/keeper" "github.com/dymensionxyz/dymension/v3/x/sequencer/types" ) func SimulateMsgCreateSequencer( ak types.AccountKeeper, bk types.BankKeeper, - k keeper.Keeper, ) simtypes.Operation { return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { @@ -43,7 +41,7 @@ func SimulateMsgCreateSequencer( Creator: seqAddress, DymintPubKey: pkAny, RollappId: rollappId, - Description: types.Description{}, + Metadata: types.SequencerMetadata{}, } bExpectedError := bFailNoRollapp diff --git a/x/sequencer/types/codec.go b/x/sequencer/types/codec.go index a89d2df42..16c83ac00 100644 --- a/x/sequencer/types/codec.go +++ b/x/sequencer/types/codec.go @@ -10,7 +10,6 @@ import ( func RegisterCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgCreateSequencer{}, "sequencer/CreateSequencer", nil) cdc.RegisterConcrete(&MsgUnbond{}, "sequencer/Unbond", nil) - // this line is used by starport scaffolding # 2 } func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { @@ -18,8 +17,6 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { &MsgCreateSequencer{}, &MsgUnbond{}, ) - // this line is used by starport scaffolding # 3 - msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } diff --git a/x/sequencer/types/description.go b/x/sequencer/types/description.go deleted file mode 100644 index 5fc868239..000000000 --- a/x/sequencer/types/description.go +++ /dev/null @@ -1,74 +0,0 @@ -package types - -import ( - errorsmod "cosmossdk.io/errors" -) - -// constant for maximum string length of the Description fields -const ( - MaxMonikerLength = 70 - MaxIdentityLength = 3000 - MaxWebsiteLength = 140 - MaxSecurityContactLength = 140 - MaxDetailsLength = 280 -) - -// DoNotModifyDesc constant is used in flags to indicate that description field should not be updated -const DoNotModifyDesc = "[do-not-modify]" - -// UpdateDescription updates the fields of a given description. An error is -// returned if the resulting description contains an invalid length. -func (d Description) UpdateDescription(d2 Description) (Description, error) { - if d2.Moniker == DoNotModifyDesc { - d2.Moniker = d.Moniker - } - - if d2.Identity == DoNotModifyDesc { - d2.Identity = d.Identity - } - - if d2.Website == DoNotModifyDesc { - d2.Website = d.Website - } - - if d2.SecurityContact == DoNotModifyDesc { - d2.SecurityContact = d.SecurityContact - } - - if d2.Details == DoNotModifyDesc { - d2.Details = d.Details - } - - return Description{ - Moniker: d2.Moniker, - Identity: d2.Identity, - Website: d2.Website, - SecurityContact: d2.SecurityContact, - Details: d2.Details, - }.EnsureLength() -} - -// EnsureLength ensures the length of a sequencer's description. -func (d Description) EnsureLength() (Description, error) { - if len(d.Moniker) > MaxMonikerLength { - return d, errorsmod.Wrapf(ErrInvalidRequest, "invalid moniker length; got: %d, max: %d", len(d.Moniker), MaxMonikerLength) - } - - if len(d.Identity) > MaxIdentityLength { - return d, errorsmod.Wrapf(ErrInvalidRequest, "invalid identity length; got: %d, max: %d", len(d.Identity), MaxIdentityLength) - } - - if len(d.Website) > MaxWebsiteLength { - return d, errorsmod.Wrapf(ErrInvalidRequest, "invalid website length; got: %d, max: %d", len(d.Website), MaxWebsiteLength) - } - - if len(d.SecurityContact) > MaxSecurityContactLength { - return d, errorsmod.Wrapf(ErrInvalidRequest, "invalid security contact length; got: %d, max: %d", len(d.SecurityContact), MaxSecurityContactLength) - } - - if len(d.Details) > MaxDetailsLength { - return d, errorsmod.Wrapf(ErrInvalidRequest, "invalid details length; got: %d, max: %d", len(d.Details), MaxDetailsLength) - } - - return d, nil -} diff --git a/x/sequencer/types/errors.go b/x/sequencer/types/errors.go index cce622f1e..59ab85806 100644 --- a/x/sequencer/types/errors.go +++ b/x/sequencer/types/errors.go @@ -4,20 +4,17 @@ package types import ( errorsmod "cosmossdk.io/errors" + "github.com/dymensionxyz/gerr-cosmos/gerrc" ) // x/sequencer module sentinel errors var ( ErrSequencerExists = errorsmod.Register(ModuleName, 1000, "sequencer already exist for this address; must use new sequencer address") - ErrInvalidSequencerAddress = errorsmod.Register(ModuleName, 1001, "invalid sequencer address") ErrUnknownRollappID = errorsmod.Register(ModuleName, 1002, "rollapp does not exist") - ErrMaxSequencersLimit = errorsmod.Register(ModuleName, 1003, "too many sequencers for rollapp") - ErrSequencerNotPermissioned = errorsmod.Register(ModuleName, 1004, "sequencer is not permissioned for serving the rollapp") ErrUnknownSequencer = errorsmod.Register(ModuleName, 1005, "sequencer was not registered") ErrSequencerRollappMismatch = errorsmod.Register(ModuleName, 1006, "sequencer was not registered for this rollapp") ErrNotActiveSequencer = errorsmod.Register(ModuleName, 1007, "sequencer is not active") ErrInvalidSequencerStatus = errorsmod.Register(ModuleName, 1008, "invalid sequencer status") - ErrInvalidSequencerTokens = errorsmod.Register(ModuleName, 1009, "invalid sequencer tokens") ErrInvalidCoinDenom = errorsmod.Register(ModuleName, 1010, "invalid coin denomination") ErrInsufficientBond = errorsmod.Register(ModuleName, 1011, "insufficient bond") ErrRollappJailed = errorsmod.Register(ModuleName, 1012, "rollapp is jailed") @@ -27,4 +24,6 @@ var ( ErrInvalidType = errorsmod.Register(ModuleName, 1016, "invalid type") ErrUnknownRequest = errorsmod.Register(ModuleName, 1017, "unknown request") ErrInvalidRequest = errorsmod.Register(ModuleName, 1018, "invalid request") + ErrSequencerJailed = errorsmod.Wrap(gerrc.ErrFailedPrecondition, "sequencer is jailed") + ErrRollappNotSealed = errorsmod.Wrap(gerrc.ErrFailedPrecondition, "rollapp is not sealed") ) diff --git a/x/sequencer/types/expected_keepers.go b/x/sequencer/types/expected_keepers.go index 114daf590..2b7ed8d35 100644 --- a/x/sequencer/types/expected_keepers.go +++ b/x/sequencer/types/expected_keepers.go @@ -11,13 +11,12 @@ import ( type RollappKeeper interface { GetRollapp(ctx sdk.Context, rollappId string) (val rollapptypes.Rollapp, found bool) GetAllRollapps(ctx sdk.Context) (list []rollapptypes.Rollapp) - SetSequencerKeeper(sequencerKeeper rollapptypes.SequencerKeeper) + SealRollapp(ctx sdk.Context, rollappId string) error } // AccountKeeper defines the expected account keeper used for simulations (noalias) type AccountKeeper interface { GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI - // Methods imported from account should be defined here } // BankKeeper defines the expected interface needed to retrieve account balances. diff --git a/x/sequencer/types/genesis.go b/x/sequencer/types/genesis.go index 060954548..47121dfaf 100644 --- a/x/sequencer/types/genesis.go +++ b/x/sequencer/types/genesis.go @@ -1,6 +1,6 @@ package types -import fmt "fmt" +import "fmt" // DefaultGenesis returns the default Capability genesis state func DefaultGenesis() *GenesisState { @@ -20,7 +20,7 @@ func (gs GenesisState) Validate() error { // FIXME: should run validation on the sequencer objects - index := string(SequencerKey(elem.SequencerAddress)) + index := string(SequencerKey(elem.Address)) if _, ok := sequencerIndexMap[index]; ok { return fmt.Errorf("duplicated index for sequencer") } diff --git a/x/sequencer/types/metadata.go b/x/sequencer/types/metadata.go new file mode 100644 index 000000000..3e5a98d5e --- /dev/null +++ b/x/sequencer/types/metadata.go @@ -0,0 +1,91 @@ +package types + +import errorsmod "cosmossdk.io/errors" + +// constant for maximum string length of the SequencerMetadata fields +const ( + MaxMonikerLength = 70 + MaxContactFieldLength = 140 + MaxDetailsLength = 280 + MaxExtraDataLength = 280 +) + +// DoNotModifyDesc constant is used in flags to indicate that the metadata field should not be updated +const DoNotModifyDesc = "[do-not-modify]" + +// UpdateSequencerMetadata updates the fields of a given metadata. An error is +// returned if the resulting metadata contains an invalid length. +// TODO: add more length checks +func (d SequencerMetadata) UpdateSequencerMetadata(d2 SequencerMetadata) (SequencerMetadata, error) { + metadata := SequencerMetadata{ + Moniker: d2.Moniker, + Details: d2.Details, + P2PSeeds: d2.P2PSeeds, + Rpcs: d2.Rpcs, + EvmRpcs: d2.EvmRpcs, + RestApiUrl: d2.RestApiUrl, + ExplorerUrl: d2.ExplorerUrl, + GenesisUrls: d2.GenesisUrls, + ContactDetails: d2.ContactDetails, + ExtraData: d2.ExtraData, + Snapshots: d2.Snapshots, + GasPrice: d2.GasPrice, + } + + if d.Moniker != DoNotModifyDesc { + metadata.Moniker = d2.Moniker + } + + if d.Details != DoNotModifyDesc { + metadata.Details = d2.Details + } + + if string(d.ExtraData) != DoNotModifyDesc { + metadata.ExtraData = d2.ExtraData + } + + if d.ContactDetails != nil { + metadata.ContactDetails = &ContactDetails{} + + if d.ContactDetails.Website != DoNotModifyDesc { + metadata.ContactDetails.Website = d2.ContactDetails.Website + } + if d.ContactDetails.Telegram != DoNotModifyDesc { + metadata.ContactDetails.Telegram = d2.ContactDetails.Telegram + } + if d.ContactDetails.X != DoNotModifyDesc { + metadata.ContactDetails.X = d2.ContactDetails.X + } + } + + return metadata.EnsureLength() +} + +// EnsureLength ensures the length of a sequencer's metadata. +func (d SequencerMetadata) EnsureLength() (SequencerMetadata, error) { + if len(d.Moniker) > MaxMonikerLength { + return d, errorsmod.Wrapf(ErrInvalidRequest, "invalid moniker length; got: %d, max: %d", len(d.Moniker), MaxMonikerLength) + } + + if len(d.Details) > MaxDetailsLength { + return d, errorsmod.Wrapf(ErrInvalidRequest, "invalid details length; got: %d, max: %d", len(d.Details), MaxDetailsLength) + } + + if len(d.ExtraData) > MaxExtraDataLength { + return d, errorsmod.Wrapf(ErrInvalidRequest, "invalid extra data length; got: %d, max: %d", len(d.ExtraData), MaxExtraDataLength) + } + + if cd := d.ContactDetails; cd != nil { + if len(cd.Website) > MaxContactFieldLength { + return d, errorsmod.Wrapf(ErrInvalidRequest, "invalid website length; got: %d, max: %d", len(cd.Website), MaxContactFieldLength) + } + if len(cd.Telegram) > MaxContactFieldLength { + return d, errorsmod.Wrapf(ErrInvalidRequest, "invalid telegram length; got: %d, max: %d", len(cd.Telegram), MaxContactFieldLength) + } + if len(cd.X) > MaxContactFieldLength { + return d, errorsmod.Wrapf(ErrInvalidRequest, "invalid x length; got: %d, max: %d", len(cd.X), MaxContactFieldLength) + } + } + + return d, nil +} diff --git a/x/sequencer/types/metadata.pb.go b/x/sequencer/types/metadata.pb.go new file mode 100644 index 000000000..07cb8e9ff --- /dev/null +++ b/x/sequencer/types/metadata.pb.go @@ -0,0 +1,1489 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: dymensionxyz/dymension/sequencer/metadata.proto + +package types + +import ( + fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Metadata defines rollapp/sequencer extra information. +type SequencerMetadata struct { + // moniker defines a human-readable name for the sequencer. + Moniker string `protobuf:"bytes,1,opt,name=moniker,proto3" json:"moniker,omitempty"` + // details define other optional details. + Details string `protobuf:"bytes,2,opt,name=details,proto3" json:"details,omitempty"` + // bootstrap nodes list + P2PSeeds []string `protobuf:"bytes,3,rep,name=p2p_seeds,json=p2pSeeds,proto3" json:"p2p_seeds,omitempty"` + // RPCs list + Rpcs []string `protobuf:"bytes,4,rep,name=rpcs,proto3" json:"rpcs,omitempty"` + // evm RPCs list + EvmRpcs []string `protobuf:"bytes,5,rep,name=evm_rpcs,json=evmRpcs,proto3" json:"evm_rpcs,omitempty"` + // REST API URL + RestApiUrl string `protobuf:"bytes,6,opt,name=rest_api_url,json=restApiUrl,proto3" json:"rest_api_url,omitempty"` + // block explorer URL + ExplorerUrl string `protobuf:"bytes,7,opt,name=explorer_url,json=explorerUrl,proto3" json:"explorer_url,omitempty"` + // genesis URLs + GenesisUrls []string `protobuf:"bytes,8,rep,name=genesis_urls,json=genesisUrls,proto3" json:"genesis_urls,omitempty"` + // contact details + ContactDetails *ContactDetails `protobuf:"bytes,9,opt,name=contact_details,json=contactDetails,proto3" json:"contact_details,omitempty"` + // json dump the sequencer can add (limited by size) + ExtraData []byte `protobuf:"bytes,10,opt,name=extra_data,json=extraData,proto3" json:"extra_data,omitempty"` + // snapshots of the sequencer + Snapshots []*SnapshotInfo `protobuf:"bytes,11,rep,name=snapshots,proto3" json:"snapshots,omitempty"` + // gas_price defines the value for each gas unit + GasPrice *github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,12,opt,name=gas_price,json=gasPrice,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"gas_price,omitempty"` +} + +func (m *SequencerMetadata) Reset() { *m = SequencerMetadata{} } +func (m *SequencerMetadata) String() string { return proto.CompactTextString(m) } +func (*SequencerMetadata) ProtoMessage() {} +func (*SequencerMetadata) Descriptor() ([]byte, []int) { + return fileDescriptor_0ffb58cf0478671a, []int{0} +} +func (m *SequencerMetadata) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SequencerMetadata) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SequencerMetadata.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 *SequencerMetadata) XXX_Merge(src proto.Message) { + xxx_messageInfo_SequencerMetadata.Merge(m, src) +} +func (m *SequencerMetadata) XXX_Size() int { + return m.Size() +} +func (m *SequencerMetadata) XXX_DiscardUnknown() { + xxx_messageInfo_SequencerMetadata.DiscardUnknown(m) +} + +var xxx_messageInfo_SequencerMetadata proto.InternalMessageInfo + +func (m *SequencerMetadata) GetMoniker() string { + if m != nil { + return m.Moniker + } + return "" +} + +func (m *SequencerMetadata) GetDetails() string { + if m != nil { + return m.Details + } + return "" +} + +func (m *SequencerMetadata) GetP2PSeeds() []string { + if m != nil { + return m.P2PSeeds + } + return nil +} + +func (m *SequencerMetadata) GetRpcs() []string { + if m != nil { + return m.Rpcs + } + return nil +} + +func (m *SequencerMetadata) GetEvmRpcs() []string { + if m != nil { + return m.EvmRpcs + } + return nil +} + +func (m *SequencerMetadata) GetRestApiUrl() string { + if m != nil { + return m.RestApiUrl + } + return "" +} + +func (m *SequencerMetadata) GetExplorerUrl() string { + if m != nil { + return m.ExplorerUrl + } + return "" +} + +func (m *SequencerMetadata) GetGenesisUrls() []string { + if m != nil { + return m.GenesisUrls + } + return nil +} + +func (m *SequencerMetadata) GetContactDetails() *ContactDetails { + if m != nil { + return m.ContactDetails + } + return nil +} + +func (m *SequencerMetadata) GetExtraData() []byte { + if m != nil { + return m.ExtraData + } + return nil +} + +func (m *SequencerMetadata) GetSnapshots() []*SnapshotInfo { + if m != nil { + return m.Snapshots + } + return nil +} + +type ContactDetails struct { + // website URL + Website string `protobuf:"bytes,11,opt,name=website,proto3" json:"website,omitempty"` + // telegram handle + Telegram string `protobuf:"bytes,1,opt,name=telegram,proto3" json:"telegram,omitempty"` + // twitter handle + X string `protobuf:"bytes,2,opt,name=x,proto3" json:"x,omitempty"` +} + +func (m *ContactDetails) Reset() { *m = ContactDetails{} } +func (m *ContactDetails) String() string { return proto.CompactTextString(m) } +func (*ContactDetails) ProtoMessage() {} +func (*ContactDetails) Descriptor() ([]byte, []int) { + return fileDescriptor_0ffb58cf0478671a, []int{1} +} +func (m *ContactDetails) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ContactDetails) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ContactDetails.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 *ContactDetails) XXX_Merge(src proto.Message) { + xxx_messageInfo_ContactDetails.Merge(m, src) +} +func (m *ContactDetails) XXX_Size() int { + return m.Size() +} +func (m *ContactDetails) XXX_DiscardUnknown() { + xxx_messageInfo_ContactDetails.DiscardUnknown(m) +} + +var xxx_messageInfo_ContactDetails proto.InternalMessageInfo + +func (m *ContactDetails) GetWebsite() string { + if m != nil { + return m.Website + } + return "" +} + +func (m *ContactDetails) GetTelegram() string { + if m != nil { + return m.Telegram + } + return "" +} + +func (m *ContactDetails) GetX() string { + if m != nil { + return m.X + } + return "" +} + +type SnapshotInfo struct { + // the snapshot url + SnapshotUrl string `protobuf:"bytes,1,opt,name=snapshot_url,json=snapshotUrl,proto3" json:"snapshot_url,omitempty"` + // The snapshot height + Height uint64 `protobuf:"varint,2,opt,name=height,proto3" json:"height,omitempty"` + // sha-256 checksum value for the snapshot file + Checksum string `protobuf:"bytes,3,opt,name=checksum,proto3" json:"checksum,omitempty"` +} + +func (m *SnapshotInfo) Reset() { *m = SnapshotInfo{} } +func (m *SnapshotInfo) String() string { return proto.CompactTextString(m) } +func (*SnapshotInfo) ProtoMessage() {} +func (*SnapshotInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_0ffb58cf0478671a, []int{2} +} +func (m *SnapshotInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SnapshotInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SnapshotInfo.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 *SnapshotInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_SnapshotInfo.Merge(m, src) +} +func (m *SnapshotInfo) XXX_Size() int { + return m.Size() +} +func (m *SnapshotInfo) XXX_DiscardUnknown() { + xxx_messageInfo_SnapshotInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_SnapshotInfo proto.InternalMessageInfo + +func (m *SnapshotInfo) GetSnapshotUrl() string { + if m != nil { + return m.SnapshotUrl + } + return "" +} + +func (m *SnapshotInfo) GetHeight() uint64 { + if m != nil { + return m.Height + } + return 0 +} + +func (m *SnapshotInfo) GetChecksum() string { + if m != nil { + return m.Checksum + } + return "" +} + +func init() { + proto.RegisterType((*SequencerMetadata)(nil), "dymensionxyz.dymension.sequencer.SequencerMetadata") + proto.RegisterType((*ContactDetails)(nil), "dymensionxyz.dymension.sequencer.ContactDetails") + proto.RegisterType((*SnapshotInfo)(nil), "dymensionxyz.dymension.sequencer.SnapshotInfo") +} + +func init() { + proto.RegisterFile("dymensionxyz/dymension/sequencer/metadata.proto", fileDescriptor_0ffb58cf0478671a) +} + +var fileDescriptor_0ffb58cf0478671a = []byte{ + // 526 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x53, 0x41, 0x8f, 0xd3, 0x3c, + 0x14, 0x6c, 0xbe, 0xf6, 0x6b, 0x1b, 0x27, 0x5a, 0x84, 0x85, 0x90, 0x59, 0x44, 0x08, 0x3d, 0xa0, + 0x0a, 0x89, 0x04, 0x75, 0x25, 0xee, 0x2c, 0x2b, 0xa1, 0x95, 0x40, 0x5a, 0xa5, 0xec, 0x01, 0x2e, + 0x91, 0x9b, 0x3e, 0xd2, 0xa8, 0x49, 0x6c, 0x6c, 0xb7, 0xa4, 0xfc, 0x06, 0x0e, 0xfc, 0x2c, 0x8e, + 0x7b, 0x44, 0x1c, 0x10, 0x6a, 0xff, 0x08, 0xb2, 0x93, 0x74, 0xbb, 0x07, 0xb4, 0xa7, 0x64, 0xc6, + 0x33, 0x7e, 0xf6, 0x3c, 0x3f, 0x14, 0xce, 0x37, 0x05, 0x94, 0x32, 0x63, 0x65, 0xb5, 0xf9, 0x7a, + 0x0d, 0x42, 0x09, 0x9f, 0x57, 0x50, 0x26, 0x20, 0xc2, 0x02, 0x14, 0x9d, 0x53, 0x45, 0x03, 0x2e, + 0x98, 0x62, 0xd8, 0x3f, 0x34, 0x04, 0x7b, 0x10, 0xec, 0x0d, 0xc7, 0xf7, 0x52, 0x96, 0x32, 0x23, + 0x0e, 0xf5, 0x5f, 0xed, 0x1b, 0x7d, 0xeb, 0xa1, 0xbb, 0xd3, 0x56, 0xf3, 0xae, 0xd9, 0x13, 0x13, + 0x34, 0x28, 0x58, 0x99, 0x2d, 0x41, 0x10, 0xcb, 0xb7, 0xc6, 0x76, 0xd4, 0x42, 0xbd, 0x32, 0x07, + 0x45, 0xb3, 0x5c, 0x92, 0xff, 0xea, 0x95, 0x06, 0xe2, 0x87, 0xc8, 0xe6, 0x13, 0x1e, 0x4b, 0x80, + 0xb9, 0x24, 0x5d, 0xbf, 0x3b, 0xb6, 0xa3, 0x21, 0x9f, 0xf0, 0xa9, 0xc6, 0x18, 0xa3, 0x9e, 0xe0, + 0x89, 0x24, 0x3d, 0xc3, 0x9b, 0x7f, 0xfc, 0x00, 0x0d, 0x61, 0x5d, 0xc4, 0x86, 0xff, 0xdf, 0xf0, + 0x03, 0x58, 0x17, 0x91, 0x5e, 0xf2, 0x91, 0x2b, 0x40, 0xaa, 0x98, 0xf2, 0x2c, 0x5e, 0x89, 0x9c, + 0xf4, 0x4d, 0x29, 0xa4, 0xb9, 0x57, 0x3c, 0xbb, 0x14, 0x39, 0x7e, 0x82, 0x5c, 0xa8, 0x78, 0xce, + 0x04, 0x08, 0xa3, 0x18, 0x18, 0x85, 0xd3, 0x72, 0x8d, 0x24, 0x85, 0x12, 0x64, 0x26, 0xb5, 0x42, + 0x92, 0xa1, 0xa9, 0xe1, 0x34, 0xdc, 0xa5, 0xc8, 0x25, 0xfe, 0x80, 0xee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x2e, 0x94, 0xd9, 0xa5, 0x17, 0x35, 0x48, 0x17, 0x4d, 0x16, 0x90, 0x2c, 0xe5, 0xaa, + 0x20, 0xdd, 0xba, 0x68, 0x8b, 0x4f, 0x2f, 0x7e, 0x6c, 0x3d, 0xeb, 0x6a, 0xeb, 0x59, 0x7f, 0xb6, + 0x9e, 0xf5, 0x7d, 0xe7, 0x75, 0xae, 0x76, 0x5e, 0xe7, 0xe7, 0xce, 0xeb, 0x7c, 0x7c, 0x79, 0x10, + 0xc4, 0x3f, 0x26, 0x6b, 0x7d, 0x12, 0x56, 0x07, 0xe3, 0x65, 0xc2, 0x99, 0xf5, 0xcd, 0x90, 0x9c, + 0xfc, 0x0d, 0x00, 0x00, 0xff, 0xff, 0x50, 0x02, 0xfb, 0x74, 0x8f, 0x03, 0x00, 0x00, +} + +func (m *SequencerMetadata) 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 *SequencerMetadata) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SequencerMetadata) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.GasPrice != nil { + { + size := m.GasPrice.Size() + i -= size + if _, err := m.GasPrice.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintMetadata(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x62 + } + if len(m.Snapshots) > 0 { + for iNdEx := len(m.Snapshots) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Snapshots[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintMetadata(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x5a + } + } + if len(m.ExtraData) > 0 { + i -= len(m.ExtraData) + copy(dAtA[i:], m.ExtraData) + i = encodeVarintMetadata(dAtA, i, uint64(len(m.ExtraData))) + i-- + dAtA[i] = 0x52 + } + if m.ContactDetails != nil { + { + size, err := m.ContactDetails.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintMetadata(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x4a + } + if len(m.GenesisUrls) > 0 { + for iNdEx := len(m.GenesisUrls) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.GenesisUrls[iNdEx]) + copy(dAtA[i:], m.GenesisUrls[iNdEx]) + i = encodeVarintMetadata(dAtA, i, uint64(len(m.GenesisUrls[iNdEx]))) + i-- + dAtA[i] = 0x42 + } + } + if len(m.ExplorerUrl) > 0 { + i -= len(m.ExplorerUrl) + copy(dAtA[i:], m.ExplorerUrl) + i = encodeVarintMetadata(dAtA, i, uint64(len(m.ExplorerUrl))) + i-- + dAtA[i] = 0x3a + } + if len(m.RestApiUrl) > 0 { + i -= len(m.RestApiUrl) + copy(dAtA[i:], m.RestApiUrl) + i = encodeVarintMetadata(dAtA, i, uint64(len(m.RestApiUrl))) + i-- + dAtA[i] = 0x32 + } + if len(m.EvmRpcs) > 0 { + for iNdEx := len(m.EvmRpcs) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.EvmRpcs[iNdEx]) + copy(dAtA[i:], m.EvmRpcs[iNdEx]) + i = encodeVarintMetadata(dAtA, i, uint64(len(m.EvmRpcs[iNdEx]))) + i-- + dAtA[i] = 0x2a + } + } + if len(m.Rpcs) > 0 { + for iNdEx := len(m.Rpcs) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Rpcs[iNdEx]) + copy(dAtA[i:], m.Rpcs[iNdEx]) + i = encodeVarintMetadata(dAtA, i, uint64(len(m.Rpcs[iNdEx]))) + i-- + dAtA[i] = 0x22 + } + } + if len(m.P2PSeeds) > 0 { + for iNdEx := len(m.P2PSeeds) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.P2PSeeds[iNdEx]) + copy(dAtA[i:], m.P2PSeeds[iNdEx]) + i = encodeVarintMetadata(dAtA, i, uint64(len(m.P2PSeeds[iNdEx]))) + i-- + dAtA[i] = 0x1a + } + } + if len(m.Details) > 0 { + i -= len(m.Details) + copy(dAtA[i:], m.Details) + i = encodeVarintMetadata(dAtA, i, uint64(len(m.Details))) + i-- + dAtA[i] = 0x12 + } + if len(m.Moniker) > 0 { + i -= len(m.Moniker) + copy(dAtA[i:], m.Moniker) + i = encodeVarintMetadata(dAtA, i, uint64(len(m.Moniker))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *ContactDetails) 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 *ContactDetails) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ContactDetails) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Website) > 0 { + i -= len(m.Website) + copy(dAtA[i:], m.Website) + i = encodeVarintMetadata(dAtA, i, uint64(len(m.Website))) + i-- + dAtA[i] = 0x5a + } + if len(m.X) > 0 { + i -= len(m.X) + copy(dAtA[i:], m.X) + i = encodeVarintMetadata(dAtA, i, uint64(len(m.X))) + i-- + dAtA[i] = 0x12 + } + if len(m.Telegram) > 0 { + i -= len(m.Telegram) + copy(dAtA[i:], m.Telegram) + i = encodeVarintMetadata(dAtA, i, uint64(len(m.Telegram))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *SnapshotInfo) 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 *SnapshotInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SnapshotInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Checksum) > 0 { + i -= len(m.Checksum) + copy(dAtA[i:], m.Checksum) + i = encodeVarintMetadata(dAtA, i, uint64(len(m.Checksum))) + i-- + dAtA[i] = 0x1a + } + if m.Height != 0 { + i = encodeVarintMetadata(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x10 + } + if len(m.SnapshotUrl) > 0 { + i -= len(m.SnapshotUrl) + copy(dAtA[i:], m.SnapshotUrl) + i = encodeVarintMetadata(dAtA, i, uint64(len(m.SnapshotUrl))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintMetadata(dAtA []byte, offset int, v uint64) int { + offset -= sovMetadata(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *SequencerMetadata) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Moniker) + if l > 0 { + n += 1 + l + sovMetadata(uint64(l)) + } + l = len(m.Details) + if l > 0 { + n += 1 + l + sovMetadata(uint64(l)) + } + if len(m.P2PSeeds) > 0 { + for _, s := range m.P2PSeeds { + l = len(s) + n += 1 + l + sovMetadata(uint64(l)) + } + } + if len(m.Rpcs) > 0 { + for _, s := range m.Rpcs { + l = len(s) + n += 1 + l + sovMetadata(uint64(l)) + } + } + if len(m.EvmRpcs) > 0 { + for _, s := range m.EvmRpcs { + l = len(s) + n += 1 + l + sovMetadata(uint64(l)) + } + } + l = len(m.RestApiUrl) + if l > 0 { + n += 1 + l + sovMetadata(uint64(l)) + } + l = len(m.ExplorerUrl) + if l > 0 { + n += 1 + l + sovMetadata(uint64(l)) + } + if len(m.GenesisUrls) > 0 { + for _, s := range m.GenesisUrls { + l = len(s) + n += 1 + l + sovMetadata(uint64(l)) + } + } + if m.ContactDetails != nil { + l = m.ContactDetails.Size() + n += 1 + l + sovMetadata(uint64(l)) + } + l = len(m.ExtraData) + if l > 0 { + n += 1 + l + sovMetadata(uint64(l)) + } + if len(m.Snapshots) > 0 { + for _, e := range m.Snapshots { + l = e.Size() + n += 1 + l + sovMetadata(uint64(l)) + } + } + if m.GasPrice != nil { + l = m.GasPrice.Size() + n += 1 + l + sovMetadata(uint64(l)) + } + return n +} + +func (m *ContactDetails) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Telegram) + if l > 0 { + n += 1 + l + sovMetadata(uint64(l)) + } + l = len(m.X) + if l > 0 { + n += 1 + l + sovMetadata(uint64(l)) + } + l = len(m.Website) + if l > 0 { + n += 1 + l + sovMetadata(uint64(l)) + } + return n +} + +func (m *SnapshotInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.SnapshotUrl) + if l > 0 { + n += 1 + l + sovMetadata(uint64(l)) + } + if m.Height != 0 { + n += 1 + sovMetadata(uint64(m.Height)) + } + l = len(m.Checksum) + if l > 0 { + n += 1 + l + sovMetadata(uint64(l)) + } + return n +} + +func sovMetadata(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozMetadata(x uint64) (n int) { + return sovMetadata(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *SequencerMetadata) 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 ErrIntOverflowMetadata + } + 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: SequencerMetadata: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SequencerMetadata: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Moniker", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + 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 ErrInvalidLengthMetadata + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Moniker = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Details", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + 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 ErrInvalidLengthMetadata + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Details = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field P2PSeeds", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + 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 ErrInvalidLengthMetadata + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.P2PSeeds = append(m.P2PSeeds, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Rpcs", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + 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 ErrInvalidLengthMetadata + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Rpcs = append(m.Rpcs, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EvmRpcs", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + 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 ErrInvalidLengthMetadata + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.EvmRpcs = append(m.EvmRpcs, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RestApiUrl", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + 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 ErrInvalidLengthMetadata + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RestApiUrl = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ExplorerUrl", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + 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 ErrInvalidLengthMetadata + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ExplorerUrl = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GenesisUrls", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + 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 ErrInvalidLengthMetadata + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.GenesisUrls = append(m.GenesisUrls, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ContactDetails", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthMetadata + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.ContactDetails == nil { + m.ContactDetails = &ContactDetails{} + } + if err := m.ContactDetails.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ExtraData", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthMetadata + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ExtraData = append(m.ExtraData[:0], dAtA[iNdEx:postIndex]...) + if m.ExtraData == nil { + m.ExtraData = []byte{} + } + iNdEx = postIndex + case 11: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Snapshots", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthMetadata + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Snapshots = append(m.Snapshots, &SnapshotInfo{}) + if err := m.Snapshots[len(m.Snapshots)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 12: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GasPrice", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + 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 ErrInvalidLengthMetadata + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var v github_com_cosmos_cosmos_sdk_types.Int + m.GasPrice = &v + if err := m.GasPrice.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipMetadata(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMetadata + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ContactDetails) 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 ErrIntOverflowMetadata + } + 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: ContactDetails: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ContactDetails: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Telegram", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + 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 ErrInvalidLengthMetadata + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Telegram = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field X", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + 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 ErrInvalidLengthMetadata + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.X = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 11: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Website", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + 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 ErrInvalidLengthMetadata + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Website = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipMetadata(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMetadata + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SnapshotInfo) 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 ErrIntOverflowMetadata + } + 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: SnapshotInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SnapshotInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SnapshotUrl", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + 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 ErrInvalidLengthMetadata + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SnapshotUrl = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + } + m.Height = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Height |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Checksum", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + 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 ErrInvalidLengthMetadata + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Checksum = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipMetadata(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMetadata + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipMetadata(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, ErrIntOverflowMetadata + } + 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, ErrIntOverflowMetadata + } + 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, ErrIntOverflowMetadata + } + 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, ErrInvalidLengthMetadata + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupMetadata + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthMetadata + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthMetadata = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowMetadata = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupMetadata = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/sequencer/types/messages.go b/x/sequencer/types/msg_create_sequencer.go similarity index 58% rename from x/sequencer/types/messages.go rename to x/sequencer/types/msg_create_sequencer.go index 2e71c0a5e..fb0f0358f 100644 --- a/x/sequencer/types/messages.go +++ b/x/sequencer/types/msg_create_sequencer.go @@ -10,7 +10,6 @@ import ( const ( TypeMsgCreateSequencer = "create_sequencer" - TypeMsgUnbond = "unbond" ) var ( @@ -19,14 +18,7 @@ var ( _ codectypes.UnpackInterfacesMessage = (*MsgCreateSequencer)(nil) ) -// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (msg MsgCreateSequencer) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { - var pubKey cryptotypes.PubKey - return unpacker.UnpackAny(msg.DymintPubKey, &pubKey) -} - -/* --------------------------- MsgCreateSequencer --------------------------- */ -func NewMsgCreateSequencer(creator string, pubkey cryptotypes.PubKey, rollappId string, description *Description, bond sdk.Coin) (*MsgCreateSequencer, error) { +func NewMsgCreateSequencer(creator string, pubkey cryptotypes.PubKey, rollappId string, metadata SequencerMetadata, bond sdk.Coin) (*MsgCreateSequencer, error) { var pkAny *codectypes.Any if pubkey != nil { var err error @@ -39,7 +31,7 @@ func NewMsgCreateSequencer(creator string, pubkey cryptotypes.PubKey, rollappId Creator: creator, DymintPubKey: pkAny, RollappId: rollappId, - Description: *description, + Metadata: metadata, Bond: bond, }, nil } @@ -72,27 +64,28 @@ func (msg *MsgCreateSequencer) ValidateBasic() error { } // public key also checked by the application logic - if msg.DymintPubKey != nil { - // check it is a pubkey - if _, err = codectypes.NewAnyWithValue(msg.DymintPubKey); err != nil { - return errorsmod.Wrapf(ErrInvalidPubKey, "invalid sequencer pubkey(%s)", err) - } + if msg.DymintPubKey == nil { + return errorsmod.Wrap(ErrInvalidPubKey, "sequencer pubkey is required") + } - // cast to cryptotypes.PubKey type - pk, ok := msg.DymintPubKey.GetCachedValue().(cryptotypes.PubKey) - if !ok { - return errorsmod.Wrapf(ErrInvalidType, "Expecting cryptotypes.PubKey, got %T", pk) - } + // check it is a pubkey + if _, err = codectypes.NewAnyWithValue(msg.DymintPubKey); err != nil { + return errorsmod.Wrapf(ErrInvalidPubKey, "invalid sequencer pubkey(%s)", err) + } - _, err = edwards.ParsePubKey(edwards.Edwards(), pk.Bytes()) - // err means the pubkey validation failed - if err != nil { - return errorsmod.Wrapf(ErrInvalidPubKey, "%s", err) - } + // cast to cryptotypes.PubKey type + pk, ok := msg.DymintPubKey.GetCachedValue().(cryptotypes.PubKey) + if !ok { + return errorsmod.Wrapf(ErrInvalidType, "expecting cryptotypes.PubKey, got %T", pk) + } + _, err = edwards.ParsePubKey(edwards.Edwards(), pk.Bytes()) + // err means the pubkey validation failed + if err != nil { + return errorsmod.Wrapf(ErrInvalidPubKey, "%s", err) } - if _, err := msg.Description.EnsureLength(); err != nil { + if _, err = msg.Metadata.UpdateSequencerMetadata(msg.Metadata); err != nil { return err } @@ -103,26 +96,8 @@ func (msg *MsgCreateSequencer) ValidateBasic() error { return nil } -/* -------------------------------- MsgUnbond ------------------------------- */ -func NewMsgUnbond(creator string) *MsgUnbond { - return &MsgUnbond{ - Creator: creator, - } -} - -func (msg *MsgUnbond) ValidateBasic() error { - _, err := sdk.AccAddressFromBech32(msg.Creator) - if err != nil { - return errorsmod.Wrapf(ErrInvalidAddress, "invalid creator address (%s)", err) - } - - return nil -} - -func (msg *MsgUnbond) GetSigners() []sdk.AccAddress { - creator, err := sdk.AccAddressFromBech32(msg.Creator) - if err != nil { - panic(err) - } - return []sdk.AccAddress{creator} +// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces +func (msg MsgCreateSequencer) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { + var pubKey cryptotypes.PubKey + return unpacker.UnpackAny(msg.DymintPubKey, &pubKey) } diff --git a/x/sequencer/types/messages_test.go b/x/sequencer/types/msg_create_sequencer_test.go similarity index 71% rename from x/sequencer/types/messages_test.go rename to x/sequencer/types/msg_create_sequencer_test.go index 6ba48a2a1..730c0c814 100644 --- a/x/sequencer/types/messages_test.go +++ b/x/sequencer/types/msg_create_sequencer_test.go @@ -8,11 +8,13 @@ import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + "github.com/dymensionxyz/sdk-utils/utils/uptr" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/dymensionxyz/dymension/v3/testutil/sample" "github.com/stretchr/testify/require" + + "github.com/dymensionxyz/dymension/v3/testutil/sample" ) func TestMsgCreateSequencer_ValidateBasic(t *testing.T) { @@ -53,17 +55,34 @@ func TestMsgCreateSequencer_ValidateBasic(t *testing.T) { Bond: bond, }, }, { - name: "valid description", + name: "valid metadata", msg: MsgCreateSequencer{ Creator: sample.AccAddress(), DymintPubKey: pkAny, Bond: bond, - Description: Description{ - Moniker: strings.Repeat("a", MaxMonikerLength), - Identity: strings.Repeat("a", MaxIdentityLength), - Website: strings.Repeat("a", MaxWebsiteLength), - SecurityContact: strings.Repeat("a", MaxSecurityContactLength), - Details: strings.Repeat("a", MaxDetailsLength), + Metadata: SequencerMetadata{ + Moniker: strings.Repeat("a", MaxMonikerLength), + Details: strings.Repeat("a", MaxDetailsLength), + P2PSeeds: []string{"seed1", "seed2"}, + Rpcs: []string{"rpc1", "rpc2"}, + EvmRpcs: []string{"evm1", "evm2"}, + RestApiUrl: "rest_api_url", + ExplorerUrl: "explorer_url", + GenesisUrls: []string{"genesis1", "genesis2"}, + ContactDetails: &ContactDetails{ + Website: strings.Repeat("a", MaxContactFieldLength), + Telegram: strings.Repeat("a", MaxContactFieldLength), + X: strings.Repeat("a", MaxContactFieldLength), + }, + ExtraData: []byte(strings.Repeat("a", MaxExtraDataLength)), + Snapshots: []*SnapshotInfo{ + { + SnapshotUrl: "snapshot_url", + Height: 123, + Checksum: "checksum", + }, + }, + GasPrice: uptr.To(sdk.NewInt(100)), }, }, }, { @@ -72,52 +91,43 @@ func TestMsgCreateSequencer_ValidateBasic(t *testing.T) { Creator: sample.AccAddress(), DymintPubKey: pkAny, Bond: bond, - Description: Description{ + Metadata: SequencerMetadata{ Moniker: strings.Repeat("a", MaxMonikerLength+1), }, }, err: ErrInvalidRequest, - }, { - name: "invalid identity length", - msg: MsgCreateSequencer{ - Creator: sample.AccAddress(), - DymintPubKey: pkAny, - Bond: bond, - Description: Description{ - Identity: strings.Repeat("a", MaxIdentityLength+1), - }, - }, - err: ErrInvalidRequest, }, { name: "invalid website length", msg: MsgCreateSequencer{ Creator: sample.AccAddress(), DymintPubKey: pkAny, Bond: bond, - Description: Description{ - Website: strings.Repeat("a", MaxWebsiteLength+1), + Metadata: SequencerMetadata{ + ContactDetails: &ContactDetails{ + Website: strings.Repeat("a", MaxContactFieldLength+1), + }, }, }, err: ErrInvalidRequest, }, { - name: "invalid security contact length", + name: "invalid details length", msg: MsgCreateSequencer{ Creator: sample.AccAddress(), DymintPubKey: pkAny, Bond: bond, - Description: Description{ - SecurityContact: strings.Repeat("a", MaxSecurityContactLength+1), + Metadata: SequencerMetadata{ + Details: strings.Repeat("a", MaxDetailsLength+1), }, }, err: ErrInvalidRequest, }, { - name: "invalid details length", + name: "invalid extra data length", msg: MsgCreateSequencer{ Creator: sample.AccAddress(), DymintPubKey: pkAny, Bond: bond, - Description: Description{ - Details: strings.Repeat("a", MaxDetailsLength+1), + Metadata: SequencerMetadata{ + ExtraData: []byte(strings.Repeat("a", MaxExtraDataLength+1)), }, }, err: ErrInvalidRequest, diff --git a/x/sequencer/types/msg_unbond.go b/x/sequencer/types/msg_unbond.go new file mode 100644 index 000000000..77a8d9ee0 --- /dev/null +++ b/x/sequencer/types/msg_unbond.go @@ -0,0 +1,29 @@ +package types + +import ( + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func NewMsgUnbond(creator string) *MsgUnbond { + return &MsgUnbond{ + Creator: creator, + } +} + +func (msg *MsgUnbond) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return errorsmod.Wrapf(ErrInvalidAddress, "invalid creator address (%s)", err) + } + + return nil +} + +func (msg *MsgUnbond) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} diff --git a/x/sequencer/types/msg_update_sequencer.go b/x/sequencer/types/msg_update_sequencer.go new file mode 100644 index 000000000..20334f892 --- /dev/null +++ b/x/sequencer/types/msg_update_sequencer.go @@ -0,0 +1,58 @@ +package types + +import ( + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +const ( + TypeMsgUpdateSequencerInformation = "update_sequencer" +) + +var ( + _ sdk.Msg = &MsgUpdateSequencerInformation{} + _ sdk.Msg = &MsgUnbond{} + _ codectypes.UnpackInterfacesMessage = (*MsgUpdateSequencerInformation)(nil) +) + +func NewMsgUpdateSequencerInformation(creator string, rollappId string, metadata SequencerMetadata) (*MsgUpdateSequencerInformation, error) { + return &MsgUpdateSequencerInformation{ + Creator: creator, + RollappId: rollappId, + Metadata: metadata, + }, nil +} + +func (msg *MsgUpdateSequencerInformation) Route() string { + return RouterKey +} + +func (msg *MsgUpdateSequencerInformation) Type() string { + return TypeMsgUpdateSequencerInformation +} + +func (msg *MsgUpdateSequencerInformation) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgUpdateSequencerInformation) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgUpdateSequencerInformation) ValidateBasic() error { + // validation if the sequencer metadata can be updated + if _, err := msg.Metadata.UpdateSequencerMetadata(msg.Metadata); err != nil { + return err + } + + return nil +} + +func (msg *MsgUpdateSequencerInformation) UnpackInterfaces(codectypes.AnyUnpacker) error { + return nil +} diff --git a/x/sequencer/types/msg_update_sequencer_test.go b/x/sequencer/types/msg_update_sequencer_test.go new file mode 100644 index 000000000..37e05ca70 --- /dev/null +++ b/x/sequencer/types/msg_update_sequencer_test.go @@ -0,0 +1,99 @@ +package types + +import ( + "strings" + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/dymensionxyz/sdk-utils/utils/uptr" + "github.com/stretchr/testify/require" + + "github.com/dymensionxyz/dymension/v3/testutil/sample" +) + +func TestMsgUpdateSequencerInformation_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgUpdateSequencerInformation + err error + }{ + { + name: "valid metadata", + msg: MsgUpdateSequencerInformation{ + Creator: sample.AccAddress(), + Metadata: SequencerMetadata{ + Moniker: strings.Repeat("a", MaxMonikerLength), + Details: strings.Repeat("a", MaxDetailsLength), + P2PSeeds: []string{"seed1", "seed2"}, + Rpcs: []string{"rpc1", "rpc2"}, + EvmRpcs: []string{"evm1", "evm2"}, + RestApiUrl: "rest1", + GenesisUrls: []string{"genesis1", "genesis2"}, + ExplorerUrl: "explorer", + ContactDetails: &ContactDetails{ + Website: strings.Repeat("a", MaxContactFieldLength), + Telegram: strings.Repeat("a", MaxContactFieldLength), + X: strings.Repeat("a", MaxContactFieldLength), + }, + ExtraData: []byte(strings.Repeat("a", MaxExtraDataLength)), + Snapshots: []*SnapshotInfo{ + { + SnapshotUrl: "snapshot", + Height: 1234, + Checksum: "checksum", + }, + }, + GasPrice: uptr.To(sdk.NewInt(100)), + }, + }, + }, { + name: "invalid moniker length", + msg: MsgUpdateSequencerInformation{ + Creator: sample.AccAddress(), + Metadata: SequencerMetadata{ + Moniker: strings.Repeat("a", MaxMonikerLength+1), + }, + }, + err: ErrInvalidRequest, + }, { + name: "invalid website length", + msg: MsgUpdateSequencerInformation{ + Creator: sample.AccAddress(), + Metadata: SequencerMetadata{ + ContactDetails: &ContactDetails{ + Website: strings.Repeat("a", MaxContactFieldLength+1), + }, + }, + }, + err: ErrInvalidRequest, + }, { + name: "invalid details length", + msg: MsgUpdateSequencerInformation{ + Creator: sample.AccAddress(), + Metadata: SequencerMetadata{ + Details: strings.Repeat("a", MaxDetailsLength+1), + }, + }, + err: ErrInvalidRequest, + }, { + name: "invalid extra data length", + msg: MsgUpdateSequencerInformation{ + Creator: sample.AccAddress(), + Metadata: SequencerMetadata{ + ExtraData: []byte(strings.Repeat("a", MaxExtraDataLength+1)), + }, + }, + err: ErrInvalidRequest, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} diff --git a/x/sequencer/types/params.go b/x/sequencer/types/params.go index 396374fa6..e1a9ee010 100644 --- a/x/sequencer/types/params.go +++ b/x/sequencer/types/params.go @@ -1,7 +1,7 @@ package types import ( - fmt "fmt" + "fmt" "time" sdk "github.com/cosmos/cosmos-sdk/types" @@ -12,12 +12,9 @@ import ( var _ paramtypes.ParamSet = (*Params)(nil) var ( - // MinBond types.Coin `protobuf:"bytes,1,opt,name=min_bond,json=minBond,proto3" json:"min_bond,omitempty"` - // UnbondingTime time.Duration `protobuf:"bytes,2,opt,name=unbonding_time,json=unbondingTime,proto3,stdduration" json:"unbonding_time"` - - // MinBond is the minimum bond required to be a validator + // DefaultMinBond is the minimum bond required to be a validator DefaultMinBond uint64 = 1000000 - // UnbondingTime is the time duration for unbonding + // DefaultUnbondingTime is the time duration for unbonding DefaultUnbondingTime time.Duration = time.Hour * 24 * 7 * 2 // 2 weeks // KeyMinBond is store's key for MinBond Params diff --git a/x/sequencer/types/sequencer.pb.go b/x/sequencer/types/sequencer.pb.go index a6c392c3b..5b3675716 100644 --- a/x/sequencer/types/sequencer.pb.go +++ b/x/sequencer/types/sequencer.pb.go @@ -35,14 +35,14 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Sequencer defines a sequencer identified by its' address (sequencerAddress). // The sequencer could be attached to only one rollapp (rollappId). type Sequencer struct { - // sequencerAddress is the bech32-encoded address of the sequencer account which is the account that the message was sent from. - SequencerAddress string `protobuf:"bytes,1,opt,name=sequencerAddress,proto3" json:"sequencerAddress,omitempty"` + // address is the bech32-encoded address of the sequencer account which is the account that the message was sent from. + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` // pubkey is the public key of the sequencers' dymint client, as a Protobuf Any. DymintPubKey *types.Any `protobuf:"bytes,2,opt,name=dymintPubKey,proto3" json:"dymintPubKey,omitempty"` // rollappId defines the rollapp to which the sequencer belongs. - RollappId string `protobuf:"bytes,3,opt,name=rollappId,proto3" json:"rollappId,omitempty"` - // description defines the descriptive terms for the sequencer. - Description Description `protobuf:"bytes,4,opt,name=description,proto3" json:"description"` + RollappId string `protobuf:"bytes,3,opt,name=rollapp_id,json=rollappId,proto3" json:"rollapp_id,omitempty"` + // metadata defines the extra information for the sequencer. + Metadata SequencerMetadata `protobuf:"bytes,4,opt,name=metadata,proto3" json:"metadata"` // jailed defined whether the sequencer has been jailed from bonded status or not. Jailed bool `protobuf:"varint,5,opt,name=jailed,proto3" json:"jailed,omitempty"` // proposer defines whether the sequencer is a proposer or not. @@ -90,9 +90,9 @@ func (m *Sequencer) XXX_DiscardUnknown() { var xxx_messageInfo_Sequencer proto.InternalMessageInfo -func (m *Sequencer) GetSequencerAddress() string { +func (m *Sequencer) GetAddress() string { if m != nil { - return m.SequencerAddress + return m.Address } return "" } @@ -111,11 +111,11 @@ func (m *Sequencer) GetRollappId() string { return "" } -func (m *Sequencer) GetDescription() Description { +func (m *Sequencer) GetMetadata() SequencerMetadata { if m != nil { - return m.Description + return m.Metadata } - return Description{} + return SequencerMetadata{} } func (m *Sequencer) GetJailed() bool { @@ -169,42 +169,41 @@ func init() { } var fileDescriptor_997b8663a5fc0f58 = []byte{ - // 545 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x53, 0x4f, 0x6f, 0xd3, 0x30, - 0x14, 0x6f, 0x68, 0x29, 0xad, 0x8b, 0x60, 0xb2, 0x2a, 0xf0, 0x2a, 0x94, 0x46, 0x9c, 0x02, 0x52, - 0xed, 0xb5, 0x93, 0xe0, 0xbc, 0x02, 0x12, 0x13, 0x07, 0xa6, 0x0c, 0x2e, 0x5c, 0xaa, 0xfc, 0x31, - 0x69, 0x58, 0x63, 0x87, 0xd8, 0xa9, 0x16, 0x3e, 0xc5, 0x3e, 0x07, 0x67, 0x3e, 0xc4, 0xc4, 0x69, - 0x27, 0xc4, 0x89, 0xa1, 0xf6, 0x8b, 0xa0, 0x38, 0x4e, 0x5a, 0x98, 0x50, 0x4f, 0xf6, 0xef, 0x3d, - 0xff, 0x7e, 0x7e, 0xcf, 0xbf, 0x67, 0x70, 0x10, 0xe4, 0x31, 0x65, 0x22, 0xe2, 0xec, 0x3c, 0xff, - 0x42, 0x6a, 0x40, 0x04, 0xfd, 0x9c, 0x51, 0xe6, 0xd3, 0x74, 0xb3, 0xc3, 0x49, 0xca, 0x25, 0x87, - 0xd6, 0x36, 0x03, 0xd7, 0x00, 0xd7, 0xe7, 0x06, 0x93, 0x9d, 0x9a, 0x01, 0x15, 0x7e, 0x1a, 0x25, - 0xb2, 0xe0, 0x29, 0xd5, 0xc1, 0xf3,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0xc6, 0xc5, 0xda, 0x6c, 0x5c, 0xad, 0xcd, 0xc6, 0xcf, 0xb5, 0xd9, 0xf8, - 0xf0, 0x6c, 0xab, 0xfa, 0xff, 0x7c, 0xae, 0xe5, 0x21, 0x39, 0xdf, 0xfa, 0x61, 0xaa, 0x23, 0xaf, - 0xad, 0xee, 0x3e, 0xfc, 0x13, 0x00, 0x00, 0xff, 0xff, 0x7b, 0xb4, 0x65, 0x96, 0x1a, 0x04, 0x00, - 0x00, + // 543 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x52, 0x41, 0x6f, 0xd3, 0x30, + 0x14, 0x6e, 0xd8, 0xe8, 0x5a, 0x17, 0x01, 0xb2, 0x2a, 0x70, 0x2b, 0x91, 0x46, 0x9c, 0xc2, 0x61, + 0xf6, 0xda, 0x4a, 0x70, 0xa6, 0x08, 0x89, 0x09, 0x21, 0xa6, 0x0c, 0x2e, 0x5c, 0x2a, 0x27, 0x31, + 0x69, 0x58, 0x63, 0x87, 0xd8, 0xa9, 0x16, 0x7e, 0xc5, 0x7e, 0x07, 0x67, 0xfe, 0x02, 0xd2, 0xc4, + 0x69, 0x47, 0x4e, 0x0c, 0xb5, 0x7f, 0x04, 0xc5, 0x71, 0x42, 0x01, 0xa1, 0x9e, 0xec, 0xef, 0xbd, + 0xf7, 0x3d, 0xbf, 0xf7, 0xf9, 0x03, 0x47, 0x61, 0x91, 0x30, 0x2e, 0x63, 0xc1, 0xcf, 0x8b, 0x4f, + 0xa4, 0x01, 0x44, 0xb2, 0x8f, 0x39, 0xe3, 0x01, 0xcb, 0x7e, 0xdf, 0x70, 0x9a, 0x09, 0x25, 0xa0, + 0xb3, 0xcd, 0xc0, 0x0d, 0xc0, 0x4d, 0xdd, 0x70, 0x10, 0x08, 0x99, 0x08, 0x39, 0xd7, 0xf5, 0xa4, + 0x02, 0x15, 0x79, 0x38, 0x88, 0x84, 0x88,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0xd8, 0xd8, 0xad, 0xab, 0x8d, 0xdd, 0xfa, 0xbe, 0xb1, 0x5b, 0xef, 0x1e, + 0x6f, 0x4d, 0xff, 0x1f, 0x97, 0xae, 0xa6, 0xe4, 0x7c, 0xcb, 0xaa, 0x7a, 0x23, 0xbf, 0xad, 0xdf, + 0x9e, 0xfe, 0x0a, 0x00, 0x00, 0xff, 0xff, 0xb0, 0x77, 0xe0, 0xb6, 0x06, 0x04, 0x00, 0x00, } func (m *Sequencer) Marshal() (dAtA []byte, err error) { @@ -280,7 +279,7 @@ func (m *Sequencer) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x28 } { - size, err := m.Description.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Metadata.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -308,10 +307,10 @@ func (m *Sequencer) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x12 } - if len(m.SequencerAddress) > 0 { - i -= len(m.SequencerAddress) - copy(dAtA[i:], m.SequencerAddress) - i = encodeVarintSequencer(dAtA, i, uint64(len(m.SequencerAddress))) + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintSequencer(dAtA, i, uint64(len(m.Address))) i-- dAtA[i] = 0xa } @@ -335,7 +334,7 @@ func (m *Sequencer) Size() (n int) { } var l int _ = l - l = len(m.SequencerAddress) + l = len(m.Address) if l > 0 { n += 1 + l + sovSequencer(uint64(l)) } @@ -347,7 +346,7 @@ func (m *Sequencer) Size() (n int) { if l > 0 { n += 1 + l + sovSequencer(uint64(l)) } - l = m.Description.Size() + l = m.Metadata.Size() n += 1 + l + sovSequencer(uint64(l)) if m.Jailed { n += 2 @@ -409,7 +408,7 @@ func (m *Sequencer) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SequencerAddress", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -437,7 +436,7 @@ func (m *Sequencer) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.SequencerAddress = string(dAtA[iNdEx:postIndex]) + m.Address = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { @@ -509,7 +508,7 @@ func (m *Sequencer) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -536,7 +535,7 @@ func (m *Sequencer) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Description.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Metadata.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/sequencer/types/tx.pb.go b/x/sequencer/types/tx.pb.go index b512e947d..76c955e0d 100644 --- a/x/sequencer/types/tx.pb.go +++ b/x/sequencer/types/tx.pb.go @@ -36,17 +36,17 @@ var _ = time.Kitchen // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// MsgCreateSequencer defines a SDK message for creating a new sequencer. type MsgCreateSequencer struct { // creator is the bech32-encoded address of the sequencer account which is the account that the message was sent from. Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` // pubkey is the public key of the sequencers' dymint client, as a Protobuf Any. DymintPubKey *types.Any `protobuf:"bytes,2,opt,name=dymintPubKey,proto3" json:"dymintPubKey,omitempty"` - // rollappId defines the rollapp to which the sequencer belongs. - RollappId string `protobuf:"bytes,3,opt,name=rollappId,proto3" json:"rollappId,omitempty"` - // description defines the descriptive terms for the sequencer. - Description Description `protobuf:"bytes,4,opt,name=description,proto3" json:"description"` - Bond types1.Coin `protobuf:"bytes,5,opt,name=bond,proto3" json:"bond"` + // rollapp_id defines the rollapp to which the sequencer belongs. + RollappId string `protobuf:"bytes,3,opt,name=rollapp_id,json=rollappId,proto3" json:"rollapp_id,omitempty"` + // metadata defines the extra information for the sequencer. + Metadata SequencerMetadata `protobuf:"bytes,4,opt,name=metadata,proto3" json:"metadata"` + // entry bond for the sequencer. + Bond types1.Coin `protobuf:"bytes,5,opt,name=bond,proto3" json:"bond"` } func (m *MsgCreateSequencer) Reset() { *m = MsgCreateSequencer{} } @@ -103,11 +103,11 @@ func (m *MsgCreateSequencer) GetRollappId() string { return "" } -func (m *MsgCreateSequencer) GetDescription() Description { +func (m *MsgCreateSequencer) GetMetadata() SequencerMetadata { if m != nil { - return m.Description + return m.Metadata } - return Description{} + return SequencerMetadata{} } func (m *MsgCreateSequencer) GetBond() types1.Coin { @@ -153,6 +153,105 @@ func (m *MsgCreateSequencerResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgCreateSequencerResponse proto.InternalMessageInfo +type MsgUpdateSequencerInformation struct { + // creator is the bech32-encoded address of the sequencer account which is the account that the message was sent from. + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + // rollapp_id defines the rollapp to which the sequencer belongs. + RollappId string `protobuf:"bytes,2,opt,name=rollapp_id,json=rollappId,proto3" json:"rollapp_id,omitempty"` + // metadata defines the extra information for the sequencer. + Metadata SequencerMetadata `protobuf:"bytes,3,opt,name=metadata,proto3" json:"metadata"` +} + +func (m *MsgUpdateSequencerInformation) Reset() { *m = MsgUpdateSequencerInformation{} } +func (m *MsgUpdateSequencerInformation) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateSequencerInformation) ProtoMessage() {} +func (*MsgUpdateSequencerInformation) Descriptor() ([]byte, []int) { + return fileDescriptor_02cdd6b9ffa005b4, []int{2} +} +func (m *MsgUpdateSequencerInformation) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateSequencerInformation) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateSequencerInformation.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 *MsgUpdateSequencerInformation) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateSequencerInformation.Merge(m, src) +} +func (m *MsgUpdateSequencerInformation) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateSequencerInformation) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateSequencerInformation.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateSequencerInformation proto.InternalMessageInfo + +func (m *MsgUpdateSequencerInformation) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgUpdateSequencerInformation) GetRollappId() string { + if m != nil { + return m.RollappId + } + return "" +} + +func (m *MsgUpdateSequencerInformation) GetMetadata() SequencerMetadata { + if m != nil { + return m.Metadata + } + return SequencerMetadata{} +} + +type MsgUpdateSequencerInformationResponse struct { +} + +func (m *MsgUpdateSequencerInformationResponse) Reset() { *m = MsgUpdateSequencerInformationResponse{} } +func (m *MsgUpdateSequencerInformationResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateSequencerInformationResponse) ProtoMessage() {} +func (*MsgUpdateSequencerInformationResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_02cdd6b9ffa005b4, []int{3} +} +func (m *MsgUpdateSequencerInformationResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateSequencerInformationResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateSequencerInformationResponse.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 *MsgUpdateSequencerInformationResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateSequencerInformationResponse.Merge(m, src) +} +func (m *MsgUpdateSequencerInformationResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateSequencerInformationResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateSequencerInformationResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateSequencerInformationResponse proto.InternalMessageInfo + // MsgUnbond defines a SDK message for performing an undelegation from a // bond and a sequencer. type MsgUnbond struct { @@ -163,7 +262,7 @@ func (m *MsgUnbond) Reset() { *m = MsgUnbond{} } func (m *MsgUnbond) String() string { return proto.CompactTextString(m) } func (*MsgUnbond) ProtoMessage() {} func (*MsgUnbond) Descriptor() ([]byte, []int) { - return fileDescriptor_02cdd6b9ffa005b4, []int{2} + return fileDescriptor_02cdd6b9ffa005b4, []int{4} } func (m *MsgUnbond) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -208,7 +307,7 @@ func (m *MsgUnbondResponse) Reset() { *m = MsgUnbondResponse{} } func (m *MsgUnbondResponse) String() string { return proto.CompactTextString(m) } func (*MsgUnbondResponse) ProtoMessage() {} func (*MsgUnbondResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_02cdd6b9ffa005b4, []int{3} + return fileDescriptor_02cdd6b9ffa005b4, []int{5} } func (m *MsgUnbondResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -247,6 +346,8 @@ func (m *MsgUnbondResponse) GetCompletionTime() time.Time { func init() { proto.RegisterType((*MsgCreateSequencer)(nil), "dymensionxyz.dymension.sequencer.MsgCreateSequencer") proto.RegisterType((*MsgCreateSequencerResponse)(nil), "dymensionxyz.dymension.sequencer.MsgCreateSequencerResponse") + proto.RegisterType((*MsgUpdateSequencerInformation)(nil), "dymensionxyz.dymension.sequencer.MsgUpdateSequencerInformation") + proto.RegisterType((*MsgUpdateSequencerInformationResponse)(nil), "dymensionxyz.dymension.sequencer.MsgUpdateSequencerInformationResponse") proto.RegisterType((*MsgUnbond)(nil), "dymensionxyz.dymension.sequencer.MsgUnbond") proto.RegisterType((*MsgUnbondResponse)(nil), "dymensionxyz.dymension.sequencer.MsgUnbondResponse") } @@ -256,42 +357,46 @@ func init() { } var fileDescriptor_02cdd6b9ffa005b4 = []byte{ - // 551 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0xbf, 0x6e, 0xd3, 0x40, - 0x18, 0x8f, 0xdb, 0x50, 0xc8, 0xa5, 0xa2, 0x60, 0x45, 0xc2, 0xb5, 0x2a, 0x27, 0xca, 0x54, 0x40, - 0xbd, 0x53, 0x12, 0xc4, 0x50, 0xb1, 0xd4, 0x65, 0x41, 0x28, 0x52, 0x71, 0xe9, 0xc2, 0x52, 0xf9, - 0xcf, 0x71, 0x18, 0xc5, 0x77, 0xc6, 0x77, 0x89, 0x62, 0x46, 0x24, 0xf6, 0x3e, 0x02, 0x8f, 0xc0, - 0xc0, 0xc4, 0x13, 0x54, 0x4c, 0x15, 0x13, 0x13, 0xa0, 0x64, 0x80, 0x57, 0x60, 0x43, 0x67, 0xfb, - 0x9c, 0x34, 0x11, 0x0a, 0x30, 0x25, 0xdf, 0xf7, 0xfd, 0xfe, 0xdc, 0xf7, 0x3b, 0xeb, 0xc0, 0xed, - 0x20, 0x8d, 0x30, 0xe5, 0x21, 0xa3, 0xe3, 0xf4, 0x35, 0x2a, 0x0b, 0xc4, 0xf1, 0xab, 0x21, 0xa6, - 0x3e, 0x4e, 0x90, 0x18, 0xc3, 0x38, 0x61, 0x82, 0xe9, 0xad, 0x79, 0x28, 0x2c, 0x0b, 0x58, 0x42, - 0xcd, 0xee, 0x4a, 0xb1, 0x00, 0x73, 0x3f, 0x09, 0x63, 0x21, 0x79, 0x99, 0xaa, 0xb9, 0x4d, 0x18, - 0x23, 0x03, 0x8c, 0xb2, 0xca, 0x1b, 0x3e, 0x47, 0x2e, 0x4d, 0xd5, 0xc8, 0x67, 0x3c, 0x62, 0xfc, - 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 0x60, 0xd4, 0x43, 0xe3, 0xf9, - 0xe7, 0x25, 0x8d, 0x31, 0xf7, 0x36, 0xb2, 0xec, 0x7b, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0x08, - 0xb3, 0x2c, 0x00, 0x8f, 0x04, 0x00, 0x00, + // 618 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xbf, 0x6f, 0xd3, 0x40, + 0x14, 0x8e, 0x9b, 0x50, 0x9a, 0x6b, 0x45, 0xc1, 0x8a, 0x84, 0x63, 0x51, 0x27, 0x8a, 0x84, 0x28, + 0x20, 0xee, 0x94, 0x04, 0x31, 0x54, 0x48, 0xa8, 0xe9, 0x80, 0x2a, 0x14, 0xa9, 0xb8, 0x74, 0x61, + 0x89, 0xfc, 0xe3, 0x6a, 0x8c, 0xe2, 0x3b, 0xe3, 0xbb, 0x44, 0x31, 0x23, 0x12, 0x7b, 0xff, 0x04, + 0xc4, 0xc0, 0xcc, 0xc0, 0x86, 0xd8, 0x2b, 0xa6, 0x8a, 0x89, 0x09, 0x50, 0x32, 0xc0, 0x9f, 0x81, + 0x6c, 0x9f, 0xdd, 0xfc, 0x50, 0x93, 0xf2, 0x63, 0x4a, 0xde, 0xbd, 0xef, 0x7d, 0xef, 0x7d, 0xdf, + 0xbb, 0x33, 0xb8, 0x69, 0x87, 0x1e, 0x26, 0xcc, 0xa5, 0x64, 0x10, 0xbe, 0x44, 0x59, 0x80, 0x18, + 0x7e, 0xd1, 0xc3, 0xc4, 0xc2, 0x01, 0xe2, 0x03, 0xe8, 0x07, 0x94, 0x53, 0xb9, 0x3a, 0x0e, 0x85, + 0x59, 0x00, 0x33, 0xa8, 0x5a, 0x76, 0x28, 0x75, 0xba, 0x18, 0xc5, 0x78, 0xb3, 0x77, 0x88, 0x0c, + 0x12, 0x26, 0xc5, 0x6a, 0xd9, 0xa2, 0xcc, 0xa3, 0xac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c, 0x7a, 0xff, 0x6f, 0xaa, 0x32, 0x79, 0xef, 0x24, 0xa0, 0xce, 0xb9, 0x2c, 0x0f, + 0xce, 0x45, 0x7e, 0x36, 0x81, 0xfa, 0xf0, 0x1f, 0x09, 0xb2, 0x41, 0x9f, 0x83, 0x65, 0xb1, 0xec, + 0xdb, 0xe7, 0xa3, 0x8c, 0xc1, 0x6a, 0xf3, 0x0f, 0xc0, 0x69, 0xaf, 0xd6, 0xde, 0xf1, 0x50, 0x93, + 0x4e, 0x86, 0x9a, 0xf4, 0x63, 0xa8, 0x49, 0x47, 0x23, 0x2d, 0x77, 0x32, 0xd2, 0x72, 0x5f, 0x47, + 0x5a, 0xee, 0xe9, 0x3d, 0xc7, 0xe5, 0xcf, 0x7a, 0x26, 0xb4, 0xa8, 0x77, 0xd6, 0x67, 0xaf, 0xdf, + 0x44, 0x83, 0xf1, 0xcf, 0x7d, 0xe8, 0x63, 0x66, 0x2e, 0xc7, 0x97, 0xa4, 0xf9, 0x3b, 0x00, 0x00, + 0xff, 0xff, 0xc1, 0x67, 0xa0, 0x16, 0x1f, 0x06, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -308,6 +413,8 @@ const _ = grpc.SupportPackageIsVersion4 type MsgClient interface { // CreateSequencer defines a method for creating a new sequencer. CreateSequencer(ctx context.Context, in *MsgCreateSequencer, opts ...grpc.CallOption) (*MsgCreateSequencerResponse, error) + // UpdateSequencerInformation defines a method for updating the sequencer's metadata. + UpdateSequencerInformation(ctx context.Context, in *MsgUpdateSequencerInformation, opts ...grpc.CallOption) (*MsgUpdateSequencerInformationResponse, error) // Unbond defines a method for removing coins from sequencer's bond Unbond(ctx context.Context, in *MsgUnbond, opts ...grpc.CallOption) (*MsgUnbondResponse, error) } @@ -329,6 +436,15 @@ func (c *msgClient) CreateSequencer(ctx context.Context, in *MsgCreateSequencer, return out, nil } +func (c *msgClient) UpdateSequencerInformation(ctx context.Context, in *MsgUpdateSequencerInformation, opts ...grpc.CallOption) (*MsgUpdateSequencerInformationResponse, error) { + out := new(MsgUpdateSequencerInformationResponse) + err := c.cc.Invoke(ctx, "/dymensionxyz.dymension.sequencer.Msg/UpdateSequencerInformation", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *msgClient) Unbond(ctx context.Context, in *MsgUnbond, opts ...grpc.CallOption) (*MsgUnbondResponse, error) { out := new(MsgUnbondResponse) err := c.cc.Invoke(ctx, "/dymensionxyz.dymension.sequencer.Msg/Unbond", in, out, opts...) @@ -342,6 +458,8 @@ func (c *msgClient) Unbond(ctx context.Context, in *MsgUnbond, opts ...grpc.Call type MsgServer interface { // CreateSequencer defines a method for creating a new sequencer. CreateSequencer(context.Context, *MsgCreateSequencer) (*MsgCreateSequencerResponse, error) + // UpdateSequencerInformation defines a method for updating the sequencer's metadata. + UpdateSequencerInformation(context.Context, *MsgUpdateSequencerInformation) (*MsgUpdateSequencerInformationResponse, error) // Unbond defines a method for removing coins from sequencer's bond Unbond(context.Context, *MsgUnbond) (*MsgUnbondResponse, error) } @@ -353,6 +471,9 @@ type UnimplementedMsgServer struct { func (*UnimplementedMsgServer) CreateSequencer(ctx context.Context, req *MsgCreateSequencer) (*MsgCreateSequencerResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method CreateSequencer not implemented") } +func (*UnimplementedMsgServer) UpdateSequencerInformation(ctx context.Context, req *MsgUpdateSequencerInformation) (*MsgUpdateSequencerInformationResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateSequencerInformation not implemented") +} func (*UnimplementedMsgServer) Unbond(ctx context.Context, req *MsgUnbond) (*MsgUnbondResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Unbond not implemented") } @@ -379,6 +500,24 @@ func _Msg_CreateSequencer_Handler(srv interface{}, ctx context.Context, dec func return interceptor(ctx, in, info, handler) } +func _Msg_UpdateSequencerInformation_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateSequencerInformation) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateSequencerInformation(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/dymensionxyz.dymension.sequencer.Msg/UpdateSequencerInformation", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateSequencerInformation(ctx, req.(*MsgUpdateSequencerInformation)) + } + return interceptor(ctx, in, info, handler) +} + func _Msg_Unbond_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgUnbond) if err := dec(in); err != nil { @@ -405,6 +544,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "CreateSequencer", Handler: _Msg_CreateSequencer_Handler, }, + { + MethodName: "UpdateSequencerInformation", + Handler: _Msg_UpdateSequencerInformation_Handler, + }, { MethodName: "Unbond", Handler: _Msg_Unbond_Handler, @@ -445,7 +588,7 @@ func (m *MsgCreateSequencer) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x2a { - size, err := m.Description.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Metadata.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -506,6 +649,76 @@ func (m *MsgCreateSequencerResponse) MarshalToSizedBuffer(dAtA []byte) (int, err return len(dAtA) - i, nil } +func (m *MsgUpdateSequencerInformation) 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 *MsgUpdateSequencerInformation) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateSequencerInformation) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Metadata.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.RollappId) > 0 { + i -= len(m.RollappId) + copy(dAtA[i:], m.RollappId) + i = encodeVarintTx(dAtA, i, uint64(len(m.RollappId))) + i-- + dAtA[i] = 0x12 + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateSequencerInformationResponse) 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 *MsgUpdateSequencerInformationResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateSequencerInformationResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func (m *MsgUnbond) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -556,12 +769,12 @@ func (m *MsgUnbondResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - n4, err4 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.CompletionTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.CompletionTime):]) - if err4 != nil { - return 0, err4 + n5, err5 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.CompletionTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.CompletionTime):]) + if err5 != nil { + return 0, err5 } - i -= n4 - i = encodeVarintTx(dAtA, i, uint64(n4)) + i -= n5 + i = encodeVarintTx(dAtA, i, uint64(n5)) i-- dAtA[i] = 0xa return len(dAtA) - i, nil @@ -596,7 +809,7 @@ func (m *MsgCreateSequencer) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = m.Description.Size() + l = m.Metadata.Size() n += 1 + l + sovTx(uint64(l)) l = m.Bond.Size() n += 1 + l + sovTx(uint64(l)) @@ -612,6 +825,34 @@ func (m *MsgCreateSequencerResponse) Size() (n int) { return n } +func (m *MsgUpdateSequencerInformation) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.RollappId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Metadata.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgUpdateSequencerInformationResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func (m *MsgUnbond) Size() (n int) { if m == nil { return 0 @@ -773,7 +1014,7 @@ func (m *MsgCreateSequencer) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -800,7 +1041,7 @@ func (m *MsgCreateSequencer) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Description.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Metadata.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -908,6 +1149,203 @@ func (m *MsgCreateSequencerResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgUpdateSequencerInformation) 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 ErrIntOverflowTx + } + 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: MsgUpdateSequencerInformation: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateSequencerInformation: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RollappId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RollappId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Metadata.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateSequencerInformationResponse) 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 ErrIntOverflowTx + } + 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: MsgUpdateSequencerInformationResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateSequencerInformationResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *MsgUnbond) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/sequencer/types/types.go b/x/sequencer/types/types.go deleted file mode 100644 index ab1254f4c..000000000 --- a/x/sequencer/types/types.go +++ /dev/null @@ -1 +0,0 @@ -package types