…lls behind
When this node is ahead of its Zakura header-sync overlay peers (they are
behind) and legacy body sync keeps committing, the verified body tip can
outrun the header-sync frontier, leaving header sync stuck below the local
verified state with no peer to fetch from. Those blocks are locally verified,
so once the verified tip leads the frontier by more than
HEADER_SYNC_FOLLOW_VERIFIED_TIP_GAP, header sync now re-anchors up to the
verified tip (reusing the existing re-anchor path, which rebuilds the frontier
history tree there). The gap gate keeps the re-anchor's status broadcast well
under the inbound status-spam interval even while the verified tip climbs fast.
Motivation
Stacked on top of #458 (Zakura header-sync anchor-root validation).
After a restart, Zakura header sync resumes at the confirmed roots frontier. If this node is ahead of its Zakura header-sync overlay peers (they are behind) and legacy body sync keeps committing, the verified body tip can outrun the header-sync frontier — leaving header sync stuck below the local verified state with no peer to fetch from (
refresh_forward_rangeschedules nothing whenbest_peer_tip <= best_header_tip). Those blocks are already locally verified: their headers and roots are the trusted committed rows, so header sync has no reason to sit behind them.Found while validating #458 on a live mainnet archive node: the node was healthy and at the tip via legacy sync, but Zakura header sync stayed ~300 blocks behind the verified tip because all its overlay peers advertised a lower height.
Solution
handle_state_frontiers_changednow advances the header frontier up to the verified body tip once the verified tip leads it by more thanHEADER_SYNC_FOLLOW_VERIFIED_TIP_GAP(256), reusing the existingreanchor_to_verified_block_tippath (repositions the tip and reloads the frontier history tree at the verified tip).The gap gate keeps the re-anchor's status broadcast well under the 5s inbound status-spam interval (
DEFAULT_HS_INBOUND_STATUS_MIN_INTERVAL) even during a full-speed legacy catch-up: a 256-block gap spaces re-anchors seconds apart in the worst case. On a node that is keeping up (header sync at/ahead of the verified tip) the branch never fires.Tests
verified_tip_beyond_gap_reanchors_header_sync_to_follow_itcovers both directions: a verified lead at the gap boundary leaves the frontier put (strictly-greater gate), and a lead one block beyond the gap re-anchors up to the verified tip and dispatches the frontier-tree rebuild there.zakura::header_syncunit tests pass;cargo fmt --all -- --checkandcargo clippy -p zebra-network --all-targetsare clean.AI Disclosure