upgrade

package
v1.0.0-rc64 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

README

x/upgrade

Abstract

This upgrade module is a fork of the cosmos-sdk's x/upgrade module that removes the entrypoints to the standard upgrade module by not registering a message server.

The goal of this approach is to force social consensus to reach an upgrade instead of relying on token voting. It works by simply removing the ability of the gov module to schedule an upgrade. This way, the only way to upgrade the chain is to agree on the upgrade logic and the upgrade height offchain.

This fork registers the standard upgrade module types to preserve the ability to marshal them. Additionally the keeper of the standard upgrade module is still added to the application.

Resources

  1. https://github.com/celestiaorg/celestia-app/pull/1491
  2. https://github.com/cosmos/cosmos-sdk/blob/v0.46.15/x/upgrade/README.md
  3. https://github.com/cosmos/cosmos-sdk/blob/v0.46.15/x/gov/README.md

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func VersionFromBytes

func VersionFromBytes(version []byte) uint64

func VersionToBytes

func VersionToBytes(version uint64) []byte

Types

type AppModule

type AppModule struct {
	AppModuleBasic
	// contains filtered or unexported fields
}

AppModule implements the sdk.AppModule interface

func NewAppModule

func NewAppModule(keeper Keeper) AppModule

NewAppModule creates a new AppModule object

func (AppModule) ConsensusVersion

func (AppModule) ConsensusVersion() uint64

ConsensusVersion implements AppModule/ConsensusVersion.

func (AppModule) ExportGenesis

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

ExportGenesis is always empty, as InitGenesis does nothing either

func (AppModule) InitGenesis

InitGenesis is ignored, no sense in serializing future upgrades

func (AppModule) LegacyQuerierHandler

func (am AppModule) LegacyQuerierHandler(_ *codec.LegacyAmino) sdk.Querier

LegacyQuerierHandler registers a query handler to respond to the module-specific queries

func (AppModule) QuerierRoute

func (AppModule) QuerierRoute() string

QuerierRoute returns the route we respond to for abci queries

func (AppModule) RegisterInvariants

func (AppModule) RegisterInvariants(_ sdk.InvariantRegistry)

RegisterInvariants does nothing, there are no invariants to enforce

func (AppModule) RegisterServices

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

RegisterServices registers module services.

func (AppModule) Route deprecated

func (AppModule) Route() sdk.Route

Deprecated: Route returns the message routing key for the upgrade module.

type AppModuleBasic

type AppModuleBasic struct{}

AppModuleBasic implements the sdk.AppModuleBasic interface

func (AppModuleBasic) DefaultGenesis

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

DefaultGenesis is an empty object

func (AppModuleBasic) GetQueryCmd

func (AppModuleBasic) GetQueryCmd() *cobra.Command

GetQueryCmd returns the cli query commands for this module

func (AppModuleBasic) GetTxCmd

func (AppModuleBasic) GetTxCmd() *cobra.Command

GetTxCmd returns the transaction commands for this module

func (AppModuleBasic) Name

func (AppModuleBasic) Name() string

Name returns the ModuleName

func (AppModuleBasic) RegisterGRPCGatewayRoutes

func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux)

RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the upgrade module.

func (AppModuleBasic) RegisterInterfaces

func (b AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry)

func (AppModuleBasic) RegisterLegacyAminoCodec

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

RegisterLegacyAminoCodec registers the upgrade types on the LegacyAmino codec

func (AppModuleBasic) ValidateGenesis

ValidateGenesis is always successful, as we ignore the value

type Fraction

type Fraction struct {
	Numerator   int64
	Denominator int64
}

func SignalThreshold

func SignalThreshold(version uint64) Fraction

SignalThreshold is the fraction of voting power that is required to signal for a version change. It is set to 5/6 as the middle point between 2/3 and 3/3 providing 1/6 fault tolerance to halting the network during an upgrade period. It can be modified through a hard fork change that modified the app version

type Keeper

type Keeper struct {
	// contains filtered or unexported fields
}

func NewKeeper

func NewKeeper(
	storeKey storetypes.StoreKey,
	upgradeHeight int64,
	stakingKeeper StakingKeeper,
) Keeper

NewKeeper constructs an upgrade keeper

func (Keeper) ClearIBCState

func (k Keeper) ClearIBCState(ctx sdk.Context, lastHeight int64)

ClearIBCState clears any planned IBC state

