Documentation
¶
Overview ¶
Package upgrade provides a Cosmos SDK module that can be used for smoothly upgrading a live Cosmos chain to a new software version. It accomplishes this by providing a BeginBlocker hook that prevents the blockchain state machine from proceeding once a pre-defined upgrade block height has been reached. The module does not prescribe anything regarding how governance decides to do an upgrade, but just the mechanism for coordinating the upgrade safely. Without software support for upgrades, upgrading a live chain is risky because all of the validators need to pause their state machines at exactly the same point in the process. If this is not done correctly, there can be state inconsistencies which are hard to recover from.
For more information, read the documentation on https://docs.cosmos.network/main/modules/upgrade.
Index ¶
- Constants
- func BuildUpgradeNeededMsg(plan types.Plan) string
- func PopulateVersionMap(upgradeKeeper *keeper.Keeper, modules map[string]appmodule.AppModule)
- func PreBlocker(ctx context.Context, k *keeper.Keeper) (appmodule.ResponsePreBlock, error)
- type AppModule
- func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions
- func (AppModule) ConsensusVersion() uint64
- func (am AppModule) ExportGenesis(_ sdk.Context, cdc codec.JSONCodec) json.RawMessage
- func (am AppModule) InitGenesis(ctx sdk.Context, _ codec.JSONCodec, _ json.RawMessage)
- func (am AppModule) IsAppModule()
- func (am AppModule) IsOnePerModuleType()
- func (am AppModule) PreBlock(ctx context.Context) (appmodule.ResponsePreBlock, error)
- func (am AppModule) RegisterServices(cfg module.Configurator)
- type AppModuleBasic
- func (AppModuleBasic) DefaultGenesis(_ codec.JSONCodec) json.RawMessage
- func (ab AppModuleBasic) GetTxCmd() *cobra.Command
- func (AppModuleBasic) Name() string
- func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwruntime.ServeMux)
- func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry)
- func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino)
- func (AppModuleBasic) ValidateGenesis(_ codec.JSONCodec, config client.TxEncodingConfig, _ json.RawMessage) error
- type ModuleInputs
- type ModuleOutputs
Constants ¶
const ConsensusVersion uint64 = 2
ConsensusVersion defines the current x/upgrade module consensus version.
Variables ¶
This section is empty.
Functions ¶
func BuildUpgradeNeededMsg ¶ added in v0.40.0
BuildUpgradeNeededMsg prints the message that notifies that an upgrade is needed.
func PopulateVersionMap ¶ added in v0.47.0
func PreBlocker ¶ added in v0.53.1
PreBlocker will check if there is a scheduled plan and if it is ready to be executed. If the current height is in the provided set of heights to skip, it will skip and clear the upgrade plan. If it is ready, it will execute it if the handler is installed, and panic/abort otherwise. If the plan is not ready, it will ensure the handler is not registered too early (and abort otherwise).
The purpose is to ensure the binary is switched EXACTLY at the desired block, and to allow a migration to be executed if needed upon this switch (migration defined in the new binary) skipUpgradeHeightArray is a set of block heights for which the upgrade must be skipped
Note: The MetricKey will change to MetricKeyPreBlocker in v0.54.0.
Types ¶
type AppModule ¶
type AppModule struct {
AppModuleBasic
// contains filtered or unexported fields
}
AppModule implements the sdk.AppModule interface
func NewAppModule ¶
NewAppModule creates a new AppModule object
func (AppModule) AutoCLIOptions ¶ added in v0.53.1
func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions
func (AppModule) ConsensusVersion ¶ added in v0.43.0
ConsensusVersion implements AppModule/ConsensusVersion.
func (AppModule) ExportGenesis ¶
ExportGenesis is always empty, as there is no sense in serializing future upgrades.
func (AppModule) InitGenesis ¶
InitGenesis sets the initial module version map (if provided). Upgrade plans themselves are not initialized from genesis.
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) PreBlock ¶ added in v0.53.1
PreBlock calls the upgrade module hooks
CONTRACT: this is called *before* all other modules' BeginBlock functions
func (AppModule) RegisterServices ¶ added in v0.40.0
func (am AppModule) RegisterServices(cfg module.Configurator)
RegisterServices registers module services.
type AppModuleBasic ¶
type AppModuleBasic struct {
// contains filtered or unexported fields
}
AppModuleBasic implements the sdk.AppModuleBasic interface
func (AppModuleBasic) DefaultGenesis ¶
func (AppModuleBasic) DefaultGenesis(_ codec.JSONCodec) json.RawMessage
DefaultGenesis is an empty object
func (AppModuleBasic) GetTxCmd ¶
func (ab AppModuleBasic) GetTxCmd() *cobra.Command
GetTxCmd returns the CLI transaction commands for this module
func (AppModuleBasic) RegisterGRPCGatewayRoutes ¶ added in v0.40.0
func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwruntime.ServeMux)
RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the upgrade module.
func (AppModuleBasic) RegisterInterfaces ¶ added in v0.40.0
func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry)
RegisterInterfaces registers interfaces and implementations of the upgrade module.
func (AppModuleBasic) RegisterLegacyAminoCodec ¶ added in v0.40.0
func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino)
RegisterLegacyAminoCodec registers the upgrade types on the LegacyAmino codec
func (AppModuleBasic) ValidateGenesis ¶
func (AppModuleBasic) ValidateGenesis(_ codec.JSONCodec, config client.TxEncodingConfig, _ json.RawMessage) error
ValidateGenesis is always successful, as we ignore the value
type ModuleInputs ¶ added in v0.53.1
type ModuleInputs struct {
depinject.In
Config *modulev1.Module
StoreService store.KVStoreService
Cdc codec.Codec
AddressCodec address.Codec
AppOpts servertypes.AppOptions `optional:"true"`
Viper *viper.Viper `optional:"true"`
}
type ModuleOutputs ¶ added in v0.53.1
type ModuleOutputs struct {
depinject.Out
UpgradeKeeper *keeper.Keeper
Module appmodule.AppModule
BaseAppOption runtime.BaseAppOption
}
func ProvideModule ¶ added in v0.47.0
func ProvideModule(in ModuleInputs) ModuleOutputs