chore: remove crisis from simapp and deprecate (#23722)
This commit is contained in:
parent
c665a95892
commit
c2ec9f795c
@ -13,7 +13,6 @@ $mockgen_cmd -source=x/nft/expected_keepers.go -package testutil -destination x/
|
||||
$mockgen_cmd -source=x/feegrant/expected_keepers.go -package testutil -destination x/feegrant/testutil/expected_keepers_mocks.go
|
||||
$mockgen_cmd -source=x/mint/types/expected_keepers.go -package testutil -destination x/mint/testutil/expected_keepers_mocks.go
|
||||
$mockgen_cmd -source=x/params/proposal_handler_test.go -package testutil -destination x/params/testutil/staking_keeper_mock.go
|
||||
$mockgen_cmd -source=x/crisis/types/expected_keepers.go -package testutil -destination x/crisis/testutil/expected_keepers_mocks.go
|
||||
$mockgen_cmd -source=x/auth/tx/config/expected_keepers.go -package testutil -destination x/auth/tx/testutil/expected_keepers_mocks.go
|
||||
$mockgen_cmd -source=x/auth/types/expected_keepers.go -package testutil -destination x/auth/testutil/expected_keepers_mocks.go
|
||||
$mockgen_cmd -source=x/auth/ante/expected_keepers.go -package testutil -destination x/auth/ante/testutil/expected_keepers_mocks.go
|
||||
|
||||
@ -78,9 +78,6 @@ import (
|
||||
consensus "github.com/cosmos/cosmos-sdk/x/consensus"
|
||||
consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper"
|
||||
consensusparamtypes "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"
|
||||
@ -155,7 +152,6 @@ type SimApp struct {
|
||||
MintKeeper mintkeeper.Keeper
|
||||
DistrKeeper distrkeeper.Keeper
|
||||
GovKeeper govkeeper.Keeper
|
||||
CrisisKeeper *crisiskeeper.Keeper
|
||||
UpgradeKeeper *upgradekeeper.Keeper
|
||||
ParamsKeeper paramskeeper.Keeper
|
||||
AuthzKeeper authzkeeper.Keeper
|
||||
@ -256,7 +252,7 @@ func NewSimApp(
|
||||
bApp.SetTxEncoder(txConfig.TxEncoder())
|
||||
|
||||
keys := storetypes.NewKVStoreKeys(
|
||||
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, crisistypes.StoreKey,
|
||||
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey,
|
||||
minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
|
||||
govtypes.StoreKey, paramstypes.StoreKey, consensusparamtypes.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey,
|
||||
evidencetypes.StoreKey, circuittypes.StoreKey,
|
||||
@ -323,10 +319,6 @@ func NewSimApp(
|
||||
appCodec, legacyAmino, runtime.NewKVStoreService(keys[slashingtypes.StoreKey]), app.StakingKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(),
|
||||
)
|
||||
|
||||
invCheckPeriod := cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod))
|
||||
app.CrisisKeeper = crisiskeeper.NewKeeper(appCodec, runtime.NewKVStoreService(keys[crisistypes.StoreKey]), invCheckPeriod,
|
||||
app.BankKeeper, authtypes.FeeCollectorName, authtypes.NewModuleAddress(govtypes.ModuleName).String(), app.AccountKeeper.AddressCodec())
|
||||
|
||||
app.FeeGrantKeeper = feegrantkeeper.NewKeeper(appCodec, runtime.NewKVStoreService(keys[feegrant.StoreKey]), app.AccountKeeper)
|
||||
|
||||
// register the staking hooks
|
||||
@ -393,10 +385,6 @@ func NewSimApp(
|
||||
|
||||
/**** 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))
|
||||
|
||||
// NOTE: Any module instantiated in the module manager that is later modified
|
||||
// must be passed by reference here.
|
||||
app.ModuleManager = module.NewManager(
|
||||
@ -407,7 +395,6 @@ func NewSimApp(
|
||||
auth.NewAppModule(appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts, app.GetSubspace(authtypes.ModuleName)),
|
||||
vesting.NewAppModule(app.AccountKeeper, app.BankKeeper),
|
||||
bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper, app.GetSubspace(banktypes.ModuleName)),
|
||||
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, nil, app.GetSubspace(minttypes.ModuleName)),
|
||||
@ -459,7 +446,6 @@ func NewSimApp(
|
||||
authz.ModuleName,
|
||||
)
|
||||
app.ModuleManager.SetOrderEndBlockers(
|
||||
crisistypes.ModuleName,
|
||||
govtypes.ModuleName,
|
||||
stakingtypes.ModuleName,
|
||||
genutiltypes.ModuleName,
|
||||
@ -473,7 +459,7 @@ func NewSimApp(
|
||||
genesisModuleOrder := []string{
|
||||
authtypes.ModuleName, banktypes.ModuleName,
|
||||
distrtypes.ModuleName, stakingtypes.ModuleName, slashingtypes.ModuleName, govtypes.ModuleName,
|
||||
minttypes.ModuleName, crisistypes.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, authz.ModuleName,
|
||||
minttypes.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, authz.ModuleName,
|
||||
feegrant.ModuleName, nft.ModuleName, group.ModuleName, paramstypes.ModuleName, upgradetypes.ModuleName,
|
||||
vestingtypes.ModuleName, consensusparamtypes.ModuleName, circuittypes.ModuleName,
|
||||
}
|
||||
@ -483,7 +469,6 @@ func NewSimApp(
|
||||
// Uncomment if you want to set a custom migration order here.
|
||||
// app.ModuleManager.SetOrderMigrations(custom order)
|
||||
|
||||
app.ModuleManager.RegisterInvariants(app.CrisisKeeper)
|
||||
app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter())
|
||||
err = app.ModuleManager.RegisterServices(app.configurator)
|
||||
if err != nil {
|
||||
@ -793,7 +778,6 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
|
||||
paramsKeeper.Subspace(distrtypes.ModuleName)
|
||||
paramsKeeper.Subspace(slashingtypes.ModuleName)
|
||||
paramsKeeper.Subspace(govtypes.ModuleName)
|
||||
paramsKeeper.Subspace(crisistypes.ModuleName)
|
||||
|
||||
return paramsKeeper
|
||||
}
|
||||
|
||||
@ -12,7 +12,6 @@ import (
|
||||
bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1"
|
||||
circuitmodulev1 "cosmossdk.io/api/cosmos/circuit/module/v1"
|
||||
consensusmodulev1 "cosmossdk.io/api/cosmos/consensus/module/v1"
|
||||
crisismodulev1 "cosmossdk.io/api/cosmos/crisis/module/v1"
|
||||
distrmodulev1 "cosmossdk.io/api/cosmos/distribution/module/v1"
|
||||
evidencemodulev1 "cosmossdk.io/api/cosmos/evidence/module/v1"
|
||||
feegrantmodulev1 "cosmossdk.io/api/cosmos/feegrant/module/v1"
|
||||
@ -52,8 +51,6 @@ import (
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
_ "github.com/cosmos/cosmos-sdk/x/consensus" // import for side-effects
|
||||
consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
|
||||
_ "github.com/cosmos/cosmos-sdk/x/crisis" // import for side-effects
|
||||
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
|
||||
_ "github.com/cosmos/cosmos-sdk/x/distribution" // import for side-effects
|
||||
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/genutil"
|
||||
@ -122,7 +119,6 @@ var (
|
||||
authz.ModuleName,
|
||||
},
|
||||
EndBlockers: []string{
|
||||
crisistypes.ModuleName,
|
||||
govtypes.ModuleName,
|
||||
stakingtypes.ModuleName,
|
||||
feegrant.ModuleName,
|
||||
@ -145,7 +141,6 @@ var (
|
||||
slashingtypes.ModuleName,
|
||||
govtypes.ModuleName,
|
||||
minttypes.ModuleName,
|
||||
crisistypes.ModuleName,
|
||||
genutiltypes.ModuleName,
|
||||
evidencetypes.ModuleName,
|
||||
authz.ModuleName,
|
||||
@ -250,10 +245,6 @@ var (
|
||||
Name: govtypes.ModuleName,
|
||||
Config: appconfig.WrapAny(&govmodulev1.Module{}),
|
||||
},
|
||||
{
|
||||
Name: crisistypes.ModuleName,
|
||||
Config: appconfig.WrapAny(&crisismodulev1.Module{}),
|
||||
},
|
||||
{
|
||||
Name: consensustypes.ModuleName,
|
||||
Config: appconfig.WrapAny(&consensusmodulev1.Module{}),
|
||||
|
||||
@ -36,7 +36,6 @@ import (
|
||||
authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper"
|
||||
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
|
||||
consensuskeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper"
|
||||
crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper"
|
||||
distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper"
|
||||
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
|
||||
groupkeeper "github.com/cosmos/cosmos-sdk/x/group/keeper"
|
||||
@ -73,7 +72,6 @@ type SimApp struct {
|
||||
MintKeeper mintkeeper.Keeper
|
||||
DistrKeeper distrkeeper.Keeper
|
||||
GovKeeper *govkeeper.Keeper
|
||||
CrisisKeeper *crisiskeeper.Keeper
|
||||
UpgradeKeeper *upgradekeeper.Keeper
|
||||
ParamsKeeper paramskeeper.Keeper
|
||||
AuthzKeeper authzkeeper.Keeper
|
||||
@ -174,7 +172,6 @@ func NewSimApp(
|
||||
&app.MintKeeper,
|
||||
&app.DistrKeeper,
|
||||
&app.GovKeeper,
|
||||
&app.CrisisKeeper,
|
||||
&app.UpgradeKeeper,
|
||||
&app.ParamsKeeper,
|
||||
&app.AuthzKeeper,
|
||||
@ -230,8 +227,6 @@ func NewSimApp(
|
||||
|
||||
/**** Module Options ****/
|
||||
|
||||
app.ModuleManager.RegisterInvariants(app.CrisisKeeper)
|
||||
|
||||
// RegisterUpgradeHandlers is used for registering any on-chain upgrades.
|
||||
app.RegisterUpgradeHandlers()
|
||||
|
||||
|
||||
@ -33,7 +33,6 @@ import (
|
||||
authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank"
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/crisis"
|
||||
"github.com/cosmos/cosmos-sdk/x/distribution"
|
||||
"github.com/cosmos/cosmos-sdk/x/genutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov"
|
||||
@ -209,7 +208,6 @@ func TestRunMigrations(t *testing.T) {
|
||||
"vesting": vesting.AppModule{}.ConsensusVersion(),
|
||||
"feegrant": feegrantmodule.AppModule{}.ConsensusVersion(),
|
||||
"evidence": evidence.AppModule{}.ConsensusVersion(),
|
||||
"crisis": crisis.AppModule{}.ConsensusVersion(),
|
||||
"genutil": genutil.AppModule{}.ConsensusVersion(),
|
||||
},
|
||||
)
|
||||
@ -258,7 +256,6 @@ func TestInitGenesisOnMigration(t *testing.T) {
|
||||
"vesting": vesting.AppModule{}.ConsensusVersion(),
|
||||
"feegrant": feegrantmodule.AppModule{}.ConsensusVersion(),
|
||||
"evidence": evidence.AppModule{}.ConsensusVersion(),
|
||||
"crisis": crisis.AppModule{}.ConsensusVersion(),
|
||||
"genutil": genutil.AppModule{}.ConsensusVersion(),
|
||||
},
|
||||
)
|
||||
|
||||
@ -71,9 +71,6 @@ func (app *SimApp) 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
|
||||
|
||||
@ -1,11 +1,9 @@
|
||||
package simapp
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
||||
flag "github.com/spf13/pflag"
|
||||
"github.com/spf13/viper"
|
||||
"github.com/stretchr/testify/require"
|
||||
@ -143,22 +141,4 @@ func BenchmarkInvariants(b *testing.B) {
|
||||
if config.Commit {
|
||||
simtestutil.PrintStats(db)
|
||||
}
|
||||
|
||||
ctx := app.NewContextLegacy(true, cmtproto.Header{Height: app.LastBlockHeight() + 1})
|
||||
|
||||
// 3. Benchmark each invariant separately
|
||||
//
|
||||
// NOTE: We use the crisis keeper as it has all the invariants registered with
|
||||
// their respective metadata which makes it useful for testing/benchmarking.
|
||||
for _, cr := range app.CrisisKeeper.Routes() {
|
||||
cr := cr
|
||||
b.Run(fmt.Sprintf("%s/%s", cr.ModuleName, cr.Route), func(b *testing.B) {
|
||||
if res, stop := cr.Invar(ctx); stop {
|
||||
b.Fatalf(
|
||||
"broken invariant at block %d of %d\n%s",
|
||||
ctx.BlockHeight()-1, config.NumBlocks, res,
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,7 +26,6 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
authcmd "github.com/cosmos/cosmos-sdk/x/auth/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"
|
||||
)
|
||||
|
||||
@ -118,7 +117,6 @@ func initRootCmd(
|
||||
|
||||
server.AddCommandsWithStartCmdOptions(rootCmd, simapp.DefaultNodeHome, newApp, appExport, server.StartCmdOptions{
|
||||
AddFlags: func(startCmd *cobra.Command) {
|
||||
crisis.AddModuleInitFlags(startCmd)
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
@ -50,7 +50,6 @@ func defaultConfig() *Config {
|
||||
"auth",
|
||||
"bank",
|
||||
"gov",
|
||||
"crisis",
|
||||
"genutil",
|
||||
"authz",
|
||||
"feegrant",
|
||||
@ -62,7 +61,6 @@ func defaultConfig() *Config {
|
||||
"circuit",
|
||||
},
|
||||
EndBlockersOrder: []string{
|
||||
"crisis",
|
||||
"gov",
|
||||
"staking",
|
||||
"auth",
|
||||
@ -90,7 +88,6 @@ func defaultConfig() *Config {
|
||||
"slashing",
|
||||
"gov",
|
||||
"mint",
|
||||
"crisis",
|
||||
"genutil",
|
||||
"evidence",
|
||||
"authz",
|
||||
|
||||
@ -9,7 +9,6 @@ Here are some production-grade modules that can be used in Cosmos SDK applicatio
|
||||
* [Auth](./auth/README.md) - Authentication of accounts and transactions for Cosmos SDK applications.
|
||||
* [Authz](./authz/README.md) - Authorization for accounts to perform actions on behalf of other accounts.
|
||||
* [Bank](./bank/README.md) - Token transfer functionalities.
|
||||
* [Crisis](./crisis/README.md) - Halting the blockchain under certain circumstances (e.g. if an invariant is broken).
|
||||
* [Distribution](./distribution/README.md) - Fee distribution, and staking token provision distribution.
|
||||
* [Evidence](./evidence/README.md) - Evidence handling for double signing, misbehaviour, etc.
|
||||
* [Feegrant](./feegrant/README.md) - Grant fee allowances for executing transactions.
|
||||
@ -23,6 +22,7 @@ Here are some production-grade modules that can be used in Cosmos SDK applicatio
|
||||
* [Consensus](./consensus/README.md) - Consensus module for modifying CometBFT's ABCI consensus params.
|
||||
* [Circuit](./circuit/README.md) - Circuit breaker module for pausing messages.
|
||||
* [Genutil](./genutil/README.md) - Genesis utilities for the Cosmos SDK.
|
||||
* [Crisis](./crisis/README.md) - *Deprecated* halting the blockchain under certain circumstances (e.g. if an invariant is broken).
|
||||
|
||||
To learn more about the process of building modules, visit the [building modules reference documentation](https://docs.cosmos.network/main/building-modules/intro).
|
||||
|
||||
|
||||
@ -4,6 +4,8 @@ sidebar_position: 1
|
||||
|
||||
# `x/crisis`
|
||||
|
||||
NOTE: `x/crisis` is deprecated as of Cosmos SDK v0.53 and will be removed in the next release.
|
||||
|
||||
## Overview
|
||||
|
||||
The crisis module halts the blockchain under the circumstance that a blockchain
|
||||
|
||||
@ -16,6 +16,8 @@ import (
|
||||
)
|
||||
|
||||
// Keeper - crisis keeper
|
||||
//
|
||||
// Deprecated: the crisis keeper is deprecated and will be removed in the next Cosmos SDK major release.
|
||||
type Keeper struct {
|
||||
routes []types.InvarRoute
|
||||
invCheckPeriod uint
|
||||
@ -37,6 +39,8 @@ type Keeper struct {
|
||||
}
|
||||
|
||||
// NewKeeper creates a new Keeper object
|
||||
//
|
||||
// Deprecated: the crisis keeper is deprecated and will be removed in the next Cosmos SDK major release.
|
||||
func NewKeeper(
|
||||
cdc codec.BinaryCodec, storeService storetypes.KVStoreService, invCheckPeriod uint,
|
||||
supplyKeeper types.SupplyKeeper, feeCollectorName, authority string, ac address.Codec,
|
||||
|
||||
@ -43,6 +43,8 @@ var (
|
||||
|
||||
// Module init related flags
|
||||
const (
|
||||
// Deprecated: this flag is no longer used and will be removed along with x/crisis in the next major
|
||||
// Cosmos SDK release.
|
||||
FlagSkipGenesisInvariants = "x-crisis-skip-assert-invariants"
|
||||
)
|
||||
|
||||
@ -85,6 +87,8 @@ func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry)
|
||||
}
|
||||
|
||||
// AppModule implements an application module for the crisis module.
|
||||
//
|
||||
// Deprecated: the crisis module is deprecated and will be removed in the next Cosmos SDK major release.
|
||||
type AppModule struct {
|
||||
AppModuleBasic
|
||||
|
||||
@ -103,6 +107,8 @@ type AppModule struct {
|
||||
// we will call keeper.AssertInvariants during InitGenesis (it may take a significant time)
|
||||
// - which doesn't impact the chain security unless 66+% of validators have a wrongly
|
||||
// modified genesis file.
|
||||
//
|
||||
// Deprecated: the crisis module is deprecated and will be removed in the next Cosmos SDK major release.
|
||||
func NewAppModule(keeper *keeper.Keeper, skipGenesisInvariants bool, ss exported.Subspace) AppModule {
|
||||
return AppModule{
|
||||
AppModuleBasic: AppModuleBasic{},
|
||||
@ -120,6 +126,8 @@ func (am AppModule) IsOnePerModuleType() {}
|
||||
func (am AppModule) IsAppModule() {}
|
||||
|
||||
// AddModuleInitFlags implements servertypes.ModuleInitFlags interface.
|
||||
//
|
||||
// Deprecated: this flag is deprecated and will be removed in the next major Cosmos SDK release.
|
||||
func AddModuleInitFlags(startCmd *cobra.Command) {
|
||||
startCmd.Flags().Bool(FlagSkipGenesisInvariants, false, "Skip x/crisis invariants check on startup")
|
||||
}
|
||||
|
||||
2
x/genutil/types/testdata/app_genesis.json
vendored
2
x/genutil/types/testdata/app_genesis.json
vendored
File diff suppressed because one or more lines are too long
@ -246,8 +246,6 @@ module_versions:
|
||||
version: "1"
|
||||
- name: bank
|
||||
version: "2"
|
||||
- name: crisis
|
||||
version: "1"
|
||||
- name: distribution
|
||||
version: "2"
|
||||
- name: evidence
|
||||
@ -410,10 +408,6 @@ Example Output:
|
||||
"name": "bank",
|
||||
"version": "2"
|
||||
},
|
||||
{
|
||||
"name": "crisis",
|
||||
"version": "1"
|
||||
},
|
||||
{
|
||||
"name": "distribution",
|
||||
"version": "2"
|
||||
@ -552,10 +546,6 @@ Example Output:
|
||||
"name": "bank",
|
||||
"version": "2"
|
||||
},
|
||||
{
|
||||
"name": "crisis",
|
||||
"version": "1"
|
||||
},
|
||||
{
|
||||
"name": "distribution",
|
||||
"version": "2"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user