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 all 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
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,15 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Features

- [2472](https://github.com/umee-network/umee/pull/2472) un-wire the `crisis` module from umee app.
gsk967 marked this conversation as resolved.
Show resolved Hide resolved

### Improvements

- [2474](https://github.com/umee-network/umee/pull/2464) (proto) add `gogo.messagename_all` option to all messages.
- [2474](https://github.com/umee-network/umee/pull/2474) (proto) add `gogo.messagename_all` option to all messages.

gsk967 marked this conversation as resolved.
Show resolved Hide resolved
### Bug Fixes

- [2473](https://github.com/umee-network/umee/pull/2462) Correct x/ugov Amino registration for x/ugov messages (they don't have MessageName option).
- [2473](https://github.com/umee-network/umee/pull/2473) Correct x/ugov Amino registration for x/ugov messages (they don't have MessageName option).

gsk967 marked this conversation as resolved.
Show resolved Hide resolved
## v6.4.0 - 2024-03-21

Expand Down
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 @@ -188,7 +185,6 @@ func init() {
distr.AppModuleBasic{},
gov.NewAppModuleBasic(getGovProposalHandlers()),
params.AppModuleBasic{},
CrisisModule{},
SlashingModule{},
feegrantmodule.AppModuleBasic{},
upgrade.AppModuleBasic{},
Expand Down Expand Up @@ -270,7 +266,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 @@ -345,7 +340,7 @@ func New(
ibcexported.StoreKey, ibctransfertypes.StoreKey, icahosttypes.StoreKey,
packetforwardtypes.StoreKey,
wasmtypes.StoreKey,
consensusparamstypes.StoreKey, crisistypes.StoreKey,
consensusparamstypes.StoreKey,

auction.StoreKey,
incentive.StoreKey,
Expand Down Expand Up @@ -441,10 +436,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 @@ -706,10 +697,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 @@ -728,7 +715,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 @@ -776,7 +762,6 @@ func New(
authtypes.ModuleName,
banktypes.ModuleName,
govtypes.ModuleName,
crisistypes.ModuleName,
genutiltypes.ModuleName,
authz.ModuleName,
feegrant.ModuleName,
Expand All @@ -796,7 +781,6 @@ func New(
auction.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 @@ -825,7 +809,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 @@ -844,7 +828,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 @@ -866,7 +850,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 @@ -1159,7 +1142,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
Loading