upgrade

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2020 License: Apache-2.0 Imports: 40 Imported by: 0

README

软件升级流程:

graph TB
proposal[提交升级提案] --> proposalCond{提案通过?}
proposalCond --是--> nodeUpgrading[节点升级]
proposalCond --否--> finish[结束]
nodeUpgrading --> upgradeSuccCond{超过阈值?}
upgradeSuccCond --是--> newVersion[启动新版本]
upgradeSuccCond --否--> finish
newVersion --> finish

提交升级提案

提案内容以json的方式存储在文件software_upgrade_proposal中

{
    "title":"testnet-v1.1.0 upgrade",
    "description":"upgrade for smart contract",
    "type":"SoftwareUpgrade",
    "deposit":{
        "denom":"pdip",
        "amount":"10000000000000"
    },
    "version":1,
    "software":"https://github.com/Dipper-Labs/Dipper-Protocol/releases/tag/testnet-v1.1.0",
    "switch_height":160,
    "threshold":"0.8"
}

字段详情

  • title 标题
  • description 升级的描述
  • type 软件升级使用SoftwareUpgrade
  • deposit 为本次提案抵押的token
  • version 本次升级的版本号,软件切换的时候根据版本号来切换,重要
  • software 本次升级的程序下载地址,比如github的release链接
  • switch_height 升级的指定高度,在指定高度统计验证人节点生升级比例,如果超过阈值则执行版本切换
  • threshold 升级阈值,指已经升级的验证人voting power占整个voting power的比例,超过这个值才执行全网的版本升级

提交提案

dipcli tx gov submit-proposal software-upgrade ~/software_upgrade_proposal --from $(dipcli keys show -a bob) -y

对提案投票

dipcli tx gov vote 1 yes --from $(dipcli keys show -a bob) -y

节点升级

主动升级

在提案通过后指定高度前升级,到达指定高度自动切换为新版本

# 1. 下载新版本dipd1

# 2. 关闭旧软件
kill -f dipd

# 3. 安装新版本 dipd1 并启动(copy to bin)
dipd1 start

# 4. 区块到达指定高度,自动升级

# 5. 查询当前版本是否升级成功
dipcli query upgrade info

被动升级

如果本次升级提案通过并且在指定高度升级到新版本的voting power比例超过软件升级的阈值那么本次升级会最终会执行,对于没有在指定高度升级的节点会自动退出程序,需要升级到新版本才能继续运行,升级成功后会继续自动同步到最近区块

# 1. 下载新版本dipd1

# 2. 确保关闭旧软件
kill -f dipd

# 3. 安装新版本 dipd1 并启动
dipd1 start

# 4. 查询当前版本是否升级成功
dipcli query upgrade info

Documentation

Index

Constants

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

Variables

View Source
var (
	Addrs = createTestAddrs(500)
	PKs   = createTestPubKeys(500)
)

Functions

func EndBlocker

func EndBlocker(ctx sdk.Context, keeper Keeper)

EndBlocker does signal maintenance in the end of block

func InitGenesis

func InitGenesis(ctx sdk.Context, k Keeper, data GenesisState)

InitGenesis builds the genesis version for first version

func MakeTestCodec

func MakeTestCodec() *codec.Codec

create a codec used only for testing

func NewPubKey

func NewPubKey(pk string) (res crypto.PubKey)

func TestAddr

func TestAddr(addr string, bech string) sdk.AccAddress

for incode address generation

Types

type AppModule

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

AppModule is a struct of app module

func NewAppModule

func NewAppModule(keeper Keeper) AppModule

NewAppModule creates a new AppModule object for upgrade module

func (AppModule) BeginBlock

func (a AppModule) BeginBlock(sdk.Context, types.RequestBeginBlock)

BeginBlock returns the begin blocker for the upgrade module.

func (AppModule) EndBlock

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

func (AppModule) ExportGenesis

func (a AppModule) ExportGenesis(sdk.Context) json.RawMessage

ExportGenesis exports module genesis

func (AppModule) InitGenesis

func (a AppModule) InitGenesis(ctx sdk.Context, d json.RawMessage) []types.ValidatorUpdate

InitGenesis initializes module genesis

func (AppModule) NewHandler

func (a AppModule) NewHandler() sdk.Handler

