Skip to content

fix(consensus): supersede held timeout votes when NEWVIEW advances high_pc - #4240

Open
cyzcz wants to merge 1 commit into
tari-project:developmentfrom
cyzcz:fix/consensus-supersede-certified-timeout-high-pc
Open

cyzcz wants to merge 1 commit into
tari-project:developmentfrom
cyzcz:fix/consensus-supersede-certified-timeout-high-pc

Conversation

@cyzcz

@cyzcz cyzcz commented Dec 4, 2026

Copy link
Copy Markdown

Description

When a validator waiting on a stalled timeout view learns a higher ProposalCertificate while next_timeout_height still names the same view, OnNextSyncViewHandler::handle (crates/consensus/src/hotstuff/on_next_sync_view.rs:120-125) signs a new to_leader TimeoutVote carrying the higher high_pc_height and persists it in LastSentNewView.to_leader, while keeping to_members unchanged.

Previously, TimeoutVoteCollector::check_and_collect_vote rejected that updated to_leader vote as DuplicateVoteDetected in both certified_votes and pacing_votes:

  1. certified_votes kept the earlier claim: if the leader already held an earlier vote for that view from the same signer, the higher high_pc_height vote was discarded, so a TimeoutCertificate subsequently formed for the view attested to a stale max_high_pc_height below what the quorum had signed and proven.
  2. pacing_votes flagged the waiting member's NEWVIEW as an answer: duplicates_held_vote was set to true on both the upgraded NEWVIEW and every subsequent re-send of LastSentNewView.to_leader whenever pacing_votes still held the signer's earlier vote (including when the node first received to_members before a leader-skip boundary made it the effective leader of that view). is_waiting_on_a_counted_out_view (crates/consensus/src/hotstuff/on_receive_new_view.rs:546-559) then suppressed answer_member_behind for that waiting member on every retry.

Changes:

  • Add VoteCollector::collect_vote_replacing (crates/consensus/src/hotstuff/vote_collector/collector.rs), which replaces a differently signed vote already held from the same signer at the same (epoch, height) when supersedes(held, incoming) holds, without duplicating per-sender view tracking or re-emitting an already-formed quorum.
  • In TimeoutVoteCollector::check_and_collect_vote (crates/consensus/src/hotstuff/vote_collector/timeout_collector.rs) — called only after OnReceiveNewViewHandler::handle has verified timeout_claim_matches_high_pc() and validate_qc(&high_pc) — supersede the held vote in both pacing_votes and certified_votes when incoming.high_pc_height > held.high_pc_height (has_higher_high_pc).
  • Leave TimeoutVoteCollector::check_and_count_vote unchanged (replace_higher_high_pc = false), because standalone HotstuffMessage::TimeoutVote messages carry no certificate and are how answer_member_behind delivers freshly signed answers, which must still set duplicates_held_vote = true so two counted-out members do not answer each other's answers.

Motivation and Context

Follow-up to #4074, which split SentTimeoutVotes into to_members (kept fixed across HighPc advances) and to_leader (re-signed when high_pc_height advances). Updating the collector on certified NEWVIEWs ensures that TimeoutCertificate::max_high_pc_height reflects the highest verified certificate claim a quorum has signed for that view, and keeps waiting members whose HighPc advanced answerable by a leader that has already counted the view out.

How Has This Been Tested?

  • hotstuff::vote_collector::collector::tests::collect_vote_replacing_supersedes_held_vote_without_re_emitting_quorum: verifies in-place replacement under VoteStoreBound::PerSender, rejection of non-superseding votes without overwriting the higher vote, inclusion of the superseding vote when quorum is reached, and no second quorum emission after quorum.
  • hotstuff::vote_collector::timeout_collector::tests::collector_behavior:
    • a_certified_vote_with_a_higher_high_pc_supersedes_the_held_vote_and_stays_answerable: verifies duplicates_held_vote stays false on both the upgraded NEWVIEW and its re-send, a lower re-signed vote is still flagged as duplicate without downgrading the claim, and the resulting TimeoutCertificate carries max_high_pc_height() == NodeHeight(6) and passes check_quorum_certificate_signatures.
    • a_waiting_member_whose_newview_advances_high_pc_after_pacing_quorum_stays_answerable: verifies that after a node has already counted the view out via uncertified pacing votes, a waiting member's upgraded NEWVIEW and its re-send neither emit a second pacing quorum nor set duplicates_held_vote = true.
    • an_uncertified_timeout_vote_with_a_higher_high_pc_still_duplicates_the_held_vote: verifies standalone TimeoutVote answers with a higher high_pc_height still set duplicates_held_vote = true.
  • Full tari_consensus unit test suite (413 passed) and clippy with workspace lints clean.

What process can a PR reviewer use to test or verify this change?

cargo test -p tari_consensus --lib vote_collector

To observe the original failure, revert check_and_collect_vote in crates/consensus/src/hotstuff/vote_collector/timeout_collector.rs to collect_vote / replace_higher_high_pc = false and re-run the command above.

Breaking Changes

  • None
  • Requires data directory to be deleted
  • Other - Please specify

…gh_pc

When a validator waiting on a stalled timeout view learns a higher
ProposalCertificate without moving to a higher timeout view, OnNextSyncViewHandler
signs a new `to_leader` TimeoutVote carrying the higher `high_pc_height` and
persists it in `LastSentNewView`.

Previously, `TimeoutVoteCollector::check_and_collect_vote` rejected that
updated vote in both `certified_votes` and `pacing_votes` as a duplicate:
- `certified_votes` kept the signer's earlier vote, so a TimeoutCertificate
  subsequently formed for the view attested to a stale `max_high_pc_height`.
- `pacing_votes` set `duplicates_held_vote = true` on the upgraded NEWVIEW and
  every later re-send of `LastSentNewView.to_leader`, causing
  `is_waiting_on_a_counted_out_view` to suppress `answer_member_behind`.

Allow `check_and_collect_vote` (where the caller has verified the accompanying
`high_pc` certificate) to replace a held vote in `certified_votes` and
`pacing_votes` when `incoming.high_pc_height > held.high_pc_height`, while
keeping uncertified `TimeoutVote` messages on the existing duplicate rule so
answers from counted-out members never trigger reply loops.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant