mirror of
https://github.com/0glabs/0g-chain.git
synced 2025-01-12 16:25:17 +00:00
Audit app.go (#1221)
* remove duplicate module registrations * remove testnet in-place migration * standardise formating * move authz to no begin/endblocker section as it has none * standardise gov router formatting
This commit is contained in:
parent
c5de1302f6
commit
35da890db0
40
app/app.go
40
app/app.go
@ -141,8 +141,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
appName = "kava"
|
appName = "kava"
|
||||||
upgradeName = "testnet-evm-alpha-2"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -420,9 +419,11 @@ func NewApp(
|
|||||||
app.bankKeeper,
|
app.bankKeeper,
|
||||||
stakingSubspace,
|
stakingSubspace,
|
||||||
)
|
)
|
||||||
|
app.authzKeeper = authzkeeper.NewKeeper(
|
||||||
app.authzKeeper = authzkeeper.NewKeeper(keys[authzkeeper.StoreKey], appCodec, app.BaseApp.MsgServiceRouter())
|
keys[authzkeeper.StoreKey],
|
||||||
|
appCodec,
|
||||||
|
app.BaseApp.MsgServiceRouter(),
|
||||||
|
)
|
||||||
app.mintKeeper = mintkeeper.NewKeeper(
|
app.mintKeeper = mintkeeper.NewKeeper(
|
||||||
appCodec,
|
appCodec,
|
||||||
keys[minttypes.StoreKey],
|
keys[minttypes.StoreKey],
|
||||||
@ -637,7 +638,8 @@ func NewApp(
|
|||||||
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.paramsKeeper)).
|
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.paramsKeeper)).
|
||||||
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.upgradeKeeper)).
|
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.upgradeKeeper)).
|
||||||
AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.ibcKeeper.ClientKeeper)).
|
AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.ibcKeeper.ClientKeeper)).
|
||||||
AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.distrKeeper)).AddRoute(kavadisttypes.RouterKey, kavadist.NewCommunityPoolMultiSpendProposalHandler(app.kavadistKeeper)).
|
AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.distrKeeper)).
|
||||||
|
AddRoute(kavadisttypes.RouterKey, kavadist.NewCommunityPoolMultiSpendProposalHandler(app.kavadistKeeper)).
|
||||||
AddRoute(committeetypes.RouterKey, committee.NewProposalHandler(app.committeeKeeper))
|
AddRoute(committeetypes.RouterKey, committee.NewProposalHandler(app.committeeKeeper))
|
||||||
app.govKeeper = govkeeper.NewKeeper(
|
app.govKeeper = govkeeper.NewKeeper(
|
||||||
appCodec,
|
appCodec,
|
||||||
@ -680,7 +682,6 @@ func NewApp(
|
|||||||
evidence.NewAppModule(app.evidenceKeeper),
|
evidence.NewAppModule(app.evidenceKeeper),
|
||||||
transferModule,
|
transferModule,
|
||||||
vesting.NewAppModule(app.accountKeeper, app.bankKeeper),
|
vesting.NewAppModule(app.accountKeeper, app.bankKeeper),
|
||||||
params.NewAppModule(app.paramsKeeper),
|
|
||||||
authzmodule.NewAppModule(appCodec, app.authzKeeper, app.accountKeeper, app.bankKeeper, app.interfaceRegistry),
|
authzmodule.NewAppModule(appCodec, app.authzKeeper, app.accountKeeper, app.bankKeeper, app.interfaceRegistry),
|
||||||
kavadist.NewAppModule(app.kavadistKeeper, app.accountKeeper),
|
kavadist.NewAppModule(app.kavadistKeeper, app.accountKeeper),
|
||||||
auction.NewAppModule(app.auctionKeeper, app.accountKeeper, app.bankKeeper),
|
auction.NewAppModule(app.auctionKeeper, app.accountKeeper, app.bankKeeper),
|
||||||
@ -698,6 +699,7 @@ func NewApp(
|
|||||||
bridge.NewAppModule(app.bridgeKeeper, app.accountKeeper),
|
bridge.NewAppModule(app.bridgeKeeper, app.accountKeeper),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Warning: Some begin blockers must run before others. Ensure the dependencies are understood before modifying this list.
|
||||||
app.mm.SetOrderBeginBlockers(
|
app.mm.SetOrderBeginBlockers(
|
||||||
// Upgrade begin blocker runs migrations on the first block after an upgrade. It should run before any other module.
|
// Upgrade begin blocker runs migrations on the first block after an upgrade. It should run before any other module.
|
||||||
upgradetypes.ModuleName,
|
upgradetypes.ModuleName,
|
||||||
@ -714,7 +716,6 @@ func NewApp(
|
|||||||
slashingtypes.ModuleName,
|
slashingtypes.ModuleName,
|
||||||
evidencetypes.ModuleName,
|
evidencetypes.ModuleName,
|
||||||
stakingtypes.ModuleName,
|
stakingtypes.ModuleName,
|
||||||
authz.ModuleName,
|
|
||||||
feemarkettypes.ModuleName,
|
feemarkettypes.ModuleName,
|
||||||
evmtypes.ModuleName,
|
evmtypes.ModuleName,
|
||||||
kavadisttypes.ModuleName,
|
kavadisttypes.ModuleName,
|
||||||
@ -739,6 +740,7 @@ func NewApp(
|
|||||||
genutiltypes.ModuleName,
|
genutiltypes.ModuleName,
|
||||||
ibctransfertypes.ModuleName,
|
ibctransfertypes.ModuleName,
|
||||||
paramstypes.ModuleName,
|
paramstypes.ModuleName,
|
||||||
|
authz.ModuleName,
|
||||||
evmutiltypes.ModuleName,
|
evmutiltypes.ModuleName,
|
||||||
savingstypes.ModuleName,
|
savingstypes.ModuleName,
|
||||||
bridgetypes.ModuleName,
|
bridgetypes.ModuleName,
|
||||||
@ -749,7 +751,6 @@ func NewApp(
|
|||||||
crisistypes.ModuleName,
|
crisistypes.ModuleName,
|
||||||
govtypes.ModuleName,
|
govtypes.ModuleName,
|
||||||
stakingtypes.ModuleName,
|
stakingtypes.ModuleName,
|
||||||
authz.ModuleName,
|
|
||||||
evmtypes.ModuleName,
|
evmtypes.ModuleName,
|
||||||
// fee market module must go after evm module in order to retrieve the block gas used.
|
// fee market module must go after evm module in order to retrieve the block gas used.
|
||||||
feemarkettypes.ModuleName,
|
feemarkettypes.ModuleName,
|
||||||
@ -771,16 +772,14 @@ func NewApp(
|
|||||||
kavadisttypes.ModuleName,
|
kavadisttypes.ModuleName,
|
||||||
swaptypes.ModuleName,
|
swaptypes.ModuleName,
|
||||||
vestingtypes.ModuleName,
|
vestingtypes.ModuleName,
|
||||||
pricefeedtypes.ModuleName,
|
|
||||||
ibchost.ModuleName,
|
ibchost.ModuleName,
|
||||||
validatorvestingtypes.ModuleName,
|
validatorvestingtypes.ModuleName,
|
||||||
authtypes.ModuleName,
|
authtypes.ModuleName,
|
||||||
banktypes.ModuleName,
|
banktypes.ModuleName,
|
||||||
govtypes.ModuleName,
|
|
||||||
crisistypes.ModuleName,
|
|
||||||
genutiltypes.ModuleName,
|
genutiltypes.ModuleName,
|
||||||
ibctransfertypes.ModuleName,
|
ibctransfertypes.ModuleName,
|
||||||
paramstypes.ModuleName,
|
paramstypes.ModuleName,
|
||||||
|
authz.ModuleName,
|
||||||
evmutiltypes.ModuleName,
|
evmutiltypes.ModuleName,
|
||||||
savingstypes.ModuleName,
|
savingstypes.ModuleName,
|
||||||
bridgetypes.ModuleName,
|
bridgetypes.ModuleName,
|
||||||
@ -800,7 +799,8 @@ func NewApp(
|
|||||||
evidencetypes.ModuleName,
|
evidencetypes.ModuleName,
|
||||||
authz.ModuleName,
|
authz.ModuleName,
|
||||||
ibctransfertypes.ModuleName,
|
ibctransfertypes.ModuleName,
|
||||||
evmtypes.ModuleName, feemarkettypes.ModuleName,
|
evmtypes.ModuleName,
|
||||||
|
feemarkettypes.ModuleName,
|
||||||
kavadisttypes.ModuleName,
|
kavadisttypes.ModuleName,
|
||||||
auctiontypes.ModuleName,
|
auctiontypes.ModuleName,
|
||||||
issuancetypes.ModuleName,
|
issuancetypes.ModuleName,
|
||||||
@ -813,7 +813,6 @@ func NewApp(
|
|||||||
incentivetypes.ModuleName, // reads cdp params, so must run after cdp genesis
|
incentivetypes.ModuleName, // reads cdp params, so must run after cdp genesis
|
||||||
committeetypes.ModuleName,
|
committeetypes.ModuleName,
|
||||||
evmutiltypes.ModuleName,
|
evmutiltypes.ModuleName,
|
||||||
savingstypes.ModuleName,
|
|
||||||
bridgetypes.ModuleName,
|
bridgetypes.ModuleName,
|
||||||
genutiltypes.ModuleName, // runs arbitrary txs included in genisis state, so run after modules have been initialized
|
genutiltypes.ModuleName, // runs arbitrary txs included in genisis state, so run after modules have been initialized
|
||||||
crisistypes.ModuleName, // runs the invariants at genesis, should run after other modules
|
crisistypes.ModuleName, // runs the invariants at genesis, should run after other modules
|
||||||
@ -884,15 +883,6 @@ func NewApp(
|
|||||||
app.SetBeginBlocker(app.BeginBlocker)
|
app.SetBeginBlocker(app.BeginBlocker)
|
||||||
app.SetEndBlocker(app.EndBlocker)
|
app.SetEndBlocker(app.EndBlocker)
|
||||||
|
|
||||||
app.upgradeKeeper.SetUpgradeHandler(
|
|
||||||
upgradeName,
|
|
||||||
func(ctx sdk.Context, _ upgradetypes.Plan, previousModuleVersions module.VersionMap) (module.VersionMap, error) {
|
|
||||||
return app.mm.RunMigrations(ctx, app.configurator, previousModuleVersions)
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
// TODO if we need modules added/removed, add upgrade store loader
|
|
||||||
|
|
||||||
// load store
|
// load store
|
||||||
if !options.SkipLoadLatest {
|
if !options.SkipLoadLatest {
|
||||||
if err := app.LoadLatestVersion(); err != nil {
|
if err := app.LoadLatestVersion(); err != nil {
|
||||||
@ -923,6 +913,10 @@ func (app *App) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.Res
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Store current module versions in kava-10 to setup future in-place upgrades.
|
||||||
|
// During in-place migrations, the old module versions in the store will be referenced to determine which migrations to run.
|
||||||
|
app.upgradeKeeper.SetModuleVersionMap(ctx, app.mm.GetVersionMap())
|
||||||
|
|
||||||
return app.mm.InitGenesis(ctx, app.appCodec, genesisState)
|
return app.mm.InitGenesis(ctx, app.appCodec, genesisState)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user