-
Notifications
You must be signed in to change notification settings - Fork 808
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add migration for new params (#1840)
* Add migration function for DeliverTxHookWasmGasLimitParam --------- Co-authored-by: blindchaser <[email protected]>
- Loading branch information
1 parent
942e73d
commit c2a0d85
Showing
4 changed files
with
63 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters