v0.50.1 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2023 License: Apache-2.0 Imports: 27 Imported by: 1,668


sidebar_position: 1



The crisis module halts the blockchain under the circumstance that a blockchain invariant is broken. Invariants can be registered with the application during the application initialization process.




Due to the anticipated large gas cost requirement to verify an invariant (and potential to exceed the maximum allowable block gas limit) a constant fee is used instead of the standard gas consumption method. The constant fee is intended to be larger than the anticipated gas cost of running the invariant with the standard gas consumption method.

The ConstantFee param is stored in the module params state with the prefix of 0x01, it can be updated with governance or the address with authority.

  • Params: mint/params -> legacy_amino(sdk.Coin)


In this section we describe the processing of the crisis messages and the corresponding updates to the state.


Blockchain invariants can be checked using the MsgVerifyInvariant message.

This message is expected to fail if:

  • the sender does not have enough coins for the constant fee
  • the invariant route is not registered

This message checks the invariant provided, and if the invariant is broken it panics, halting the blockchain. If the invariant is broken, the constant fee is never deducted as the transaction is never committed to a block (equivalent to being refunded). However, if the invariant is not broken, the constant fee will not be refunded.


The crisis module emits the following events:


Type Attribute Key Attribute Value
invariant route {invariantRoute}
message module crisis
message action verify_invariant
message sender {senderAddress}


The crisis module contains the following parameters:

Key Type Example
ConstantFee object (coin) {"denom":"uatom","amount":"1000"}



A user can query and interact with the crisis module using the CLI.


The tx commands allow users to interact with the crisis module.

simd tx crisis --help

The invariant-broken command submits proof when an invariant was broken to halt the chain

simd tx crisis invariant-broken [module-name] [invariant-route] [flags]


simd tx crisis invariant-broken bank total-supply --from=[keyname or address]




View Source
const ConsensusVersion = 2

ConsensusVersion defines the current x/crisis module consensus version.

View Source
const (
	FlagSkipGenesisInvariants = "x-crisis-skip-assert-invariants"

Module init related flags


This section is empty.


func AddModuleInitFlags added in v0.40.0

func AddModuleInitFlags(startCmd *cobra.Command)

AddModuleInitFlags implements servertypes.ModuleInitFlags interface.

func EndBlocker

func EndBlocker(ctx context.Context, k keeper.Keeper)

check all registered invariants


type AppModule

type AppModule struct {
	// contains filtered or unexported fields

AppModule implements an application module for the crisis module.

func NewAppModule

func NewAppModule(keeper *keeper.Keeper, skipGenesisInvariants bool, ss exported.Subspace) AppModule

NewAppModule creates a new AppModule object. If initChainAssertInvariants is set, 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.

func (AppModule) AutoCLIOptions added in v0.50.0

func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions

AutoCLIOptions implements the autocli.HasAutoCLIConfig interface.

func (AppModule) ConsensusVersion added in v0.43.0

func (AppModule) ConsensusVersion() uint64

ConsensusVersion implements AppModule/ConsensusVersion.

func (AppModule) EndBlock

func (am AppModule) EndBlock(ctx context.Context) error

EndBlock returns the end blocker for the crisis module. It returns no validator updates.

func (AppModule) ExportGenesis

func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage

ExportGenesis returns the exported genesis state as raw bytes for the crisis module.

func (AppModule) InitGenesis

func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage)

InitGenesis performs genesis initialization for the crisis module. It returns no validator updates.

func (AppModule) IsAppModule added in v0.47.0

func (am AppModule) IsAppModule()

IsAppModule implements the appmodule.AppModule interface.

func (AppModule) IsOnePerModuleType added in v0.47.0

func (am AppModule) IsOnePerModuleType()

IsOnePerModuleType implements the depinject.OnePerModuleType interface.

func (AppModule) RegisterServices added in v0.40.0

func (am AppModule) RegisterServices(cfg module.Configurator)

RegisterServices registers module services.

type AppModuleBasic

type AppModuleBasic struct{}

AppModuleBasic defines the basic application module used by the crisis module.

func (AppModuleBasic) DefaultGenesis

func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage

DefaultGenesis returns default genesis state as raw bytes for the crisis module.

func (AppModuleBasic) Name

func (AppModuleBasic) Name() string

Name returns the crisis module's name.

func (AppModuleBasic) RegisterGRPCGatewayRoutes added in v0.40.0

func (AppModuleBasic) RegisterGRPCGatewayRoutes(_ client.Context, _ *gwruntime.ServeMux)

RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the crisis module.

func (AppModuleBasic) RegisterInterfaces added in v0.40.0

func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry)

RegisterInterfaces registers interfaces and implementations of the crisis module.

func (AppModuleBasic) RegisterLegacyAminoCodec added in v0.40.0

func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino)

RegisterLegacyAminoCodec registers the crisis module's types on the given LegacyAmino codec.

func (AppModuleBasic) ValidateGenesis

func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error

ValidateGenesis performs genesis state validation for the crisis module.

type ModuleInputs added in v0.50.0

type ModuleInputs struct {

	Config       *modulev1.Module
	StoreService store.KVStoreService
	Cdc          codec.Codec
	AppOpts      servertypes.AppOptions `optional:"true"`

	BankKeeper   types.SupplyKeeper
	AddressCodec address.Codec

	// LegacySubspace is used solely for migration of x/params managed parameters
	LegacySubspace exported.Subspace `optional:"true"`

type ModuleOutputs added in v0.50.0

type ModuleOutputs struct {

	Module       appmodule.AppModule
	CrisisKeeper *keeper.Keeper

func ProvideModule added in v0.47.0

func ProvideModule(in ModuleInputs) ModuleOutputs


Path Synopsis
Package testutil is a generated GoMock package.
Package testutil is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL