Skip to content

Commit

Permalink
Merge pull request #18 from Kava-Labs/v0.21.1-kava
Browse files Browse the repository at this point in the history
Fix evm migration issues & rewrite feemarket migration
  • Loading branch information
DracoLi committed Apr 14, 2023
2 parents a1c73fd + f58d8b2 commit 949af4b
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 851 deletions.
2 changes: 1 addition & 1 deletion x/evm/keeper/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func NewMigrator(keeper Keeper, legacySubspace types.Subspace) Migrator {
}
}

// Migrate3to4 migrates the store from consensus version 2 to 3
// Migrate2to3 migrates the store from consensus version 2 to 3
func (m Migrator) Migrate2to3(ctx sdk.Context) error {
return v3.MigrateStore(
ctx,
Expand Down
5 changes: 5 additions & 0 deletions x/evm/migrations/v3/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ func MigrateStore(
cdc codec.BinaryCodec,
) error {
var legacyParams v2types.V2Params
if !paramstore.HasKeyTable() {
ps := paramstore.WithKeyTable(v2types.ParamKeyTable())
paramstore = ps
}

paramstore.GetParamSetIfExists(ctx, &legacyParams)

// -------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions x/evm/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {

// ConsensusVersion returns the consensus state-breaking version for the module.
func (AppModuleBasic) ConsensusVersion() uint64 {
return 5
return ConsensusVersion
}

// DefaultGenesis returns default genesis state as raw bytes for the evm
Expand Down Expand Up @@ -148,7 +148,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {

// This migration is a Kava specific migration that also includes the
// upstream migrations from 3 to 5.
err := cfg.RegisterMigration(types.ModuleName, 3, m.Migrate2to3)
err := cfg.RegisterMigration(types.ModuleName, 2, m.Migrate2to3)
if err != nil {
panic(err)
}
Expand Down
2 changes: 2 additions & 0 deletions x/evm/types/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,7 @@ type (
// NOTE: This is used solely for migration of the Cosmos SDK x/params managed parameters.
Subspace interface {
GetParamSetIfExists(ctx sdk.Context, ps LegacyParams)
HasKeyTable() bool
WithKeyTable(table paramtypes.KeyTable) paramtypes.Subspace
}
)
8 changes: 4 additions & 4 deletions x/feemarket/keeper/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package keeper

import (
sdk "github.com/cosmos/cosmos-sdk/types"
v4 "github.com/evmos/ethermint/x/feemarket/migrations/v4"
v3 "github.com/evmos/ethermint/x/feemarket/migrations/v3"
"github.com/evmos/ethermint/x/feemarket/types"
)

Expand All @@ -35,7 +35,7 @@ func NewMigrator(keeper Keeper, legacySubspace types.Subspace) Migrator {
}
}

// Migrate3to4 migrates the store from consensus version 3 to 4
func (m Migrator) Migrate3to4(ctx sdk.Context) error {
return v4.MigrateStore(ctx, m.keeper.storeKey, m.legacySubspace, m.keeper.cdc)
// Migrate2to3 migrates the store from consensus version 2 to 3
func (m Migrator) Migrate2to3(ctx sdk.Context) error {
return v3.MigrateStore(ctx, m.keeper.storeKey, m.keeper.cdc)
}
4 changes: 2 additions & 2 deletions x/feemarket/keeper/migrations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ func (suite *KeeperTestSuite) TestMigrations() {
migrateFunc func(ctx sdk.Context) error
}{
{
"Run Migrate3to4",
migrator.Migrate3to4,
"Run Migrate2to3",
migrator.Migrate2to3,
},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,17 @@ import (
"github.com/evmos/ethermint/x/feemarket/types"
)

// MigrateStore migrates the x/evm module state from the consensus version 3 to
// version 4. Specifically, it takes the parameters that are currently stored
// and managed by the Cosmos SDK params module and stores them directly into the x/evm module state.
// MigrateStore migrates the x/feemarket module state from the consensus version 2 to version 3
func MigrateStore(
ctx sdk.Context,
storeKey storetypes.StoreKey,
legacySubspace types.Subspace,
cdc codec.BinaryCodec,
) error {
var (
store = ctx.KVStore(storeKey)
params types.Params
params = types.DefaultParams()
)

legacySubspace.GetParamSetIfExists(ctx, &params)
params.NoBaseFee = true

if err := params.Validate(); err != nil {
return err
Expand Down
51 changes: 0 additions & 51 deletions x/feemarket/migrations/v4/migrate_test.go

This file was deleted.

Loading

0 comments on commit 949af4b

Please sign in to comment.