Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: un-wire crisis module from umee app #2472

Merged
merged 7 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 3 additions & 21 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ import (
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
consensusparamskeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper"
consensusparamstypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
"github.com/cosmos/cosmos-sdk/x/crisis"
crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper"
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
distr "github.com/cosmos/cosmos-sdk/x/distribution"
distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
Expand Down Expand Up @@ -185,7 +182,6 @@ func init() {
distr.AppModuleBasic{},
gov.NewAppModuleBasic(getGovProposalHandlers()),
params.AppModuleBasic{},
CrisisModule{},
SlashingModule{},
feegrantmodule.AppModuleBasic{},
upgrade.AppModuleBasic{},
Expand Down Expand Up @@ -264,7 +260,6 @@ type UmeeApp struct {
MintKeeper mintkeeper.Keeper
DistrKeeper distrkeeper.Keeper
GovKeeper *govkeeper.Keeper
CrisisKeeper *crisiskeeper.Keeper
UpgradeKeeper *upgradekeeper.Keeper
ParamsKeeper paramskeeper.Keeper
AuthzKeeper authzkeeper.Keeper
Expand Down Expand Up @@ -340,7 +335,7 @@ func New(
wasmtypes.StoreKey,
incentive.StoreKey,
metoken.StoreKey,
consensusparamstypes.StoreKey, crisistypes.StoreKey,
consensusparamstypes.StoreKey,
gsk967 marked this conversation as resolved.
Show resolved Hide resolved
}
// if Experimental {}

Expand Down Expand Up @@ -428,10 +423,6 @@ func New(
appCodec, app.legacyAmino, keys[slashingtypes.StoreKey],
app.StakingKeeper, govModuleAddr,
)
app.CrisisKeeper = crisiskeeper.NewKeeper(
appCodec, keys[crisistypes.StoreKey], invCheckPeriod, app.BankKeeper,
authtypes.FeeCollectorName, govModuleAddr,
)
app.FeeGrantKeeper = feegrantkeeper.NewKeeper(
appCodec, keys[feegrant.StoreKey], app.AccountKeeper,
)
Expand Down Expand Up @@ -688,10 +679,6 @@ func New(
Module Options
/****************/

// NOTE: we may consider parsing `appOpts` inside module constructors. For the moment
// we prefer to be more strict in what arguments the modules expect.
skipGenesisInvariants := cast.ToBool(appOpts.Get(crisis.FlagSkipGenesisInvariants))

inflationCalculator := inflation.Calculator{
UgovKeeperB: app.UGovKeeperB.Params,
MintKeeper: &app.MintKeeper,
Expand All @@ -710,7 +697,6 @@ func New(
vesting.NewAppModule(app.AccountKeeper, app.BankKeeper),
bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper, app.GetSubspace(banktypes.ModuleName)),
capability.NewAppModule(appCodec, *app.CapabilityKeeper, true),
crisis.NewAppModule(app.CrisisKeeper, skipGenesisInvariants, app.GetSubspace(crisistypes.ModuleName)),
feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry),
gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(govtypes.ModuleName)),
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, inflationCalculator.InflationRate, app.GetSubspace(minttypes.ModuleName)), //nolint: lll
Expand Down Expand Up @@ -757,7 +743,6 @@ func New(
authtypes.ModuleName,
banktypes.ModuleName,
govtypes.ModuleName,
crisistypes.ModuleName,
genutiltypes.ModuleName,
authz.ModuleName,
feegrant.ModuleName,
Expand All @@ -776,7 +761,6 @@ func New(
incentive.ModuleName,
}
endBlockers := []string{
crisistypes.ModuleName,
metoken.ModuleName, // must be before oracle
oracletypes.ModuleName, // must be before gov and staking
govtypes.ModuleName, stakingtypes.ModuleName,
Expand Down Expand Up @@ -804,7 +788,7 @@ func New(
initGenesis := []string{
capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, distrtypes.ModuleName,
stakingtypes.ModuleName, slashingtypes.ModuleName, govtypes.ModuleName, minttypes.ModuleName,
crisistypes.ModuleName, ibcexported.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName,
ibcexported.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName,
authz.ModuleName,
ibctransfertypes.ModuleName, icatypes.ModuleName, // ibcfeetypes.ModuleName
feegrant.ModuleName, nft.ModuleName, group.ModuleName,
Expand All @@ -822,7 +806,7 @@ func New(
orderMigrations := []string{
capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, distrtypes.ModuleName,
stakingtypes.ModuleName, slashingtypes.ModuleName, govtypes.ModuleName, minttypes.ModuleName,
crisistypes.ModuleName, ibcexported.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName,
ibcexported.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName,
authz.ModuleName, ibctransfertypes.ModuleName, icatypes.ModuleName, // ibcfeetypes.ModuleName
feegrant.ModuleName, nft.ModuleName, group.ModuleName,
paramstypes.ModuleName, upgradetypes.ModuleName, vestingtypes.ModuleName,
Expand All @@ -843,7 +827,6 @@ func New(
app.mm.SetOrderInitGenesis(initGenesis...)
app.mm.SetOrderMigrations(orderMigrations...)

app.mm.RegisterInvariants(app.CrisisKeeper)
app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter())
app.mm.RegisterServices(app.configurator)

Expand Down Expand Up @@ -1136,7 +1119,6 @@ func initParamsKeeper(
paramsKeeper.Subspace(distrtypes.ModuleName)
paramsKeeper.Subspace(slashingtypes.ModuleName)
paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govv1.ParamKeyTable()) //nolint: staticcheck
paramsKeeper.Subspace(crisistypes.ModuleName)
paramsKeeper.Subspace(ibctransfertypes.ModuleName)
paramsKeeper.Subspace(ibcexported.ModuleName)
paramsKeeper.Subspace(icahosttypes.SubModuleName)
Expand Down
3 changes: 0 additions & 3 deletions app/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ func (app *UmeeApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [
allowedAddrsMap[addr] = true
}

/* Just to be safe, assert the invariants on current state. */
app.CrisisKeeper.AssertInvariants(ctx)

/* Handle fee distribution state. */

// withdraw all validator commission
Expand Down
15 changes: 0 additions & 15 deletions app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/bank"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/cosmos/cosmos-sdk/x/crisis"
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
"github.com/cosmos/cosmos-sdk/x/gov"
govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
"github.com/cosmos/cosmos-sdk/x/mint"
gsk967 marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -55,19 +53,6 @@ func (StakingModule) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
})
}

// CrisisModule defines a custom wrapper around the x/crisis module's
// AppModuleBasic implementation to provide custom default genesis state.
type CrisisModule struct {
crisis.AppModuleBasic
}

// DefaultGenesis returns custom Umee x/crisis module genesis state.
func (CrisisModule) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
return cdc.MustMarshalJSON(&crisistypes.GenesisState{
ConstantFee: sdk.NewCoin(appparams.BondDenom, sdk.NewInt(1000)),
})
}

// MintModule defines a custom wrapper around the x/mint module's
// AppModuleBasic implementation to provide custom default genesis state.
type MintModule struct {
Expand Down
17 changes: 10 additions & 7 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
Expand Down Expand Up @@ -48,9 +49,10 @@ func (app UmeeApp) RegisterUpgradeHandlers() {
app.registerUpgrade6_0(upgradeInfo)
app.registerOutdatedPlaceholderUpgrade("v6.1")
app.registerOutdatedPlaceholderUpgrade("v6.2")
app.registerUpgrade("v6.3", upgradeInfo)
app.registerUpgrade("v6.3", upgradeInfo, nil, nil, nil)

app.registerUpgrade6_4(upgradeInfo)
app.registerUpgrade("v6.5", upgradeInfo, nil, []string{crisistypes.ModuleName}, nil)
}

func (app *UmeeApp) registerUpgrade6_4(upgradeInfo upgradetypes.Plan) {
Expand Down Expand Up @@ -175,14 +177,15 @@ func (app *UmeeApp) storeUpgrade(planName string, ui upgradetypes.Plan, stores s

// registerUpgrade sets an upgrade handler which only runs module migrations
// and adds new storages storages
func (app *UmeeApp) registerUpgrade(planName string, upgradeInfo upgradetypes.Plan, newStores ...string) {
func (app *UmeeApp) registerUpgrade(planName string, upgradeInfo upgradetypes.Plan, newStores []string,
deletedStores []string, renamedStores []storetypes.StoreRename) {
app.UpgradeKeeper.SetUpgradeHandler(planName, onlyModuleMigrations(app, planName))

if len(newStores) > 0 {
app.storeUpgrade(planName, upgradeInfo, storetypes.StoreUpgrades{
Added: newStores,
})
}
app.storeUpgrade(planName, upgradeInfo, storetypes.StoreUpgrades{
Added: newStores,
Deleted: deletedStores,
Renamed: renamedStores,
})
}

// oldUpgradePlan is a noop, placeholder handler required for old (completed) upgrade plans.
Expand Down