NewHandler returns an sdk.Handler for the upgrade module.

func (AppModule) NewQuerierHandler

func (a AppModule) NewQuerierHandler() sdk.Querier

NewQuerierHandler returns the auth module sdk.Querier.

func (AppModule) QuerierRoute

func (a AppModule) QuerierRoute() string

QuerierRoute returns module querier route name

func (AppModule) RegisterInvariants

func (a AppModule) RegisterInvariants(sdk.InvariantRegistry)

RegisterInvariants performs a no-op.

func (AppModule) Route

func (a AppModule) Route() string

Route returns module message route name

type AppModuleBasic

type AppModuleBasic struct{}

AppModuleBasic is a struct of app module basics object

func (AppModuleBasic) DefaultGenesis

func (a AppModuleBasic) DefaultGenesis() json.RawMessage

DefaultGenesis returns default genesis state

func (AppModuleBasic) GetQueryCmd

func (a AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command

GetQueryCmd gets the root query command of the upgrade module

func (AppModuleBasic) GetTxCmd

func (a AppModuleBasic) GetTxCmd(*codec.Codec) *cobra.Command

GetTxCmd returns the transaction commands for this module

func (AppModuleBasic) Name

func (a AppModuleBasic) Name() string

Name returns module name

func (AppModuleBasic) RegisterCodec

func (a AppModuleBasic) RegisterCodec(*codec.Codec)

RegisterCodec registers module codec

func (AppModuleBasic) RegisterRESTRoutes

func (a AppModuleBasic) RegisterRESTRoutes(ctx context.CLIContext, rtr *mux.Router)

RegisterRESTRoutes register rest routes

func (AppModuleBasic) ValidateGenesis

func (a AppModuleBasic) ValidateGenesis(d json.RawMessage) error

ValidateGenesis validates genesis

type GenesisState

type GenesisState struct {
	GenesisVersion types.VersionInfo `json:"genesis_version" yaml:"genesis_version"`
}

GenesisState contains all upgrade state that must be provided at genesis

func DefaultGenesisState

func DefaultGenesisState() GenesisState

DefaultGenesisState returns default raw genesis raw message

func ExportGenesis

func ExportGenesis() GenesisState

ExportGenesis outputs genesis state

type Keeper

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

Keeper defines the keeper struct of the upgrade store

func CreateTestInput

func CreateTestInput(t *testing.T, initPower int64) (ctx sdk.Context, keeper Keeper, stakingKeeper staking.Keeper, paramsKeeper params.Keeper)

CreateTestInput create test input nolint

func NewKeeper

func NewKeeper(cdc *codec.Codec, key sdk.StoreKey, protocolKeeper sdk.ProtocolKeeper, sk staking.Keeper) Keeper

NewKeeper creates a new upgrade keeper

func (Keeper) AddNewVersionInfo

func (k Keeper) AddNewVersionInfo(ctx sdk.Context, versionInfo types.VersionInfo)

AddNewVersionInfo adds new version info

func (Keeper) DeleteSignal

func (k Keeper) DeleteSignal(ctx sdk.Context, protocol uint64, address string) bool

DeleteSignal removes signal

func (Keeper) GetCurrentVersion

func (k Keeper) GetCurrentVersion(ctx sdk.Context) uint64

GetCurrentVersion gets current version

func (Keeper) GetSignal

func (k Keeper) GetSignal(ctx sdk.Context, protocol uint64, address string) bool

GetSignal gets signal

func (Keeper) IterateBondedValidatorsByPower

func (k Keeper) IterateBondedValidatorsByPower(ctx sdk.Context,
	fn func(index int64, validator exported.ValidatorI) (stop bool))

IterateBondedValidatorsByPower iterates bonded validators by power

func (Keeper) SetAppUpgradeConfig

func (k Keeper) SetAppUpgradeConfig(ctx sdk.Context, proposalID, version, upgradeHeight uint64, software string,
) error

SetAppUpgradeConfig sets app upgrade config for test deprecated

func (Keeper) SetSignal

func (k Keeper) SetSignal(ctx sdk.Context, protocol uint64, address string)

SetSignal sets signal for upgrade

Directories

Path Synopsis
cli

Jump to

Keyboard shortcuts

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