Skip to content

node: origin-directory genesis replay silently proceeds on a from > latest range anomaly #1152

Closed

Description

@yigitdot

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions