Skip to content

Commit

Permalink
add migration function for DeliverTxHookWasmGasLimitParam
Browse files Browse the repository at this point in the history
  • Loading branch information
blindchaser committed Aug 30, 2024
1 parent 58544eb commit 426c5b3
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
15 changes: 15 additions & 0 deletions x/evm/migrations/migrate_deliver_tx_gas_limit.go
Original file line number Diff line number Diff line change
@@ -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 MigrateDeliverTxHookWasmGasLimitParam(ctx sdk.Context, k *keeper.Keeper) error {
defaultParams := types.DefaultParams()
defaultDeliverTxHookWasmGasLimit := defaultParams.DeliverTxHookWasmGasLimit
defaultParams.DeliverTxHookWasmGasLimit = defaultDeliverTxHookWasmGasLimit
k.SetParams(ctx, defaultParams)
return nil
}
26 changes: 26 additions & 0 deletions x/evm/migrations/migrate_deliver_tx_gas_limit_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
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{})

err := migrations.MigrateDeliverTxHookWasmGasLimitParam(ctx, &k)

require.NoError(t, err)

require.NotPanics(t, func() { k.GetParams(ctx) })

keeperParams := k.GetParams(ctx)

require.Equal(t, keeperParams.GetDeliverTxHookWasmGasLimit(), types.DefaultParams().DeliverTxHookWasmGasLimit)
}
2 changes: 1 addition & 1 deletion x/evm/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {
})

_ = cfg.RegisterMigration(types.ModuleName, 11, func(ctx sdk.Context) error {
return migrations.AddNewParamsAndSetAllToDefaults(ctx, am.keeper)
return migrations.MigrateDeliverTxHookWasmGasLimitParam(ctx, am.keeper)
})
}

Expand Down

0 comments on commit 426c5b3

Please sign in to comment.