upgrade

package
v1.0.0-rc59 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2023 License: Apache-2.0 Imports: 12 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

View Source
const (
	StoreKey   = upgradetypes.StoreKey
	ModuleName = upgradetypes.ModuleName
)

Variables

View Source
var (
	ErrInvalidLengthTypes        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowTypes          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupTypes = fmt.Errorf("proto: unexpected end of group")
)

Functions

func IsUpgradeMsg

func IsUpgradeMsg(msg []sdk.Msg) (uint64, bool)

func NewMsgVersionChange

func NewMsgVersionChange(txConfig client.TxConfig, version uint64) ([]byte, error)

NewMsgVersionChange creates a tx in byte form used to signal to validators to change to a new version

Types

type Keeper

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

func NewKeeper

func NewKeeper(storeKey storetypes.StoreKey, upgradeHeight int64) 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) 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) 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) ShouldUpgrade

func (k Keeper) ShouldUpgrade(height int64) bool

ShouldUpgrade returns true if the current height is one before the locally provided upgrade height that is passed as a flag

type MsgVersionChange

type MsgVersionChange struct {
	// the app version this message proposes upgrading to
	Version uint64 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"`
}

MsgVersionChange is a message that signals an app version change

func (*MsgVersionChange) Descriptor

func (*MsgVersionChange) Descriptor() ([]byte, []int)

func (*MsgVersionChange) GetSigners

func (msg *MsgVersionChange) GetSigners() []sdk.AccAddress

func (*MsgVersionChange) GetVersion

func (m *MsgVersionChange) GetVersion() uint64

func (*MsgVersionChange) Marshal

func (m *MsgVersionChange) Marshal() (dAtA []byte, err error)

func (*MsgVersionChange) MarshalTo

func (m *MsgVersionChange) MarshalTo(dAtA []byte) (int, error)

func (*MsgVersionChange) MarshalToSizedBuffer

func (m *MsgVersionChange) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*MsgVersionChange) ProtoMessage

func (*MsgVersionChange) ProtoMessage()

func (*MsgVersionChange) Reset

func (m *MsgVersionChange) Reset()

func (*MsgVersionChange) Size

func (m *MsgVersionChange) Size() (n int)

func (*MsgVersionChange) String

func (m *MsgVersionChange) String() string

func (*MsgVersionChange) Unmarshal

func (m *MsgVersionChange) Unmarshal(dAtA []byte) error

func (*MsgVersionChange) ValidateBasic

func (msg *MsgVersionChange) ValidateBasic() error

func (*MsgVersionChange) XXX_DiscardUnknown

func (m *MsgVersionChange) XXX_DiscardUnknown()

func (*MsgVersionChange) XXX_Marshal

func (m *MsgVersionChange) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*MsgVersionChange) XXX_Merge

func (m *MsgVersionChange) XXX_Merge(src proto.Message)

func (*MsgVersionChange) XXX_Size

func (m *MsgVersionChange) XXX_Size() int

func (*MsgVersionChange) XXX_Unmarshal

func (m *MsgVersionChange) XXX_Unmarshal(b []byte) error

type TypeRegister

type TypeRegister struct{}

TypeRegister is used to register the upgrade module's types in the encoding config without defining an entire module.

func (TypeRegister) RegisterInterfaces

func (TypeRegister) RegisterInterfaces(registry codectypes.InterfaceRegistry)

RegisterInterfaces registers the upgrade module types.

func (TypeRegister) RegisterLegacyAminoCodec

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

RegisterLegacyAminoCodec registers the upgrade types on the LegacyAmino codec.

type VersionSetter

type VersionSetter func(version uint64)

Jump to

Keyboard shortcuts

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