mirror of
https://github.com/fluencelabs/tendermint
synced 2025-07-31 12:11:58 +00:00
add pubkey to conflicting vote evidence
This commit is contained in:
@@ -1340,7 +1340,7 @@ func (cs *ConsensusState) tryAddVote(vote *types.Vote, peerKey string) error {
|
||||
}
|
||||
cs.Logger.Error("Found conflicting vote. Recording evidence in the RoundState", "height", vote.Height, "round", vote.Round, "type", vote.Type, "valAddr", vote.ValidatorAddress, "valIndex", vote.ValidatorIndex)
|
||||
|
||||
cs.Evidence = append(cs.Evidence, &types.DuplicateVoteEvidence{voteErr.VoteA, voteErr.VoteB})
|
||||
cs.Evidence = append(cs.Evidence, voteErr.DuplicateVoteEvidence)
|
||||
return err
|
||||
} else {
|
||||
// Probably an invalid signature / Bad peer.
|
||||
|
@@ -3,6 +3,8 @@ package types
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
|
||||
"github.com/tendermint/go-crypto"
|
||||
)
|
||||
|
||||
// Evidence represents any provable malicious activity by a validator
|
||||
@@ -14,13 +16,14 @@ type Evidence interface {
|
||||
//-------------------------------------------
|
||||
|
||||
type DuplicateVoteEvidence struct {
|
||||
PubKey crypto.PubKey
|
||||
VoteA *Vote
|
||||
VoteB *Vote
|
||||
}
|
||||
|
||||
// Address returns the address of the validator
|
||||
func (dve *DuplicateVoteEvidence) Address() []byte {
|
||||
return dve.VoteA.ValidatorAddress
|
||||
return dve.PubKey.Address()
|
||||
}
|
||||
|
||||
// Verify returns an error if the two votes aren't from the same validator, for the same H/R/S, but for different blocks
|
||||
|
@@ -22,12 +22,21 @@ var (
|
||||
)
|
||||
|
||||
type ErrVoteConflictingVotes struct {
|
||||
VoteA *Vote
|
||||
VoteB *Vote
|
||||
*DuplicateVoteEvidence
|
||||
}
|
||||
|
||||
func (err *ErrVoteConflictingVotes) Error() string {
|
||||
return "Conflicting votes"
|
||||
return fmt.Sprintf("Conflicting votes from validator %v", err.PubKey.Address())
|
||||
}
|
||||
|
||||
func NewConflictingVoteError(val *Validator, voteA, voteB *Vote) *ErrVoteConflictingVotes {
|
||||
return &ErrVoteConflictingVotes{
|
||||
&DuplicateVoteEvidence{
|
||||
PubKey: val.PubKey,
|
||||
VoteA: voteA,
|
||||
VoteB: voteB,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// Types of votes
|
||||
|
@@ -186,10 +186,7 @@ func (voteSet *VoteSet) addVote(vote *Vote) (added bool, err error) {
|
||||
// Add vote and get conflicting vote if any
|
||||
added, conflicting := voteSet.addVerifiedVote(vote, blockKey, val.VotingPower)
|
||||
if conflicting != nil {
|
||||
return added, &ErrVoteConflictingVotes{
|
||||
VoteA: conflicting,
|
||||
VoteB: vote,
|
||||
}
|
||||
return added, NewConflictingVoteError(val, conflicting, vote)
|
||||
} else {
|
||||
if !added {
|
||||
cmn.PanicSanity("Expected to add non-conflicting vote")
|
||||
|
Reference in New Issue
Block a user