Skip to content

Commit

Permalink
feat(cosmos): un-wire x/crisis (#8582)
Browse files Browse the repository at this point in the history
* feat(cosmos): un-wire x/crisis

* fixup! feat(cosmos): un-wire x/crisis

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
mhofman and mergify[bot] authored Dec 6, 2023
1 parent dca42b9 commit 7153535
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 23 deletions.
33 changes: 16 additions & 17 deletions golang/cosmos/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/cosmos/cosmos-sdk/server/config"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
"github.com/cosmos/cosmos-sdk/simapp"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/module"
Expand All @@ -44,8 +45,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/capability"
capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper"
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/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"
distrclient "github.com/cosmos/cosmos-sdk/x/distribution/client"
Expand Down Expand Up @@ -160,7 +159,6 @@ var (
swingsetclient.CoreEvalProposalHandler,
),
params.AppModuleBasic{},
crisis.AppModuleBasic{},
slashing.AppModuleBasic{},
feegrantmodule.AppModuleBasic{},
authzmodule.AppModuleBasic{},
Expand Down Expand Up @@ -234,7 +232,6 @@ type GaiaApp struct { // nolint: golint
MintKeeper mintkeeper.Keeper
DistrKeeper distrkeeper.Keeper
GovKeeper govkeeper.Keeper
CrisisKeeper crisiskeeper.Keeper
UpgradeKeeper upgradekeeper.Keeper
ParamsKeeper paramskeeper.Keeper
// IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
Expand Down Expand Up @@ -415,12 +412,6 @@ func NewAgoricApp(
&stakingKeeper,
app.GetSubspace(slashingtypes.ModuleName),
)
app.CrisisKeeper = crisiskeeper.NewKeeper(
app.GetSubspace(crisistypes.ModuleName),
invCheckPeriod,
app.BankKeeper,
vbanktypes.ReservePoolName,
)
app.UpgradeKeeper = upgradekeeper.NewKeeper(
skipUpgradeHeights,
keys[upgradetypes.StoreKey],
Expand Down Expand Up @@ -596,7 +587,6 @@ func NewAgoricApp(

app.EvidenceKeeper = *evidenceKeeper

skipGenesisInvariants := cast.ToBool(appOpts.Get(crisis.FlagSkipGenesisInvariants))
swingStoreExportDir := cast.ToString(appOpts.Get(FlagSwingStoreExportDir))

// NOTE: Any module instantiated in the module manager that is later modified
Expand All @@ -612,7 +602,6 @@ func NewAgoricApp(
vesting.NewAppModule(app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper),
capability.NewAppModule(appCodec, *app.CapabilityKeeper),
crisis.NewAppModule(&app.CrisisKeeper, skipGenesisInvariants),
gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper),
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper),
slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
Expand Down Expand Up @@ -642,7 +631,6 @@ func NewAgoricApp(
// upgrades should be run first
upgradetypes.ModuleName,
capabilitytypes.ModuleName,
crisistypes.ModuleName,
govtypes.ModuleName,
stakingtypes.ModuleName,
ibctransfertypes.ModuleName,
Expand Down Expand Up @@ -671,7 +659,6 @@ func NewAgoricApp(
vibc.ModuleName,
vbank.ModuleName,
lien.ModuleName,
crisistypes.ModuleName,
govtypes.ModuleName,
stakingtypes.ModuleName,
ibctransfertypes.ModuleName,
Expand Down Expand Up @@ -712,7 +699,6 @@ func NewAgoricApp(
slashingtypes.ModuleName,
govtypes.ModuleName,
minttypes.ModuleName,
crisistypes.ModuleName,
ibctransfertypes.ModuleName,
ibchost.ModuleName,
icatypes.ModuleName,
Expand All @@ -733,7 +719,6 @@ func NewAgoricApp(
app.mm.SetOrderInitGenesis(moduleOrderForGenesisAndUpgrade...)
app.mm.SetOrderMigrations(moduleOrderForGenesisAndUpgrade...)

app.mm.RegisterInvariants(&app.CrisisKeeper)
app.mm.RegisterRoutes(app.Router(), app.QueryRouter(), encodingConfig.Amino)

app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter())
Expand Down Expand Up @@ -805,6 +790,21 @@ func NewAgoricApp(
unreleasedUpgradeHandler(app, upgradeNameTest),
)

upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
if err != nil {
panic(err)
}
if (upgradeInfo.Name == upgradeName || upgradeInfo.Name == upgradeNameTest) && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
storeUpgrades := storetypes.StoreUpgrades{
Deleted: []string{
crisistypes.ModuleName, // The SDK discontinued the crisis module in v0.51.0
},
}

// configure store loader that checks if version == upgradeHeight and applies store upgrades
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
}

if loadLatest {
if err := app.LoadLatestVersion(); err != nil {
tmos.Exit(fmt.Sprintf("failed to load latest version: %s", err))
Expand Down Expand Up @@ -1178,7 +1178,6 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(distrtypes.ModuleName)
paramsKeeper.Subspace(slashingtypes.ModuleName)
paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govtypes.ParamKeyTable())
paramsKeeper.Subspace(crisistypes.ModuleName)
paramsKeeper.Subspace(ibctransfertypes.ModuleName)
paramsKeeper.Subspace(ibchost.ModuleName)
paramsKeeper.Subspace(icahosttypes.SubModuleName)
Expand Down
3 changes: 0 additions & 3 deletions golang/cosmos/app/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ func (app *GaiaApp) 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
2 changes: 0 additions & 2 deletions golang/cosmos/daemon/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/auth/types"
vestingcli "github.com/cosmos/cosmos-sdk/x/auth/vesting/client/cli"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/cosmos/cosmos-sdk/x/crisis"
genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
"github.com/spf13/cast"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -177,7 +176,6 @@ func addAgoricVMFlags(cmd *cobra.Command) {
}

func addModuleInitFlags(startCmd *cobra.Command) {
crisis.AddModuleInitFlags(startCmd)
addAgoricVMFlags(startCmd)
}

Expand Down
1 change: 0 additions & 1 deletion packages/agoric-cli/src/chain-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ export function finishCosmosGenesis({ genesisJson, exportedGenesisJson }) {

// Set the denomination for different modules.
genesis.app_state.mint.params.mint_denom = MINT_DENOM;
genesis.app_state.crisis.constant_fee.denom = MINT_DENOM;
genesis.app_state.gov.deposit_params.min_deposit = GOV_DEPOSIT_COINS;
genesis.app_state.gov.voting_params.voting_period = GOV_VOTING_PERIOD;

Expand Down

0 comments on commit 7153535

Please sign in to comment.