29d3abcf09
* Reuse cosmos-sdk client library to create keyring Extracted from https://github.com/evmos/ethermint/pull/1168 Cleanup cmd code for easier to migration to cosmos-sdk 0.46 * Update cosmos-sdk v0.46 prepare for implementing cosmos-sdk feemarket and tx prioritization changelog refactor cmd use sdkmath fix lint fix unit tests fix unit test genesis fix unit tests fix unit test env setup fix unit tests fix unit tests register PrivKey impl fix extension options fix lint fix unit tests make HandlerOption.Validate private gofumpt fix msg response decoding fix sim test bump cosmos-sdk version fix sim test sdk 46 fix unit test fix unit tests update ibc-go
77 lines
2.5 KiB
Go
77 lines
2.5 KiB
Go
package v010
|
|
|
|
import (
|
|
"math/big"
|
|
|
|
sdkmath "cosmossdk.io/math"
|
|
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
|
|
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
|
"github.com/evmos/ethermint/x/feemarket/migrations/v010/types"
|
|
v09types "github.com/evmos/ethermint/x/feemarket/migrations/v09/types"
|
|
)
|
|
|
|
// KeyPrefixBaseFeeV1 is the base fee key prefix used in version 1
|
|
var KeyPrefixBaseFeeV1 = []byte{2}
|
|
|
|
// MigrateStore migrates the BaseFee value from the store to the params for
|
|
// In-Place Store migration logic.
|
|
func MigrateStore(ctx sdk.Context, paramstore *paramtypes.Subspace, storeKey storetypes.StoreKey) error {
|
|
baseFee := types.DefaultParams().BaseFee
|
|
|
|
store := ctx.KVStore(storeKey)
|
|
|
|
if !paramstore.HasKeyTable() {
|
|
ps := paramstore.WithKeyTable(types.ParamKeyTable())
|
|
paramstore = &ps
|
|
}
|
|
|
|
switch {
|
|
case store.Has(KeyPrefixBaseFeeV1):
|
|
bz := store.Get(KeyPrefixBaseFeeV1)
|
|
baseFee = sdkmath.NewIntFromBigInt(new(big.Int).SetBytes(bz))
|
|
case paramstore.Has(ctx, types.ParamStoreKeyNoBaseFee):
|
|
paramstore.GetIfExists(ctx, types.ParamStoreKeyBaseFee, &baseFee)
|
|
}
|
|
|
|
var (
|
|
noBaseFee bool
|
|
baseFeeChangeDenom, elasticityMultiplier uint32
|
|
enableHeight int64
|
|
)
|
|
|
|
paramstore.GetIfExists(ctx, types.ParamStoreKeyNoBaseFee, &noBaseFee)
|
|
paramstore.GetIfExists(ctx, types.ParamStoreKeyBaseFeeChangeDenominator, &baseFeeChangeDenom)
|
|
paramstore.GetIfExists(ctx, types.ParamStoreKeyElasticityMultiplier, &elasticityMultiplier)
|
|
paramstore.GetIfExists(ctx, types.ParamStoreKeyEnableHeight, &enableHeight)
|
|
|
|
params := types.Params{
|
|
NoBaseFee: noBaseFee,
|
|
BaseFeeChangeDenominator: baseFeeChangeDenom,
|
|
ElasticityMultiplier: elasticityMultiplier,
|
|
BaseFee: baseFee,
|
|
EnableHeight: enableHeight,
|
|
}
|
|
|
|
paramstore.SetParamSet(ctx, ¶ms)
|
|
store.Delete(KeyPrefixBaseFeeV1)
|
|
return nil
|
|
}
|
|
|
|
// MigrateJSON accepts exported v0.9 x/feemarket genesis state and migrates it to
|
|
// v0.10 x/feemarket genesis state. The migration includes:
|
|
// - Migrate BaseFee to Params
|
|
func MigrateJSON(oldState v09types.GenesisState) types.GenesisState {
|
|
return types.GenesisState{
|
|
Params: types.Params{
|
|
NoBaseFee: oldState.Params.NoBaseFee,
|
|
BaseFeeChangeDenominator: oldState.Params.BaseFeeChangeDenominator,
|
|
ElasticityMultiplier: oldState.Params.ElasticityMultiplier,
|
|
EnableHeight: oldState.Params.EnableHeight,
|
|
BaseFee: oldState.BaseFee,
|
|
},
|
|
BlockGas: oldState.BlockGas,
|
|
}
|
|
}
|