Browse Source

Fix consensus: use the right ValidatorSet upon Vote receive

pull/96/head
Jae Kwon 10 years ago
parent
commit
4d209ee349
1 changed files with 9 additions and 6 deletions
  1. +9
    -6
      consensus/reactor.go

+ 9
- 6
consensus/reactor.go View File

@ -177,16 +177,19 @@ func (conR *ConsensusReactor) Receive(chId byte, peer *p2p.Peer, msgBytes []byte
switch msg := msg_.(type) {
case *VoteMessage:
vote := msg.Vote
if rs.Height != vote.Height {
if rs.Height == vote.Height+1 {
if rs.Step == RoundStepNewHeight && vote.Type == types.VoteTypePrecommit {
goto VOTE_PASS // *ducks*
}
var validators *ValidatorSet
if rs.Height == vote.Height {
validators = rs.Validators
} else if rs.Height == vote.Height+1 {
validators = rs.LastBondedValidators
if !(rs.Step == RoundStepNewHeight && vote.Type == types.VoteTypePrecommit) {
return // Wrong height, not a LastCommit straggler commit.
}
} else {
return // Wrong height. Not necessarily a bad peer.
}
VOTE_PASS:
address, _ := rs.Validators.GetByIndex(msg.ValidatorIndex)
address, _ := validators.GetByIndex(msg.ValidatorIndex)
added, index, err := conR.conS.AddVote(address, vote, peer.Key)
if err != nil {
// If conflicting sig, broadcast evidence tx for slashing. Else punish peer.


Loading…
Cancel
Save