Browse Source

add pubkey to conflicting vote evidence

pull/592/head
Ethan Buchman 7 years ago
parent
commit
4661c98c17
4 changed files with 20 additions and 11 deletions
  1. +1
    -1
      consensus/state.go
  2. +6
    -3
      types/evidence.go
  3. +12
    -3
      types/vote.go
  4. +1
    -4
      types/vote_set.go

+ 1
- 1
consensus/state.go View File

@ -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.


+ 6
- 3
types/evidence.go View File

@ -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 {
VoteA *Vote
VoteB *Vote
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


+ 12
- 3
types/vote.go View File

@ -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


+ 1
- 4
types/vote_set.go View File

@ -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")


Loading…
Cancel
Save