diff --git a/x/feemarket/keeper/migrations.go b/x/feemarket/keeper/migrations.go index 3be1ada66f..640805bda3 100644 --- a/x/feemarket/keeper/migrations.go +++ b/x/feemarket/keeper/migrations.go @@ -1,5 +1,11 @@ package keeper +import ( + "math/big" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + // Migrator is a struct for handling in-place store migrations. type Migrator struct { keeper Keeper @@ -11,3 +17,15 @@ func NewMigrator(keeper Keeper) Migrator { keeper: keeper, } } + +func (m Migrator) Migrate1to2(ctx sdk.Context) error { + store := ctx.KVStore(m.keeper.storeKey) + baseFeeKeyPrefix := []byte{2} + bz := store.Get(baseFeeKeyPrefix) + if len(bz) > 0 { + baseFee := new(big.Int).SetBytes(bz) + m.keeper.SetBaseFee(ctx, baseFee) + } + store.Delete(baseFeeKeyPrefix) + return nil +} diff --git a/x/feemarket/module.go b/x/feemarket/module.go index 3abf7c769b..71e0c6d0d7 100644 --- a/x/feemarket/module.go +++ b/x/feemarket/module.go @@ -44,7 +44,7 @@ func (AppModuleBasic) RegisterLegacyAminoCodec(_ *codec.LegacyAmino) { // ConsensusVersion returns the consensus state-breaking version for the module. func (AppModuleBasic) ConsensusVersion() uint64 { - return 1 + return 2 } // DefaultGenesis returns default genesis state as raw bytes for the fee market @@ -117,7 +117,11 @@ func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {} func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterQueryServer(cfg.QueryServer(), am.keeper) - _ = keeper.NewMigrator(am.keeper) + m := keeper.NewMigrator(am.keeper) + err := cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1to2) + if err != nil { + panic(err) + } } // Route returns the message routing key for the fee market module.