From 76790fbce711c285b5b34bf81ffdb6a330bcab8f Mon Sep 17 00:00:00 2001 From: Nick DeLuca Date: Tue, 2 May 2023 08:04:14 -0700 Subject: [PATCH] Fixes bug were migration targeted legacy parameters at the wrong store (#21) key location; should have been using the params module store keys when creating a subspace; --- app/app.go | 3 ++- x/evm/keeper/keeper.go | 7 +++++++ x/evm/keeper/migrations.go | 3 ++- x/evm/migrations/v3/store.go | 7 ++++--- x/evm/migrations/v3/store_test.go | 8 ++++---- 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/app/app.go b/app/app.go index 9b2ff62eb9..2c2256c456 100644 --- a/app/app.go +++ b/app/app.go @@ -418,7 +418,8 @@ func NewEthermintApp( // Set authority to x/gov module account to only expect the module account to update params evmSs := app.GetSubspace(evmtypes.ModuleName) app.EvmKeeper = evmkeeper.NewKeeper( - appCodec, cdc, keys[evmtypes.StoreKey], tkeys[evmtypes.TransientKey], authtypes.NewModuleAddress(govtypes.ModuleName), + appCodec, cdc, keys[evmtypes.StoreKey], tkeys[evmtypes.TransientKey], keys[paramstypes.StoreKey], tkeys[paramstypes.TStoreKey], + authtypes.NewModuleAddress(govtypes.ModuleName), app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.FeeMarketKeeper, nil, geth.NewEVM, tracer, evmSs, ) diff --git a/x/evm/keeper/keeper.go b/x/evm/keeper/keeper.go index 51e4e6486a..79288b696e 100644 --- a/x/evm/keeper/keeper.go +++ b/x/evm/keeper/keeper.go @@ -53,6 +53,10 @@ type Keeper struct { // key to access the transient store, which is reset on every block during Commit transientKey storetypes.StoreKey + // keys used by migrator and interaction with legacy parameter store + paramStoreKey storetypes.StoreKey + paramStoreTKey storetypes.StoreKey + // the address capable of executing a MsgUpdateParams message. Typically, this should be the x/gov module account. authority sdk.AccAddress // access to account state @@ -87,6 +91,7 @@ func NewKeeper( cdc codec.BinaryCodec, legacyAmino *codec.LegacyAmino, storeKey, transientKey storetypes.StoreKey, + paramStoreKey, paramStoreTKey storetypes.StoreKey, authority sdk.AccAddress, ak types.AccountKeeper, bankKeeper types.BankKeeper, @@ -118,6 +123,8 @@ func NewKeeper( feeMarketKeeper: fmk, storeKey: storeKey, transientKey: transientKey, + paramStoreKey: paramStoreKey, + paramStoreTKey: paramStoreTKey, customPrecompiles: customPrecompiles, evmConstructor: evmConstructor, tracer: tracer, diff --git a/x/evm/keeper/migrations.go b/x/evm/keeper/migrations.go index ebe6c7b882..646def4d96 100644 --- a/x/evm/keeper/migrations.go +++ b/x/evm/keeper/migrations.go @@ -39,6 +39,7 @@ func (m Migrator) Migrate2to3(ctx sdk.Context) error { m.keeper.cdc, m.keeper.legacyAmino, m.keeper.storeKey, - m.keeper.transientKey, + m.keeper.paramStoreKey, + m.keeper.paramStoreTKey, ) } diff --git a/x/evm/migrations/v3/store.go b/x/evm/migrations/v3/store.go index 2304ce2787..09566fba85 100644 --- a/x/evm/migrations/v3/store.go +++ b/x/evm/migrations/v3/store.go @@ -16,15 +16,16 @@ func MigrateStore( cdc codec.BinaryCodec, legacyAmino *codec.LegacyAmino, storeKey storetypes.StoreKey, - transientKey storetypes.StoreKey, + paramStoreKey storetypes.StoreKey, + paramStoreTKey storetypes.StoreKey, ) error { // create independent paramstore with key table that is // not tied to global state paramstore := paramtypes.NewSubspace( cdc, legacyAmino, - storeKey, - transientKey, + paramStoreKey, + paramStoreTKey, types.ModuleName, ).WithKeyTable(v2types.ParamKeyTable()) diff --git a/x/evm/migrations/v3/store_test.go b/x/evm/migrations/v3/store_test.go index 4a26d52f5e..9b5786dab3 100644 --- a/x/evm/migrations/v3/store_test.go +++ b/x/evm/migrations/v3/store_test.go @@ -20,8 +20,8 @@ func TestMigrate(t *testing.T) { encCfg := encoding.MakeConfig(app.ModuleBasics) cdc := encCfg.Codec - storeKey := sdk.NewKVStoreKey(types.ModuleName) - tKey := sdk.NewTransientStoreKey(types.TransientKey) + storeKey := sdk.NewKVStoreKey(paramtypes.ModuleName) + tKey := sdk.NewTransientStoreKey(paramtypes.TStoreKey) ctx := testutil.DefaultContext(storeKey, tKey) kvStore := ctx.KVStore(storeKey) @@ -73,8 +73,8 @@ func TestMigrate_Mainnet(t *testing.T) { encCfg := encoding.MakeConfig(app.ModuleBasics) cdc := encCfg.Codec - storeKey := sdk.NewKVStoreKey(types.ModuleName) - tKey := sdk.NewTransientStoreKey(types.TransientKey) + storeKey := sdk.NewKVStoreKey(paramtypes.ModuleName) + tKey := sdk.NewTransientStoreKey(paramtypes.TStoreKey) ctx := testutil.DefaultContext(storeKey, tKey) kvStore := ctx.KVStore(storeKey)