privval: return error on getpubkey (#4534)

closes #3602

Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>
This commit is contained in:
Marko
2020-03-12 11:10:36 +04:00
committed by GitHub
co-authored by Anton Kaliaev
parent 038aff1fdb
commit 48f073d796
30 changed files with 501 additions and 216 deletions
+8 -3
View File
@@ -3,7 +3,9 @@ package commands
import (
"fmt"
"github.com/pkg/errors"
"github.com/spf13/cobra"
cfg "github.com/tendermint/tendermint/config"
tmos "github.com/tendermint/tendermint/libs/os"
tmrand "github.com/tendermint/tendermint/libs/rand"
@@ -60,10 +62,13 @@ func initFilesWithConfig(config *cfg.Config) error {
GenesisTime: tmtime.Now(),
ConsensusParams: types.DefaultConsensusParams(),
}
key := pv.GetPubKey()
pubKey, err := pv.GetPubKey()
if err != nil {
return errors.Wrap(err, "can't get pubkey")
}
genDoc.Validators = []types.GenesisValidator{{
Address: key.Address(),
PubKey: key,
Address: pubKey.Address(),
PubKey: pubKey,
Power: 10,
}}
+7 -1
View File
@@ -24,7 +24,13 @@ func showValidator(cmd *cobra.Command, args []string) error {
}
pv := privval.LoadFilePV(keyFilePath, config.PrivValidatorStateFile())
bz, err := cdc.MarshalJSON(pv.GetPubKey())
pubKey, err := pv.GetPubKey()
if err != nil {
return errors.Wrap(err, "can't get pubkey")
}
bz, err := cdc.MarshalJSON(pubKey)
if err != nil {
return errors.Wrap(err, "failed to marshal private validator pubkey")
}
+8 -3
View File
@@ -7,6 +7,7 @@ import (
"path/filepath"
"strings"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/viper"
@@ -137,11 +138,15 @@ func testnetFiles(cmd *cobra.Command, args []string) error {
pvKeyFile := filepath.Join(nodeDir, config.BaseConfig.PrivValidatorKey)
pvStateFile := filepath.Join(nodeDir, config.BaseConfig.PrivValidatorState)
pv := privval.LoadFilePV(pvKeyFile, pvStateFile)
pubKey, err := pv.GetPubKey()
if err != nil {
return errors.Wrap(err, "can't get pubkey")
}
genVals[i] = types.GenesisValidator{
Address: pv.GetPubKey().Address(),
PubKey: pv.GetPubKey(),
Address: pubKey.Address(),
PubKey: pubKey,
Power: 1,
Name: nodeDirName,
}