Skip to content

fix(client,cli): stop a fetch on a spent capability signer instead of retrying - #2349

Merged
thiras merged 2 commits into
mainfrom
fix/2338-drained-capability-fails-fast
Oct 7, 2026
Merged

thiras merged 2 commits into
mainfrom
fix/2338-drained-capability-fails-fast

Conversation

@thiras

@thiras thiras commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

What

A delegated decdn fetch / bundle pull whose signer had spent its registered cap retried until its stop policy gave up. A node refuses such a signer at admission (SignerCapExhausted) and answers with the same NotFound code as a cache miss, so the client cooled the holder and tried again. This implements the issue's Option 1: no wire change.

  • PeerSource::with_signer_check(&dyn SignerRegistry): on an open-stage NotFound whose signed body carries a non-zero rate, the lane reads its signer's getAuthorization row, bounded by the open deadline, and turns a registration that cannot pay one chunk at that rate into SignerCapDrained.
  • Scope follows what the read proves:
    • expired, or nothing left of the cap → no node can serve the signer → Fatal(Command);
    • some headroom below one chunk at this node's rate → only that node is barred for the blob (a cheaper node can still serve). Once every node is barred, the item ends with NoSourceServesSigner (Fatal(Item)), carrying the drained cause.
  • A failed or slow read leaves the refusal as it arrived and logs at info (sanitized).
  • The CLI wires the check on delegated lanes only, and annotate_delegated_exhaustion names the remedy a write-once registration leaves: a capability for a new signer key. The same text now covers a mid-stream SignerCapExhausted and a registered signer's SpendingCapExhausted.
  • SignerAuthorization moves from decdn-node to decdn_incentive::payment_pool, so the node's admission gate and the client's check share one covers predicate.

Closes #2338

Reviewer notes

  • Start with confirm_refusal / signer_cap_drained in crates/client/src/source.rs, then the signer_drained bar in source_set.rs and classify in fault.rs.
  • The client floor is one chunk at the signed rate — a lower bound on the node's floor. A node with the ramp off (wider first window) or a projection that counts spent high can refuse a signer with more headroom; the lane then keeps the plain NotFound, as before.
  • Expiry is judged on the client clock, not chain time.
  • Deliberately unchanged: self-owned pools get no check; no per-signer read cache (a covering signer costs one eth_call per rated NotFound).
  • Public API: SignerRegistry, SignerCapDrained, NoSourceServesSigner, PeerSource::with_signer_check (snapshot regenerated).
  • ADR 003 (§ Pool solvency "Client confirm" bullet, remedy text), ADR 005 (NotFound exception, SignerCapExhausted row), ADR 016 (caller column).

Verification

  • cargo fmt -- --check
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo nextest run -p decdn-incentive -p decdn-client -p decdn-cli -p decdn-node — 3409 passed
  • RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-items
  • cargo nextest run -p decdn-client --features public-api-test --test public_api (snapshot regenerated)
  • cargo nextest run -p decdn-e2e --features anvil-e2e -E 'binary(cli_fetch_delegated)' on rebuilt binaries — 3/3 passes. The new clamp-journey step (re-fetch on the spent signer must fail within 30 s with the new-key remedy) fails without the fix: it hits the 30 s timeout.
  • New loopback test a_drained_signer_refused_at_admission_is_named_by_the_signer_check: a real handler refuses, and the checked lane yields SignerCapDrained while an unchecked one keeps NotFound.
  • contracts/ changed — n/a
  • User-visible change: CHANGELOG.md entry added
  • Design change: ADR 003/005/016 updated
  • PR title uses an allowed type with a lowercase subject

🤖 Generated with Claude Code

… retrying

A node refuses a registered signer whose cap - spent cannot cover its
serve floor at admission, and answers with the same NotFound code as a
cache miss. A delegated `decdn fetch` / `bundle pull` cooled the holder
and retried until its stop policy gave up: in the cli_fetch_delegated
clamp journey every retry hung for the 60 s test timeout.

PeerSource takes an optional SignerRegistry (with_signer_check). On an
open-stage NotFound whose signed body carries a non-zero rate, it reads
the signer's getAuthorization row, bounded by the open deadline. A
registration that cannot pay one chunk at that rate becomes
SignerCapDrained:

- expired, or nothing left of the cap: no node can serve the signer,
  so the command ends;
