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

Commit

Permalink
fix(evm): handle RC1 params during migration (#1624)
Browse files Browse the repository at this point in the history
* fix(evm): handle RC1 params during migration

* migration

* fix: test case updated for RC1

* v5 migration

* tests

* tests pt2

* comment

* execute make proto-all

Co-authored-by: Vladislav Varadinov <[email protected]>
Co-authored-by: MalteHerrmann <[email protected]>
  • Loading branch information
3 people authored Jan 23, 2023
1 parent 2c50d32 commit 085f84f
Show file tree
Hide file tree
Showing 16 changed files with 1,199 additions and 1,146 deletions.
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(ibctransfertypes.ModuleName)
paramsKeeper.Subspace(ibchost.ModuleName)
// ethermint subspaces
paramsKeeper.Subspace(evmtypes.ModuleName).WithKeyTable(evmtypes.ParamKeyTable())
paramsKeeper.Subspace(evmtypes.ModuleName).WithKeyTable(evmtypes.ParamKeyTable()) //nolint: staticcheck
paramsKeeper.Subspace(feemarkettypes.ModuleName).WithKeyTable(feemarkettypes.ParamKeyTable())
return paramsKeeper
}
12 changes: 1 addition & 11 deletions proto/ethermint/evm/v1/evm.proto
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,14 @@ message Params {
// enable_call toggles state transitions that use the vm.Call function
bool enable_call = 3 [(gogoproto.moretags) = "yaml:\"enable_call\""];
// extra_eips defines the additional EIPs for the vm.Config
ExtraEIPs extra_eips = 4 [
(gogoproto.customname) = "ExtraEIPs",
(gogoproto.moretags) = "yaml:\"extra_eips\"",
(gogoproto.nullable) = false
];
repeated int64 extra_eips = 4 [(gogoproto.customname) = "ExtraEIPs", (gogoproto.moretags) = "yaml:\"extra_eips\""];
// chain_config defines the EVM chain configuration parameters
ChainConfig chain_config = 5 [(gogoproto.moretags) = "yaml:\"chain_config\"", (gogoproto.nullable) = false];
// allow_unprotected_txs defines if replay-protected (i.e non EIP155
// signed) transactions can be executed on the state machine.
bool allow_unprotected_txs = 6;
}

// ExtraEIPs represents extra EIPs for the vm.Config
message ExtraEIPs {
// eips defines the additional EIPs for the vm.Config
repeated int64 eips = 1 [(gogoproto.customname) = "EIPs", (gogoproto.moretags) = "yaml:\"eips\""];
}

// ChainConfig defines the Ethereum ChainConfig parameters using *sdk.Int values
// instead of *big.Int.
message ChainConfig {
Expand Down
6 changes: 6 additions & 0 deletions x/evm/keeper/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package keeper
import (
sdk "github.com/cosmos/cosmos-sdk/types"
v4 "github.com/evmos/ethermint/x/evm/migrations/v4"
v5 "github.com/evmos/ethermint/x/evm/migrations/v5"
"github.com/evmos/ethermint/x/evm/types"
)

Expand All @@ -39,3 +40,8 @@ func NewMigrator(keeper Keeper, legacySubspace types.Subspace) Migrator {
func (m Migrator) Migrate3to4(ctx sdk.Context) error {
return v4.MigrateStore(ctx, m.keeper.storeKey, m.legacySubspace, m.keeper.cdc)
}

// Migrate4to5 migrates the store from consensus version 4 to 5
func (m Migrator) Migrate4to5(ctx sdk.Context) error {
return v5.MigrateStore(ctx, m.keeper.storeKey, m.keeper.cdc)
}
12 changes: 7 additions & 5 deletions x/evm/migrations/v4/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ func MigrateStore(
legacySubspace types.Subspace,
cdc codec.BinaryCodec,
) error {
var (
store = ctx.KVStore(storeKey)
params types.Params
)

var params types.Params
legacySubspace.GetParamSetIfExists(ctx, &params)

err := params.Validate()
if err != nil {
return err
}

if err := params.Validate(); err != nil {
return err
}
Expand All @@ -32,6 +33,7 @@ func MigrateStore(
return err
}

store := ctx.KVStore(storeKey)
store.Set(types.KeyPrefixParams, bz)

return nil
Expand Down
7 changes: 4 additions & 3 deletions x/evm/migrations/v4/migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ package v4_test
import (
"testing"

"github.com/evmos/ethermint/x/evm/types"
"github.com/stretchr/testify/require"

"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/evmos/ethermint/app"
"github.com/evmos/ethermint/encoding"
v4 "github.com/evmos/ethermint/x/evm/migrations/v4"
"github.com/stretchr/testify/require"
"github.com/evmos/ethermint/x/evm/types"
)

type mockSubspace struct {
Expand All @@ -30,7 +31,7 @@ func TestMigrate(t *testing.T) {
cdc := encCfg.Codec

storeKey := sdk.NewKVStoreKey(types.ModuleName)
tKey := sdk.NewTransientStoreKey("transient_test")
tKey := sdk.NewTransientStoreKey(types.TransientKey)
ctx := testutil.DefaultContext(storeKey, tKey)
kvStore := ctx.KVStore(storeKey)

Expand Down
175 changes: 0 additions & 175 deletions x/evm/migrations/v4/types/chain_config.go

This file was deleted.

Loading

0 comments on commit 085f84f

Please sign in to comment.