wrap error in remote signer only

This commit is contained in:
Ismail Khoffi
2018-12-07 12:17:49 +01:00
parent 094699f9bc
commit 5c09275691
6 changed files with 16 additions and 19 deletions
+1 -1
View File
@@ -60,7 +60,7 @@ func initFilesWithConfig(config *cfg.Config) error {
}
key, err := pv.GetPubKey()
if err != nil {
return errors.Wrap(err, "failed to get pubkey from private validator")
return err
}
genDoc.Validators = []types.GenesisValidator{{
Address: key.Address(),
+1 -2
View File
@@ -7,7 +7,6 @@ import (
"path/filepath"
"strings"
"github.com/pkg/errors"
"github.com/spf13/cobra"
cfg "github.com/tendermint/tendermint/config"
@@ -93,7 +92,7 @@ func testnetFiles(cmd *cobra.Command, args []string) error {
pv := privval.LoadFilePV(pvFile)
pubKey, err := pv.GetPubKey()
if err != nil {
return errors.Wrap(err, "failed to get pubkey from private validator")
return err
}
genVals[i] = types.GenesisValidator{
Address: pubKey.Address(),
+2 -4
View File
@@ -13,9 +13,7 @@ import (
"testing"
"time"
"github.com/pkg/errors"
abcicli "github.com/tendermint/tendermint/abci/client"
"github.com/tendermint/tendermint/abci/client"
abci "github.com/tendermint/tendermint/abci/types"
bc "github.com/tendermint/tendermint/blockchain"
cfg "github.com/tendermint/tendermint/config"
@@ -76,7 +74,7 @@ func NewValidatorStub(privValidator types.PrivValidator, valIndex int) *validato
func (vs *validatorStub) signVote(voteType types.SignedMsgType, hash []byte, header types.PartSetHeader) (*types.Vote, error) {
addr, err := vs.PrivValidator.GetAddress()
if err != nil {
return nil, errors.Wrap(err, "failed to get private validator's address")
return nil, err
}
vote := &types.Vote{
ValidatorIndex: vs.Index,
+6 -6
View File
@@ -832,7 +832,7 @@ func (cs *ConsensusState) enterPropose(height int64, round int) {
// if not a validator, we're done
address, err := cs.privValidator.GetAddress()
if err != nil {
logger.Error("Failed to get private validator's address", "err", err)
logger.Error("enterPropose: Can not propose without validator's address", "err", err)
return
}
if !cs.Validators.HasAddress(address) {
@@ -937,7 +937,7 @@ func (cs *ConsensusState) createProposalBlock() (block *types.Block, blockParts
), maxGas)
proposerAddr, err := cs.privValidator.GetAddress()
if err != nil {
cs.Logger.Error("Failed to get private validator's address", "err", err)
cs.Logger.Error("enterPropose: Cannot create block without private validator's address:", "err", err)
return
}
block, parts := cs.state.MakeBlock(cs.Height, txs, commit, evidence, proposerAddr)
@@ -1486,7 +1486,7 @@ func (cs *ConsensusState) tryAddVote(vote *types.Vote, peerID p2p.ID) (bool, err
} else if voteErr, ok := err.(*types.ErrVoteConflictingVotes); ok {
addr, err := cs.privValidator.GetAddress()
if err != nil {
cs.Logger.Error("Failed to get private validator's address", "err", err)
cs.Logger.Error("Can not add vote without validator's address", "err", err)
return added, err
}
if bytes.Equal(vote.ValidatorAddress, addr) {
@@ -1656,8 +1656,8 @@ func (cs *ConsensusState) addVote(vote *types.Vote, peerID p2p.ID) (added bool,
func (cs *ConsensusState) signVote(type_ types.SignedMsgType, hash []byte, header types.PartSetHeader) (*types.Vote, error) {
addr, err := cs.privValidator.GetAddress()
if err != nil {
cs.Logger.Error("Failed to get private validator's address", "err", err)
return nil, errors.Wrap(err, "Failed to get private validator's address")
cs.Logger.Error("Can not sign vote without private validator's address", "err", err)
return nil, err
}
valIndex, _ := cs.Validators.GetByAddress(addr)
@@ -1696,7 +1696,7 @@ func (cs *ConsensusState) signAddVote(type_ types.SignedMsgType, hash []byte, he
// if we don't have a key or we're not in the validator set, do nothing
privValAddr, err := cs.privValidator.GetAddress()
if err != nil {
cs.Logger.Error("Failed to get private validator's address", "err", err, "height", cs.Height, "round", cs.Round)
cs.Logger.Error("Can not sign vote without validator's address", "err", err, "height", cs.Height, "round", cs.Round)
return nil
}
if cs.privValidator == nil || !cs.Validators.HasAddress(privValAddr) {
+3 -3
View File
@@ -242,7 +242,7 @@ func NewNode(config *cfg.Config,
addr, _ := state.Validators.GetByIndex(0)
privValAddr, err := privValidator.GetAddress()
if err != nil {
return nil, errors.Wrap(err, "failed to get private validator's address")
return nil, err
}
if bytes.Equal(privValAddr, addr) {
fastSync = false
@@ -251,7 +251,7 @@ func NewNode(config *cfg.Config,
pubKey, err := privValidator.GetPubKey()
if err != nil {
return nil, errors.Wrap(err, "failed to get private validator's public key")
return nil, err
}
addr := pubKey.Address()
// Log whether this node is a validator or an observer
@@ -627,7 +627,7 @@ func (n *Node) ConfigureRPC() {
rpccore.SetP2PTransport(n)
pubKey, err := n.privValidator.GetPubKey()
if err != nil {
n.Logger.Error("Error configuring RPC. Failed to get private validator's public key", "err", err)
n.Logger.Error("Error configuring RPC.", "err", err)
}
rpccore.SetPubKey(pubKey)
rpccore.SetGenesisDoc(n.genesisDoc)
+3 -3
View File
@@ -38,7 +38,7 @@ func NewRemoteSignerClient(
func (sc *RemoteSignerClient) GetAddress() (types.Address, error) {
pubKey, err := sc.getPubKey()
if err != nil {
return nil, err
return nil, errors.Wrap(err, "failed to get private validator's public key")
}
return pubKey.Address(), nil
@@ -48,7 +48,7 @@ func (sc *RemoteSignerClient) GetAddress() (types.Address, error) {
func (sc *RemoteSignerClient) GetPubKey() (crypto.PubKey, error) {
pubKey, err := sc.getPubKey()
if err != nil {
return nil, err
return nil, errors.Wrap(err, "failed to get private validator's address")
}
return pubKey, nil
@@ -235,7 +235,7 @@ func handleRequest(req RemoteSignerMsg, chainID string, privVal types.PrivValida
if err != nil {
// TODO: split up PubKeyMsg into PubKeyRequest / PubKeyResponse and wrap the error
// into the response as done below. For now we just return the error:
return nil, errors.Wrap(err, "failed to get private validator's public key")
return nil, err
}
res = &PubKeyMsg{p}
case *SignVoteRequest: