From b36d08ab227888c6222fe1a01e1c8659810a5131 Mon Sep 17 00:00:00 2001 From: Raymond Date: Thu, 11 Oct 2018 17:25:22 +0800 Subject: [PATCH] update software upgrade example --- examples/irishub-bugfix-2/app/app.go | 27 ++++++++++++------------ examples/irishub-bugfix-2/app/genesis.go | 14 ++++++++---- examples/irishub1/app/app.go | 25 +++++++++++----------- examples/irishub1/app/genesis.go | 14 ++++++++---- 4 files changed, 47 insertions(+), 33 deletions(-) diff --git a/examples/irishub-bugfix-2/app/app.go b/examples/irishub-bugfix-2/app/app.go index 37ee9a2f6..0f8b4ab6e 100644 --- a/examples/irishub-bugfix-2/app/app.go +++ b/examples/irishub-bugfix-2/app/app.go @@ -16,26 +16,26 @@ import ( "github.com/cosmos/cosmos-sdk/wire" "github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/bank" - "github.com/irisnet/irishub/modules/gov" "github.com/cosmos/cosmos-sdk/x/ibc" "github.com/cosmos/cosmos-sdk/x/params" "github.com/cosmos/cosmos-sdk/x/slashing" "github.com/cosmos/cosmos-sdk/x/stake" ibcbugfix "github.com/irisnet/irishub/examples/irishub-bugfix-2/ibc" + "github.com/irisnet/irishub/modules/gov" "github.com/irisnet/irishub/modules/upgrade" "errors" "fmt" "github.com/cosmos/cosmos-sdk/server" + "github.com/irisnet/irishub/modules/gov/params" + "github.com/irisnet/irishub/modules/iparam" + "github.com/irisnet/irishub/modules/upgrade/params" "github.com/spf13/viper" + bc "github.com/tendermint/tendermint/blockchain" tmcli "github.com/tendermint/tendermint/libs/cli" "github.com/tendermint/tendermint/node" sm "github.com/tendermint/tendermint/state" - bc "github.com/tendermint/tendermint/blockchain" "strings" - "github.com/irisnet/irishub/modules/iparam" - "github.com/irisnet/irishub/modules/gov/params" - "github.com/irisnet/irishub/modules/upgrade/params" ) const ( @@ -160,15 +160,16 @@ func NewIrisApp(logger log.Logger, db dbm.DB, traceStore io.Writer, baseAppOptio upgrade.RegisterModuleList(app.Router()) iparam.SetParamReadWriter(app.paramsKeeper.Setter(), - &govparams.DepositProcedureParameter, - &govparams.VotingProcedureParameter, - &govparams.TallyingProcedureParameter, - &upgradeparams.CurrentUpgradeProposalIdParameter, - &upgradeparams.ProposalAcceptHeightParameter) + &govparams.DepositProcedureParameter, + &govparams.VotingProcedureParameter, + &govparams.TallyingProcedureParameter, + &upgradeparams.CurrentUpgradeProposalIdParameter, + &upgradeparams.ProposalAcceptHeightParameter, + &upgradeparams.SwitchPeriodParameter) iparam.RegisterGovParamMapping(&govparams.DepositProcedureParameter, - &govparams.VotingProcedureParameter, - &govparams.TallyingProcedureParameter,) + &govparams.VotingProcedureParameter, + &govparams.TallyingProcedureParameter) return app } @@ -265,7 +266,7 @@ func (app *IrisApp) initChainer(ctx sdk.Context, req abci.RequestInitChain) abci // load the address to pubkey map slashing.InitGenesis(ctx, app.slashingKeeper, genesisState.StakeData) - upgrade.InitGenesis(ctx, app.upgradeKeeper, app.Router()) + upgrade.InitGenesis(ctx, app.upgradeKeeper, app.Router(), genesisState.UpgradeData) return abci.ResponseInitChain{ Validators: validators, diff --git a/examples/irishub-bugfix-2/app/genesis.go b/examples/irishub-bugfix-2/app/genesis.go index db61f2009..276ef4397 100644 --- a/examples/irishub-bugfix-2/app/genesis.go +++ b/examples/irishub-bugfix-2/app/genesis.go @@ -15,14 +15,18 @@ import ( "github.com/cosmos/cosmos-sdk/wire" "github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/stake" + "github.com/irisnet/irishub/modules/gov" + "github.com/irisnet/irishub/modules/upgrade" "github.com/irisnet/irishub/types" "time" ) // State to Unmarshal type GenesisState struct { - Accounts []GenesisAccount `json:"accounts"` - StakeData stake.GenesisState `json:"stake"` + Accounts []GenesisAccount `json:"accounts"` + StakeData stake.GenesisState `json:"stake"` + GovData gov.GenesisState `json:"gov"` + UpgradeData upgrade.GenesisState `json:"upgrade"` } // GenesisAccount doesn't need pubkey or sequence @@ -194,8 +198,10 @@ func IrisAppGenState(cdc *wire.Codec, appGenTxs []json.RawMessage) (genesisState // create the final app state genesisState = GenesisState{ - Accounts: genaccs, - StakeData: stakeData, + Accounts: genaccs, + StakeData: stakeData, + GovData: gov.DefaultGenesisState(), + UpgradeData: upgrade.DefaultGenesisState(), } return } diff --git a/examples/irishub1/app/app.go b/examples/irishub1/app/app.go index f1e8be415..3f35a1701 100644 --- a/examples/irishub1/app/app.go +++ b/examples/irishub1/app/app.go @@ -12,14 +12,17 @@ import ( "github.com/cosmos/cosmos-sdk/wire" "github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/bank" - "github.com/irisnet/irishub/modules/gov" "github.com/cosmos/cosmos-sdk/x/ibc" "github.com/cosmos/cosmos-sdk/x/params" "github.com/cosmos/cosmos-sdk/x/slashing" "github.com/cosmos/cosmos-sdk/x/stake" bam "github.com/irisnet/irishub/baseapp" ibc1 "github.com/irisnet/irishub/examples/irishub1/ibc" + "github.com/irisnet/irishub/modules/gov" + "github.com/irisnet/irishub/modules/gov/params" + "github.com/irisnet/irishub/modules/iparam" "github.com/irisnet/irishub/modules/upgrade" + "github.com/irisnet/irishub/modules/upgrade/params" "github.com/spf13/viper" abci "github.com/tendermint/tendermint/abci/types" bc "github.com/tendermint/tendermint/blockchain" @@ -31,9 +34,6 @@ import ( sm "github.com/tendermint/tendermint/state" tmtypes "github.com/tendermint/tendermint/types" "strings" - "github.com/irisnet/irishub/modules/iparam" - "github.com/irisnet/irishub/modules/gov/params" - "github.com/irisnet/irishub/modules/upgrade/params" ) const ( @@ -157,15 +157,16 @@ func NewIrisApp(logger log.Logger, db dbm.DB, traceStore io.Writer, baseAppOptio upgrade.RegisterModuleList(app.Router()) iparam.SetParamReadWriter(app.paramsKeeper.Setter(), - &govparams.DepositProcedureParameter, - &govparams.VotingProcedureParameter, - &govparams.TallyingProcedureParameter, - &upgradeparams.CurrentUpgradeProposalIdParameter, - &upgradeparams.ProposalAcceptHeightParameter) + &govparams.DepositProcedureParameter, + &govparams.VotingProcedureParameter, + &govparams.TallyingProcedureParameter, + &upgradeparams.CurrentUpgradeProposalIdParameter, + &upgradeparams.ProposalAcceptHeightParameter, + &upgradeparams.SwitchPeriodParameter) iparam.RegisterGovParamMapping(&govparams.DepositProcedureParameter, - &govparams.VotingProcedureParameter, - &govparams.TallyingProcedureParameter,) + &govparams.VotingProcedureParameter, + &govparams.TallyingProcedureParameter) return app } @@ -263,7 +264,7 @@ func (app *IrisApp) initChainer(ctx sdk.Context, req abci.RequestInitChain) abci // load the address to pubkey map slashing.InitGenesis(ctx, app.slashingKeeper, genesisState.StakeData) - upgrade.InitGenesis(ctx, app.upgradeKeeper, app.Router()) + upgrade.InitGenesis(ctx, app.upgradeKeeper, app.Router(), genesisState.UpgradeData) return abci.ResponseInitChain{ Validators: validators, diff --git a/examples/irishub1/app/genesis.go b/examples/irishub1/app/genesis.go index db61f2009..276ef4397 100644 --- a/examples/irishub1/app/genesis.go +++ b/examples/irishub1/app/genesis.go @@ -15,14 +15,18 @@ import ( "github.com/cosmos/cosmos-sdk/wire" "github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/stake" + "github.com/irisnet/irishub/modules/gov" + "github.com/irisnet/irishub/modules/upgrade" "github.com/irisnet/irishub/types" "time" ) // State to Unmarshal type GenesisState struct { - Accounts []GenesisAccount `json:"accounts"` - StakeData stake.GenesisState `json:"stake"` + Accounts []GenesisAccount `json:"accounts"` + StakeData stake.GenesisState `json:"stake"` + GovData gov.GenesisState `json:"gov"` + UpgradeData upgrade.GenesisState `json:"upgrade"` } // GenesisAccount doesn't need pubkey or sequence @@ -194,8 +198,10 @@ func IrisAppGenState(cdc *wire.Codec, appGenTxs []json.RawMessage) (genesisState // create the final app state genesisState = GenesisState{ - Accounts: genaccs, - StakeData: stakeData, + Accounts: genaccs, + StakeData: stakeData, + GovData: gov.DefaultGenesisState(), + UpgradeData: upgrade.DefaultGenesisState(), } return }