Repository navigation
refactor(node): read the origin namespace set instead of replaying for it - #1500
Conversation
|
Warning Review limit reached
Next review available in: 36 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Free Run ID: 📒 Files selected for processing (5)
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. Comment |
|
Heads-up for whoever reviews this: CI does not run on this PR. It is verified locally instead:
Once #1497 merges I will retarget this onto |
There was a problem hiding this comment.
Pull request overview
This PR refactors the node’s chain-backed origin directory bootstrap to stop replaying AssignmentActivated logs just to discover the namespace key set. Instead, it pages the on-chain assignedNamespaces view at a pinned block height, keeping the snapshot semantics intact while removing replay floors, replay windows, and the associated persisted scan cursor.
Changes:
- Replace bootstrap “namespace discovery” from windowed
eth_getLogsreplay with paginatedassignedNamespacesenumeration at a pinned block height. - Remove Origin replay-cursor plumbing (config floor wiring, checkpoint persistence/flush-on-shutdown) and the now-unreachable inverted-range anomaly metric.
- Update runtime wiring to match the new bootstrap contract reads and shutdown behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| crates/node/src/runtime/mod.rs | Stops passing origin replay floor / checkpoint store into origin directory bootstrap and removes Origin-cursor flush on shutdown. |
| crates/node/src/metrics.rs | Removes the bootstrap range-anomaly counter, recorder hook, and its unit test. |
| crates/node/src/dht/chain_origin_directory.rs | Implements pinned-block namespace enumeration via assignedNamespaces, removes replay-floor logic, and seeds the watcher from the snapshot block without persisting a cursor. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…r it The origin directory's membership was always authoritative via `getOrigins` — the bootstrap replays `AssignmentActivated` from a configured floor purely to learn *which namespace ids exist*, because the key set was not enumerable on chain. `assignedNamespaces` closes that, so the replay goes away entirely. `bootstrap_cache` now reads the namespace set at a pinned block and pages it. Pinning is load-bearing rather than tidiness: the on-chain set removes by swap-and-pop, so paging across two heights can relocate an unread element into an already-read slot and skip it silently. The count is re-read at the same height and a mismatch aborts the snapshot instead of seating a partial set, which would leave a namespace's authorized origins invisible until its next live event. What this deletes, and why each was only there for the replay: - `REPLAY_WINDOW_BLOCKS` and the windowed `AssignmentActivated` query. - `replay_floor` / `resume_replay_floor` and the `REORG_MARGIN_BLOCKS` rewind. A cross-restart rewind exists to distrust a checkpoint written before a reorg; with no checkpoint there is nothing to distrust. - `CheckpointKey::Origin` persistence, and the ordered shutdown flush that existed so a clean stop would not lose a debounce window of scan progress. There is no scan progress to lose. - The inverted-range degradation path (`replay_from > latest` on a lagging RPC) and its `origin_directory_bootstrap_range_anomaly` counter. The condition is unreachable now — there is no range to invert — and a counter that can never increment is worse than none. Nothing in `monitoring/`, `docs/`, or `adr/` referenced it. This also removes a real gap rather than only cost: a namespace assigned while the node was down used to be missing from the snapshot until its next live event, because the replay resumed from a persisted cursor. The enumeration covers all of history on every boot, so it is present immediately. Verified against a live anvil chain: both G-NODE-08 journeys pass (authorized-origin gate opening, and revocation reclosing it). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The origin directory now enumerates the namespace set on chain (assignedNamespaces, #1497) instead of replaying AssignmentActivated, so this key is no longer read. It is retained only because [blockchain] denies unknown fields; removing it is a startup-breaking change deferred until the remaining *_from_block watchers migrate. Update the three sites that still described it as an active log-replay knob: the config-type doc comment, the `decdn config` printed line, and the sample-config comment. Purely documentation — no behavior change. Co-Authored-By: Claude Opus 4.8 <[email protected]>
9b27f93 to
448b47a
Compare
…cause The `seen != count` abort message named swap-and-pop mid-page removal as the sole cause. Since the pages are pinned by block number, an inconsistent or reorged RPC view of that block can trip it too. Describe the invariant violation without asserting a single root cause. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Coverage reportTotal: 80.79% (was 80.77%, ▲ +0.01%) — 54772/67799 lines
History
|
…1504) Migrates the slash, buyer-reconcile, and blacklist watchers off eth_getLogs replay onto the #1497 enumeration views (enumerate at a pinned block + follow the tail + periodic re-enumeration), removes the three *_from_block config knobs (config-breaking) and the dead replay framework, and aligns ADRs 011/019/003/016 + the observability appendix. Blacklist address-liveness uses the isOriginBlacklisted||isOperatorBlacklisted union; slash appeal deadlines fold in pausedTotal. Consolidates the deferred follow-ups from #1497/#1498/#1500 so nothing is left outstanding.
Why
The origin directory's membership was always authoritative via
getOrigins. The bootstrap replayedAssignmentActivatedfrom a configured floor purely to learn which namespace ids exist — the key set was the only thing not readable on chain.assignedNamespacescloses that, so the replay goes away entirely.This is the smallest of the watcher migrations and the clearest illustration of the pattern: nothing about the projection changes, only where the node learns the keys.
What
bootstrap_cachereads the namespace set at a pinned block and pages it.Pinning is load-bearing, not tidiness. The on-chain set removes by swap-and-pop, so paging across two heights can relocate an unread element into an already-read slot and skip it silently. The count is re-read at the same height and a mismatch aborts the snapshot rather than seating a partial set — a missing namespace means its authorized origins are invisible until its next live event.
What this deletes, and why each existed only for the replay
REPLAY_WINDOW_BLOCKS+ the windowedAssignmentActivatedqueryreplay_floor/resume_replay_floor,REORG_MARGIN_BLOCKSrewindCheckpointKey::Originpersistence + the ordered shutdown flushorigin_directory_bootstrap_range_anomalyOn that last one: I removed the counter rather than leaving it. The condition it counted cannot occur any more, and a counter that can never increment is an alert that can never fire — the same argument the repo used when retiring
node_address_watcher_*. I checkedmonitoring/,docs/, andadr/first; nothing referenced it.Not just cost — a real gap closes
A namespace assigned while the node was down used to be missing from the snapshot until its next live event, because the replay resumed from a persisted cursor that had already advanced past it. The enumeration covers all of history on every boot, so it is present immediately.
Testing
replay_floorarithmetic, theresume_replay_floorwiring guardrail, and the metric's zero-exposure test); one added — a policy pin that the watcher seeds at its enumeration block and persists nothing, so a regression that reintroduces a cursor fails.authorized_origin_fetches_opaquely_from_its_own_backend, 25.7s) and revocation reclosing it (revoking_an_assignment_recloses_the_gate_without_dropping_held_content, 6.1s).cargo clippy --workspace --all-targets -- -D warnings,cargo fmt --check, all pre-commit hooks.Follow-up
blockchain.origin_directory_from_blockis now unread. It stays for now — removing a config key is a startup-breaking change underdeny_unknown_fields, so all three*_from_blockknobs come out together with one CHANGELOG entry once the remaining watchers migrate.🤖 Generated with Claude Code