Repository navigation
feat(protocol,node,client-pull): tell the proven pool owner its deposit is short (#2013) - #2093
Conversation
…it is short (#2013) A serving node refuses a new stream once a pool's on-chain `remaining − M` cannot cover a credit window, and reports that as `NotFound` alongside real misses so a prober cannot map pool balances (#1520). But `M` is node policy, not a protocol constant: a buyer that under-estimates one node's `M` re-opens with a deposit the node still refuses, sees `NotFound`, reassigns the range, and the pull dies as "held by no reachable provider" — even when the buyer could afford the real floor. Adopt issue #2013 option 2: speak a signed refusal reason to the authenticated lane owner, keep `NotFound` for probers. - protocol: add the delivery-side `StreamError::InsufficientDeposit`, appended last to keep discriminants frozen. - node: `ServeRejectReason::InsufficientDeposit` now maps to the true wire code instead of collapsing to `NotFound`. The floor gate is reached only past the lane-ownership proof (a known lane keyed to a verified signer holding an owner-signed capability), so its audience is the proven owner — which already reads on-chain `remaining` — never an unauthenticated prober. The per-signer gates (`SignerFloorAtCap`, `SignerCapExhausted`) and the unconfirmed-pool gate stay collapsed. `node_origin::classify_refusal` scores the new code `Transient` (our own upstream pool short of the peer's `M`, no peer fault). - client-pull: the driver routes an open-time `InsufficientDeposit` into its fund-and-retry loop — tops the deposit up toward the buyer's own `working_deposit` ceiling and re-opens — and settle-waits it after a top-up like a stale resume. `retry_disposition` fails it over (a smaller-`M` provider may admit). The buyer's ceiling is the sole clamp on how much a lying node can make it escrow, so the owner-only signal is money-safe. - cli: an `InsufficientDeposit` first-contact refusal no longer suppresses the peer via `record_failure` — it is our pool's shortfall, not the peer's fault. - adr 003/005: document the owner-scoped carve-out to #1520 and the owner-only binary-search residual on `M`. Co-Authored-By: Claude Opus 4.8 <[email protected]>
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The new is_insufficient_deposit predicate should ensure it only matches open-stage refusals, and ADR 005’s StreamError snippet is currently internally inconsistent with the protocol surface.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (3)
What changed in this PR
This PR adds an owner-scoped wire refusal (StreamError::InsufficientDeposit) so an authenticated pool owner can distinguish “pool can’t cover the floor/window” from a real cache miss, enabling the buyer to top up and retry without breaking the prober privacy goal.
Changes:
- Protocol: append
StreamError::InsufficientDepositand extend variant-order/domain-split tests. - Node: map the pool-floor admission refusal to
InsufficientDeposit(while keeping other privacy-collapsed gates asNotFound) and classify it asTransient. - Client-pull/CLI: route
InsufficientDepositinto the existing fund-and-retry loop and avoid penalizing the peer for an owner-fixable shortfall; update ADRs to document the carve-out.
| File | Description |
|---|---|
| crates/protocol/src/client.rs | Adds StreamError::InsufficientDeposit and updates ordering/domain-split tests and docs. |
| crates/node/tests/node_origin_pull.rs | Updates expectations/comments for owner-facing refusal code in same-lane miss tests. |
| crates/node/tests/client_loopback.rs | Updates loopback tests to expect InsufficientDeposit for proven-owner floor refusals. |
| crates/node/src/node_origin/mod.rs | Treats InsufficientDeposit as transient in upstream refusal classification/tests. |
| crates/node/src/handlers/client/mod.rs | Introduces ServeRejectReason::InsufficientDeposit wire mapping (non-collapsing) and clarifies collapse policy in docs/tests. |
| crates/node/src/handlers/client/dispatch.rs | Updates dispatch-path comments to reflect new owner-facing wire code. |
| crates/e2e/tests/pool_floor_ceiling_aggregate.rs | Updates e2e assertions/comments to expect InsufficientDeposit for proven-owner overflow refusal. |
| crates/client-pull/src/retry.rs | Ensures InsufficientDeposit triggers failover (after top-up loop gives up) and extends tests. |
| crates/client-pull/src/lib.rs | Adds is_insufficient_deposit predicate for routing refusal into top-up/retry behavior. |
| crates/client-pull/src/driver.rs | Adds driver handling to settle-wait / top-up-and-reopen on InsufficientDeposit; adds a driver test. |
| crates/cli/src/commands/fetch.rs | Avoids suppressing peers on InsufficientDeposit because it’s not peer fault. |
| adr/005-protocol.md | Documents the new refusal code and its lifecycle position. |
| adr/003-payments.md | Documents the owner-only floor-refusal carve-out and what it leaks (inequality bound only). |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Coverage reportTotal: 83.39% (was 83.37%, ▲ +0.02%) — 84526/101359 lines
History
|
…tage evidence; sync API + ADR snippets Address review on #2093: - `is_insufficient_deposit` now requires open-stage evidence (`UpstreamRefused::evidence().is_some()`). A legitimate `InsufficientDeposit` rides only in the signed open-stage `StreamResponse { ok: false }`; a protocol-violating bare mid-stream `StreamError::InsufficientDeposit` no longer drives the top-up loop. New test pins both directions. - driver test now builds a real open-stage refusal via `UpstreamRefused::open` (signed `ok: false` + ext), matching its doc, instead of `mid_stream`. - ADR 005: the illustrative `StreamError` snippet now lists `OriginBlacklisted` and `HashBlacklisted` (ADR 011) alongside the new `InsufficientDeposit`, so it matches the real wire surface. - regenerate the `decdn-protocol` public-API insta snapshot for the new variant. Co-Authored-By: Claude Opus 4.8 <[email protected]>


Closes #2013.
Decision
Issue #2013 needed a decision between three ways to close the buyer's
M-estimate gap. Per the issue thread we go with option 2: speak a signed refusal reason to the authenticated lane owner, keepNotFoundfor probers. Option 1 (keep the estimate) leaves a silent dead-end; option 3 (advertiseM) fails the trustless axiom (a self-declared counterparty number the buyer could over-trust into a capital-lockup grief).Problem
A serving node refuses a new stream once a pool's on-chain
remaining − Mcannot cover a credit window, and reports that asNotFoundalongside real misses so a prober cannot map pool balances (#1520). ButMis node policy, not a protocol constant. A buyer that under-estimates one node'sMre-opens with a deposit the node still refuses, seesNotFound, reassigns the range, and the pull dies as "held by no reachable provider" — even when it could afford the real floor.What changed
StreamError::InsufficientDeposit, appended last so postcard discriminants stay frozen.ServeRejectReason::InsufficientDepositnow maps to the true wire code instead of collapsing toNotFound. The safety argument is a code invariant: the floor gate is reachable only past the lane-ownership proof — a known lane keyed to a verified signer holding an owner-signed capability — so its audience is the proven pool owner (which already reads on-chainremaining), never an unauthenticated prober. The per-signer gates (SignerFloorAtCap,SignerCapExhausted) and the unconfirmed-pool gate stay collapsed.node_origin::classify_refusalscores the new codeTransient.InsufficientDepositinto its existing fund-and-retry loop (tops the deposit up toward the buyer's ownworking_depositceiling, then re-opens) and settle-waits it after a top-up like a stale resume.retry_dispositionfails it over. The buyer's ceiling is the only clamp on how much a lying node can make it escrow, so the owner-only signal is money-safe.InsufficientDepositfirst-contact refusal no longer suppresses the peer viarecord_failure(our pool's shortfall, not the peer's fault).InsufficientDepositreveals only the inequalityremaining − M < window, an owner-only, self-funded bound onM, neverMitself.Tests
an_insufficient_deposit_open_refusal_tops_up_and_reopens(buyer can afford the voucher, sogenuine_exhaustionrejects it — only the new route recovers);retry_dispositionfailover case.insufficient_deposit_speaks_its_true_code_but_signer_gates_stay_collapsed; updated the proven-owner floor-refusal loopback/e2e tests to expect the owner-facing code (they exercise exactly this scenario).Known residual (follow-up, not this PR)
The CLI single-source first-contact throwaway handshake open surfaces
InsufficientDepositas a truthful terminal rather than recovering it (it needstotal_bytesit can't get from a refused open). The issue's core case — a mid-fetch under-guess — recovers through the driver's re-open, and a first-contact refusal on a pool opened atworking_depositis the correct terminal anyway. A resumed-below-Mfirst contact could be recovered by a top-up-and-re-handshake; left as a follow-up.Full local gate:
cargo build --workspace,cargo clippy --all-targets --all-features(protocol/node/client-pull/cli/e2e),cargo fmt --check,RUSTDOCFLAGS=-D warnings cargo doc, andcargo nextest runfor protocol/client-pull/node/cli all pass;decdn-e2e --features anvil-e2ecompiles.🤖 Generated with Claude Code