- some headroom below one chunk at this rate: only the refusing node is
  barred for the blob, since a cheaper node can still serve. Once every
  node is barred the item ends with NoSourceServesSigner.

A failed or slow read leaves the refusal as it was and logs at info,
sanitized. The CLI wires the check on delegated lanes only, and names
the remedy a write-once registration leaves: a capability for a new
signer key (also for a mid-stream SignerCapExhausted, and for a
registered signer's SpendingCapExhausted).

SignerAuthorization moves from decdn-node to
decdn_incentive::payment_pool, so the client and the node test a
registration with one predicate. ADR 003, 005 and 016 describe the
client confirm. No wire change.

Closes #2338

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 7, 2026 08:14
@thiras thiras self-assigned this Oct 7, 2026

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

🟡 Changes recommended

The recovery guidance overstates what provider-specific and mixed refusals prove.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Addresses #2338 by detecting spent capability signers during delegated downloads without changing the wire protocol.

Changes:

  • Confirms admission refusals against on-chain signer authorization.
  • Distinguishes provider-specific failures from item- and command-wide stops.
  • Shares authorization logic and adds CLI guidance, tests, and documentation.
File Description
crates/​node/​tests/​client_loopback.rs Tests admission-refusal confirmation.
crates/​node/​src/​pool_view.rs Uses shared authorization type.
crates/​node/​src/​payment_settlement.rs Updates authorization import.
crates/​node/​src/​handlers/​client/​dispatch.rs Updates authorization import.
crates/​incentive/​src/​payment_pool.rs Houses shared authorization logic and tests.
crates/​e2e/​tests/​cli_fetch_delegated.rs Tests prompt failure for spent signers.
crates/​client/​tests/​snapshots/​public_api__public_api.snap Records new public APIs.
crates/​client/​src/​source.rs Adds bounded signer checks.
crates/​client/​src/​source_set.rs Tracks signer-specific provider exclusions.
crates/​client/​src/​lib.rs Exports new types.
crates/​client/​src/​fault.rs Classifies signer-exhaustion scope.
crates/​cli/​src/​commands/​fetch.rs Enables delegated checks and recovery guidance.
crates/​cli/​src/​commands/​bundle_pull.rs Tests bundle failure scope.
CHANGELOG.md Documents user-visible behavior.
adr/​016-contract-interactions.md Documents client authorization reads.
adr/​005-protocol.md Clarifies refusal handling and remedies.
adr/​003-payments.md Defines client confirmation behavior.

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

Comment thread crates/cli/src/commands/fetch.rs Resolved
@github-code-quality

github-code-quality Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Code Coverage Overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

The overall line coverage in commit 8011c0c in the fix/2338-drained-cap... branch remains at 88%, unchanged from commit 61f7df0 in the main branch.

Show a line coverage summary of the most impacted files.
File main 61f7df0 fix/2338-drained-cap... 8011c0c +/-
crates/node/src/dht/publish.rs 92% 92% 0%
crates/cli/src/...mmands/fetch.rs 76% 76% 0%
crates/client/src/scheduler.rs 95% 95% 0%
crates/node/src...ent/dispatch.rs 84% 84% 0%
crates/node/src...s/client/mod.rs 95% 95% 0%
crates/client/src/streamer.rs 91% 91% 0%
crates/client/src/lib.rs 92% 92% 0%
crates/cli/src/.../bundle_pull.rs 82% 82% 0%
crates/node/src...ient/outcome.rs 98% 98% 0%
crates/client/src/source.rs 92% 93% +1%

Updated October 07, 2026 08:39 UTC

…one rate

A SignerCapDrained read at one provider's rate, a mid-stream
SignerCapExhausted, and the NoSourceServesSigner stop prove only that
the refusing provider's floor is not covered; other providers may be
barred for absence or size. The remedy said no node could be paid for
any of them.

Only an expired registration, or one with nothing left of its cap, is
now named as shutting out every provider. Every other drain says a
provider at a lower rate may still serve while headroom remains, and
names a new signer key as the way to raise the limit. The stop's
Display no longer claims every provider refused the signer. Failure
scopes are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@thiras
thiras merged commit 2e091fe into main Oct 7, 2026
30 checks passed
@thiras
thiras deleted the fix/2338-drained-capability-fails-fast branch October 7, 2026 08:42
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.

cli: a fetch with a drained capability retries until its timeout instead of failing

2 participants