Upgrade tendermint to 0.28.0-dev0 (#3279)

This commit is contained in:
Alessio Treglia
2019-01-11 09:19:01 -08:00
committed by Jack Zampolin
parent 05d53894a3
commit df567616a9
13 changed files with 65 additions and 42 deletions
+1 -1
View File
@@ -33,7 +33,7 @@ func ExportCmd(ctx *Context, cdc *codec.Codec, appExporter AppExporter) *cobra.C
return err
}
if emptyState {
if emptyState || appExporter == nil {
fmt.Println("WARNING: State is not initialized. Returning genesis file.")
genesisFile := path.Join(home, "config", "genesis.json")
genesis, err := ioutil.ReadFile(genesisFile)
+2 -1
View File
@@ -114,10 +114,11 @@ func startInProcess(ctx *Context, appCreator AppCreator) (*node.Node, error) {
return nil, err
}
UpgradeOldPrivValFile(cfg)
// create & start tendermint node
tmNode, err := node.NewNode(
cfg,
pvm.LoadOrGenFilePV(cfg.PrivValidatorFile()),
pvm.LoadOrGenFilePV(cfg.PrivValidatorKeyFile(), cfg.PrivValidatorStateFile()),
nodeKey,
proxy.NewLocalClientCreator(app),
node.DefaultGenesisDocProviderFunc(cfg),
+10 -5
View File
@@ -41,8 +41,10 @@ func ShowValidatorCmd(ctx *Context) *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
cfg := ctx.Config
privValidator := pvm.LoadOrGenFilePV(cfg.PrivValidatorFile())
valPubKey := privValidator.PubKey
UpgradeOldPrivValFile(cfg)
privValidator := pvm.LoadOrGenFilePV(
cfg.PrivValidatorKeyFile(), cfg.PrivValidatorStateFile())
valPubKey := privValidator.GetPubKey()
if viper.GetBool(client.FlagJson) {
return printlnJSON(valPubKey)
@@ -67,9 +69,12 @@ func ShowAddressCmd(ctx *Context) *cobra.Command {
Use: "show-address",
Short: "Shows this node's tendermint validator consensus address",
RunE: func(cmd *cobra.Command, args []string) error {
cfg := ctx.Config
privValidator := pvm.LoadOrGenFilePV(cfg.PrivValidatorFile())
valConsAddr := (sdk.ConsAddress)(privValidator.Address)
UpgradeOldPrivValFile(cfg)
privValidator := pvm.LoadOrGenFilePV(
cfg.PrivValidatorKeyFile(), cfg.PrivValidatorStateFile())
valConsAddr := (sdk.ConsAddress)(privValidator.GetAddress())
if viper.GetBool(client.FlagJson) {
return printlnJSON(valConsAddr)
@@ -102,7 +107,7 @@ func UnsafeResetAllCmd(ctx *Context) *cobra.Command {
Short: "Resets the blockchain database, removes address book files, and resets priv_validator.json to the genesis state",
RunE: func(cmd *cobra.Command, args []string) error {
cfg := ctx.Config
tcmd.ResetAll(cfg.DBDir(), cfg.P2P.AddrBookFile(), cfg.PrivValidatorFile(), ctx.Logger)
tcmd.ResetAll(cfg.DBDir(), cfg.P2P.AddrBookFile(), cfg.PrivValidatorKeyFile(), cfg.PrivValidatorStateFile(), ctx.Logger)
return nil
},
}
+11
View File
@@ -18,6 +18,7 @@ import (
"github.com/tendermint/tendermint/libs/cli"
tmflags "github.com/tendermint/tendermint/libs/cli/flags"
"github.com/tendermint/tendermint/libs/log"
pvm "github.com/tendermint/tendermint/privval"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
@@ -221,6 +222,16 @@ func TrapSignal(cleanupFunc func()) {
}()
}
// UpgradeOldPrivValFile converts old priv_validator.json file (prior to Tendermint 0.28)
// to the new priv_validator_key.json and priv_validator_state.json files.
func UpgradeOldPrivValFile(config *cfg.Config) {
if _, err := os.Stat(config.OldPrivValidatorFile()); !os.IsNotExist(err) {
if oldFilePV, err := pvm.LoadOldFilePV(config.OldPrivValidatorFile()); err == nil {
oldFilePV.Upgrade(config.PrivValidatorKeyFile(), config.PrivValidatorStateFile())
}
}
}
func skipInterface(iface net.Interface) bool {
if iface.Flags&net.FlagUp == 0 {
return true // interface down