From 4cd7778dba6ee6095ad9b394e97bec9b22258346 Mon Sep 17 00:00:00 2001 From: Sai Kumar Date: Mon, 25 Mar 2024 14:49:52 +0530 Subject: [PATCH 1/4] un-wire crisis from umee app --- app/app.go | 23 +++-------------------- app/export.go | 3 --- app/upgrades.go | 17 ++++++++++------- 3 files changed, 13 insertions(+), 30 deletions(-) diff --git a/app/app.go b/app/app.go index f6569b9a9b..b5da7648eb 100644 --- a/app/app.go +++ b/app/app.go @@ -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" @@ -264,7 +261,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 @@ -340,7 +336,7 @@ func New( wasmtypes.StoreKey, incentive.StoreKey, metoken.StoreKey, - consensusparamstypes.StoreKey, crisistypes.StoreKey, + consensusparamstypes.StoreKey, } // if Experimental {} @@ -428,10 +424,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, ) @@ -688,10 +680,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, @@ -710,7 +698,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 @@ -757,7 +744,6 @@ func New( authtypes.ModuleName, banktypes.ModuleName, govtypes.ModuleName, - crisistypes.ModuleName, genutiltypes.ModuleName, authz.ModuleName, feegrant.ModuleName, @@ -776,7 +762,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, @@ -804,7 +789,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, @@ -822,7 +807,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, @@ -843,7 +828,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) @@ -1136,7 +1120,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) diff --git a/app/export.go b/app/export.go index 4bcdfff2b4..4a33b1508d 100644 --- a/app/export.go +++ b/app/export.go @@ -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 diff --git a/app/upgrades.go b/app/upgrades.go index ae6414cb61..478c4d3917 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -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" @@ -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) { @@ -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. From c9892561ba7ddde4f12b4fd07764851f7640c6e5 Mon Sep 17 00:00:00 2001 From: Sai Kumar Date: Tue, 26 Mar 2024 07:20:08 +0530 Subject: [PATCH 2/4] removed custom crisis module wrapper --- app/app.go | 1 - app/modules.go | 15 --------------- 2 files changed, 16 deletions(-) diff --git a/app/app.go b/app/app.go index b5da7648eb..719cd21502 100644 --- a/app/app.go +++ b/app/app.go @@ -182,7 +182,6 @@ func init() { distr.AppModuleBasic{}, gov.NewAppModuleBasic(getGovProposalHandlers()), params.AppModuleBasic{}, - CrisisModule{}, SlashingModule{}, feegrantmodule.AppModuleBasic{}, upgrade.AppModuleBasic{}, diff --git a/app/modules.go b/app/modules.go index 861a20b1f8..d907218cce 100644 --- a/app/modules.go +++ b/app/modules.go @@ -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" @@ -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 { From 440334b89aa30be951959670c3637a3d8156e1b7 Mon Sep 17 00:00:00 2001 From: Sai Kumar Date: Tue, 26 Mar 2024 07:25:46 +0530 Subject: [PATCH 3/4] update the changelog --- CHANGELOG.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 753733ddaa..0ed24139ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,14 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## Unreleased +### Features + +- [2472](https://github.com/umee-network/umee/pull/2472) un-wire the `crisis` module from umee app. + +### Improvements + +### Bug Fixes + ## v6.4.0 - 2024-03-21 ### Features @@ -54,7 +62,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Bug Fixes -- [2462](https://github.com/umee-network/umee/pull/2462) (x/leverage) Take `MaxModuleWithdraw` into account when computing user `MaxWithdraw`. +- [2462](https://github.com/umee-network/umee/pull/2462) (x/leverage) Take `MaxModuleWithdraw` into account when computing user `MaxWithdraw`. ## v6.4.0-beta1 - 2024-03-11 From ae71520964f1e40417825d4bf6a628f8119ae7a4 Mon Sep 17 00:00:00 2001 From: Sai Kumar Date: Tue, 26 Mar 2024 15:25:59 +0530 Subject: [PATCH 4/4] fix the tests issue --- CHANGELOG.md | 1 - app/app.go | 1 - 2 files changed, 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 742e5b975b..f1641b17f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -58,7 +58,6 @@ Ref: https://keepachangelog.com/en/1.0.0/ - [2473](https://github.com/umee-network/umee/pull/2473) Correct x/ugov Amino registration for x/ugov messages (they don't have MessageName option). - ## v6.4.0 - 2024-03-21 ### Features diff --git a/app/app.go b/app/app.go index 7306e1438a..c15e9a5fcf 100644 --- a/app/app.go +++ b/app/app.go @@ -349,7 +349,6 @@ func New( oracletypes.StoreKey, ugov.StoreKey, uibc.StoreKey, - consensusparamstypes.StoreKey, } // if Experimental {}