diff --git a/x/evm/migrations/migrate_eip_1559_params.go b/x/evm/migrations/migrate_eip_1559_params.go new file mode 100644 index 000000000..e6dba7b16 --- /dev/null +++ b/x/evm/migrations/migrate_eip_1559_params.go @@ -0,0 +1,15 @@ +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 MigrateEip1559Params(ctx sdk.Context, k *keeper.Keeper) error { + keeperParams := k.GetParamsIfExists(ctx) + keeperParams.MaxDynamicBaseFeeUpwardAdjustment = types.DefaultParams().MaxDynamicBaseFeeUpwardAdjustment + keeperParams.MaxDynamicBaseFeeDownwardAdjustment = types.DefaultParams().MaxDynamicBaseFeeDownwardAdjustment + k.SetParams(ctx, keeperParams) + return nil +} diff --git a/x/evm/migrations/migrate_eip_1559_params_test.go b/x/evm/migrations/migrate_eip_1559_params_test.go new file mode 100644 index 000000000..df32ccb77 --- /dev/null +++ b/x/evm/migrations/migrate_eip_1559_params_test.go @@ -0,0 +1,27 @@ +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 TestMigrateEip1559Params(t *testing.T) { + k := testkeeper.EVMTestApp.EvmKeeper + ctx := testkeeper.EVMTestApp.NewContext(false, tmtypes.Header{}) + + // Perform the migration + err := migrations.MigrateEip1559Params(ctx, &k) + require.NoError(t, err) + + keeperParams := k.GetParams(ctx) + + // Ensure that the EIP-1559 parameters were migrated to the default values + require.Equal(t, keeperParams.BaseFeePerGas, types.DefaultParams().BaseFeePerGas) + require.Equal(t, keeperParams.MaxDynamicBaseFeeUpwardAdjustment, types.DefaultParams().MaxDynamicBaseFeeUpwardAdjustment) + require.Equal(t, keeperParams.MaxDynamicBaseFeeDownwardAdjustment, types.DefaultParams().MaxDynamicBaseFeeDownwardAdjustment) +} diff --git a/x/evm/module.go b/x/evm/module.go index d1ebceb3e..90b891720 100644 --- a/x/evm/module.go +++ b/x/evm/module.go @@ -216,6 +216,10 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { _ = cfg.RegisterMigration(types.ModuleName, 12, func(ctx sdk.Context) error { return migrations.MigrateBlockBloom(ctx, am.keeper) }) + + _ = cfg.RegisterMigration(types.ModuleName, 13, func(ctx sdk.Context) error { + return migrations.MigrateEip1559Params(ctx, am.keeper) + }) } // RegisterInvariants registers the capability module's invariants.