From 79c7d1157304b60b2ce5ff70cfd4de45188b5380 Mon Sep 17 00:00:00 2001 From: Sergi Rene Date: Fri, 6 Sep 2024 15:48:03 +0200 Subject: [PATCH] feat(rollapparams): remove block params from rollapp params (#545) --- go.mod | 4 +- go.sum | 8 ++-- proto/rollappparams/params.proto | 2 - testutil/utils/test_app.go | 2 +- x/rollappparams/keeper/genesis_test.go | 2 +- x/rollappparams/keeper/keeper.go | 5 --- x/rollappparams/types/genesis_test.go | 20 +--------- x/rollappparams/types/params.go | 39 +++---------------- x/rollappparams/types/params.pb.go | 53 ++++---------------------- 9 files changed, 23 insertions(+), 112 deletions(-) diff --git a/go.mod b/go.mod index 28cc4d7e..3994aa7d 100644 --- a/go.mod +++ b/go.mod @@ -310,10 +310,10 @@ replace ( github.com/CosmWasm/wasmd => github.com/decentrio/wasmd v0.33.0-sdk46.2 github.com/centrifuge/go-substrate-rpc-client/v4 => github.com/availproject/go-substrate-rpc-client/v4 v4.0.12-avail-1.4.0-rc1-5e286e3 github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0 - github.com/dymensionxyz/dymint => github.com/dymensionxyz/dymint v1.2.0-rc01.0.20240829131258-304d68a116e2 + github.com/dymensionxyz/dymint => github.com/dymensionxyz/dymint v1.2.0-rc01.0.20240906093437-dbc1b5dbf96e github.com/evmos/evmos/v12 => github.com/dymensionxyz/evmos/v12 v12.1.6-dymension-v0.3 github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.2-alpha.regen.4 github.com/gorilla/rpc => github.com/dymensionxyz/rpc v1.3.1 github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 - github.com/tendermint/tendermint => github.com/dymensionxyz/cometbft v0.34.29-0.20240827102743-fafae27f8527 + github.com/tendermint/tendermint => github.com/dymensionxyz/cometbft v0.34.29-0.20240906093934-57cd50faef13 ) diff --git a/go.sum b/go.sum index d21d4da6..362058e4 100644 --- a/go.sum +++ b/go.sum @@ -538,14 +538,14 @@ github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkp github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= github.com/dvsekhvalnov/jose2go v1.5.0 h1:3j8ya4Z4kMCwT5nXIKFSV84YS+HdqSSO0VsTQxaLAeM= github.com/dvsekhvalnov/jose2go v1.5.0/go.mod h1:QsHjhyTlD/lAVqn/NSbVZmSCGeDehTB/mPZadG+mhXU= -github.com/dymensionxyz/cometbft v0.34.29-0.20240827102743-fafae27f8527 h1:ueS52CpkFmlu2indSCa78e4WkjiEZuhy2gBTkFI5F20= -github.com/dymensionxyz/cometbft v0.34.29-0.20240827102743-fafae27f8527/go.mod h1:L9shMfbkZ8B+7JlwANEr+NZbBcn+hBpwdbeYvA5rLCw= +github.com/dymensionxyz/cometbft v0.34.29-0.20240906093934-57cd50faef13 h1:Bz7HmEY2v76i+9ODm5yDArQk5pZw3ND0ecKVbD7Gt4I= +github.com/dymensionxyz/cometbft v0.34.29-0.20240906093934-57cd50faef13/go.mod h1:L9shMfbkZ8B+7JlwANEr+NZbBcn+hBpwdbeYvA5rLCw= github.com/dymensionxyz/cosmosclient v0.4.2-beta.0.20240821081230-b4018b2bac13 h1:u5yeve5jZR6TdRjjR+vYT/8PWKbhwCZxUmAu+/Tnxyg= github.com/dymensionxyz/cosmosclient v0.4.2-beta.0.20240821081230-b4018b2bac13/go.mod h1:jabDQYXrccscSE0fXkh7eQFYPWJCRiuWKonFGObVq6s= github.com/dymensionxyz/dymension/v3 v3.1.0-rc03.0.20240411195658-f7cd96f53b56 h1:cmpJYdRviuUfmlJdHrcAND8Jd6JIY4rp63bWAQzPr54= github.com/dymensionxyz/dymension/v3 v3.1.0-rc03.0.20240411195658-f7cd96f53b56/go.mod h1:3Pfrr8j/BR9ztNKztGfC5PqDiO6CcrzMLCJtFtPEVW4= -github.com/dymensionxyz/dymint v1.2.0-rc01.0.20240829131258-304d68a116e2 h1:qhLnrc4d69aPQUoRq5scv3dys2xP7/u7Jn/jvBAkMSg= -github.com/dymensionxyz/dymint v1.2.0-rc01.0.20240829131258-304d68a116e2/go.mod h1:nAQxTrx8e21wuRWhgDJitH/WjusHxJXtaVd3kJGIfXE= +github.com/dymensionxyz/dymint v1.2.0-rc01.0.20240906093437-dbc1b5dbf96e h1:3k6Hfngc0m2xKr6Slf43ePlf28i1IQOEDaCxGNGJPW0= +github.com/dymensionxyz/dymint v1.2.0-rc01.0.20240906093437-dbc1b5dbf96e/go.mod h1:96jnUUXmBZ6fHboIz6G1oH2vbkF1L9dTR8szR+69Djc= github.com/dymensionxyz/evmos/v12 v12.1.6-dymension-v0.3 h1:vmAdUGUc4rTIiO3Phezr7vGq+0uPDVKSA4WAe8+yl6w= github.com/dymensionxyz/evmos/v12 v12.1.6-dymension-v0.3/go.mod h1:LfPv2O1HXMgETpka81Pg3nXy+U/7urq8dn85ZnSXK5Y= github.com/dymensionxyz/gerr-cosmos v1.0.0 h1:oi91rgOkpJWr41oX9JOyjvvBnhGY54tj513x8VlDAEc= diff --git a/proto/rollappparams/params.proto b/proto/rollappparams/params.proto index 51fd6d83..7d95ee74 100644 --- a/proto/rollappparams/params.proto +++ b/proto/rollappparams/params.proto @@ -10,6 +10,4 @@ message Params { string da = 1; // commit of the version used for the rollapp executable string version = 2; - // maximum allowed block size in bytes - uint32 blockmaxbytes = 3; } diff --git a/testutil/utils/test_app.go b/testutil/utils/test_app.go index 8b48f733..6c262f76 100644 --- a/testutil/utils/test_app.go +++ b/testutil/utils/test_app.go @@ -112,7 +112,7 @@ func Setup(t *testing.T, isCheckTx bool) *app.App { // setup for rollapp params rollappParamsGenesis := rollappparamstypes.GenesisState{ - Params: rollappparamstypes.NewParams("mock", "5f8393904fb1e9c616fe89f013cafe7501a63f86", 500000), + Params: rollappparamstypes.NewParams("mock", "5f8393904fb1e9c616fe89f013cafe7501a63f86"), } genesisState[rollappparamstypes.ModuleName] = app.AppCodec().MustMarshalJSON(&rollappParamsGenesis) diff --git a/x/rollappparams/keeper/genesis_test.go b/x/rollappparams/keeper/genesis_test.go index 3bbbc609..86def2a6 100644 --- a/x/rollappparams/keeper/genesis_test.go +++ b/x/rollappparams/keeper/genesis_test.go @@ -15,7 +15,7 @@ func TestGenesis(t *testing.T) { state := types.GenesisState{} - state.Params = types.NewParams("mock", "5f8393904fb1e9c616fe89f013cafe7501a63f86", 500000) + state.Params = types.NewParams("mock", "5f8393904fb1e9c616fe89f013cafe7501a63f86") k.InitGenesis(ctx, &state) got := k.ExportGenesis(ctx) diff --git a/x/rollappparams/keeper/keeper.go b/x/rollappparams/keeper/keeper.go index 37a65c35..78086fe6 100644 --- a/x/rollappparams/keeper/keeper.go +++ b/x/rollappparams/keeper/keeper.go @@ -46,8 +46,3 @@ func (k Keeper) Version(ctx sdk.Context) (res string) { k.paramSpace.Get(ctx, types.KeyVersion, &res) return } - -func (k Keeper) BlockMaxBytes(ctx sdk.Context) (res uint32) { - k.paramSpace.Get(ctx, types.KeyBlockMaxBytes, &res) - return -} diff --git a/x/rollappparams/types/genesis_test.go b/x/rollappparams/types/genesis_test.go index d2020828..90757e94 100644 --- a/x/rollappparams/types/genesis_test.go +++ b/x/rollappparams/types/genesis_test.go @@ -10,7 +10,7 @@ import ( func TestGenesisState(t *testing.T) { - testParams := types.NewParams("mock", "5f8393904fb1e9c616fe89f013cafe7501a63f86", 500000) + testParams := types.NewParams("mock", "5f8393904fb1e9c616fe89f013cafe7501a63f86") testCases := []struct { name string params func() types.Params @@ -50,24 +50,6 @@ func TestGenesisState(t *testing.T) { }, expectedErr: true, }, - { - name: "block max size too small", - params: func() types.Params { - p := testParams - p.Blockmaxbytes = 50000 - return p - }, - expectedErr: true, - }, - { - name: "block max size too big", - params: func() types.Params { - p := types.DefaultParams() - p.Blockmaxbytes = 1000000 - return p - }, - expectedErr: true, - }, } for _, tc := range testCases { diff --git a/x/rollappparams/types/params.go b/x/rollappparams/types/params.go index c249c77e..1f073275 100644 --- a/x/rollappparams/types/params.go +++ b/x/rollappparams/types/params.go @@ -10,25 +10,20 @@ import ( ) const ( - // length of the version commit string. VersionLength = 40 - // default minimum block size. not specific reason to set it to 100K, but we need to avoid no transactions can be included in a block. - MinBlockMaxBytes = 100000 ) // Parameter store keys. var ( - KeyDa = []byte("da") - KeyVersion = []byte("version") - KeyBlockMaxBytes = []byte("blockmaxbytes") + KeyDa = []byte("da") + KeyVersion = []byte("version") // Data availability used by the RollApp. it must be overwritten in the build process DA = "" // git commit for the version used for the rollapp binary. it must be overwritten in the build process Version = "" // default max block size accepted (equivalent to block max size it can fit into a celestia blob). - DefaultBlockMaxBytes = 500000 // regexp used to validate version commit VersionRegExp = regexp.MustCompile(`^[a-z0-9]*$`) ) @@ -41,21 +36,18 @@ func ParamKeyTable() paramtypes.KeyTable { func NewParams( da string, version string, - blockMaxBytes uint32, ) Params { return Params{ - Da: da, - Version: version, - Blockmaxbytes: blockMaxBytes, + Da: da, + Version: version, } } // DefaultParams returns default x/rollappparams module parameters. func DefaultParams() Params { return Params{ - Da: DA, - Version: Version, - Blockmaxbytes: uint32(DefaultBlockMaxBytes), + Da: DA, + Version: Version, } } @@ -68,10 +60,6 @@ func (p Params) Validate() error { if err != nil { return err } - err = ValidateBlockMaxBytes(p.Blockmaxbytes) - if err != nil { - return err - } return nil } @@ -100,25 +88,10 @@ func ValidateVersion(i any) error { return nil } -func ValidateBlockMaxBytes(i any) error { - size, ok := i.(uint32) - if !ok { - return fmt.Errorf("invalid block max size param type : %w", gerrc.ErrInvalidArgument) - } - if size < uint32(MinBlockMaxBytes) { - return fmt.Errorf("invalid block max size value: used %d: minimum accepted %d : %w", size, MinBlockMaxBytes, gerrc.ErrInvalidArgument) - } - if size > uint32(DefaultBlockMaxBytes) { - return fmt.Errorf("invalid block max size value: used %d: max accepted %d : %w", size, DefaultBlockMaxBytes, gerrc.ErrInvalidArgument) - } - return nil -} - // Implements params.ParamSet. func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { return paramtypes.ParamSetPairs{ paramtypes.NewParamSetPair(KeyDa, &p.Da, ValidateDa), paramtypes.NewParamSetPair(KeyVersion, &p.Version, ValidateVersion), - paramtypes.NewParamSetPair(KeyBlockMaxBytes, &p.Blockmaxbytes, ValidateBlockMaxBytes), } } diff --git a/x/rollappparams/types/params.pb.go b/x/rollappparams/types/params.pb.go index 454b0bc4..7e1708b0 100644 --- a/x/rollappparams/types/params.pb.go +++ b/x/rollappparams/types/params.pb.go @@ -29,8 +29,6 @@ type Params struct { Da string `protobuf:"bytes,1,opt,name=da,proto3" json:"da,omitempty"` // commit of the version used for the rollapp executable Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` - // maximum allowed block size in bytes - Blockmaxbytes uint32 `protobuf:"varint,3,opt,name=blockmaxbytes,proto3" json:"blockmaxbytes,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -80,13 +78,6 @@ func (m *Params) GetVersion() string { return "" } -func (m *Params) GetBlockmaxbytes() uint32 { - if m != nil { - return m.Blockmaxbytes - } - return 0 -} - func init() { proto.RegisterType((*Params)(nil), "rollapp.params.types.Params") } @@ -94,20 +85,19 @@ func init() { func init() { proto.RegisterFile("rollappparams/params.proto", fileDescriptor_c7f89f13f4d953f6) } var fileDescriptor_c7f89f13f4d953f6 = []byte{ - // 207 bytes of a gzipped FileDescriptorProto + // 181 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2a, 0xca, 0xcf, 0xc9, 0x49, 0x2c, 0x28, 0x28, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x87, 0x50, 0x7a, 0x05, 0x45, 0xf9, 0x25, 0xf9, 0x42, 0x22, 0x50, 0x39, 0x3d, 0xa8, 0x68, 0x49, 0x65, 0x41, 0x6a, 0xb1, 0x94, 0x48, - 0x7a, 0x7e, 0x7a, 0x3e, 0x58, 0x81, 0x3e, 0x88, 0x05, 0x51, 0xab, 0x14, 0xc1, 0xc5, 0x16, 0x00, + 0x7a, 0x7e, 0x7a, 0x3e, 0x58, 0x81, 0x3e, 0x88, 0x05, 0x51, 0xab, 0x64, 0xc4, 0xc5, 0x16, 0x00, 0x56, 0x25, 0xc4, 0xc7, 0xc5, 0x94, 0x92, 0x28, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x19, 0xc4, 0x94, 0x92, 0x28, 0x24, 0xc1, 0xc5, 0x5e, 0x96, 0x5a, 0x54, 0x9c, 0x99, 0x9f, 0x27, 0xc1, 0x04, 0x16, - 0x84, 0x71, 0x85, 0x54, 0xb8, 0x78, 0x93, 0x72, 0xf2, 0x93, 0xb3, 0x73, 0x13, 0x2b, 0x92, 0x2a, - 0x4b, 0x52, 0x8b, 0x25, 0x98, 0x15, 0x18, 0x35, 0x78, 0x83, 0x50, 0x05, 0x9d, 0x42, 0x4f, 0x3c, - 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, - 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0xca, 0x3a, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, - 0x2f, 0x39, 0x3f, 0x57, 0x3f, 0xa5, 0x32, 0x37, 0x35, 0x0f, 0x64, 0x6a, 0x45, 0x65, 0x15, 0x82, - 0xa3, 0x5b, 0x94, 0x92, 0xad, 0x5f, 0xa1, 0x8f, 0xea, 0x47, 0xb0, 0x37, 0x92, 0xd8, 0xc0, 0xee, - 0x36, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x3b, 0x0c, 0xec, 0x26, 0x01, 0x01, 0x00, 0x00, + 0x84, 0x71, 0x9d, 0x42, 0x4f, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, + 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0xca, 0x3a, + 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x3f, 0xa5, 0x32, 0x37, 0x35, 0x0f, + 0xa4, 0xbe, 0xa2, 0xb2, 0x0a, 0xc1, 0xd1, 0x2d, 0x4a, 0xc9, 0xd6, 0xaf, 0xd0, 0x47, 0x75, 0x3d, + 0xd8, 0x81, 0x49, 0x6c, 0x60, 0x17, 0x19, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x40, 0x0f, 0x32, + 0xfa, 0xdb, 0x00, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -130,11 +120,6 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.Blockmaxbytes != 0 { - i = encodeVarintParams(dAtA, i, uint64(m.Blockmaxbytes)) - i-- - dAtA[i] = 0x18 - } if len(m.Version) > 0 { i -= len(m.Version) copy(dAtA[i:], m.Version) @@ -177,9 +162,6 @@ func (m *Params) Size() (n int) { if l > 0 { n += 1 + l + sovParams(uint64(l)) } - if m.Blockmaxbytes != 0 { - n += 1 + sovParams(uint64(m.Blockmaxbytes)) - } return n } @@ -282,25 +264,6 @@ func (m *Params) Unmarshal(dAtA []byte) error { } m.Version = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Blockmaxbytes", wireType) - } - m.Blockmaxbytes = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Blockmaxbytes |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:])