From 9ade45d81b804da7b1c722e22d0c9f422f5d70a0 Mon Sep 17 00:00:00 2001 From: William Banfield <4561443+williambanfield@users.noreply.github.com> Date: Wed, 22 Dec 2021 11:09:57 -0500 Subject: [PATCH] consensus: check that proposal is non-nil before voting (#7480) --- internal/consensus/state.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/internal/consensus/state.go b/internal/consensus/state.go index 1409a6f51..f0988318a 100644 --- a/internal/consensus/state.go +++ b/internal/consensus/state.go @@ -1321,6 +1321,12 @@ func (cs *State) defaultDoPrevote(height int64, round int32) { return } + if cs.Proposal == nil || cs.ProposalBlock == nil { + logger.Debug("prevote step; did not receive proposal, prevoting nil") + cs.signAddVote(tmproto.PrevoteType, nil, types.PartSetHeader{}) + return + } + if !cs.Proposal.Timestamp.Equal(cs.ProposalBlock.Header.Time) { logger.Debug("proposal timestamp not equal, prevoting nil") cs.signAddVote(tmproto.PrevoteType, nil, types.PartSetHeader{}) @@ -1489,6 +1495,13 @@ func (cs *State) enterPrecommit(height int64, round int32) { } // At this point, +2/3 prevoted for a particular block. + // If we never received a proposal for this block, we must precommit nil + if cs.Proposal == nil || cs.ProposalBlock == nil { + logger.Debug("precommit step; did not receive proposal, precommitting nil") + cs.signAddVote(tmproto.PrecommitType, nil, types.PartSetHeader{}) + return + } + // If the proposal time does not match the block time, precommit nil. if !cs.Proposal.Timestamp.Equal(cs.ProposalBlock.Header.Time) { logger.Debug("proposal timestamp not equal, precommitting nil")