Skip to content

docs(node): describe both OriginDirectory impls in dht/origin.rs - #1290

Merged
thiras merged 2 commits into
mainfrom
docs/1289-origin-directory-module-doc
Jul 18, 2026
Merged

thiras merged 2 commits into
mainfrom
docs/1289-origin-directory-module-doc

Conversation

@yigitdot

@yigitdot yigitdot commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

crates/node/src/dht/origin.rs still claimed that the chain-backed ChainOriginDirectory "lands with the on-chain origin-directory follow-up" and that the module "ships only the trait + a ConfigOriginDirectory". That rotted when crates/node/src/dht/chain_origin_directory.rs landed — ChainOriginDirectory is a full impl OriginDirectory, exported from dht/mod.rs, and it is the implementation the runtime selects. The stale comment already caused real harm: PR #1285 scoped an e2e test away from origin recognition on its strength.

Changes (docs only)

c412304 — initial rewrite (dht/origin.rs)

  • Module doc: now describes the trait plus its two implementations, and the runtime selection rule — ChainOriginDirectory when both blockchain.origin_assignment_address and blockchain.publisher_registry_address are configured, ConfigOriginDirectory otherwise.
  • ConfigOriginDirectory doc: reframed from "testnet bring-up before the contracts ship" to what it actually is — the in-memory fallback plus the test constructor.

68b3457 — post-review corrections (dht/origin.rs, node_origin.rs)

Since the deliverable here is prose about code, the new text was itself verified claim-by-claim against the implementation. Most of it held up: the selection rule matches runtime/mod.rs:699-734 exactly, the fallback really is built empty, ConfigOriginDirectory::new really is the test-fixture constructor, and the intra-doc link resolves via dht/mod.rs:31. Three claims did not hold, all inside this branch own goal of removing origin-directory rot:

  • The new bullet overstated the chain implementation. It said ChainOriginDirectory "reads the resolution chain above from RPC". That chain is quoted verbatim from ADR 022 §Bootstrap and is correct as spec, but the implementation does not perform it: there is no namespaceOf call anywhere in chain_origin_directory.rs (the hash → namespace view is replayed from ContentClaimed logs, which leaves a documented coverage hole below the resumed cursor), and the active == true filter is applied from the shared StakerSet at lookup time rather than taken from the nodeIdOf tuple. The bullet now states it yields the same candidate set by a different route, and names both divergences.
  • A contradiction survived in the preamble. Lines 15-16 still described an implementation reading from "an operator-supplied file (initial-network bootstrap)" — contradicting the new text seven lines below it. It sits above the rewritten hunk, which is why the first pass missed it.
  • A fourth dht.static_origins reference survived in node_origin.rs:1210, outside the edited file. DhtConfig carries #[serde(deny_unknown_fields)], so that key would be actively rejected at parse time, not silently ignored. The underlying point — the unfiltered fallback re-serves a non-staker on the cold path — still holds for test-built directories, so the comment now says that instead of naming a config field that cannot exist.

Discrepancy found and documented, not fixed

The issue framing (and the old doc) said ConfigOriginDirectory "reads from operator-supplied TOML" via a dht.static_origins config field. That field does not exist in the config schema — DhtConfig (crates/common/src/config/types.rs:860-865) carries exactly one field, rate_limit. The runtime at crates/node/src/runtime/mod.rs:729 always constructs the fallback with HashMap::new(), so on a node without the chain directory every origin-fallback lookup returns nothing.

Per the issue scope I documented the actual behavior and left the runtime alone; all four dht.static_origins references are now gone. If a config-fed static origin map is wanted, that is a separate feature issue.

No behavior, signature, or item changes.

Verification

Docs-only, so no behavior to test; ran the exact CI commands instead, all clean:

  • cargo fmt -- --check — pass
  • cargo clippy --workspace --all-targets -- -D warnings — Finished, no warnings
  • cargo doc -p decdn-node --no-deps — Generated, no broken intra-doc links (the [crate::dht::ChainOriginDirectory] links resolve)

