Skip to content

refactor: remove the residual authorized-origin content-authorization gate - #1525

Merged
alpergundogdu merged 1 commit into
mainfrom
claude/remove-residual-authorized-origin-gate
Jul 30, 2026
Merged

alpergundogdu merged 1 commit into
mainfrom
claude/remove-residual-authorized-origin-gate

Conversation

@alpergundogdu

@alpergundogdu alpergundogdu commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Removes the pull_through_require_authorized_origin gate. It refused to initiate a backend pull/warm for a request whose namespaceId had no on-chain authorized origin — treating the request namespace as a serve-authorization trust anchor. But ADR 002 § Hash-to-namespace association is explicit that the namespace is a routing hint, not a trust anchor. So the gate was residual: a husk left after the per-hash on-chain claim layer was removed.

The gate never authorized anything per-content. As ADR 037 §87 itself documented, it was namespace-scoped, not operator-scoped (#1368): it admitted a serve for any hash in any namespace with any registered origin — "even one the DAO assigned to a different operator." An operator couldn't express "don't serve a namespace I'm not assigned to" through it at all.

What's removed

  • pull_origin_gate / pull_origin_gate_blocks (the serve-path check)
  • OriginDirectory::has_origin (its only consumer)
  • ServeRejectReason::UnauthorizedOrigin + its wire mapping + the serve_stream_rejected_unauthorized_origin metric
  • cache.pull_through_require_authorized_origin config — raw, resolved, and reload layers + literals
  • the launch_authorized_origin e2e fixture and the three g_node_08_* tests (they existed only to exercise the gate)
  • gate framing in ADRs 037, 022, 019, 011

What's kept

The origin directory and lookup_origins stay — that's the legitimate node→node routing mechanism (node_origin.rs uses it to find which upstream origins to pull from for a namespace), which ADR 002/022 sanction. Namespace stays routing-only.

Why it's safe

The gate was opt-in and default-off, so removal is behavior-neutral for anyone not opted in (effectively everyone on testnet). The real protections are untouched:

  • pull_authorized — channel-ownership, the actual guard against unpaid upstream egress
  • seed-leech caps — bound speculative pull spend
  • ContentBlacklist — removes unwanted content once held
  • BLAKE3 verification — every delivered byte

Verification

cargo build, cargo clippy --workspace --all-targets, cargo fmt --check, cargo nextest run (2655/2655), and both cargo test --no-run -p decdn-{e2e,node} --features anvil-e2e gates all green. Pre-commit markdownlint + ADR reference-hygiene pass on the ADR edits.

Net: 22 files, +23 / −1245.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Behavior Changes

    • Cache-miss pull-through is no longer restricted by optional authorized-origin settings.
    • Origin directories now guide routing and fallback discovery rather than authorize content delivery.
    • Requests no longer fail early due to unauthorized-origin checks.
    • Blacklisted content handling now distinguishes between retryable hash blocks and non-retryable origin blocks.
  • Configuration

    • Removed the optional authorized-origin pull-through setting from configuration.
  • Documentation

    • Updated architecture and operator guidance to reflect the revised routing, caching, and content-removal behavior.

… gate

The `pull_through_require_authorized_origin` gate refused to initiate a backend
pull/warm for a request whose `namespaceId` had no on-chain authorized origin.
But ADR 002 is explicit that the request namespace is a **routing hint, not a
trust anchor** — so using it as a serve-authorization decision was residual: a
husk left after the per-hash on-chain claim layer was removed. ADR 037 already
documented that the gate was namespace-scoped, not operator-scoped (#1368), and
authorized nothing per-content (it admitted a serve for any hash in any namespace
that had *any* registered origin, even one assigned to a different operator).

Remove the gate and everything specific to it: `pull_origin_gate` /
`pull_origin_gate_blocks`, `OriginDirectory::has_origin` (its only consumer),
`ServeRejectReason::UnauthorizedOrigin` and its wire mapping + metric, the
`cache.pull_through_require_authorized_origin` config across all three layers, the
`launch_authorized_origin` e2e fixture, and the three `g_node_08_*` tests that
existed only to exercise the gate.

KEEP the origin directory and `lookup_origins`: that is the legitimate node→node
*routing* mechanism (find which upstream origins to pull from for a namespace),
which ADR 002/022 sanction. Namespace stays routing-only.

Safe by construction: the gate was opt-in and default-off, and the real
protections are untouched — `pull_authorized` (channel ownership, the actual
unpaid-egress guard), the seed-leech caps, `ContentBlacklist`, and BLAKE3
verification. ADRs 037/022/019/011 updated to match.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@coderabbitai

coderabbitai Bot commented Jul 30, 2026 •

Copy link
Copy Markdown

Review Change Stack

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Free

Run ID: 9b125288-5cf0-47fa-9a49-a6ca571092b2

📥 Commits

Reviewing files that changed from the base of the PR and between d4caf8c and 8bf9687.

📒 Files selected for processing (22)
  • adr/011-content-takedown.md
  • adr/019-node-onboarding.md
  • adr/022-content-discovery.md
  • adr/037-regional-proxy-warming.md
  • crates/cli/tests/config_validate.rs
  • crates/common/src/config/mod.rs
  • crates/common/src/config/resolved.rs
  • crates/common/src/config/types.rs
  • crates/e2e/src/node.rs
  • crates/e2e/tests/g_node_08_authorized_origin.rs
  • crates/e2e/tests/g_node_08_namespace_scope.rs
  • crates/e2e/tests/g_node_08_revocation.rs
  • crates/node/src/dht/chain_origin_directory.rs
  • crates/node/src/dht/origin.rs
  • crates/node/src/handlers/client/dispatch.rs
  • crates/node/src/handlers/client/mod.rs
  • crates/node/src/handlers/client/wire.rs
  • crates/node/src/metrics.rs
  • crates/node/src/runtime/mod.rs
  • crates/node/src/runtime/reload.rs
  • crates/node/tests/anvil_bringup_shutdown_e2e.rs
  • crates/node/tests/sighup_signal.rs
💤 Files with no reviewable changes (13)
  • crates/e2e/tests/g_node_08_authorized_origin.rs
  • crates/e2e/tests/g_node_08_namespace_scope.rs
  • crates/node/tests/anvil_bringup_shutdown_e2e.rs
  • crates/e2e/tests/g_node_08_revocation.rs
  • crates/node/tests/sighup_signal.rs
  • crates/node/src/handlers/client/wire.rs
  • crates/cli/tests/config_validate.rs
  • crates/node/src/dht/chain_origin_directory.rs
  • crates/node/src/metrics.rs
  • crates/node/src/runtime/reload.rs
  • crates/common/src/config/mod.rs
  • crates/node/src/runtime/mod.rs
  • crates/node/src/handlers/client/mod.rs

Walkthrough

The pull-through authorized-origin configuration and enforcement path are removed. Origin discovery now supplies routing candidates directly, runtime and client wiring are simplified, related metrics and tests are updated, and ADRs describe routing-only origin assignments and blacklist-based handling.

Changes

Authorized-origin pull gating removal

Layer / File(s) Summary
Configuration contract and fixtures
crates/common/src/config/*, crates/cli/tests/config_validate.rs, crates/e2e/src/node.rs, crates/node/src/runtime/reload.rs, crates/node/tests/*
The pull_through_require_authorized_origin field is removed from configuration schemas, resolved settings, rendered TOML, reload classification, and test fixtures.
Origin-directory API simplification
crates/node/src/dht/origin.rs, crates/node/src/dht/chain_origin_directory.rs
Origin lookup implementations use lookup_origins and resolve results directly; has_origin and has_any are removed with their related tests.
Client and runtime flow
crates/node/src/handlers/client/*, crates/node/src/runtime/mod.rs, crates/node/src/metrics.rs
Reactive pull-through authorization rejection, dependency wiring, rejection reason, and metric are removed; insufficient-deposit metric recording remains explicit. Related authorized-origin E2E modules are deleted.
ADR behavior and error documentation
adr/011-content-takedown.md, adr/019-node-onboarding.md, adr/022-content-discovery.md, adr/037-regional-proxy-warming.md
Documentation describes origin assignments as routing hints, permissionless reactive warming bounded by caps and blacklists, and retry behavior for blacklist errors.

Estimated code review effort: 3 (Moderate) | ~25 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.

@github-actions

Copy link
Copy Markdown

Coverage report

Total: 80.16% (was 80.15%, ▲ +0.01%) — 53874/67205 lines

File Coverage Lines Δ
crates/common/src/config/mod.rs 97.04% 6826/7034 ● 0.00%
crates/common/src/config/resolved.rs 100.00% 33/33 ● 0.00%
crates/e2e/src/node.rs 25.60% 118/461 ▼ 0.71%
crates/node/src/dht/chain_origin_directory.rs 70.43% 555/788 ▼ 0.29%
crates/node/src/dht/origin.rs 100.00% 34/34 ▲ +5.00%
crates/node/src/handlers/client/dispatch.rs 89.17% 280/314 ▲ +0.70%
crates/node/src/handlers/client/mod.rs 89.31% 660/739 ▼ 0.27%
crates/node/src/handlers/client/wire.rs 97.73% 129/132 ▲ +2.17%
crates/node/src/metrics.rs 95.35% 963/1010 ▼ 0.01%
crates/node/src/runtime/mod.rs 46.38% 1082/2333 ▲ +0.14%
crates/node/src/runtime/reload.rs 96.36% 1640/1702 ▼ 0.01%
History
Commit Total Δ vs base
8bf9687 (HEAD) 80.16% ▲ +0.01%

@alpergundogdu
alpergundogdu merged commit 7dcbb66 into main Jul 30, 2026
25 checks passed
@alpergundogdu
alpergundogdu deleted the claude/remove-residual-authorized-origin-gate branch July 30, 2026 14:35
alpergundogdu added a commit that referenced this pull request Sep 18, 2026
…review)

Two accuracy fixes from PR review:
- ADR 037 said the probe `has_blob` answer is "unsigned"; it is signed
  (EIP-712 `slash_sig` over `{hash, has_blob, rate_per_mb, timestamp_us}`).
  The real point is that `ProbeResponse` carries no policy/role field, so a
  client cannot tell an origin-only node from a relay edge — reworded to say
  exactly that.
- ADR 002 described the origin-only decline in namespace terms, risking the
  implication that `namespaceId` drives the serve/decline decision. The gate
  is backend-authoritative (`origin_probe_presence(hash)`) and never consults
  `namespaceId`, which stays a routing hint (#1525). Reworded to backend
  presence and stated the non-consultation explicitly.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
alpergundogdu added a commit that referenced this pull request Sep 18, 2026
) (#2055)

* docs(adr): record proxy-warming vs origin-only policy composition (#1990)

Two deliberate policies interact in a way neither ADR documented: the
client's cold-blob / warming fallback (ADR 037) targets RTT-nearest
non-holders, and an origin-configured node defaults to origin-only
(`relay_foreign_namespaces = false`, #1759) and declines a foreign miss.
The fallback can therefore route a warming attempt to a node that
categorically declines it.

Run through spec discipline, the two policies compose correctly rather
than conflict: proxy warming is a relay-edge mechanism by construction,
and an origin-only node declining a warming pull is the origin-only
policy holding, not a warming failure. The decline collapses to
`NotFound`, the client fails over over the shared pool at the cost of one
round-trip, and pays nothing.

Document the composition:
- ADR 037 gains a "Warming is a relay-edge mechanism" section and a
  Cross-ADR Impact bullet for ADR 002.
- ADR 002 § Retrieval by namespace gains the canonical statement of the
  `relay_foreign_namespaces` role-derived policy (previously code-only,
  referenced obliquely by ADR 041 as "a separate policy").

No mechanism is added. The two options that would (a self-attested probe
flag to pre-filter origin-only nodes, and reversing the #1759 default)
stay out — both add surface to force an optimization that is correctly
not firing. The interaction is already observable: the serving node
counts declines in `decdn_serve_stream_rejected_foreign_declined_total`
(exists since #1766) and the client logs its warming lead and each
failover; the client is an ephemeral CLI with no scrape endpoint, so a
client-side counter would be dead instrumentation.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* docs(adr): fix probe-signing and namespace-vs-backend wording (#1990 review)

Two accuracy fixes from PR review:
- ADR 037 said the probe `has_blob` answer is "unsigned"; it is signed
  (EIP-712 `slash_sig` over `{hash, has_blob, rate_per_mb, timestamp_us}`).
  The real point is that `ProbeResponse` carries no policy/role field, so a
  client cannot tell an origin-only node from a relay edge — reworded to say
  exactly that.
- ADR 002 described the origin-only decline in namespace terms, risking the
  implication that `namespaceId` drives the serve/decline decision. The gate
  is backend-authoritative (`origin_probe_presence(hash)`) and never consults
  `namespaceId`, which stays a routing hint (#1525). Reworded to backend
  presence and stated the non-consultation explicitly.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

---------

Co-authored-by: Claude Opus 4.8 <[email protected]>
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.

1 participant