Repository navigation
Description
Spun out of the review on #1151 (gemini-code-assist), filed to keep the PR a zero-behavior-change refactor.
Observation
bootstrap_cache in crates/node/src/dht/chain_origin_directory.rs computes latest = get_block_number() and replays ContentClaimed over backfill_windows(replay_from_block, latest, REPLAY_WINDOW_BLOCKS). If replay_from_block > latest — a transient RPC replication-lag / reorg anomaly where a load-balanced endpoint answers get_block_number from a stale node — backfill_windows yields no windows, so the replay is silently skipped and namespaces_of bootstraps empty/partial.
This is pre-existing, not introduced by #1139: the prior hand-rolled while from <= latest loop had the identical silent behavior. #1139 only changed how the windows are produced, not this edge case.
Since the origin directory now resumes replay_from from a persisted checkpoint (#1108), replay_from > latest against a stale RPC head is realistically reachable (the same reason the buyer-side reconcile scan guards it).
Why not just check_backfill_range(...)?
The obvious fix (propagate the range error) is wrong here: bootstrap_cache's Err propagates through ChainOriginDirectory::bootstrap(...)? at crates/node/src/runtime/mod.rs:907, which is one-shot with no retry loop — so ? would turn a transient anomaly into a fatal node-startup crash. That's strictly worse than today's graceful degradation (empty replay → routing-only until re-surfaced by the live tail; membership stays authoritative via getOrigins).
Suggested fix
Match the codebase's existing check_backfill_range consumer — the buyer reconcile scan at crates/node/src/buyer_channel.rs:1876, which does warn + skip, not propagate:
if let Err(err) = check_backfill_range(replay_from_block, latest) {
warn!(%err, replay_from_block, latest, "origin-directory genesis replay: invalid range; skipping replay this boot (routing-only until re-surfaced)");
} else {
for (from, to) in backfill_windows(replay_from_block, latest, REPLAY_WINDOW_BLOCKS) { /* ... */ }
}This makes the anomaly observable (a warn!) without changing the graceful posture or risking a startup crash. Consider a metric bump too, mirroring the watcher-restart counters.
Related
- chore: tech-debt batch — origin-replay window unify + Resolved address typing (#1139, #1140) #1151 (the refactor PR that surfaced this), refactor(node): origin-directory genesis replay hand-rolls its window walk instead of using
backfill_windows#1139, Event watchers re-scan full history on every start; needs persisted cursor / bounded backfill #1108 (persisted replay checkpoint),buyer_channel.rs:1876(the pattern to follow).
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
docs(node): correct replay-skip degradation to default-open, not auth…
fix(node,cli): observable origin-replay range guard + zero-address gu…