Note: the local cargo deny pre-commit hook fails in this worktree with 7 bug[unresolved-workspace-dependency] errors. Reproduced on clean HEAD with the changes stashed, so it is pre-existing and environment-local — a comment-only edit cannot change dependency resolution. The cargo deny CI job passes on this branch.

Closes #1289

🤖 Generated with Claude Code

The module doc claimed ChainOriginDirectory was still a follow-up and that the
module shipped only the trait plus a ConfigOriginDirectory reading
operator-supplied TOML. Both statements rotted when
dht/chain_origin_directory.rs landed: ChainOriginDirectory is a full impl,
exported from dht/mod.rs, and selected by the runtime whenever
blockchain.origin_assignment_address and blockchain.publisher_registry_address
are both configured.

Rewrite the module doc and the ConfigOriginDirectory doc comment to describe
the trait plus its two implementations and the runtime's selection rule. Also
drop the three references to a `dht.static_origins` config field, which does
not exist in the schema — the runtime always builds the fallback with an empty
map.

Docs only; no behavior, signature, or item changes.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Jul 18, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

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

Next review available in: 32 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: f6954248-5f7c-4f71-9260-5b505af4bc09

📥 Commits

Reviewing files that changed from the base of the PR and between c412304 and 68b3457.

📒 Files selected for processing (2)
  • crates/node/src/dht/origin.rs
  • crates/node/src/node_origin.rs

Walkthrough

Updated origin.rs documentation to describe ChainOriginDirectory, the runtime-installed empty ConfigOriginDirectory fallback, the required blockchain addresses, and how tests construct populated fixtures. No code logic, signatures, or test behavior changed.

Changes

Origin directory documentation

Layer / File(s) Summary
Runtime origin fallback documentation
crates/node/src/dht/origin.rs
Documents chain directory selection when both required addresses are configured, empty fallback behavior, and constructor usage for runtime and test instances.

Estimated code review effort: 1 (Trivial) | ~2 minutes


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.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request updates the documentation in crates/node/src/dht/origin.rs to clarify the roles of the two OriginDirectory implementations: the production ChainOriginDirectory and the fallback ConfigOriginDirectory. It explains how the runtime selects between them and notes that the fallback directory is initialized empty in production. There are no review comments, and I have no additional feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@github-actions

github-actions Bot commented Jul 18, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 81.47% (was 81.47%, ● 0.00%) — 48845/59953 lines

File Coverage Lines Δ
crates/node/src/dht/origin.rs 94.83% 55/58 ● 0.00%
crates/node/src/node_origin.rs 90.51% 963/1064 ● 0.00%
History
Commit Total Δ vs base
c412304 81.47% ▼ 0.20%
68b3457 (HEAD) 81.47% ● 0.00%

…tic_origins ref

Review of the previous commit turned up three doc claims that do not match the
code, all inside this branch's own stated goal of removing origin-directory
comment rot.

The module-doc bullet claimed ChainOriginDirectory "reads the resolution chain
above from RPC". That chain is quoted verbatim from ADR 022 §Bootstrap and is
correct as spec, but the implementation does not perform it: there is no
namespaceOf call in dht/chain_origin_directory.rs (the hash → namespace view is
replayed from ContentClaimed logs), and the active filter comes from the shared
StakerSet at lookup time rather than the nodeIdOf tuple. State that the impl
yields the same candidate set by a different route, and name both divergences.

The module-doc preamble still described an implementation reading from "an
operator-supplied file (initial-network bootstrap)", contradicting the new text
seven lines below it. It sits above the previously rewritten hunk, which is why
it survived.

node_origin.rs carried a fourth reference to the nonexistent dht.static_origins
field. DhtConfig is #[serde(deny_unknown_fields)], so that key would be rejected
at parse time, not ignored. The comment's point — the unfiltered fallback
re-serves a non-staker on the cold path — still holds for test-built
directories, so it now says that instead.

Docs only; no behavior, signature, or item changes.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@thiras
thiras merged commit d9b2091 into main Jul 18, 2026
43 of 45 checks passed
@thiras
thiras deleted the docs/1289-origin-directory-module-doc branch July 18, 2026 21:53
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.

docs(node): dht/origin.rs module doc still says ChainOriginDirectory doesn't exist

2 participants