func (Keeper) DeleteValidatorVersion

func (k Keeper) DeleteValidatorVersion(ctx sdk.Context, valAddress sdk.ValAddress)

DeleteValidatorVersion deletes a signalled version for a validator using the keeper's store key

func (Keeper) GetUpgradePlan

func (k Keeper) GetUpgradePlan(_ sdk.Context) (plan types.Plan, havePlan bool)

GetUpgradePlan implements the ibc upgrade keeper interface. This is used in BeginBlock to know when to write the upgraded consensus state. The IBC module needs to sign over the next consensus state to ensure a smooth transition for counterparty chains. This is implemented as a noop. Any IBC breaking change would be invoked by this upgrade module in end blocker.

func (Keeper) GetUpgradedClient

func (k Keeper) GetUpgradedClient(ctx sdk.Context, height int64) ([]byte, bool)

GetUpgradedClient gets the expected upgraded client for the next version of this chain

func (Keeper) GetUpgradedConsensusState

func (k Keeper) GetUpgradedConsensusState(ctx sdk.Context, lastHeight int64) ([]byte, bool)

GetUpgradedConsensusState get the expected upgraded consensus state for the next version of this chain

func (Keeper) GetVotingPowerThreshold

func (k Keeper) GetVotingPowerThreshold(ctx sdk.Context) sdkmath.Int

GetVotingPowerThreshold returns the voting power threshold required to upgrade to a new version.

func (*Keeper) ResetTally

func (k *Keeper) ResetTally(ctx sdk.Context, version uint64)

ResetTally resets the tally after a version change. It iterates over the store, and deletes any versions that are less than the provided version. It also resets the quorumVersion to 0.

func (Keeper) ScheduleUpgrade

func (k Keeper) ScheduleUpgrade(_ sdk.Context, _ types.Plan) error

ScheduleUpgrade implements the ibc upgrade keeper interface. This is a noop as no other process is allowed to schedule an upgrade but the upgrade keeper itself. This is kept around to support the interface.

func (Keeper) SetUpgradedClient

func (k Keeper) SetUpgradedClient(ctx sdk.Context, planHeight int64, bz []byte) error

SetUpgradedClient sets the expected upgraded client for the next version of this chain at the last height the current chain will commit.

func (Keeper) SetUpgradedConsensusState

func (k Keeper) SetUpgradedConsensusState(ctx sdk.Context, planHeight int64, bz []byte) error

SetUpgradedConsensusState set the expected upgraded consensus state for the next version of this chain using the last height committed on this chain.

func (Keeper) SetValidatorVersion

func (k Keeper) SetValidatorVersion(ctx sdk.Context, valAddress sdk.ValAddress, version uint64)

SetValidatorVersion saves a signalled version for a validator using the keeper's store key

func (*Keeper) ShouldUpgrade

func (k *Keeper) ShouldUpgrade() (bool, uint64)

ShouldUpgrade returns true if the signalling mechanism has concluded that the network is ready to upgrade. It also returns the version that the node should upgrade to.

func (Keeper) ShouldUpgradeToV2

func (k Keeper) ShouldUpgradeToV2(height int64) bool

ShouldUpgradeToV2 returns true if the current height is one before the locally provided upgrade height that is passed as a flag NOTE: This is only used to upgrade to v2 and should be deprecated in v3

func (Keeper) SignalVersion

SignalVersion is a method required by the MsgServer interface

func (Keeper) TallyVotingPower

func (k Keeper) TallyVotingPower(ctx sdk.Context, threshold int64) (bool, uint64)

TallyVotingPower tallies the voting power for each version and returns true if any version has reached the quorum in voting power

func (*Keeper) TryUpgrade

TryUpgrade is a method required by the MsgServer interface It tallies the voting power that has voted on each version. If one version has quorum, it is set as the quorum version which the application can use as signal to upgrade to that version.

func (Keeper) VersionTally

VersionTally is a method required by the QueryServer interface

type StakingKeeper

type StakingKeeper interface {
	GetLastValidatorPower(ctx sdk.Context, addr sdk.ValAddress) int64
	GetLastTotalPower(ctx sdk.Context) math.Int
	GetValidator(ctx sdk.Context, addr sdk.ValAddress) (validator stakingtypes.Validator, found bool)
}

Directories

Path Synopsis
Package types is a reverse proxy.
Package types is a reverse proxy.

Jump to

Keyboard shortcuts

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