Skip to content

Commit

Permalink
feat(rollapparams): remove block params from rollapp params (#545)
Browse files Browse the repository at this point in the history
  • Loading branch information
srene authored Sep 6, 2024
1 parent 7afd5f7 commit 79c7d11
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 112 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
2 changes: 0 additions & 2 deletions proto/rollappparams/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion testutil/utils/test_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion x/rollappparams/keeper/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 0 additions & 5 deletions x/rollappparams/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
20 changes: 1 addition & 19 deletions x/rollappparams/types/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
39 changes: 6 additions & 33 deletions x/rollappparams/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<da>"
// git commit for the version used for the rollapp binary. it must be overwritten in the build process
Version = "<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]*$`)
)
Expand All @@ -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,
}
}

Expand All @@ -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
}

Expand Down Expand Up @@ -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),
}
}
53 changes: 8 additions & 45 deletions x/rollappparams/types/params.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 79c7d11

Please sign in to comment.