Skip to content

fetch: stream_fetch omits the ADR 005 client identity binding, so reactive origin pull-through never fires for a direct client fetch #1115

Closed

Description

@alpergundogdu

Summary

A direct decdn fetch can never trigger reactive origin pull-through, because the client (stream_fetch) does not send the ADR 005 client identity binding. The node's pull-authorization gate (pull_authorized) therefore always fails for client fetches, and a cache miss for a blob that exists only in the node's configured cache.origin (fs/http/s3) is refused as NotFound — the origin is never read.

This is already flagged as a follow-up in the serve-path source (see the "stream_fetch does not yet [send a binding]" comment), so this issue is to track finishing it.

Evidence (file/line)

  • crates/node/src/handlers/client.rs:563 — pull_authorized() returns false unless verified_client is Some and the request's channel is owned by that verified address.
  • crates/node/src/handlers/client.rs:940-972 — verified_client is derived only from ext.binding (ADR 005 §Client identity binding). No binding ⇒ verified_client == None.
  • crates/node/src/handlers/client.rs:1017-1029 — the cache-miss pull-through gate, with the explicit note: "Multi-hop node→node pulls therefore require the downstream requester to send a binding; stream_fetch does not yet, so chained pull-through is a follow-up."
  • crates/node/src/handlers/client.rs:1044-1121 — serve-miss flow: the range pull (1044), node→node window path (1073), and buffered populate (1107) are all gated on pull_authorized. With it false, the branch falls straight to ServeRejectReason::CacheMiss → wire NotFound.
  • crates/cli/src/commands/fetch.rs → decdn_client_pull::stream_fetch_tracked — the client pull path; it does not construct/sign/send an ext.binding.
  • crates/cache/src/engine.rs:1432 populate() → pull_through() → origin.fetch() (decdn_cache_origin_fetches_total) — confirms the engine would read the configured fs/http/s3 origin (fs first in the chain) if populate were ever invoked.

Reproduction

  1. Node config: [cache.origin] kind = "fs", path = /var/lib/decdn/origin, and cache.node_to_node_pull_through_enabled = true.
  2. Place a blob at {path}/{hex[0..2]}/{hex} (BLAKE3 hex).
  3. Open a funded PaymentChannel and run decdn fetch --node-id <id> --hash <hex> --provider-address <node-eth> --addr <ip:4433> -o out.
  4. Observed: Error: delivery refused: Some(NotFound). Node metrics: decdn_cache_origin_fetches_total = 0, decdn_node_pull_through_background_spawned_total = 0, decdn_serve_stream_rejected_cache_miss_total increments. The local fs origin is never read.

(Confirmed end-to-end: stubbing pull_authorized to true and skipping the window branch makes the exact same fetch succeed and pull from the fs origin.)

Proposed fix

  1. Client: in decdn_client_pull / crates/cli/src/commands/fetch.rs, sign and send the ADR 005 ephemeral client identity binding (EPHEMERAL_BINDING_NONCE, the client bind domain) with the buyer key, so the node can verify the request owns the named channel and pull_authorized passes legitimately.
  2. Related (same area): for whole-blob (offset-0) requests, when pull_through_origin (the node→node NodeOrigin) is attached via node_to_node_pull_through_enabled, the serve path (client.rs:1073) prefers the node→node window path over the node's own local cache.origin. An origin operator serving its own fs/http/s3 content reactively will therefore never reach the buffered local-origin populate. Consider consulting local configured origins before/independently of the node→node path, or decoupling the local-origin populate from node_to_node_pull_through_enabled.

Impact

Nodes cannot reactively serve content that exists only in their configured cache.origin to a paying client via decdn fetch; content must be pre-warmed into cache (e.g., ADR 022 publish → prefetch). The "operator hand-curates an fs/http/s3 origin, clients fetch on demand" flow is currently non-functional without this.

Activity

  1. added a commit that references this issue on Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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