diff --git a/proto/rollappparams/params.proto b/proto/rollappparams/params.proto index 7d95ee74..da5b91a6 100644 --- a/proto/rollappparams/params.proto +++ b/proto/rollappparams/params.proto @@ -8,6 +8,6 @@ option go_package = "github.com/dymensionxyz/dymension-rdk/x/rollappparams/types message Params { // data availability type (e.g. celestia) used in the rollapp string da = 1; - // commit of the version used for the rollapp executable - string version = 2; + // drs version + uint32 drs_version = 2; } diff --git a/testutil/utils/test_app.go b/testutil/utils/test_app.go index ead88328..62e02f99 100644 --- a/testutil/utils/test_app.go +++ b/testutil/utils/test_app.go @@ -21,7 +21,6 @@ import ( app "github.com/dymensionxyz/dymension-rdk/testutil/app" hubgenesistypes "github.com/dymensionxyz/dymension-rdk/x/hub-genesis/types" - rollappparamstypes "github.com/dymensionxyz/dymension-rdk/x/rollappparams/types" "github.com/stretchr/testify/require" @@ -89,8 +88,6 @@ func setup(withGenesis bool, invCheckPeriod uint) (*app.App, map[string]json.Raw log.NewNopLogger(), db, nil, true, map[int64]bool{}, "/tmp", invCheckPeriod, encCdc, app.GetEnabledProposals(), EmptyAppOptions{}, emptyWasmOpts, ) if withGenesis { - // override the rollapp version, so we'll have a valid default genesis - rollappparamstypes.Version = "5f8393904fb1e9c616fe89f013cafe7501a63f86" return testApp, app.NewDefaultGenesisState(encCdc.Codec) } return testApp, map[string]json.RawMessage{} diff --git a/x/rollappparams/keeper/genesis_test.go b/x/rollappparams/keeper/genesis_test.go index 86def2a6..bfb9fc88 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") + state.Params = types.NewParams("mock", 1) k.InitGenesis(ctx, &state) got := k.ExportGenesis(ctx) diff --git a/x/rollappparams/keeper/keeper.go b/x/rollappparams/keeper/keeper.go index 78086fe6..51ff89a3 100644 --- a/x/rollappparams/keeper/keeper.go +++ b/x/rollappparams/keeper/keeper.go @@ -42,7 +42,7 @@ func (k Keeper) DA(ctx sdk.Context) (res string) { return } -func (k Keeper) Version(ctx sdk.Context) (res string) { +func (k Keeper) Version(ctx sdk.Context) (res uint32) { k.paramSpace.Get(ctx, types.KeyVersion, &res) return } diff --git a/x/rollappparams/types/genesis_test.go b/x/rollappparams/types/genesis_test.go index 90757e94..068b5bb7 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") + testParams := types.NewParams("mock", 1) testCases := []struct { name string params func() types.Params @@ -24,28 +24,10 @@ func TestGenesisState(t *testing.T) { }, }, { - name: "missing version", + name: "wrong drs version", params: func() types.Params { p := testParams - p.Version = "" - return p - }, - expectedErr: true, - }, - { - name: "wrong length version", - params: func() types.Params { - p := testParams - p.Version = "fdasfewkq102382w523" - return p - }, - expectedErr: true, - }, - { - name: "version not alphanumeric", - params: func() types.Params { - p := testParams - p.Version = "3a19edd887_9b576a866750bc9d480ada53d2c0d" + p.DrsVersion = 0 return p }, expectedErr: true, @@ -56,7 +38,7 @@ func TestGenesisState(t *testing.T) { state := types.NewGenesisState(tc.params()) err := types.ValidateGenesis(state) if tc.expectedErr { - require.ErrorIs(t, err, gerrc.ErrInvalidArgument) + require.Error(t, err, gerrc.ErrInvalidArgument) } else { require.NoError(t, err) } diff --git a/x/rollappparams/types/params.go b/x/rollappparams/types/params.go index f83fb977..81d2db55 100644 --- a/x/rollappparams/types/params.go +++ b/x/rollappparams/types/params.go @@ -2,7 +2,6 @@ package types import ( "fmt" - "regexp" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/dymensionxyz/dymint/da/registry" @@ -10,8 +9,7 @@ import ( ) const ( - // length of the version commit string. - VersionLength = 40 + // Data availability used by the RollApp. Default value used is mock da. DefaultDA = "mock" ) @@ -20,12 +18,8 @@ const ( var ( KeyDa = []byte("da") KeyVersion = []byte("version") - - // 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). - // regexp used to validate version commit - VersionRegExp = regexp.MustCompile(`^[a-z0-9]*$`) + // Default version set + DrsVersion = uint32(1) ) func ParamKeyTable() paramtypes.KeyTable { @@ -35,19 +29,19 @@ func ParamKeyTable() paramtypes.KeyTable { // NewParams creates a new Params object func NewParams( da string, - version string, + drsVersion uint32, ) Params { return Params{ - Da: da, - Version: version, + Da: da, + DrsVersion: drsVersion, } } // DefaultParams returns default x/rollappparams module parameters. func DefaultParams() Params { return Params{ - Da: DefaultDA, - Version: Version, + Da: DefaultDA, + DrsVersion: DrsVersion, } } @@ -56,10 +50,11 @@ func (p Params) Validate() error { if err != nil { return err } - err = ValidateVersion(p.Version) + err = ValidateVersion(p.DrsVersion) if err != nil { return err } + return nil } @@ -73,25 +68,22 @@ func ValidateDa(i any) error { } func ValidateVersion(i any) error { - - version, ok := i.(string) + version, ok := i.(uint32) if !ok { return fmt.Errorf("invalid version type param type: %w", gerrc.ErrInvalidArgument) } - if len(version) != VersionLength { - return fmt.Errorf("invalid version length: param length: %d accepted: %d: %w", len(version), VersionLength, gerrc.ErrInvalidArgument) - } - if !VersionRegExp.MatchString(version) { - return fmt.Errorf("invalid version: it must be alphanumeric %w", gerrc.ErrInvalidArgument) + if version <= 0 { + return fmt.Errorf("invalid DRS version: Version must be positive") } 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(KeyVersion, &p.DrsVersion, ValidateVersion), } } diff --git a/x/rollappparams/types/params.pb.go b/x/rollappparams/types/params.pb.go index 7e1708b0..53e6d8ae 100644 --- a/x/rollappparams/types/params.pb.go +++ b/x/rollappparams/types/params.pb.go @@ -27,8 +27,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Params struct { // data availability type (e.g. celestia) used in the rollapp 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"` + // drs version + DrsVersion uint32 `protobuf:"varint,2,opt,name=drs_version,json=drsVersion,proto3" json:"drs_version,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -71,11 +71,11 @@ func (m *Params) GetDa() string { return "" } -func (m *Params) GetVersion() string { +func (m *Params) GetDrsVersion() uint32 { if m != nil { - return m.Version + return m.DrsVersion } - return "" + return 0 } func init() { @@ -85,19 +85,20 @@ func init() { func init() { proto.RegisterFile("rollappparams/params.proto", fileDescriptor_c7f89f13f4d953f6) } var fileDescriptor_c7f89f13f4d953f6 = []byte{ - // 181 bytes of a gzipped FileDescriptorProto + // 193 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, 0x64, 0xc4, 0xc5, 0x16, 0x00, + 0x7a, 0x7e, 0x7a, 0x3e, 0x58, 0x81, 0x3e, 0x88, 0x05, 0x51, 0xab, 0x64, 0xc9, 0xc5, 0x16, 0x00, 0x56, 0x25, 0xc4, 0xc7, 0xc5, 0x94, 0x92, 0x28, 0xc1, 0xa8, 0xc0, 0xa8,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, 0x8a, 0xca, + 0x2a, 0x04, 0x47, 0xb7, 0x28, 0x25, 0x5b, 0xbf, 0x42, 0x1f, 0xd5, 0x13, 0x60, 0x77, 0x26, 0xb1, + 0x81, 0x1d, 0x66, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0x3b, 0x98, 0x71, 0x4b, 0xe2, 0x00, 0x00, + 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -120,12 +121,10 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.Version) > 0 { - i -= len(m.Version) - copy(dAtA[i:], m.Version) - i = encodeVarintParams(dAtA, i, uint64(len(m.Version))) + if m.DrsVersion != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.DrsVersion)) i-- - dAtA[i] = 0x12 + dAtA[i] = 0x10 } if len(m.Da) > 0 { i -= len(m.Da) @@ -158,9 +157,8 @@ func (m *Params) Size() (n int) { if l > 0 { n += 1 + l + sovParams(uint64(l)) } - l = len(m.Version) - if l > 0 { - n += 1 + l + sovParams(uint64(l)) + if m.DrsVersion != 0 { + n += 1 + sovParams(uint64(m.DrsVersion)) } return n } @@ -233,10 +231,10 @@ func (m *Params) Unmarshal(dAtA []byte) error { m.Da = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field DrsVersion", wireType) } - var stringLen uint64 + m.DrsVersion = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowParams @@ -246,24 +244,11 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.DrsVersion |= uint32(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Version = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:])