Repository navigation
fix(consensus): stop a previous-height precommit marking the peer's current-height votes - #1601
Claudius-Maginificent wants to merge 3 commits into
Conversation
…urrent-height bit getVoteBitArray resolved (PRS.Height-1, LastCommitRound, Precommit) to PRS.Precommits, the bit array of the peer's current height, after #751 removed the dedicated LastPrecommits array. A late precommit of the height the peer had just left (reactor Vote handler -> SetHasVote) therefore marked the same validator index as already held for the current height, and that validator's current-height precommit was never offered to the peer. A VoteSetBits answer about the previous height's commit (ApplyVoteSetBitsMessage with ourVotes == nil) overwrote the whole current-height precommit bit array the same way. Previous-height votes are not gossiped individually (the commit is sent whole), so the lookup now returns nil for them: no tracking, no side effects. LastCommitRound bookkeeping in ApplyNewRoundStepMessage is unchanged. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ommits branch ApplyVoteSetBitsMessage has two branches (ourVotes nil or not); the previous-height regression test now exercises both. ApplyNewRoundStepMessage kept an if/else with identical branches under a "Shift Precommits to LastPrecommits" comment from before #751 removed that array; collapsed to the single assignment it performs. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
|
✅ Final review complete — no blockers (commit ced26a6) · triage: critical |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 1 + Phase 2
The change correctly prevents late previous-height votes and VoteSetBits messages from mutating the peer's current-height precommit tracking. Same-height vote tracking, catch-up commit handling, whole-commit gossip, and LastCommitRound bookkeeping remain intact; no in-scope correctness, security, or consensus findings were identified. CI has no failed code checks; build and test checks were still pending in the supplied snapshot.
Review provenance
Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: tenderdash-consensus-security); reviewer 3: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — The diff changes consensus peer-state and vote-gossip logic in internal/consensus/peer_state.go, directly affecting delivery of precommit votes and therefore BFT round liveness on the peer-facing consensus path. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(antigravity quota lookup failed),glm-5.3-flash(not used above high effort; tier asks max) - Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— tenderdash-consensus-security (completed, effort xhigh); agentphase2-reviewer
TL;DR: A node could silently stop sending some validators' votes to one of its peers for the rest of a round. This happened when a late message about the previous block arrived just after both nodes moved to the next block. It can slow a round down or, on poorly connected networks, stall it.
User story
As a validator operator, I want every peer to receive the final-stage votes it still needs, so that rounds finish quickly after network hiccups.
Scenario
Base flow
Each node remembers which votes each peer already has, so it does not send the same vote twice. When both nodes finish one block and move to the next, that memory starts fresh for the new block.
Actual behavior
A message about the block the nodes just finished sometimes arrives after both have moved on. The node then wrongly recorded the peer as already holding the matching votes for the new block. There are two ways in:
Those votes were never sent to that peer. If the peer cannot get them from anyone else, it waits, and the round can stall.
Expected behavior
Messages about the previous block never change what the node thinks a peer has for the current block. Current-block votes are sent as usual.
Detailed discussion
What was done
internal/consensus/peer_state.go,getVoteBitArray):PRS.Height == height+1 && PRS.LastCommitRound == round && Precommit, it returnedps.PRS.Precommits, which is the peer's current-height array.PRS.LastPrecommitsand left that branch pointing at the current array.reactor.goVoteChannel handler →SetHasVotefor a late height-1 precommit (sets one bit);reactor.goVoteSetBits handler →ApplyVoteSetBitsMessagefor an old height. This overwrote the whole array with the peer's previous commit bits, for bothourVotes == niland non-nil;gossiper.goupdatePeerVote→SetHasVotewhen our own send finishes after the peer's state has advanced.PickVoteToSendsubtracts those bits, so the affected current-height precommits are never offered to that peer. Vote redelivery (fix(consensus): resend same-round votes the peer never acknowledged #1599) cannot repair this, because a vote that was never sent is never tracked as unacknowledged.getVoteBitArrayreturns nil ("not tracked") for any height other thanPRS.Height.pickVoteForGossipworks only atrs.Height, andGossipCommitsends the wholeCommit, so there is nothing to track.ApplyNewRoundStepMessage, anif/elsewith identical branches and a stale "Shift Precommits to LastPrecommits" comment is collapsed into a single assignment. Behavior is unchanged.Testing
New tests in
internal/consensus/peer_state_lastcommit_test.go:TestSetHasVoteLastHeightPrecommitDoesNotMarkCurrentHeightPickVoteToSend.TestApplyVoteSetBitsLastHeightPrecommitsDoNotMarkCurrentHeight(ourVotesnil and non-nil)TestApplyNewRoundStepMessageKeepsLastCommitRoundLastCommitRoundcarry-over.The neighbouring PeerState, VoteSetBits, Maj23, gossiper and reactor tests pass, and
make lintreports 0 issues.An independent review traced every caller of
getVoteBitArrayand found none that needed the removed branch.Breaking changes
None.
Prior work
peer_state.go, so no conflict is expected. This fix also keeps fix(consensus): resend same-round votes the peer never acknowledged #1599's re-offer from resolving a stale height to the current array.🤖 Generated with Claude Code
https://claude.ai/code/session_01WunYYgcoPDNh3uebhUCwig
🤖 Co-authored by Claudius the Magnificent AI Agent