diff --git a/x/evm/migrations/migrate_deliver_tx_gas_limit.go b/x/evm/migrations/migrate_deliver_tx_gas_limit.go new file mode 100644 index 000000000..d8802005b --- /dev/null +++ b/x/evm/migrations/migrate_deliver_tx_gas_limit.go @@ -0,0 +1,20 @@ +package migrations + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/sei-protocol/sei-chain/x/evm/keeper" + "github.com/sei-protocol/sei-chain/x/evm/types" +) + +func MigrateDeliverTxHookWasmGasLimitParam(ctx sdk.Context, k *keeper.Keeper) error { + // Fetch the current parameters + keeperParams := k.GetParams(ctx) + + // Update DeliverTxHookWasmGasLimit to the default value + keeperParams.DeliverTxHookWasmGasLimit = types.DefaultParams().DeliverTxHookWasmGasLimit + + // Set the updated parameters back in the keeper + k.SetParams(ctx, keeperParams) + + return nil +} diff --git a/x/evm/migrations/migrate_deliver_tx_gas_limit_test.go b/x/evm/migrations/migrate_deliver_tx_gas_limit_test.go new file mode 100644 index 000000000..5d88fb200 --- /dev/null +++ b/x/evm/migrations/migrate_deliver_tx_gas_limit_test.go @@ -0,0 +1,37 @@ +package migrations_test + +import ( + "testing" + + testkeeper "github.com/sei-protocol/sei-chain/testutil/keeper" + "github.com/sei-protocol/sei-chain/x/evm/migrations" + "github.com/sei-protocol/sei-chain/x/evm/types" + "github.com/stretchr/testify/require" + tmtypes "github.com/tendermint/tendermint/proto/tendermint/types" +) + +func TestMigrateDeliverTxHookWasmGasLimitParam(t *testing.T) { + k := testkeeper.EVMTestApp.EvmKeeper + ctx := testkeeper.EVMTestApp.NewContext(false, tmtypes.Header{}) + + currParams := k.GetParams(ctx) + + // Keep a copy of the other parameters to compare later + priorityNormalizer := currParams.PriorityNormalizer + baseFeePerGas := currParams.BaseFeePerGas + minimumFeePerGas := currParams.MinimumFeePerGas + + // Perform the migration + err := migrations.MigrateDeliverTxHookWasmGasLimitParam(ctx, &k) + require.NoError(t, err) + + keeperParams := k.GetParams(ctx) + + // Ensure that the DeliverTxHookWasmGasLimit was migrated to the default value + require.Equal(t, keeperParams.GetDeliverTxHookWasmGasLimit(), types.DefaultParams().DeliverTxHookWasmGasLimit) + + // Verify that the other parameters were not changed by the migration + require.True(t, keeperParams.PriorityNormalizer.Equal(priorityNormalizer)) + require.True(t, keeperParams.BaseFeePerGas.Equal(baseFeePerGas)) + require.True(t, keeperParams.MinimumFeePerGas.Equal(minimumFeePerGas)) +} diff --git a/x/evm/module.go b/x/evm/module.go index b5db176a4..fbbd882a3 100644 --- a/x/evm/module.go +++ b/x/evm/module.go @@ -208,6 +208,10 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { _ = cfg.RegisterMigration(types.ModuleName, 10, func(ctx sdk.Context) error { return migrations.MigrateCastAddressBalances(ctx, am.keeper) }) + + _ = cfg.RegisterMigration(types.ModuleName, 11, func(ctx sdk.Context) error { + return migrations.MigrateDeliverTxHookWasmGasLimitParam(ctx, am.keeper) + }) } // RegisterInvariants registers the capability module's invariants. @@ -245,7 +249,7 @@ func (am AppModule) ExportGenesisStream(ctx sdk.Context, cdc codec.JSONCodec) <- } // ConsensusVersion implements ConsensusVersion. -func (AppModule) ConsensusVersion() uint64 { return 11 } +func (AppModule) ConsensusVersion() uint64 { return 12 } // BeginBlock executes all ABCI BeginBlock logic respective to the capability module. func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { diff --git a/x/evm/module_test.go b/x/evm/module_test.go index 181cd0377..d9ad4a0dd 100644 --- a/x/evm/module_test.go +++ b/x/evm/module_test.go @@ -59,7 +59,7 @@ func TestModuleExportGenesis(t *testing.T) { func TestConsensusVersion(t *testing.T) { k, _ := testkeeper.MockEVMKeeper() module := evm.NewAppModule(nil, k) - assert.Equal(t, uint64(11), module.ConsensusVersion()) + assert.Equal(t, uint64(12), module.ConsensusVersion()) } func TestABCI(t *testing.T) {