feat(network): rework below-sync-start backfill as a forward cursor and rename anchor terminology#487
Draft
p0mvn wants to merge 1 commit into
Conversation
…nd rename anchor terminology Replace the disabled backward checkpoint backfill with a second forward cursor sweeping genesis -> trusted sync start: checkpoint-bounded finalized ranges folding a dedicated backfill history tree (seeded empty at genesis), verified with the same verify_supplied_roots_from_parts gate as the forward frontier, persisting header-authenticated confirmed root prefixes into the serving index. A final non-finalized stitch range confirms the sync-start height's own root. Backfill progress is tracked by its own frontier (exempt from forward coverage, with a frontier-keyed staleness rule), never moves best_header_tip or the sync-exchange frontier, and stays dormant behind BELOW_SYNC_START_BACKFILL_ENABLED. Rename the overloaded "anchor" terminology across the header-sync layer: trusted_sync_start (sync start), link_hash (per-range link target), StaleLinkFailures, rebase_*/HeaderRebased, and peer status sync_start_height. Config keys and the zebra-state API keep their legacy names at the boundary. Design doc: docs/design/below-sync-start-backfill.md
|
Note Complete: Audit complete. No review-worthy issues remain after automatic triage. One finding was auto-invalidated. Open the full results here. Analyzed 30 files, diff |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces the disabled backward checkpoint backfill with a below-sync-start forward backfill: a second forward cursor sweeping genesis → trusted sync start that reuses the forward frontier's code path end to end — checkpoint-bounded finalized ranges with the one-block overlap, root verification via
verify_supplied_roots_from_partsagainst a dedicated backfill history tree (seeded empty at genesis), and confirmed-prefix persistence into thecommitment_roots_by_heightserving index. A final non-finalized stitch range[sync_start ..= sync_start+1]confirms the sync-start height's own root (authenticated in-span against the trusted hash).Key mechanics:
retire_stale_backfill+ in-flight cancellation), so fanout duplicates of committed brackets are dropped instead of looping.best_header_tip, the sync-exchange frontier (driver skipspublish_header_frontieronbackfill: true), or body gaps; forward ranges are always assigned first.sync.header.backfill.tree_mismatch) and retries without dispatching the forward tree rebuild.BELOW_SYNC_START_BACKFILL_ENABLED = false(per-startupbackfill_enabled, opted into by tests) until the node wiring consumes backfilled data — the targeted consumer is the VCT §10 roots-index serving backfill.Also renames the overloaded "anchor" terminology across the header-sync layer (it collided with note-commitment anchors):
trusted_sync_start,link_hash,StaleLinkFailures,rebase_*/HeaderRebased, peer-statussync_start_height, metricsync.header.history_tree.reanchor→.rebase. Config keys (anchor_height/anchor_hash) and the zebra-state API keep legacy names at the boundary.Docs: new design doc
docs/design/below-sync-start-backfill.md;verified-commitment-trees.md§6.4/§10/§12/§13/§14 updated.Motivation
The backward backfill could not verify commitment roots (backward ranges fold onto the previous checkpoint's tree, which the reactor never tracks) and had no consumer, so it was disabled. Genesis is the one tree seed the reactor always knows, so a forward-from-genesis cursor achieves the same goal while reusing a single code path and producing fully header-authenticated roots.
Tests
cargo fmt --all -- --check— cleancargo clippy -p zebra-network -p zebra-state -p zebrad --all-targets— cleancargo check --workspace --all-targets— cleancargo test -p zebra-network zakura— 709 passedcargo test -p zebra-state --lib— 311 passedcargo test -p zebrad --lib zakura— 52 passedcargo test --workspacenot run locally (long); relying on CI.New coverage: default-off regression, bracket scheduling + truncation rejection, checkpoint-end mismatch, root verification against the backfill tree (wrong root → misbehavior), frontier advance + stitch lifecycle without forward-frontier movement, forward-before-backfill ordering, late fanout drop without rebuild, state-side intermediate-anchor/idempotent re-commit, driver-side no-frontier-publish for backfill commits.
AI Disclosure
Implemented with Claude Code (design, implementation, and tests) from an approved plan; reviewed by the author.