Fix consensus: use the right ValidatorSet upon Vote receive
This commit is contained in:
parent
24b9f8647c
commit
4d209ee349
|
@ -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…
Reference in New Issue