Fix consensus: use the right ValidatorSet upon Vote receive

This commit is contained in:
Jae Kwon 2015-06-26 17:25:47 -07:00
parent 24b9f8647c
commit 4d209ee349
1 changed files with 9 additions and 6 deletions

View File

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