mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-26 16:25:21 +00:00
Merge pull request #60 from 0g-wh/dev
Some checks are pending
Continuous Integration (Commit) / lint (push) Waiting to run
Some checks are pending
Continuous Integration (Commit) / lint (push) Waiting to run
fix mint denom in upgrades.go
This commit is contained in:
commit
8bd14a6c00
@ -3,32 +3,13 @@ package app
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
|
||||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/types/module"
|
"github.com/cosmos/cosmos-sdk/types/module"
|
||||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
|
||||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
|
||||||
consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
|
|
||||||
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
|
|
||||||
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
|
|
||||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
|
||||||
govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
|
|
||||||
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
|
|
||||||
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
|
||||||
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
|
|
||||||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
|
||||||
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
|
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
|
||||||
packetforwardtypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward/types"
|
|
||||||
ibcwasmtypes "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types"
|
|
||||||
ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
|
|
||||||
ibctmmigrations "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint/migrations"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
UpgradeName_Testnet = "v0.3.0"
|
UpgradeName_Testnet = "v0.3.1"
|
||||||
|
|
||||||
CDPLiquidationBlockInterval = int64(50)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// RegisterUpgradeHandlers registers the upgrade handlers for the app.
|
// RegisterUpgradeHandlers registers the upgrade handlers for the app.
|
||||||
@ -37,27 +18,6 @@ func (app App) RegisterUpgradeHandlers() {
|
|||||||
UpgradeName_Testnet,
|
UpgradeName_Testnet,
|
||||||
upgradeHandler(app, UpgradeName_Testnet),
|
upgradeHandler(app, UpgradeName_Testnet),
|
||||||
)
|
)
|
||||||
|
|
||||||
upgradeInfo, err := app.upgradeKeeper.ReadUpgradeInfoFromDisk()
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
doUpgrade := upgradeInfo.Name == UpgradeName_Testnet
|
|
||||||
|
|
||||||
if doUpgrade && !app.upgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
|
|
||||||
storeUpgrades := storetypes.StoreUpgrades{
|
|
||||||
Added: []string{
|
|
||||||
crisistypes.ModuleName,
|
|
||||||
consensustypes.ModuleName,
|
|
||||||
packetforwardtypes.ModuleName,
|
|
||||||
ibcwasmtypes.ModuleName,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
// configure store loader that checks if version == upgradeHeight and applies store upgrades
|
|
||||||
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// upgradeHandler returns an UpgradeHandler for the given upgrade parameters.
|
// upgradeHandler returns an UpgradeHandler for the given upgrade parameters.
|
||||||
@ -72,58 +32,11 @@ func upgradeHandler(
|
|||||||
) (module.VersionMap, error) {
|
) (module.VersionMap, error) {
|
||||||
app.Logger().Info(fmt.Sprintf("running %s upgrade handler", name))
|
app.Logger().Info(fmt.Sprintf("running %s upgrade handler", name))
|
||||||
|
|
||||||
baseAppLegacySS := app.paramsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable())
|
params := app.mintKeeper.GetParams(ctx)
|
||||||
|
params.MintDenom = "ua0gi"
|
||||||
// Set param key table for params module migration
|
app.mintKeeper.SetParams(ctx, params)
|
||||||
for _, subspace := range app.paramsKeeper.GetSubspaces() {
|
|
||||||
subspace := subspace
|
|
||||||
var keyTable paramstypes.KeyTable
|
|
||||||
switch subspace.Name() {
|
|
||||||
// sdk
|
|
||||||
case authtypes.ModuleName:
|
|
||||||
keyTable = authtypes.ParamKeyTable() //nolint:staticcheck
|
|
||||||
case banktypes.ModuleName:
|
|
||||||
keyTable = banktypes.ParamKeyTable() //nolint:staticcheck,nolintlint
|
|
||||||
case stakingtypes.ModuleName:
|
|
||||||
keyTable = stakingtypes.ParamKeyTable()
|
|
||||||
case minttypes.ModuleName:
|
|
||||||
keyTable = minttypes.ParamKeyTable() //nolint:staticcheck
|
|
||||||
case distrtypes.ModuleName:
|
|
||||||
keyTable = distrtypes.ParamKeyTable() //nolint:staticcheck,nolintlint
|
|
||||||
case slashingtypes.ModuleName:
|
|
||||||
keyTable = slashingtypes.ParamKeyTable() //nolint:staticcheck
|
|
||||||
case govtypes.ModuleName:
|
|
||||||
keyTable = govv1.ParamKeyTable() //nolint:staticcheck
|
|
||||||
case crisistypes.ModuleName:
|
|
||||||
keyTable = crisistypes.ParamKeyTable() //nolint:staticcheck
|
|
||||||
|
|
||||||
// ibc
|
|
||||||
case ibctransfertypes.ModuleName:
|
|
||||||
keyTable = ibctransfertypes.ParamKeyTable() //nolint:staticcheck
|
|
||||||
|
|
||||||
default:
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if !subspace.HasKeyTable() {
|
|
||||||
// NOTE: This modifies the internal map used to store the key table entries
|
|
||||||
// which is a pointer.
|
|
||||||
subspace.WithKeyTable(keyTable)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// optional migration: prune expired tendermint consensus states to save storage space
|
|
||||||
// see https://github.com/cosmos/ibc-go/blob/v7.2.0/docs/migrations/v6-to-v7.md#chains
|
|
||||||
if _, err := ibctmmigrations.PruneExpiredConsensusStates(ctx, app.appCodec, app.ibcKeeper.ClientKeeper); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// migrate tendermint consensus parameters from x/params module to a
|
|
||||||
// dedicated x/consensus module.
|
|
||||||
baseapp.MigrateParams(ctx, baseAppLegacySS, &app.consensusParamsKeeper)
|
|
||||||
|
|
||||||
// run migrations for all modules and return new consensus version map
|
// run migrations for all modules and return new consensus version map
|
||||||
versionMap, err := app.mm.RunMigrations(ctx, app.configurator, fromVM)
|
return app.mm.RunMigrations(ctx, app.configurator, fromVM)
|
||||||
|
|
||||||
return versionMap, err
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user