Skip to content
This repository was archived by the owner on Apr 4, 2024. It is now read-only.

Commit 9bfa1ff

Browse files
fix(evm): revert v4 migration changes (#1625)
* fix(evm): revert v4 migration changes * add check for chainID * fix: renamed vars to avoid duplicate proto * test * fix: set default extraEIPs to nil * fix: updated tests Co-authored-by: Vladislav Varadinov <vladislav.varadinov@gmail.com>
1 parent f07b14f commit 9bfa1ff

File tree

5 files changed

+279
-179
lines changed

5 files changed

+279
-179
lines changed

x/evm/migrations/v4/migrate.go

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"github.com/cosmos/cosmos-sdk/codec"
55
storetypes "github.com/cosmos/cosmos-sdk/store/types"
66
sdk "github.com/cosmos/cosmos-sdk/types"
7+
8+
v4types "github.com/evmos/ethermint/x/evm/migrations/v4/types"
79
"github.com/evmos/ethermint/x/evm/types"
810
)
911

@@ -17,19 +19,33 @@ func MigrateStore(
1719
cdc codec.BinaryCodec,
1820
) error {
1921
var params types.Params
22+
2023
legacySubspace.GetParamSetIfExists(ctx, &params)
2124

2225
if err := params.Validate(); err != nil {
2326
return err
2427
}
2528

26-
bz, err := cdc.Marshal(&params)
27-
if err != nil {
28-
return err
29-
}
29+
chainCfgBz := cdc.MustMarshal(&params.ChainConfig)
30+
extraEIPsBz := cdc.MustMarshal(&v4types.ExtraEIPs{EIPs: params.ExtraEIPs})
3031

3132
store := ctx.KVStore(storeKey)
32-
store.Set(types.KeyPrefixParams, bz)
33+
34+
store.Set(types.ParamStoreKeyEVMDenom, []byte(params.EvmDenom))
35+
store.Set(types.ParamStoreKeyExtraEIPs, extraEIPsBz)
36+
store.Set(types.ParamStoreKeyChainConfig, chainCfgBz)
37+
38+
if params.AllowUnprotectedTxs {
39+
store.Set(types.ParamStoreKeyAllowUnprotectedTxs, []byte{0x01})
40+
}
41+
42+
if params.EnableCall {
43+
store.Set(types.ParamStoreKeyEnableCall, []byte{0x01})
44+
}
45+
46+
if params.EnableCreate {
47+
store.Set(types.ParamStoreKeyEnableCreate, []byte{0x01})
48+
}
3349

3450
return nil
3551
}

x/evm/migrations/v4/migrate_test.go

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ import (
55

66
"github.com/stretchr/testify/require"
77

8+
"github.com/evmos/ethermint/x/evm/types"
9+
810
"github.com/cosmos/cosmos-sdk/testutil"
911
sdk "github.com/cosmos/cosmos-sdk/types"
10-
1112
"github.com/evmos/ethermint/app"
1213
"github.com/evmos/ethermint/encoding"
1314
v4 "github.com/evmos/ethermint/x/evm/migrations/v4"
14-
"github.com/evmos/ethermint/x/evm/types"
15+
v4types "github.com/evmos/ethermint/x/evm/migrations/v4/types"
1516
)
1617

1718
type mockSubspace struct {
@@ -38,9 +39,36 @@ func TestMigrate(t *testing.T) {
3839
legacySubspace := newMockSubspace(types.DefaultParams())
3940
require.NoError(t, v4.MigrateStore(ctx, storeKey, legacySubspace, cdc))
4041

41-
paramsBz := kvStore.Get(types.KeyPrefixParams)
42-
var params types.Params
43-
cdc.MustUnmarshal(paramsBz, &params)
42+
// Get all the new parameters from the kvStore
43+
var evmDenom string
44+
bz := kvStore.Get(types.ParamStoreKeyEVMDenom)
45+
evmDenom = string(bz)
46+
47+
allowUnprotectedTx := kvStore.Has(types.ParamStoreKeyAllowUnprotectedTxs)
48+
enableCreate := kvStore.Has(types.ParamStoreKeyEnableCreate)
49+
enableCall := kvStore.Has(types.ParamStoreKeyEnableCall)
50+
51+
var chainCfg v4types.V4ChainConfig
52+
bz = kvStore.Get(types.ParamStoreKeyChainConfig)
53+
cdc.MustUnmarshal(bz, &chainCfg)
54+
55+
var extraEIPs v4types.ExtraEIPs
56+
bz = kvStore.Get(types.ParamStoreKeyExtraEIPs)
57+
cdc.MustUnmarshal(bz, &extraEIPs)
58+
require.Equal(t, []int64(nil), extraEIPs.EIPs)
59+
60+
params := v4types.V4Params{
61+
EvmDenom: evmDenom,
62+
AllowUnprotectedTxs: allowUnprotectedTx,
63+
EnableCreate: enableCreate,
64+
EnableCall: enableCall,
65+
V4ChainConfig: chainCfg,
66+
ExtraEIPs: extraEIPs,
67+
}
4468

45-
require.Equal(t, params, legacySubspace.ps)
69+
require.Equal(t, legacySubspace.ps.EnableCall, params.EnableCall)
70+
require.Equal(t, legacySubspace.ps.EnableCreate, params.EnableCreate)
71+
require.Equal(t, legacySubspace.ps.AllowUnprotectedTxs, params.AllowUnprotectedTxs)
72+
require.Equal(t, legacySubspace.ps.ExtraEIPs, params.ExtraEIPs.EIPs)
73+
require.EqualValues(t, legacySubspace.ps.ChainConfig, params.V4ChainConfig)
4674
}

0 commit comments

Comments
 (0)