Skip to content

feat(client,node): add PoolContext::new and bind_endpoint, bind the example lanes - #2358

Merged
alpergundogdu merged 1 commit into
mainfrom
claude/pool-context-constructor
Oct 7, 2026
Merged

alpergundogdu merged 1 commit into
mainfrom
claude/pool-context-constructor

Conversation

@alpergundogdu

Copy link
Copy Markdown
Contributor

Summary

Two release-readiness items for the decdn-client SDK.

The examples now work against testnet

I ran the download and stream examples against Arbitrum Sepolia, using a fresh 5 USDC pool. Every holder answered the probe as a holder, then refused every paid open with NotFound. decdn fetch of the same blob, from the same pool and the same node, succeeded in under a second.

The difference is the ADR 005 client binding. The CLI signs its own endpoint's node ID with the buyer key and attaches it to the lane; the examples attached nothing. A node that misses the blob in its cache refuses an unbound lane, because it may only pull from its origin for a buyer that proves it owns the pool. The crate guide's setup sequence never mentioned the binding, and sign_client_binding is hidden from the SDK docs, so an SDK user had no way to find it.

  • PoolContext::bind_endpoint(&endpoint, &bind_domain) signs and attaches the binding in one call.
  • Both examples bind every lane.
  • Step 5 of the crate guide now says to bind, and why.

After the fix, both examples fetched the Qwen2.5-7B manifest blob (6e9b67de…, 296,581 bytes) with zero lane faults. The output is byte-identical to decdn fetch's copy, and pool list shows the lanes' payments recorded.

PoolContext constructor

  • PoolContext::new(pool_id, deposit, signer, voucher_domain) is a general constructor. A delegated signer, which holds no BuyerPoolState, can use it. for_pool delegates to it.
  • PoolContext is #[cfg_attr(not(feature = "test-util"), non_exhaustive)], the same pattern as the fetch errors, so the roughly 30 test literals in the node and CLI stay as they are.
  • The node's one production literal (local_bookkeeping_ctx) uses the constructor.

Test plan

  • cargo clippy --workspace --all-targets with and without --all-features. The plain build proves no production literal outside the client remains.
  • RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-items
  • Public-API snapshot regenerated (new, bind_endpoint, the non_exhaustive marker)
  • cargo nextest run -p decdn-cli -p decdn-node -p decdn-client --lib. proof_wait::tests::stream_frames_count_stream_data_and_not_keep_alives failed once on a machine at load 35, then passed 3 out of 3 alone. That code is untouched here.
  • cargo test --doc -p decdn-client, and cargo test --no-run -p decdn-e2e --features anvil-e2e
  • download and stream examples run end to end on Arbitrum Sepolia, as above

🤖 Generated with Claude Code

…xample lanes

PoolContext gains a general constructor, PoolContext::new(pool_id,
deposit, signer, voucher_domain), which a delegated signer without a
pool row can use. for_pool delegates to it. The struct is non_exhaustive
outside the test-util feature, so workspace tests keep their literals.
The node's local bookkeeping context uses the constructor.

PoolContext::bind_endpoint signs the endpoint's node ID with the
context's signer and attaches the ADR 005 client binding in one call.
The download and stream examples attach none. A node that misses the
blob in its cache refuses an unbound lane with NotFound, so on testnet
both examples stalled while `decdn fetch` of the same blob succeeded.
They now bind every lane, and the crate guide's step 5 says to.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 7, 2026 12:19

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.

Copilot review overview

🟢 Approval recommended

The change is small, additive, behavior-preserving, matches an established in-crate pattern exactly, and all construction-site, import, and snapshot invariants were verified.

Review effort: Balanced
Findings: None

What changed in this PR

This PR adds two ergonomics/release-readiness items to the decdn-client SDK and fixes the shipped examples so they actually fetch against testnet. The root cause of the example failures was the missing ADR 005 client binding: a node that misses a blob refuses an unbound lane with NotFound, because it may only pull from its origin for a buyer that proves pool ownership. The CLI already signed and attached this binding inline; the examples attached nothing and sign_client_binding was #[doc(hidden)], so SDK users had no discoverable path to it.

Changes:

  • Add PoolContext::new(pool_id, deposit, signer, voucher_domain) as a general constructor (usable by delegated signers that hold no BuyerPoolState); for_pool now delegates to it, and the node's local_bookkeeping_ctx production literal uses it.
  • Add PoolContext::bind_endpoint(&endpoint, &bind_domain), a one-call wrapper over sign_client_binding + with_client_binding, and make PoolContext #[cfg_attr(not(feature = "test-util"), non_exhaustive)] so production code must use constructors while test literals stay.
  • Bind every example lane via the shared common::Buyer, update the crate-guide step 5 doc, and regenerate the public-API snapshot.
File Description
crates/​client/​src/​lib.rs Adds new, bind_endpoint, non_exhaustive gate, and refactors for_pool to delegate to new; updates docs.
crates/​node/​src/​node_origin/​pull_leg.rs Rewrites local_bookkeeping_ctx to use PoolContext::new (behavior-preserving; defaults match the removed literal).
crates/​client/​examples/​common/​mod.rs Adds bind_domain to Buyer and binds each lane via bind_endpoint, so both examples prove pool ownership.
crates/​client/​tests/​snapshots/​public_api__public_api.snap Records the non_exhaustive marker plus the new new and bind_endpoint entries.

I verified: bind_endpoint reproduces the exact binding derivation used in crates/cli/src/commands/fetch.rs:3504-3505 and crates/node/src/node_origin/mod.rs:1872-1873; new initializes all nine fields identically to the removed local_bookkeeping_ctx literal; the Address import in pull_leg.rs remains used; bind_node_id_domain is re-exported from decdn_incentive; and every out-of-crate PoolContext { .. } literal lives in a #[cfg(test)] module whose crate dev-deps enable decdn-client/test-util, so the non_exhaustive gate is satisfied.


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-code-quality

Copy link
Copy Markdown

Code Coverage Overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

The overall line coverage in commit f7aff55 in the claude/pool-context-... branch remains at 88%, unchanged from commit 41d268d in the main branch.

Show a line coverage summary of the most impacted files.
File main 41d268d claude/pool-context-... f7aff55 +/-
crates/node/src...gin/pull_leg.rs 92% 91% -1%
crates/client/s...c/connection.rs 98% 97% -1%
crates/client/src/scheduler.rs 95% 95% 0%
crates/client/src/lib.rs 92% 92% 0%

@alpergundogdu
alpergundogdu merged commit f2fc71d into main Oct 7, 2026
31 checks passed
@alpergundogdu
alpergundogdu deleted the claude/pool-context-constructor branch October 7, 2026 12:32
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.

2 participants