From bd99771b272afbf370e0ca290421673da3c76f14 Mon Sep 17 00:00:00 2001 From: Anca Zamfir Date: Fri, 7 Jan 2022 11:12:29 +0100 Subject: [PATCH] Check timely before ValidateBlock --- internal/consensus/state.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/internal/consensus/state.go b/internal/consensus/state.go index 714afcea7..9dd8d660c 100644 --- a/internal/consensus/state.go +++ b/internal/consensus/state.go @@ -1344,6 +1344,12 @@ func (cs *State) defaultDoPrevote(height int64, round int32) { return } + if cs.Proposal.POLRound == -1 && cs.LockedRound == -1 && !cs.proposalIsTimely() { + logger.Debug("prevote step: ProposalBlock is not timely; prevoting nil") + cs.signAddVote(tmproto.PrevoteType, nil, types.PartSetHeader{}) + return + } + // Validate proposal block err := cs.blockExec.ValidateBlock(cs.state, cs.ProposalBlock) if err != nil { @@ -1368,11 +1374,6 @@ func (cs *State) defaultDoPrevote(height int64, round int32) { */ if cs.Proposal.POLRound == -1 { if cs.LockedRound == -1 { - if !cs.proposalIsTimely() { - logger.Debug("prevote step: ProposalBlock is not timely; prevoting nil") - cs.signAddVote(tmproto.PrevoteType, nil, types.PartSetHeader{}) - return - } logger.Debug("prevote step: ProposalBlock is valid and there is no locked block; prevoting the proposal") cs.signAddVote(tmproto.PrevoteType, cs.ProposalBlock.Hash(), cs.ProposalBlockParts.Header()) return