keeper

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2025 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LegacyProtocolVersionByte was the prefix to look up Protocol Version (AppVersion)
	LegacyProtocolVersionByte = 0x3
)

Variables

This section is empty.

Functions

func BuildUpgradeNeededMsg

func BuildUpgradeNeededMsg(plan types.Plan) string

BuildUpgradeNeededMsg prints the message that notifies that an upgrade is needed.

func NewMsgServerImpl

func NewMsgServerImpl(k *Keeper) types.MsgServer

NewMsgServerImpl returns an implementation of the upgrade MsgServer interface for the provided Keeper.

Types

type Keeper

type Keeper struct {
	appmodule.Environment
	// contains filtered or unexported fields
}

func NewKeeper

func NewKeeper(
	env appmodule.Environment,
	skipUpgradeHeights map[int64]bool,
	cdc codec.BinaryCodec,
	homePath string,
	vs server.VersionModifier,
	authority string,
	ck types.ConsensusKeeper,
) *Keeper

NewKeeper constructs an upgrade Keeper which requires the following arguments: skipUpgradeHeights - map of heights to skip an upgrade storeKey - a store key with which to access upgrade's store cdc - the app-wide binary codec homePath - root directory of the application's config vs - the interface implemented by baseapp which allows setting baseapp's protocol version field

func (Keeper) AppliedPlan

AppliedPlan implements the Query/AppliedPlan gRPC method

func (Keeper) ApplyUpgrade

func (k Keeper) ApplyUpgrade(ctx context.Context, plan types.Plan) error

ApplyUpgrade will execute the handler associated with the Plan and mark the plan as done. If successful, it will increment the app version and clear the IBC state

func (Keeper) Authority

Authority implements the Query/Authority gRPC method, returning the account capable of performing upgrades

func (Keeper) ClearIBCState

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

ClearIBCState clears any planned IBC state

func (Keeper) ClearUpgradePlan

func (k Keeper) ClearUpgradePlan(ctx context.Context) error

ClearUpgradePlan clears any schedule upgrade and associated IBC states.

func (Keeper) CurrentPlan

CurrentPlan implements the Query/CurrentPlan gRPC method

func (Keeper) DowngradeVerified

func (k Keeper) DowngradeVerified() bool

DowngradeVerified returns downgradeVerified.

func (Keeper) DumpUpgradeInfoToDisk

func (k Keeper) DumpUpgradeInfoToDisk(height int64, p types.Plan) error

DumpUpgradeInfoToDisk writes upgrade information to UpgradeInfoFileName.

func (Keeper) GetDoneHeight

func (k Keeper) GetDoneHeight(ctx context.Context, name string) (int64, error)

GetDoneHeight returns the height at which the given upgrade was executed

func (*Keeper) GetInitVersionMap

func (k *Keeper) GetInitVersionMap() appmodule.VersionMap

GetInitVersionMap gets the initial version map This is only used in upgrade InitGenesis and should not be used in any other context.

func (Keeper) GetLastCompletedUpgrade

func (k Keeper) GetLastCompletedUpgrade(ctx context.Context) (string, int64, error)

GetLastCompletedUpgrade returns the last applied upgrade name and height.

func (Keeper) GetModuleVersionMap

func (k Keeper) GetModuleVersionMap(ctx context.Context) (appmodule.VersionMap, error)

GetModuleVersionMap returns a map of key module name and value module consensus version as defined in ADR-041.

func (Keeper) GetModuleVersions

func (k Keeper) GetModuleVersions(ctx context.Context) ([]*types.ModuleVersion, error)

GetModuleVersions gets a slice of module consensus versions

func (Keeper) GetUpgradeInfoPath

func (k Keeper) GetUpgradeInfoPath() (string, error)

GetUpgradeInfoPath returns the upgrade info file path

func (Keeper) GetUpgradePlan

func (k Keeper) GetUpgradePlan(ctx context.Context) (plan types.Plan, err error)

