diff --git a/internal/consensus/state.go b/internal/consensus/state.go index 59ebf3044..2046fb4d6 100644 --- a/internal/consensus/state.go +++ b/internal/consensus/state.go @@ -1453,23 +1453,14 @@ func (cs *State) enterPrecommit(height int64, round int32) { } // There was a polka in this round for a block we don't have. - // Fetch that block, unlock, and precommit nil. - // The +2/3 prevotes for this round is the POL for our unlock. + // Fetch that block, and precommit nil. logger.Debug("precommit step; +2/3 prevotes for a block we do not have; voting nil", "block_id", blockID) - cs.LockedRound = -1 - cs.LockedBlock = nil - cs.LockedBlockParts = nil - if !cs.ProposalBlockParts.HasHeader(blockID.PartSetHeader) { cs.ProposalBlock = nil cs.ProposalBlockParts = types.NewPartSetFromHeader(blockID.PartSetHeader) } - if err := cs.eventBus.PublishEventUnlock(cs.RoundStateEvent()); err != nil { - logger.Error("failed publishing event unlock", "err", err) - } - cs.signAddVote(tmproto.PrecommitType, nil, types.PartSetHeader{}) } @@ -2064,25 +2055,6 @@ func (cs *State) addVote(vote *types.Vote, peerID types.NodeID) (added bool, err // Greater than 2/3 of the voting power on the network voted for some // non-nil block - // If we locked a different block in an earlier round, unlock it. - // We are going to relock a new block when we precommit, so this unlock - // is only temporary. - if (cs.LockedBlock != nil) && - (cs.LockedRound < vote.Round) && - (vote.Round <= cs.Round) && - !cs.LockedBlock.HashesTo(blockID.Hash) { - - cs.Logger.Debug("unlocking because of POL for non-nil block", "locked_round", cs.LockedRound, "pol_round", vote.Round) - - cs.LockedRound = -1 - cs.LockedBlock = nil - cs.LockedBlockParts = nil - - if err := cs.eventBus.PublishEventUnlock(cs.RoundStateEvent()); err != nil { - return added, err - } - } - // Update Valid* if we can. if cs.ValidRound < vote.Round && vote.Round == cs.Round { if cs.ProposalBlock.HashesTo(blockID.Hash) { diff --git a/internal/consensus/state_test.go b/internal/consensus/state_test.go index b167eeaa0..25d062046 100644 --- a/internal/consensus/state_test.go +++ b/internal/consensus/state_test.go @@ -622,7 +622,6 @@ func TestStateLockPOLRelock(t *testing.T) { require.NoError(t, err) addr := pv1.Address() voteCh := subscribeToVoter(cs1, addr) - unlockCh := subscribe(cs1.eventBus, types.EventQueryUnlock) lockCh := subscribe(cs1.eventBus, types.EventQueryLock) newRoundCh := subscribe(cs1.eventBus, types.EventQueryNewRound) newBlockCh := subscribe(cs1.eventBus, types.EventQueryNewBlockHeader) @@ -700,8 +699,6 @@ func TestStateLockPOLRelock(t *testing.T) { // now lets add prevotes from everyone else for the new block signAddVotes(config, cs1, tmproto.PrevoteType, propBlockHash, propBlockParts.Header(), vs2, vs3, vs4) - // check that we unlock on the old block - ensureNewUnlock(t, unlockCh, height, round) // check that we lock on the new block ensureLock(t, lockCh, height, round) @@ -719,6 +716,9 @@ func TestStateLockPOLRelock(t *testing.T) { // TestStatePOLDoesNotUnlock tests that a validator maintains its locked block // despite receiving +2/3 nil prevotes and nil precommits from other validators. +// Tendermint used to 'unlock' its locked block when greater than 2/3 prevotes +// for a block nil were seen. This behavior has been removed and this test ensures +// that it has been completely removed. func TestStatePOLDoesNotUnlock(t *testing.T) { config := configSetup(t) /* @@ -1118,7 +1118,6 @@ func TestStateLockPOLSafety2(t *testing.T) { proposalCh := subscribe(cs1.eventBus, types.EventQueryCompleteProposal) timeoutWaitCh := subscribe(cs1.eventBus, types.EventQueryTimeoutWait) newRoundCh := subscribe(cs1.eventBus, types.EventQueryNewRound) - unlockCh := subscribe(cs1.eventBus, types.EventQueryUnlock) pv1, err := cs1.privValidator.GetPubKey(context.Background()) require.NoError(t, err) addr := pv1.Address() @@ -1194,7 +1193,6 @@ func TestStateLockPOLSafety2(t *testing.T) { */ ensureNewProposal(t, proposalCh, height, round) - ensureNoNewUnlock(t, unlockCh) ensurePrevote(t, voteCh, height, round) validatePrevote(t, cs1, round, vss[0], propBlockHash1)