Skip to content

fix(consensus): replay blocks with their historical quorum - #1567

Merged
lklimek merged 3 commits into
v1.8-devfrom
fix/replay-historical-quorum
Nov 5, 2026
Merged

lklimek merged 3 commits into
v1.8-devfrom
fix/replay-historical-quorum

Conversation

@lklimek

@lklimek lklimek commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

TL;DR: Allow a restarted node to replay older blocks across a signing-group change without repeatedly failing on withdrawals.

User story

As a node operator, I want recovery after a restart to rebuild older withdrawals correctly, so the node can resume processing blocks.

Scenario

A node restarts with its application a few blocks behind the stored chain, across a change of signing group. Recovery currently uses the newer group to rebuild older withdrawals, changes their hashes, and fails on every restart. It should use the group that signed the replayed block.

Detailed discussion

Issue being fixed or feature implemented

Application-only replay passes the latest persisted state to BlockExecutor.ProcessProposal, which reads QuorumHash from state.Validators. Drive includes that quorum hash in unsigned withdrawal transactions, so replay across a quorum rotation changes their txids and vote extensions.

What was done?

When the state's quorum differs from the replayed commit's quorum, replayBlock loads the validator set for the replayed height before calling ProcessProposal. Missing historical validators stop replay before any ABCI call; the latest state remains unchanged.

Targets v1.8-dev. Normal finalization waits for the application before saving Tenderdash state; replay intentionally supports an older application state. This fix handles that recovery case and does not explain how the reported application fell behind. Its database was unavailable, so the exact reported transaction hashes were not independently reproduced.

How Has This Been Tested?

  • Confirmed the regression fails on the unmodified base because the application receives the newer quorum.
  • replay_quorum_test.go covers unchanged quorums, rotation, missing history, and preservation of the latest state.
  • Passed go test -race -tags=deadlock -p 1 ./internal/consensus -run '^Test(ReplayUsesHistoricalQuorumAfterRotation|ReplayRejectsCommitExtensionsBeforeFinalize|BlockReplayerReplay|HandshakeReplay(All|Some))$' -count=1.
  • golangci-lint v2.15.0 on ./internal/consensus, with --new-from-rev=origin/v1.8-dev: 0 issues.
  • TestBlockReplayerReplay: passed, including application state six blocks behind the stored chain.
  • gofmt and git diff --check: passed.

Breaking Changes

None.

Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation (not required)

Attribution

🤖 Co-authored by Claudius the Magnificent AI Agent
-count=1`.

  • golangci-lint v2.13 on ./internal/consensus, with --new-from-rev=origin/master: 0 issues.
  • TestBlockReplayerReplay: passed, including application state six blocks behind the stored chain.
  • gofmt and git diff --check: passed.

Breaking Changes

None.

Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation (not required)

Attribution

🤖 Co-authored by Claudius the Magnificent AI Agent

PR Hygiene · db56225

  • Bots — thepastaclaw ✓
  • Self-review — posted; again after any push
  • Build green
  • Approvals — you own every area touched; none needed

When every merge requirement is met, the PR Hygiene check passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.

Reload the validator set at a replayed height when its commit belongs to
an older quorum than the persisted state. Otherwise ProcessProposal sends
the latest quorum to the application and changes withdrawal transaction
hashes, preventing FinalizeBlock from accepting the historical commit.

Cover unchanged quorums, rotation, missing history, and preservation of
the latest state. The regression fails on master before this fix.

<sub>🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent</sub>

Co-Authored-By: Codex <[email protected]>
@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@thepastaclaw

thepastaclaw commented Oct 23, 2026 •

Copy link
Copy Markdown

✅ Final review complete — no blockers (commit db56225) · triage: low

Merge the new PR base and use Tenderdash's internal database package in
the regression test. Preserve the base branch's commit-extension checks.

<sub>🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent</sub>

Co-Authored-By: Codex <[email protected]>
@lklimek
lklimek changed the base branch from master to v1.8-dev October 23, 2026 14:34
@lklimek
lklimek marked this pull request as ready for review November 4, 2026 18:02
@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@github-actions github-actions Bot added the waiting-bots Waiting for the review bots to report on this head label Nov 4, 2026

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final validation — Phase 1 + Phase 2

The historical-quorum lookup is correctly scoped to application-only replay, selects validators for the replayed height, and preserves the caller's latest state. No blocking defects were verified; one non-blocking suggestion remains to exercise quorum-sensitive behavior through the complete replay loop. Static verification was performed at db56225 without running builds or tests; current CI reports successful build, test shards, rotation and Dash Core e2e tests, lint, and vet, with only PR Hygiene pending.

🟡 1 suggestion(s)

Review provenance

Source: reviewer 1: glm-5.3-flash (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: tenderdash-consensus-security); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: low by gpt-6.1-sol (effort low) — The diff adds a small, contained historical-validator lookup in replayBlock with focused regression tests, rather than a large or intricate change to consensus rules.
  • Phase 1 reviewers: glm-5.3-flash — general (completed, effort high); agent phase1-reviewer
  • Phase 1 model: glm-5.3-flash — zai quota: 5h 99% left, weekly 59% left; passed over gemini-3.8-flash-high (antigravity quota lookup failed)
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort medium); agent phase2-reviewer, gpt-6.1-sol — tenderdash-consensus-security (completed, effort medium); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `internal/consensus/replay_quorum_test.go`:
- [SUGGESTION] internal/consensus/replay_quorum_test.go:45: Add a quorum-sensitive regression through the complete replay loop
  The new regression verifies the historical quorum by calling replayBlock directly for a single height. Existing TestBlockReplayerReplay and TestHandshakeReplayAll exercise the production replay loop, including validator changes in the handshake tests, but their kvstore application's ProcessProposal does not consume or assert RequestProcessProposal.QuorumHash. Consequently, those tests do not pin the per-height quorum delivered when several blocks are replayed across a rotation. Add a Replay-level variant with a quorum-checking application that asserts the expected quorum at every replayed height, including heights on both sides of the rotation. This would supplement the focused unit test with coverage of block/seen-commit selection and iteration wiring; it is not a blocker for the current implementation.

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Bots are done — your move: post /self-reviewed.
Full checklist in the description.

@github-actions github-actions Bot added waiting-self-review Waiting for the author to post /self-reviewed and removed waiting-bots Waiting for the review bots to report on this head labels Nov 4, 2026
@lklimek
lklimek enabled auto-merge (squash) November 5, 2026 10:03
@lklimek

lklimek commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator Author

/self-reviewed

@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown

Policy satisfied — this can merge.
Full checklist in the description.

@github-actions github-actions Bot removed the waiting-self-review Waiting for the author to post /self-reviewed label Nov 5, 2026
@lklimek
lklimek merged commit fece5ee into v1.8-dev Nov 5, 2026
26 checks passed
@lklimek
lklimek deleted the fix/replay-historical-quorum branch November 5, 2026 10:05
QuantumExplorer added a commit that referenced this pull request Nov 5, 2026
…-consensus-ccf700

v1.8-dev was renamed to dev; this brings in the two commits since then
(#1552 dev branch and release workflow, #1567 replay with historical
quorum). No conflicts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.

2 participants