From a67ae814698b76206049e378a9ed64e7a2ed3832 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Thu, 25 Oct 2018 16:40:20 +0200 Subject: [PATCH] if some process locks a block in round 0, then 0 is valid proposal.POLRound in rounds > 0 This condition is really hard to get. Initially, lockedRound and validRound are set to -1 as we start with round 0. Refs #2702 --- consensus/state.go | 6 +++--- types/vote_set.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/consensus/state.go b/consensus/state.go index 0b079f13d..c6efe98f0 100644 --- a/consensus/state.go +++ b/consensus/state.go @@ -1425,9 +1425,9 @@ func (cs *ConsensusState) defaultSetProposal(proposal *types.Proposal) error { return nil } - // Verify POLRound, which must be -1 or between 0 and proposal.Round exclusive. - if proposal.POLRound != -1 && - (proposal.POLRound < 0 || proposal.Round <= proposal.POLRound) { + // Verify POLRound, which must be -1 or between 0 inclusive and proposal.Round exclusive. + if proposal.POLRound < -1 || + (proposal.POLRound >= 0 && proposal.POLRound >= proposal.Round) { return ErrInvalidProposalPOLRound } diff --git a/types/vote_set.go b/types/vote_set.go index cdfa3d40d..0cf6cbb7f 100644 --- a/types/vote_set.go +++ b/types/vote_set.go @@ -158,7 +158,7 @@ func (voteSet *VoteSet) addVote(vote *Vote) (added bool, err error) { if (vote.Height != voteSet.height) || (vote.Round != voteSet.round) || (vote.Type != voteSet.type_) { - return false, errors.Wrapf(ErrVoteUnexpectedStep, "Got %d/%d/%d, expected %d/%d/%d", + return false, errors.Wrapf(ErrVoteUnexpectedStep, "Expected %d/%d/%d, but got %d/%d/%d", voteSet.height, voteSet.round, voteSet.type_, vote.Height, vote.Round, vote.Type) }