Skip to content

test(zakura): add header-sync reorg suite and reorg handoff docs#504

Draft
p0mvn wants to merge 1 commit into
zakura/writeguards-canary-v3from
zakura-reorg-handoff-and-suite
Draft

test(zakura): add header-sync reorg suite and reorg handoff docs#504
p0mvn wants to merge 1 commit into
zakura/writeguards-canary-v3from
zakura-reorg-handoff-and-suite

Conversation

@p0mvn

@p0mvn p0mvn commented Jul 7, 2026

Copy link
Copy Markdown

Motivation

The reorg work is being handed off to another engineer. This PR commits the durable context: the engineering handoff document, the original first-principles design plan, and the header-sync reorg test suite that pins the current behavior of every reorg-relevant path — including the three open gaps behind the 2026-07-07 testnet-4 wedge.

Solution

Tests

  • cargo test -p zebra-network --lib -- zakura:: — 679 passed
  • cargo test -p zebrad --lib -- zakura_header_sync_driver_tests — 55 passed
  • cargo test -p zebra-state --lib -- header_store_coherence — 44 passed
  • cargo fmt --all -- --check and cargo clippy -p zebra-network -p zebrad --all-targets -- -D warnings clean

Specifications & References

  • Incident evidence: zakura-testnet-4:/mnt/zakura-testnet-4-data/zakura-traces/ (commit_state.jsonl, header_sync.jsonl) — see REORG_HANDOFF.md §4/§7
  • Cure to port: zakura/fallback-keeps-zakura-alive commits 9348039, 6f8b4ad

Follow-up Work

AI Disclosure

  • Used Claude Code for the test suite implementation, the testnet-4 incident trace analysis, and drafting the handoff documents; all reviewed and validated locally.

@v12-auditor

v12-auditor Bot commented Jul 7, 2026

Copy link
Copy Markdown

Note

Complete: Audit complete. V12 found one issue worth reviewing.

Open the full results here.

FindingSeverityDetails
F-96921 🟠 High
Header range assignments wedge sync

Zakura header sync records which peers were assigned a forward GetHeaders range, but peer-failure paths retry that range without clearing the recorded assignment. A malicious peer can advertise a higher tip, receive a forward range, and answer with headers that fail to link; when the node is fully synced, the stale-anchor handler exits because best_header_tip <= verified_block_tip, so the reactor reports InvalidRange and retries without clearing the assignment. The state commit failure path has the same leak for InvalidPeerRange, because handle_header_range_commit_failed only clears assignments for Local failures. After three distinct peers fill HEADER_SYNC_FANOUT for the same range, pop_assignable will not hand that range to any peer, and ensure refuses to enqueue a replacement forward range at the same start height. Misbehavior handling is record-only, so the attacking peers remain connected and fresh honest peers advertising a higher tip cannot restore header-only forward progress; recovery depends on a separate full-block/body path covering the height or on the peers being forgotten.

And one more auto-invalidated finding.

Analyzed two files, diff e7bdbb4...2f8072e.

@p0mvn
p0mvn marked this pull request as draft July 7, 2026 19:11
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