Skip to content

refactor(node): read the origin namespace set instead of replaying for it - #1500

Merged
alpergundogdu merged 3 commits into
mainfrom
feat/origin-directory-enumerate
Jul 29, 2026
Merged

alpergundogdu merged 3 commits into
mainfrom
feat/origin-directory-enumerate

Conversation

@thiras

@thiras thiras commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Stacked on #1497 — targets feat/capacity-bond-slash-enumeration, since it consumes the assignedNamespaces view added there. Review/merge #1497 first.

Why

The origin directory's membership was always authoritative via getOrigins. The bootstrap replayed AssignmentActivated from a configured floor purely to learn which namespace ids exist — the key set was the only thing not readable on chain. assignedNamespaces closes 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_cache reads 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

Removed Why it was there
REPLAY_WINDOW_BLOCKS + the windowed AssignmentActivated query the replay itself
replay_floor / resume_replay_floor, 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 + the ordered shutdown flush the flush existed so a clean stop would not lose a debounce window of scan progress. There is no scan progress
The inverted-range degradation path + origin_directory_bootstrap_range_anomaly unreachable — there is no range left to invert

On 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 checked monitoring/, docs/, and adr/ 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

  • 2,658 unit tests pass. Five obsolete tests removed (the replay_floor arithmetic, the resume_replay_floor wiring 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.
  • Verified against a live anvil chain: both G-NODE-08 journeys pass — the authorized-origin gate opening (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_block is now unread. It stays for now — removing a config key is a startup-breaking change under deny_unknown_fields, so all three *_from_block knobs come out together with one CHANGELOG entry once the remaining watchers migrate.

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings July 29, 2026 06:56
@coderabbitai

coderabbitai Bot commented Jul 29, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

@alpergundogdu, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 36 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Free

Run ID: e2a0f889-63c3-4991-b885-e6122a2d46ef

📥 Commits

Reviewing files that changed from the base of the PR and between 5bdb59b and 1a31269.

📒 Files selected for processing (5)
  • crates/cli/src/commands/config.rs
  • crates/common/src/config/types.rs
  • crates/node/src/dht/chain_origin_directory.rs
  • crates/node/src/metrics.rs
  • crates/node/src/runtime/mod.rs

Note

🎁 Summarized by CodeRabbit Free

Your 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 @coderabbitai help to get the list of available commands.

@thiras

thiras commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

Heads-up for whoever reviews this: CI does not run on this PR. ci.yml triggers on pull_request: branches: [main], so a PR based on a feature branch gets no checks — the quiet check list here is the trigger filter, not a green run.

It is verified locally instead:

  • cargo nextest run — 2,658 pass
  • cargo nextest run -p decdn-e2e --features anvil-e2e --test g_node_08_authorized_origin --test g_node_08_revocation — 2 pass against a live anvil chain (this is the part that actually exercises the new assignedNamespaces view and the pinned-block paging; ABI drift is only ever caught by the e2e job)
  • cargo clippy --workspace --all-targets -- -D warnings, cargo fmt --check, all pre-commit hooks

Once #1497 merges I will retarget this onto main and push, since the workflow excludes edited events — a retarget alone would leave the head SHA with no run.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_getLogs replay with paginated assignedNamespaces enumeration 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.

thiras and others added 2 commits July 29, 2026 11:09
…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]>
@alpergundogdu
alpergundogdu force-pushed the feat/origin-directory-enumerate branch from 9b27f93 to 448b47a Compare July 29, 2026 10:15
@alpergundogdu
alpergundogdu changed the base branch from feat/capacity-bond-slash-enumeration to main July 29, 2026 10:15
…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]>
@github-actions

Copy link
Copy Markdown

Coverage report

Total: 80.79% (was 80.77%, ▲ +0.01%) — 54772/67799 lines

File Coverage Lines Δ
crates/cli/src/commands/config.rs 74.76% 231/309 ● 0.00%
crates/node/src/dht/chain_origin_directory.rs 70.73% 575/813 ▼ 0.99%
crates/node/src/metrics.rs 95.36% 965/1012 ▼ 0.07%
crates/node/src/runtime/mod.rs 47.07% 1085/2305 ▲ +0.12%
History
Commit Total Δ vs base
1a31269 (HEAD) 80.79% ▲ +0.01%

@alpergundogdu
alpergundogdu merged commit 6b6820c into main Jul 29, 2026
25 checks passed
@alpergundogdu
alpergundogdu deleted the feat/origin-directory-enumerate branch July 29, 2026 11:17
alpergundogdu added a commit that referenced this pull request Jul 29, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants