From 9b73cd6cade43f55e9ccc5f3e782eb3a53e2134a Mon Sep 17 00:00:00 2001 From: zale144 Date: Mon, 23 Sep 2024 10:34:56 +0200 Subject: [PATCH 1/3] Make initial supply nullable --- app/apptesting/test_suite.go | 3 +- app/upgrades/v4/upgrade.go | 3 +- .../dymension/rollapp/rollapp.proto | 2 +- x/rollapp/client/cli/tx_create_rollapp.go | 4 +- x/rollapp/genesis_test.go | 5 +- .../keeper/msg_server_create_rollapp_test.go | 3 +- .../keeper/msg_server_update_rollapp_test.go | 71 +++++++++- x/rollapp/keeper/rollapp.go | 2 +- x/rollapp/simulation/create_rollapp.go | 3 +- .../types/message_create_rollapp_test.go | 55 ++++++-- x/rollapp/types/message_update_rollapp.go | 2 +- .../types/message_update_rollapp_test.go | 33 ++++- x/rollapp/types/rollapp.go | 4 +- x/rollapp/types/rollapp.pb.go | 131 +++++++++--------- .../msg_server_create_sequencer_test.go | 3 +- x/sequencer/keeper/sequencer_suite_test.go | 3 +- 16 files changed, 227 insertions(+), 100 deletions(-) diff --git a/app/apptesting/test_suite.go b/app/apptesting/test_suite.go index 31577885b..3d3d4660a 100644 --- a/app/apptesting/test_suite.go +++ b/app/apptesting/test_suite.go @@ -5,6 +5,7 @@ import ( "time" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" + "github.com/dymensionxyz/sdk-utils/utils/uptr" "github.com/dymensionxyz/dymension/v3/app/params" dymnstypes "github.com/dymensionxyz/dymension/v3/x/dymns/types" @@ -59,7 +60,7 @@ func (s *KeeperTestHelper) CreateRollappByName(name string) { GenesisInfo: rollapptypes.GenesisInfo{ Bech32Prefix: strings.ToLower(rand.Str(3)), GenesisChecksum: "1234567890abcdefg", - InitialSupply: sdk.NewInt(1000), + InitialSupply: uptr.To(sdk.NewInt(1000)), NativeDenom: &rollapptypes.DenomMetadata{ Display: "DEN", Base: "aden", diff --git a/app/upgrades/v4/upgrade.go b/app/upgrades/v4/upgrade.go index 60d3cb64e..bc491bffb 100644 --- a/app/upgrades/v4/upgrade.go +++ b/app/upgrades/v4/upgrade.go @@ -3,6 +3,7 @@ package v4 import ( "github.com/cometbft/cometbft/crypto" "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/dymensionxyz/sdk-utils/utils/uptr" epochskeeper "github.com/osmosis-labs/osmosis/v15/x/epochs/keeper" sdk "github.com/cosmos/cosmos-sdk/types" @@ -231,7 +232,7 @@ func ConvertOldRollappToNew(oldRollapp rollapptypes.Rollapp) rollapptypes.Rollap Base: "aden", // placeholder data Exponent: 6, // placeholder data }, - InitialSupply: sdk.NewInt(100000), // placeholder data + InitialSupply: uptr.To(sdk.NewInt(100000)), // placeholder data Sealed: true, }, InitialSequencer: "*", diff --git a/proto/dymensionxyz/dymension/rollapp/rollapp.proto b/proto/dymensionxyz/dymension/rollapp/rollapp.proto index bbf8b61b4..ab8032f16 100644 --- a/proto/dymensionxyz/dymension/rollapp/rollapp.proto +++ b/proto/dymensionxyz/dymension/rollapp/rollapp.proto @@ -74,7 +74,7 @@ message GenesisInfo { // initial_supply is the initial supply of the native token string initial_supply = 4 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false + (gogoproto.nullable) = true ]; // sealed indicates if the fields in this object are no longer updatable bool sealed = 5; diff --git a/x/rollapp/client/cli/tx_create_rollapp.go b/x/rollapp/client/cli/tx_create_rollapp.go index 0d6ada235..a9258fe33 100644 --- a/x/rollapp/client/cli/tx_create_rollapp.go +++ b/x/rollapp/client/cli/tx_create_rollapp.go @@ -73,7 +73,6 @@ func parseGenesisInfo(cmd *cobra.Command) (types.GenesisInfo, error) { var ( genesisInfo types.GenesisInfo err error - ok bool ) genesisInfo.GenesisChecksum, err = cmd.Flags().GetString(FlagGenesisChecksum) @@ -104,10 +103,11 @@ func parseGenesisInfo(cmd *cobra.Command) (types.GenesisInfo, error) { } if initialSupplyFlag != "" { - genesisInfo.InitialSupply, ok = sdk.NewIntFromString(initialSupplyFlag) + initialSupply, ok := sdk.NewIntFromString(initialSupplyFlag) if !ok { return types.GenesisInfo{}, fmt.Errorf("invalid initial supply: %s", initialSupplyFlag) } + genesisInfo.InitialSupply = &initialSupply } return genesisInfo, nil diff --git a/x/rollapp/genesis_test.go b/x/rollapp/genesis_test.go index 18f9500dc..36e1361ba 100644 --- a/x/rollapp/genesis_test.go +++ b/x/rollapp/genesis_test.go @@ -4,6 +4,7 @@ import ( "testing" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/dymensionxyz/sdk-utils/utils/uptr" "github.com/stretchr/testify/require" keepertest "github.com/dymensionxyz/dymension/v3/testutil/keeper" @@ -27,13 +28,13 @@ func TestInitExportGenesis(t *testing.T) { { RollappId: rollappID1, GenesisInfo: types.GenesisInfo{ - InitialSupply: sdk.NewInt(1000), + InitialSupply: uptr.To(sdk.NewInt(1000)), }, }, { RollappId: rollappID2, GenesisInfo: types.GenesisInfo{ - InitialSupply: sdk.NewInt(1001), + InitialSupply: uptr.To(sdk.NewInt(1001)), }, }, }, diff --git a/x/rollapp/keeper/msg_server_create_rollapp_test.go b/x/rollapp/keeper/msg_server_create_rollapp_test.go index 4ee861a61..a8d64d8ce 100644 --- a/x/rollapp/keeper/msg_server_create_rollapp_test.go +++ b/x/rollapp/keeper/msg_server_create_rollapp_test.go @@ -4,6 +4,7 @@ import ( "strings" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/dymensionxyz/sdk-utils/utils/uptr" "github.com/cometbft/cometbft/libs/rand" sdk "github.com/cosmos/cosmos-sdk/types" @@ -391,5 +392,5 @@ var mockGenesisInfo = types.GenesisInfo{ Base: "aden", Exponent: 18, }, - InitialSupply: sdk.NewInt(100000000), + InitialSupply: uptr.To(sdk.NewInt(100000000)), } diff --git a/x/rollapp/keeper/msg_server_update_rollapp_test.go b/x/rollapp/keeper/msg_server_update_rollapp_test.go index 1a66b8282..e82115cac 100644 --- a/x/rollapp/keeper/msg_server_update_rollapp_test.go +++ b/x/rollapp/keeper/msg_server_update_rollapp_test.go @@ -36,7 +36,7 @@ func (suite *RollappTestSuite) TestUpdateRollapp() { GenesisInfo: types.GenesisInfo{ Bech32Prefix: "new", GenesisChecksum: "new_checksum", - InitialSupply: sdk.NewInt(1000), + InitialSupply: uptr.To(sdk.NewInt(1000)), NativeDenom: &types.DenomMetadata{ Display: "DEN", Base: "aden", @@ -54,7 +54,7 @@ func (suite *RollappTestSuite) TestUpdateRollapp() { GenesisInfo: types.GenesisInfo{ Bech32Prefix: "new", GenesisChecksum: "new_checksum", - InitialSupply: sdk.NewInt(1000), + InitialSupply: uptr.To(sdk.NewInt(1000)), NativeDenom: &types.DenomMetadata{ Display: "DEN", Base: "aden", @@ -141,11 +141,70 @@ func (suite *RollappTestSuite) TestUpdateRollapp() { Owner: alice, RollappId: rollappId, GenesisInfo: types.GenesisInfo{ - InitialSupply: sdk.NewInt(1000), + InitialSupply: uptr.To(sdk.NewInt(1000)), }, }, genInfoSealed: true, expError: types.ErrGenesisInfoSealed, + }, { + name: "Update rollapp: success - no genesis info, genesis info sealed", + update: &types.MsgUpdateRollappInformation{ + Owner: alice, + RollappId: rollappId, + }, + genInfoSealed: true, + expError: nil, + expRollapp: types.Rollapp{ + RollappId: rollappId, + Owner: alice, + VmType: types.Rollapp_EVM, + Metadata: &types.RollappMetadata{}, + GenesisInfo: types.GenesisInfo{ + Bech32Prefix: "old", + GenesisChecksum: "old", + InitialSupply: uptr.To(sdk.NewInt(1000)), + NativeDenom: &types.DenomMetadata{ + Display: "OLD", + Base: "aold", + Exponent: 18, + }, + Sealed: true, + }, + }, + }, { + name: "Update rollapp: success - no initial supply, genesis info not sealed", + update: &types.MsgUpdateRollappInformation{ + Owner: alice, + RollappId: rollappId, + GenesisInfo: types.GenesisInfo{ + Bech32Prefix: "old", + GenesisChecksum: "old", + InitialSupply: nil, + NativeDenom: &types.DenomMetadata{ + Display: "OLD", + Base: "aold", + Exponent: 18, + }, + }, + }, + genInfoSealed: false, + expError: nil, + expRollapp: types.Rollapp{ + RollappId: rollappId, + Owner: alice, + VmType: types.Rollapp_EVM, + Metadata: &types.RollappMetadata{}, + GenesisInfo: types.GenesisInfo{ + Bech32Prefix: "old", + GenesisChecksum: "old", + InitialSupply: uptr.To(sdk.NewInt(1000)), + NativeDenom: &types.DenomMetadata{ + Display: "OLD", + Base: "aold", + Exponent: 18, + }, + }, + }, }, { name: "Update rollapp: success - update metadata when sealed", update: &types.MsgUpdateRollappInformation{ @@ -168,7 +227,7 @@ func (suite *RollappTestSuite) TestUpdateRollapp() { GenesisInfo: types.GenesisInfo{ Bech32Prefix: "old", GenesisChecksum: "old", - InitialSupply: sdk.NewInt(1000), + InitialSupply: uptr.To(sdk.NewInt(1000)), NativeDenom: &types.DenomMetadata{ Display: "OLD", Base: "aold", @@ -201,7 +260,7 @@ func (suite *RollappTestSuite) TestUpdateRollapp() { GenesisInfo: types.GenesisInfo{ Bech32Prefix: "old", GenesisChecksum: "old", - InitialSupply: sdk.NewInt(1000), + InitialSupply: uptr.To(sdk.NewInt(1000)), NativeDenom: &types.DenomMetadata{ Display: "OLD", Base: "aold", @@ -239,7 +298,7 @@ func (suite *RollappTestSuite) TestCreateAndUpdateRollapp() { GenesisInfo: types.GenesisInfo{ Bech32Prefix: "rol", GenesisChecksum: "checksum", - InitialSupply: sdk.NewInt(1000), + InitialSupply: uptr.To(sdk.NewInt(1000)), NativeDenom: &types.DenomMetadata{ Display: "DEN", Base: "aden", diff --git a/x/rollapp/keeper/rollapp.go b/x/rollapp/keeper/rollapp.go index 85ff6e8ac..068c665d0 100644 --- a/x/rollapp/keeper/rollapp.go +++ b/x/rollapp/keeper/rollapp.go @@ -51,7 +51,7 @@ func (k Keeper) CheckAndUpdateRollappFields(ctx sdk.Context, update *types.MsgUp current.GenesisInfo.NativeDenom = update.GenesisInfo.NativeDenom } - if !update.GenesisInfo.InitialSupply.IsNil() { + if update.GenesisInfo.InitialSupply != nil && !update.GenesisInfo.InitialSupply.IsNil() { current.GenesisInfo.InitialSupply = update.GenesisInfo.InitialSupply } diff --git a/x/rollapp/simulation/create_rollapp.go b/x/rollapp/simulation/create_rollapp.go index 997559856..e17454b78 100644 --- a/x/rollapp/simulation/create_rollapp.go +++ b/x/rollapp/simulation/create_rollapp.go @@ -7,6 +7,7 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/dymensionxyz/sdk-utils/utils/uptr" "github.com/dymensionxyz/dymension/v3/simulation" simulationtypes "github.com/dymensionxyz/dymension/v3/simulation/types" @@ -49,7 +50,7 @@ func SimulateMsgCreateRollapp(ak simulationtypes.AccountKeeper, bk simulationtyp Base: "udym", Exponent: 6, }, - InitialSupply: sdk.NewInt(1000000000), + InitialSupply: uptr.To(sdk.NewInt(1000000000)), }, } diff --git a/x/rollapp/types/message_create_rollapp_test.go b/x/rollapp/types/message_create_rollapp_test.go index 882b47b3a..66ac083f6 100644 --- a/x/rollapp/types/message_create_rollapp_test.go +++ b/x/rollapp/types/message_create_rollapp_test.go @@ -7,6 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/dymensionxyz/gerr-cosmos/gerrc" + "github.com/dymensionxyz/sdk-utils/utils/uptr" "github.com/stretchr/testify/require" "github.com/dymensionxyz/dymension/v3/testutil/sample" @@ -32,7 +33,7 @@ func TestMsgCreateRollapp_ValidateBasic(t *testing.T) { Bech32Prefix: bech32Prefix, GenesisChecksum: "checksum", NativeDenom: &DenomMetadata{Display: "DEN", Base: "aden", Exponent: 18}, - InitialSupply: sdk.NewInt(1000), + InitialSupply: uptr.To(sdk.NewInt(1000)), }, Metadata: &RollappMetadata{ Website: "https://dymension.xyz", @@ -59,7 +60,7 @@ func TestMsgCreateRollapp_ValidateBasic(t *testing.T) { Bech32Prefix: bech32Prefix, GenesisChecksum: "checksum", NativeDenom: &DenomMetadata{Display: "DEN", Base: "aden", Exponent: 18}, - InitialSupply: sdk.NewInt(1000), + InitialSupply: uptr.To(sdk.NewInt(1000)), }, }, err: ErrInvalidRollappID, @@ -76,7 +77,7 @@ func TestMsgCreateRollapp_ValidateBasic(t *testing.T) { Bech32Prefix: bech32Prefix, GenesisChecksum: "checksum", NativeDenom: &DenomMetadata{Display: "DEN", Base: "aden", Exponent: 18}, - InitialSupply: sdk.NewInt(1000), + InitialSupply: uptr.To(sdk.NewInt(1000)), }, }, err: ErrInvalidCreatorAddress, @@ -93,7 +94,7 @@ func TestMsgCreateRollapp_ValidateBasic(t *testing.T) { Bech32Prefix: bech32Prefix, GenesisChecksum: "checksum", NativeDenom: &DenomMetadata{Display: "DEN", Base: "aden", Exponent: 18}, - InitialSupply: sdk.NewInt(1000), + InitialSupply: uptr.To(sdk.NewInt(1000)), }, }, }, @@ -109,7 +110,7 @@ func TestMsgCreateRollapp_ValidateBasic(t *testing.T) { Bech32Prefix: bech32Prefix, GenesisChecksum: "checksum", NativeDenom: &DenomMetadata{Display: "DEN", Base: "aden", Exponent: 18}, - InitialSupply: sdk.NewInt(1000), + InitialSupply: uptr.To(sdk.NewInt(1000)), }, }, err: ErrInvalidInitialSequencer, @@ -126,7 +127,7 @@ func TestMsgCreateRollapp_ValidateBasic(t *testing.T) { Bech32Prefix: bech32Prefix, GenesisChecksum: "checksum", NativeDenom: &DenomMetadata{Display: "DEN", Base: "aden", Exponent: 18}, - InitialSupply: sdk.NewInt(1000), + InitialSupply: uptr.To(sdk.NewInt(1000)), }, }, err: nil, @@ -143,7 +144,7 @@ func TestMsgCreateRollapp_ValidateBasic(t *testing.T) { Bech32Prefix: bech32Prefix, GenesisChecksum: "checksum", NativeDenom: &DenomMetadata{Display: "DEN", Base: "aden", Exponent: 18}, - InitialSupply: sdk.NewInt(1000), + InitialSupply: uptr.To(sdk.NewInt(1000)), }, }, err: nil, @@ -162,7 +163,7 @@ func TestMsgCreateRollapp_ValidateBasic(t *testing.T) { Bech32Prefix: bech32Prefix, GenesisChecksum: "checksum", NativeDenom: &DenomMetadata{Display: "DEN", Base: "aden", Exponent: 18}, - InitialSupply: sdk.NewInt(1000), + InitialSupply: uptr.To(sdk.NewInt(1000)), }, }, err: ErrInvalidInitialSequencer, @@ -179,7 +180,7 @@ func TestMsgCreateRollapp_ValidateBasic(t *testing.T) { Bech32Prefix: "DYM", GenesisChecksum: "checksum", NativeDenom: &DenomMetadata{Display: "DEN", Base: "aden", Exponent: 18}, - InitialSupply: sdk.NewInt(1000), + InitialSupply: uptr.To(sdk.NewInt(1000)), }, }, err: gerrc.ErrInvalidArgument, @@ -196,7 +197,7 @@ func TestMsgCreateRollapp_ValidateBasic(t *testing.T) { Bech32Prefix: bech32Prefix, GenesisChecksum: "checksum", NativeDenom: &DenomMetadata{Display: "DEN", Base: "aden", Exponent: 18}, - InitialSupply: sdk.NewInt(1000), + InitialSupply: uptr.To(sdk.NewInt(1000)), }, Metadata: &RollappMetadata{ Website: "https://dymension.xyz", @@ -218,7 +219,7 @@ func TestMsgCreateRollapp_ValidateBasic(t *testing.T) { Bech32Prefix: bech32Prefix, GenesisChecksum: strings.Repeat("a", maxGenesisChecksumLength+1), NativeDenom: &DenomMetadata{Display: "DEN", Base: "aden", Exponent: 18}, - InitialSupply: sdk.NewInt(1000), + InitialSupply: uptr.To(sdk.NewInt(1000)), }, }, err: ErrInvalidGenesisChecksum, @@ -235,7 +236,7 @@ func TestMsgCreateRollapp_ValidateBasic(t *testing.T) { Bech32Prefix: bech32Prefix, GenesisChecksum: "checksum", NativeDenom: &DenomMetadata{Display: "DEN", Base: "aden", Exponent: 18}, - InitialSupply: sdk.NewInt(1000), + InitialSupply: uptr.To(sdk.NewInt(1000)), }, Metadata: &RollappMetadata{ ExplorerUrl: string(rune(0x7f)), @@ -255,11 +256,39 @@ func TestMsgCreateRollapp_ValidateBasic(t *testing.T) { Bech32Prefix: bech32Prefix, GenesisChecksum: "checksum", NativeDenom: &DenomMetadata{Display: "DEN", Base: "aden", Exponent: 18}, - InitialSupply: sdk.NewInt(-1), + InitialSupply: uptr.To(sdk.NewInt(-1)), }, }, err: ErrInvalidInitialSupply, }, + { + name: "no initial supply", + msg: MsgCreateRollapp{ + Creator: sample.AccAddress(), + InitialSequencer: sample.AccAddress(), + RollappId: "dym_100-1", + Alias: "alias", + VmType: Rollapp_EVM, + GenesisInfo: GenesisInfo{ + Bech32Prefix: bech32Prefix, + GenesisChecksum: "checksum", + NativeDenom: &DenomMetadata{Display: "DEN", Base: "aden", Exponent: 18}, + InitialSupply: nil, + }, + }, + err: nil, + }, + { + name: "no genesis info", + msg: MsgCreateRollapp{ + Creator: sample.AccAddress(), + InitialSequencer: sample.AccAddress(), + RollappId: "dym_100-1", + Alias: "alias", + VmType: Rollapp_EVM, + }, + err: nil, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/x/rollapp/types/message_update_rollapp.go b/x/rollapp/types/message_update_rollapp.go index 73e3f47b0..3d4acf08e 100644 --- a/x/rollapp/types/message_update_rollapp.go +++ b/x/rollapp/types/message_update_rollapp.go @@ -84,5 +84,5 @@ func (msg *MsgUpdateRollappInformation) UpdatingGenesisInfo() bool { return msg.GenesisInfo.GenesisChecksum != "" || msg.GenesisInfo.Bech32Prefix != "" || msg.GenesisInfo.NativeDenom != nil || - !msg.GenesisInfo.InitialSupply.IsNil() + (msg.GenesisInfo.InitialSupply != nil && !msg.GenesisInfo.InitialSupply.IsNil()) } diff --git a/x/rollapp/types/message_update_rollapp_test.go b/x/rollapp/types/message_update_rollapp_test.go index 245db358d..8e85a30f0 100644 --- a/x/rollapp/types/message_update_rollapp_test.go +++ b/x/rollapp/types/message_update_rollapp_test.go @@ -5,6 +5,7 @@ import ( "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" @@ -26,7 +27,7 @@ func TestMsgUpdateRollappInformation_ValidateBasic(t *testing.T) { Bech32Prefix: bech32Prefix, GenesisChecksum: "checksum", NativeDenom: &DenomMetadata{Display: "DEN", Base: "aden", Exponent: 18}, - InitialSupply: sdk.NewInt(1000), + InitialSupply: uptr.To(sdk.NewInt(1000)), }, Metadata: &RollappMetadata{ Website: "https://dymension.xyz", @@ -55,7 +56,7 @@ func TestMsgUpdateRollappInformation_ValidateBasic(t *testing.T) { Bech32Prefix: bech32Prefix, GenesisChecksum: "checksum", NativeDenom: &DenomMetadata{Display: "DEN", Base: "aden", Exponent: 18}, - InitialSupply: sdk.NewInt(1000), + InitialSupply: uptr.To(sdk.NewInt(1000)), }, }, err: ErrInvalidInitialSequencer, @@ -70,7 +71,7 @@ func TestMsgUpdateRollappInformation_ValidateBasic(t *testing.T) { Bech32Prefix: bech32Prefix, GenesisChecksum: "checksum", NativeDenom: &DenomMetadata{Display: "DEN", Base: "aden", Exponent: 18}, - InitialSupply: sdk.NewInt(1000), + InitialSupply: uptr.To(sdk.NewInt(1000)), }, Metadata: &RollappMetadata{ Website: "https://dymension.xyz", @@ -90,11 +91,35 @@ func TestMsgUpdateRollappInformation_ValidateBasic(t *testing.T) { Bech32Prefix: bech32Prefix, GenesisChecksum: strings.Repeat("a", maxGenesisChecksumLength+1), NativeDenom: &DenomMetadata{Display: "DEN", Base: "aden", Exponent: 18}, - InitialSupply: sdk.NewInt(1000), + InitialSupply: uptr.To(sdk.NewInt(1000)), }, }, err: ErrInvalidGenesisChecksum, }, + { + name: "no initial supply", + msg: MsgUpdateRollappInformation{ + Owner: sample.AccAddress(), + InitialSequencer: sample.AccAddress(), + RollappId: "dym_100-1", + GenesisInfo: GenesisInfo{ + Bech32Prefix: bech32Prefix, + GenesisChecksum: "checksum", + NativeDenom: &DenomMetadata{Display: "DEN", Base: "aden", Exponent: 18}, + InitialSupply: nil, + }, + }, + err: nil, + }, + { + name: "no genesis info", + msg: MsgUpdateRollappInformation{ + Owner: sample.AccAddress(), + InitialSequencer: sample.AccAddress(), + RollappId: "dym_100-1", + }, + err: nil, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/x/rollapp/types/rollapp.go b/x/rollapp/types/rollapp.go index bcea125ce..76965420a 100644 --- a/x/rollapp/types/rollapp.go +++ b/x/rollapp/types/rollapp.go @@ -92,7 +92,7 @@ func (r Rollapp) GenesisInfoFieldsAreSet() bool { r.GenesisInfo.NativeDenom != nil && r.GenesisInfo.NativeDenom.Validate() == nil && r.GenesisInfo.Bech32Prefix != "" && - !r.GenesisInfo.InitialSupply.IsNil() + (r.GenesisInfo.InitialSupply != nil && !r.GenesisInfo.InitialSupply.IsNil()) } func (r GenesisInfo) Validate() error { @@ -112,7 +112,7 @@ func (r GenesisInfo) Validate() error { } } - if !r.InitialSupply.IsNil() && r.InitialSupply.IsNegative() { + if r.InitialSupply != nil && !r.InitialSupply.IsNil() && r.InitialSupply.IsNegative() { return errorsmod.Wrap(ErrInvalidInitialSupply, "InitialSupply") } diff --git a/x/rollapp/types/rollapp.pb.go b/x/rollapp/types/rollapp.pb.go index 3822ac895..733fe7320 100644 --- a/x/rollapp/types/rollapp.pb.go +++ b/x/rollapp/types/rollapp.pb.go @@ -271,7 +271,7 @@ type GenesisInfo struct { // native_denom is the base denom for the native token NativeDenom *DenomMetadata `protobuf:"bytes,3,opt,name=native_denom,json=nativeDenom,proto3" json:"native_denom,omitempty"` // initial_supply is the initial supply of the native token - InitialSupply github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=initial_supply,json=initialSupply,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"initial_supply"` + InitialSupply *github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=initial_supply,json=initialSupply,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"initial_supply,omitempty"` // sealed indicates if the fields in this object are no longer updatable Sealed bool `protobuf:"varint,5,opt,name=sealed,proto3" json:"sealed,omitempty"` } @@ -431,58 +431,59 @@ func init() { } var fileDescriptor_d4ef2bec3aea5528 = []byte{ - // 815 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0x5f, 0x6f, 0x1b, 0x45, - 0x10, 0xf7, 0xd9, 0x4e, 0x6c, 0x8f, 0x9d, 0xe4, 0xba, 0x6d, 0xe0, 0x88, 0xa8, 0x6b, 0x19, 0x09, + // 817 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0x51, 0x6f, 0x1b, 0x45, + 0x10, 0xf6, 0xd9, 0x4e, 0x6c, 0x8f, 0x9d, 0xe4, 0xba, 0x6d, 0xe0, 0x88, 0xa8, 0x63, 0x19, 0x09, 0x19, 0xda, 0xdc, 0x89, 0xa4, 0x12, 0xcf, 0x04, 0x42, 0xeb, 0xa2, 0xa0, 0xea, 0xd2, 0x14, 0xa9, - 0x0f, 0x9c, 0xce, 0x77, 0xe3, 0xf3, 0xaa, 0x77, 0x7b, 0xc7, 0xed, 0xda, 0xc4, 0xf9, 0x14, 0x7c, - 0x02, 0x3e, 0x4f, 0x1f, 0x2b, 0x5e, 0x40, 0x3c, 0x54, 0x28, 0xf9, 0x22, 0x68, 0xff, 0xd8, 0x35, - 0xa4, 0xc5, 0x11, 0x4f, 0x7b, 0xf3, 0x9b, 0x99, 0xdf, 0xce, 0xce, 0x6f, 0x6e, 0xe0, 0x41, 0x3c, - 0xcf, 0x90, 0x71, 0x9a, 0xb3, 0xf3, 0xf9, 0x85, 0xb7, 0x34, 0xbc, 0x32, 0x4f, 0xd3, 0xb0, 0x28, - 0x16, 0xa7, 0x5b, 0x94, 0xb9, 0xc8, 0x49, 0x77, 0x35, 0xda, 0x5d, 0x1a, 0xae, 0x89, 0xda, 0xbb, - 0x93, 0xe4, 0x49, 0xae, 0x42, 0x3d, 0xf9, 0xa5, 0xb3, 0xf6, 0x3e, 0x8c, 0x72, 0x9e, 0xe5, 0xdc, - 0xcb, 0x78, 0xe2, 0xcd, 0xbe, 0x90, 0x87, 0x71, 0x78, 0x6b, 0x2e, 0xe7, 0x22, 0x14, 0x18, 0x50, - 0x36, 0x5e, 0x30, 0xed, 0xaf, 0x49, 0xc8, 0x50, 0x84, 0x71, 0x28, 0x42, 0x1d, 0xde, 0x7f, 0x0c, - 0xb7, 0x7d, 0xed, 0x79, 0x84, 0x0c, 0x39, 0xe5, 0xa7, 0x92, 0x90, 0xdc, 0x87, 0x5b, 0xa2, 0x0c, - 0x19, 0x1f, 0x63, 0xc9, 0x03, 0x64, 0xe1, 0x28, 0xc5, 0xd8, 0xa9, 0xf6, 0xac, 0x41, 0xd3, 0xb7, - 0x97, 0x8e, 0x63, 0x8d, 0x3f, 0xa9, 0x37, 0x2d, 0xbb, 0xda, 0xff, 0x7d, 0x03, 0x1a, 0x86, 0x8a, - 0xdc, 0x05, 0x30, 0xf7, 0x05, 0x34, 0x76, 0xac, 0x9e, 0x35, 0x68, 0xf9, 0x2d, 0x83, 0x0c, 0x63, - 0x72, 0x07, 0x36, 0xf2, 0x9f, 0x19, 0x96, 0x8a, 0xb1, 0xe5, 0x6b, 0x83, 0xfc, 0x08, 0x5b, 0x89, - 0xae, 0x21, 0x50, 0xaf, 0x72, 0x1a, 0x3d, 0x6b, 0xd0, 0x3e, 0x38, 0x74, 0xff, 0xbb, 0xa3, 0xee, - 0x3b, 0xea, 0x3f, 0xaa, 0xbf, 0x7a, 0x73, 0xaf, 0xe2, 0x77, 0x92, 0xd5, 0x37, 0xdd, 0x05, 0x88, - 0x26, 0x21, 0x63, 0x98, 0xca, 0xa2, 0x9a, 0xba, 0x28, 0x83, 0x0c, 0x63, 0xf2, 0x01, 0x6c, 0x8e, - 0xcb, 0xfc, 0x02, 0x99, 0xd3, 0x52, 0xef, 0x34, 0x16, 0xf9, 0x1c, 0xec, 0x12, 0x13, 0xca, 0x05, - 0x96, 0x18, 0x7f, 0x83, 0x2c, 0xcf, 0xb8, 0x03, 0xbd, 0xda, 0xa0, 0xe5, 0x5f,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cc, 0x27, + 0x42, 0x91, 0x94, 0xbf, 0x88, 0x40, 0x5a, 0xae, 0x82, 0x35, 0xfd, 0x8b, 0x68, 0xab, 0xff, 0x5b, + 0x15, 0x36, 0x8d, 0xf0, 0x27, 0x93, 0x34, 0xa5, 0xc5, 0x8c, 0x7c, 0x0c, 0x6f, 0xfe, 0xf7, 0xdb, + 0x0b, 0xe0, 0x25, 0xd8, 0x09, 0x95, 0x68, 0x04, 0x1a, 0xf2, 0x08, 0x75, 0x67, 0xda, 0xab, 0x07, + 0xcc, 0x64, 0x8c, 0x32, 0x95, 0xe5, 0xdf, 0xe2, 0x21, 0x09, 0x7c, 0xa4, 0xb1, 0x6f, 0x19, 0xa7, + 0x09, 0xbb, 0xc0, 0x68, 0xe9, 0x92, 0xda, 0xff, 0xba, 0xe4, 0xdd, 0x84, 0xa4, 0x0f, 0x1d, 0xed, + 0xd4, 0xf3, 0xa5, 0xfa, 0x5c, 0xf7, 0xff, 0x81, 0x91, 0x47, 0xb0, 0xfd, 0x2f, 0x02, 0x13, 0xbc, + 0xa6, 0x82, 0xdf, 0xee, 0x3c, 0xfc, 0xfe, 0xf2, 0xba, 0x6b, 0xbd, 0xbe, 0xee, 0x5a, 0x7f, 0x5d, + 0x77, 0xad, 0x5f, 0x6e, 0xba, 0x95, 0xd7, 0x37, 0xdd, 0xca, 0x1f, 0x37, 0xdd, 0xca, 0xcb, 0x47, + 0x4b, 0xea, 0xbd, 0x63, 0xdb, 0x4f, 0x0f, 0xbc, 0xf3, 0xc5, 0xca, 0x57, 0x7a, 0x9e, 0xad, 0xab, + 0x85, 0x7f, 0xf0, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0x5f, 0x82, 0xf4, 0x8e, 0xcf, 0x06, 0x00, + 0x00, } func (m *RollappGenesisState) Marshal() (dAtA []byte, err error) { @@ -679,16 +680,18 @@ func (m *GenesisInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x28 } - { - size := m.InitialSupply.Size() - i -= size - if _, err := m.InitialSupply.MarshalTo(dAtA[i:]); err != nil { - return 0, err + if m.InitialSupply != nil { + { + size := m.InitialSupply.Size() + i -= size + if _, err := m.InitialSupply.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintRollapp(dAtA, i, uint64(size)) } - i = encodeVarintRollapp(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x22 } - i-- - dAtA[i] = 0x22 if m.NativeDenom != nil { { size, err := m.NativeDenom.MarshalToSizedBuffer(dAtA[:i]) @@ -877,8 +880,10 @@ func (m *GenesisInfo) Size() (n int) { l = m.NativeDenom.Size() n += 1 + l + sovRollapp(uint64(l)) } - l = m.InitialSupply.Size() - n += 1 + l + sovRollapp(uint64(l)) + if m.InitialSupply != nil { + l = m.InitialSupply.Size() + n += 1 + l + sovRollapp(uint64(l)) + } if m.Sealed { n += 2 } @@ -1556,6 +1561,8 @@ func (m *GenesisInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } + var v github_com_cosmos_cosmos_sdk_types.Int + m.InitialSupply = &v if err := m.InitialSupply.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/x/sequencer/keeper/msg_server_create_sequencer_test.go b/x/sequencer/keeper/msg_server_create_sequencer_test.go index 27cb8a264..1835096f0 100644 --- a/x/sequencer/keeper/msg_server_create_sequencer_test.go +++ b/x/sequencer/keeper/msg_server_create_sequencer_test.go @@ -9,6 +9,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" bankutil "github.com/cosmos/cosmos-sdk/x/bank/testutil" + "github.com/dymensionxyz/sdk-utils/utils/uptr" "github.com/dymensionxyz/sdk-utils/utils/urand" "github.com/dymensionxyz/dymension/v3/testutil/sample" @@ -128,7 +129,7 @@ func (suite *SequencerTestSuite) TestCreateSequencer() { GenesisInfo: rollapptypes.GenesisInfo{ Bech32Prefix: bech32Prefix, GenesisChecksum: "1234567890abcdefg", - InitialSupply: sdk.NewInt(1000), + InitialSupply: uptr.To(sdk.NewInt(1000)), NativeDenom: &rollapptypes.DenomMetadata{ Display: "DEN", Base: "aden", diff --git a/x/sequencer/keeper/sequencer_suite_test.go b/x/sequencer/keeper/sequencer_suite_test.go index 1ca199d1a..0395750da 100644 --- a/x/sequencer/keeper/sequencer_suite_test.go +++ b/x/sequencer/keeper/sequencer_suite_test.go @@ -10,6 +10,7 @@ import ( 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/dymensionxyz/sdk-utils/utils/uptr" "github.com/dymensionxyz/sdk-utils/utils/urand" "github.com/stretchr/testify/suite" @@ -58,7 +59,7 @@ func (suite *SequencerTestSuite) CreateRollappWithInitialSequencer(initSeq strin Bech32Prefix: "rol", GenesisChecksum: "checksum", NativeDenom: &rollapptypes.DenomMetadata{Display: "DEN", Base: "aden", Exponent: 18}, - InitialSupply: sdk.NewInt(1000), + InitialSupply: uptr.To(sdk.NewInt(1000)), }, InitialSequencer: initSeq, } From 1bddb43c304cbb71c5fe3baeeacc3f2e3aa4678b Mon Sep 17 00:00:00 2001 From: zale144 Date: Wed, 25 Sep 2024 09:26:13 +0200 Subject: [PATCH 2/3] PR comment fix --- x/rollapp/keeper/rollapp.go | 2 +- x/rollapp/types/message_update_rollapp.go | 2 +- x/rollapp/types/rollapp.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/x/rollapp/keeper/rollapp.go b/x/rollapp/keeper/rollapp.go index 068c665d0..89326ea8a 100644 --- a/x/rollapp/keeper/rollapp.go +++ b/x/rollapp/keeper/rollapp.go @@ -51,7 +51,7 @@ func (k Keeper) CheckAndUpdateRollappFields(ctx sdk.Context, update *types.MsgUp current.GenesisInfo.NativeDenom = update.GenesisInfo.NativeDenom } - if update.GenesisInfo.InitialSupply != nil && !update.GenesisInfo.InitialSupply.IsNil() { + if update.GenesisInfo.InitialSupply != nil && !update.GenesisInfo.InitialSupply.IsPositive() { current.GenesisInfo.InitialSupply = update.GenesisInfo.InitialSupply } diff --git a/x/rollapp/types/message_update_rollapp.go b/x/rollapp/types/message_update_rollapp.go index 3d4acf08e..13f1f0c9c 100644 --- a/x/rollapp/types/message_update_rollapp.go +++ b/x/rollapp/types/message_update_rollapp.go @@ -84,5 +84,5 @@ func (msg *MsgUpdateRollappInformation) UpdatingGenesisInfo() bool { return msg.GenesisInfo.GenesisChecksum != "" || msg.GenesisInfo.Bech32Prefix != "" || msg.GenesisInfo.NativeDenom != nil || - (msg.GenesisInfo.InitialSupply != nil && !msg.GenesisInfo.InitialSupply.IsNil()) + (msg.GenesisInfo.InitialSupply != nil && !msg.GenesisInfo.InitialSupply.IsPositive()) } diff --git a/x/rollapp/types/rollapp.go b/x/rollapp/types/rollapp.go index 76965420a..a0b6eb69f 100644 --- a/x/rollapp/types/rollapp.go +++ b/x/rollapp/types/rollapp.go @@ -92,7 +92,7 @@ func (r Rollapp) GenesisInfoFieldsAreSet() bool { r.GenesisInfo.NativeDenom != nil && r.GenesisInfo.NativeDenom.Validate() == nil && r.GenesisInfo.Bech32Prefix != "" && - (r.GenesisInfo.InitialSupply != nil && !r.GenesisInfo.InitialSupply.IsNil()) + (r.GenesisInfo.InitialSupply != nil && !r.GenesisInfo.InitialSupply.IsPositive()) } func (r GenesisInfo) Validate() error { From 3e9117236753a82f8ad1b8a2692ff21b47b84267 Mon Sep 17 00:00:00 2001 From: zale144 Date: Wed, 25 Sep 2024 10:20:21 +0200 Subject: [PATCH 3/3] Fix tests --- ibctesting/utils_test.go | 3 ++- x/incentives/keeper/suite_test.go | 3 ++- x/rollapp/keeper/rollapp.go | 2 +- x/rollapp/types/message_update_rollapp.go | 2 +- x/rollapp/types/rollapp.go | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/ibctesting/utils_test.go b/ibctesting/utils_test.go index 22fa55bcf..f672bfc96 100644 --- a/ibctesting/utils_test.go +++ b/ibctesting/utils_test.go @@ -21,6 +21,7 @@ import ( channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" ibctesting "github.com/cosmos/ibc-go/v7/testing" "github.com/cosmos/ibc-go/v7/testing/mock" + "github.com/dymensionxyz/sdk-utils/utils/uptr" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" @@ -144,7 +145,7 @@ func (s *utilSuite) createRollapp(transfersEnabled bool, channelID *string) { Base: "aden", Exponent: 18, }, - InitialSupply: sdk.NewInt(1000), + InitialSupply: uptr.To(sdk.NewInt(1000)), }, ) diff --git a/x/incentives/keeper/suite_test.go b/x/incentives/keeper/suite_test.go index 54fb2b02a..1d6f34249 100644 --- a/x/incentives/keeper/suite_test.go +++ b/x/incentives/keeper/suite_test.go @@ -8,6 +8,7 @@ import ( tmrand "github.com/cometbft/cometbft/libs/rand" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/dymensionxyz/sdk-utils/utils/uptr" "github.com/dymensionxyz/sdk-utils/utils/urand" "github.com/dymensionxyz/dymension/v3/x/incentives/types" @@ -222,7 +223,7 @@ func (suite *KeeperTestSuite) CreateDefaultRollapp(addr sdk.AccAddress) string { Base: "aden", Exponent: 18, }, - InitialSupply: sdk.NewInt(1000), + InitialSupply: uptr.To(sdk.NewInt(1000)), }, } diff --git a/x/rollapp/keeper/rollapp.go b/x/rollapp/keeper/rollapp.go index 211eadfe0..011cf3390 100644 --- a/x/rollapp/keeper/rollapp.go +++ b/x/rollapp/keeper/rollapp.go @@ -52,7 +52,7 @@ func (k Keeper) CheckAndUpdateRollappFields(ctx sdk.Context, update *types.MsgUp current.GenesisInfo.NativeDenom = update.GenesisInfo.NativeDenom } - if update.GenesisInfo.InitialSupply != nil && !update.GenesisInfo.InitialSupply.IsPositive() { + if update.GenesisInfo.InitialSupply != nil && update.GenesisInfo.InitialSupply.IsPositive() { current.GenesisInfo.InitialSupply = update.GenesisInfo.InitialSupply } diff --git a/x/rollapp/types/message_update_rollapp.go b/x/rollapp/types/message_update_rollapp.go index e3387daf7..2818d7d16 100644 --- a/x/rollapp/types/message_update_rollapp.go +++ b/x/rollapp/types/message_update_rollapp.go @@ -82,5 +82,5 @@ func (msg *MsgUpdateRollappInformation) UpdatingGenesisInfo() bool { return msg.GenesisInfo.GenesisChecksum != "" || msg.GenesisInfo.Bech32Prefix != "" || msg.GenesisInfo.NativeDenom.Base != "" || - (msg.GenesisInfo.InitialSupply != nil && !msg.GenesisInfo.InitialSupply.IsPositive()) + (msg.GenesisInfo.InitialSupply != nil && msg.GenesisInfo.InitialSupply.IsPositive()) } diff --git a/x/rollapp/types/rollapp.go b/x/rollapp/types/rollapp.go index 5d0a7e476..39a75ebf8 100644 --- a/x/rollapp/types/rollapp.go +++ b/x/rollapp/types/rollapp.go @@ -103,7 +103,7 @@ func (r Rollapp) GenesisInfoFieldsAreSet() bool { return r.GenesisInfo.GenesisChecksum != "" && r.GenesisInfo.NativeDenom.Validate() == nil && r.GenesisInfo.Bech32Prefix != "" && - (r.GenesisInfo.InitialSupply != nil && !r.GenesisInfo.InitialSupply.IsPositive()) + (r.GenesisInfo.InitialSupply != nil && !r.GenesisInfo.InitialSupply.IsNil()) } func (r Rollapp) IsVulnerable() bool {