From c0bf3307c9852aebba87fb8c9d03a3758a99981c Mon Sep 17 00:00:00 2001 From: William Banfield Date: Fri, 13 May 2022 17:09:47 -0400 Subject: [PATCH] use new require extensions in all places --- internal/consensus/state.go | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/internal/consensus/state.go b/internal/consensus/state.go index f38ba43c8..4747e7402 100644 --- a/internal/consensus/state.go +++ b/internal/consensus/state.go @@ -695,7 +695,7 @@ func (cs *State) sendInternalMessage(ctx context.Context, mi msgInfo) { // Reconstruct LastCommit from SeenCommit, which we saved along with the block, // (which happens even before saving the state) func (cs *State) reconstructLastCommit(state sm.State) { - requireExtensions := requireVoteExtensions(cs.state.ConsensusParams.Vote.ExtensionRequireHeight, state.LastBlockHeight) + requireExtensions := cs.state.ConsensusParams.Vote.RequireExtensions(state.LastBlockHeight) votes, err := cs.votesFromExtendedCommit(state, requireExtensions) if err == nil { cs.LastCommit = votes @@ -838,7 +838,8 @@ func (cs *State) updateToState(state sm.State) { cs.ValidRound = -1 cs.ValidBlock = nil cs.ValidBlockParts = nil - cs.Votes = cstypes.NewHeightVoteSet(state.ChainID, height, validators, requireVoteExtensions(state.ConsensusParams.Vote.ExtensionRequireHeight, height)) + requireExtensions := state.ConsensusParams.Vote.RequireExtensions(height) + cs.Votes = cstypes.NewHeightVoteSet(state.ChainID, height, validators, requireExtensions) cs.CommitRound = -1 cs.LastValidators = state.LastValidators cs.TriggeredTimeoutPrecommit = false @@ -2389,7 +2390,7 @@ func (cs *State) addVote( if !errors.Is(err, types.ErrVoteExtensionAbsent) { return false, err } - if requireVoteExtensions(cs.state.ConsensusParams.Vote.ExtensionRequireHeight, cs.Height) { + if cs.state.ConsensusParams.Vote.RequireExtensions(cs.Height) { return false, err } } @@ -2789,13 +2790,6 @@ func (cs *State) calculateProposalTimestampDifferenceMetric() { } } -func requireVoteExtensions(requireHeight, currentHeight int64) bool { - if requireHeight == 0 || currentHeight < requireHeight { - return false - } - return true -} - // proposerWaitTime determines how long the proposer should wait to propose its next block. // If the result is zero, a block can be proposed immediately. //