GetUpgradePlan returns the currently scheduled Plan if any. If not found it returns ErrNoUpgradePlanFound, but other errors may be returned if there is an error reading from the store.

func (Keeper) GetUpgradedClient

func (k Keeper) GetUpgradedClient(ctx context.Context, height int64) ([]byte, error)

GetUpgradedClient gets the expected upgraded client for the next version of this chain. If not found it returns ErrNoUpgradedClientFound, but other errors may be returned if there is an error reading from the store.

func (Keeper) GetUpgradedConsensusState

func (k Keeper) GetUpgradedConsensusState(ctx context.Context, lastHeight int64) ([]byte, error)

GetUpgradedConsensusState gets the expected upgraded consensus state for the next version of this chain. If not found it returns ErrNoUpgradedConsensusStateFound, but other errors may be returned if there is an error reading from the store.

func (Keeper) HasHandler

func (k Keeper) HasHandler(name string) bool

HasHandler returns true iff there is a handler registered for this name

func (Keeper) IsSkipHeight

func (k Keeper) IsSkipHeight(height int64) bool

IsSkipHeight checks if the given height is part of skipUpgradeHeights

func (Keeper) ModuleVersions

ModuleVersions implements the Query/QueryModuleVersions gRPC method

func (Keeper) PreBlocker

func (k Keeper) PreBlocker(ctx context.Context) error

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

func (Keeper) ReadUpgradeInfoFromDisk

func (k Keeper) ReadUpgradeInfoFromDisk() (types.Plan, error)

ReadUpgradeInfoFromDisk returns the name and height of the upgrade which is written to disk by the old binary when panicking. An error is returned if the upgrade path directory cannot be created or if the file exists and cannot be read or if the upgrade info fails to unmarshal.

func (Keeper) ScheduleUpgrade

func (k Keeper) ScheduleUpgrade(ctx context.Context, plan types.Plan) error

ScheduleUpgrade schedules an upgrade based on the specified plan. If there is another Plan already scheduled, it will cancel and overwrite it. ScheduleUpgrade will also write the upgraded IBC ClientState to the upgraded client path if it is specified in the plan.

func (*Keeper) SetDowngradeVerified

func (k *Keeper) SetDowngradeVerified(v bool)

SetDowngradeVerified updates downgradeVerified.

func (*Keeper) SetInitVersionMap

func (k *Keeper) SetInitVersionMap(vm appmodule.VersionMap)

SetInitVersionMap sets the initial version map. This is only used in app wiring and should not be used in any other context.

func (Keeper) SetModuleVersionMap

func (k Keeper) SetModuleVersionMap(ctx context.Context, vm appmodule.VersionMap) error

SetModuleVersionMap saves a given version map to state

func (Keeper) SetUpgradeHandler

func (k Keeper) SetUpgradeHandler(name string, upgradeHandler types.UpgradeHandler)

SetUpgradeHandler sets an UpgradeHandler for the upgrade specified by name. This handler will be called when the upgrade with this name is applied. In order for an upgrade with the given name to proceed, a handler for this upgrade must be set even if it is a no-op function.

func (Keeper) SetUpgradedClient

func (k Keeper) SetUpgradedClient(ctx context.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 context.Context, planHeight int64, bz []byte) error

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

func (Keeper) UpgradedConsensusState

UpgradedConsensusState implements the Query/UpgradedConsensusState gRPC method

type Migrator

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

Migrator is a struct for handling in-place store migrations.

func NewMigrator

func NewMigrator(keeper *Keeper) Migrator

NewMigrator returns a new Migrator.

func (Migrator) Migrate1to2

func (m Migrator) Migrate1to2(ctx context.Context) error

Migrate1to2 migrates from version 1 to 2.

func (Migrator) Migrate2to3

func (m Migrator) Migrate2to3(ctx context.Context) error

Migrate2to3 migrates from version 2 to 3. It takes the legacy protocol version and if it exists, uses it to set the app version (of the baseapp)

Jump to

Keyboard shortcuts

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