Skip to content

Commit

Permalink
Fixes bug were migration targeted legacy parameters at the wrong store (
Browse files Browse the repository at this point in the history
#21)

key location; should have been using the params module store keys when
creating a subspace;
  • Loading branch information
nddeluca authored May 2, 2023
1 parent 7e6046f commit 76790fb
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
3 changes: 2 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
7 changes: 7 additions & 0 deletions x/evm/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -118,6 +123,8 @@ func NewKeeper(
feeMarketKeeper: fmk,
storeKey: storeKey,
transientKey: transientKey,
paramStoreKey: paramStoreKey,
paramStoreTKey: paramStoreTKey,
customPrecompiles: customPrecompiles,
evmConstructor: evmConstructor,
tracer: tracer,
Expand Down
3 changes: 2 additions & 1 deletion x/evm/keeper/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
}
7 changes: 4 additions & 3 deletions x/evm/migrations/v3/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand Down
8 changes: 4 additions & 4 deletions x/evm/migrations/v3/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 76790fb

Please sign in to comment.