Repository navigation
feat!: scope node refusals to three classes and recover funding once per fetch - #2354
Conversation
Code Coverage OverviewLanguages: Rust Rust / code-coverage/cargo-llvm-covThe overall line coverage in commit 0d480cc in the Show a line coverage summary of the most impacted files.
Updated |
…nce per fetch The wire carries three open-time refusal classes: NotFound, Declined and Unfunded. Each refusal scopes to the node that sent it for the current fetch, so no single node can end a fetch. A client runs one funding recovery step per fetch, and only when every candidate is exhausted and at least one refused Unfunded. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… note Funding recovery repeats only after verified progress. A revoked key is Unfunded, and a node whose own upstream fill needs funding answers NotFound. The all-declined error names the collected reasons. Drop the post-eviction metric from the registry and dashboard, and fix the EvictedSinceProbe doc. Co-Authored-By: Claude Opus 5.5 <[email protected]>
StreamError is NotFound, Declined, Unfunded and VoucherRejected. The node maps its finer serve reasons onto the classes and keeps them in its per-reason metrics. The client and the node pull leg classify a refusal from its class alone, so no refusal reports a degraded node. The post-eviction probe metric goes with the code that fed it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A spent or expired signer, a lane inside its expiry margin, and a Closing pool refuse Unfunded to a proven requester; a Closing pool answers anyone else NotFound. A foreign namespace and a range past this node's size claim refuse Declined. A withdrawn hash keeps its eviction reason when the origin-only probe reads it as absent. A node whose own wallet cannot fund a buyer pool ends its fill "funding needed" and answers NotFound. Adds decdn_serve_stream_rejected_pool_closing_total. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The size-ceiling refusal that bars a lane from pull-through reaches the client as the Declined class. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… needed A node now refuses a spent capability signer Unfunded, so a delegated fetch on it ends "funding needed". The message tells the owner to top up or issue a capability for a new signer key, since registered terms are write-once. Co-Authored-By: Claude Opus 5.5 <[email protected]>
3623813 to
a7dcef7
Compare
…ed set A Declined refusal, or a mid-stream voucher rejection that no bundle heals and that names no funding reason, declines its node for the rest of the fetch. A funding rejection acts as Unfunded from its node. Only local faults end a fetch. When every known node declined, the fetch ends at once with "no node will serve this", naming the reasons collected; otherwise a priced-out set ends "funding needed" and an empty one not-found. The chain read that explained a drained signer's NotFound goes: the node now answers such a signer Unfunded. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # crates/cli/src/commands/bundle_pull.rs # crates/cli/src/commands/fetch.rs # crates/client/src/driver.rs # crates/client/src/fault.rs # crates/client/src/first_open.rs # crates/client/src/lib.rs # crates/client/src/scheduler.rs # crates/client/src/source.rs # crates/client/src/source_set.rs # crates/node/src/handlers/client/mod.rs # crates/node/src/handlers/client/outcome.rs # crates/node/src/metrics.rs # crates/node/src/node_origin/mod.rs # crates/node/src/node_origin/pull_leg.rs # crates/node/tests/node_origin_pull.rs # crates/protocol/src/client.rs # monitoring/dashboard-delivery.json # monitoring/grafana-dashboard.json
A lane never adds funds. A source priced out or refusing Unfunded waits, and only the exhausted candidate set runs one funding recovery step under a progress rule: the first step is free, a further one needs a newly verified byte. A self-funded owner tops up, or opens a new pool when the current one reverts PoolNotOpen and runs the remaining work against it. A lane that a funding refusal ends keeps its unpaid credit-window span, and its next drive bills it. A delegated fetch takes a swappable CredentialSlot: a swap retires the old-key lanes at a voucher boundary, the fetch publishes a local RunningLow signal, and the exhausted set waits for a swap before ending with a typed FundingNeeded (NewCapability or PublisherPool). ADR 003 and ADR 039 describe both. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A recovery step on a pool that already holds its working deposit runs a topUp gas estimate: PoolNotOpen opens a replacement, anything else settles so the stale nodes are asked again. Concurrent node fills share one step, the first open runs the delegated branch, a swap that came early counts under the progress rule, and the delegate's cap counts the key's recorded spend. Owed spans survive a failed merged gap and a faulted bill, and re-delivered bytes report no progress. ADR 003 says an owed span stays unpaid when its lane does not run again. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The node's recovery-step counters become decdn_node_pull_recovery_step and decdn_node_pull_recovery_step_refused. The buffered fill counts the bytes its store gained toward the progress rule, so a long pull recovers again after verified progress. ADR 005, ADR 039 and the bundle appendix scope Declined to its hash and park Unfunded sources until a recovery step. Prose that described the removed in-lane top-up is rewritten. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # crates/client/src/driver.rs # crates/client/src/driver/tests.rs # crates/client/src/lib.rs # crates/node/tests/client_loopback.rs # crates/node/tests/node_origin_pull.rs # crates/protocol/src/client.rs
There was a problem hiding this comment.
🔵 Needs a closer look
It is a wire-breaking protocol change spanning node, client, and CLI with intricate funding-recovery, owed-tail, and credential-swap semantics whose correctness hinges on cross-crate invariants that warrant final human review.
0 open findings
What changed in this PR
This PR collapses the on-wire StreamError enum from eight delivery-side codes down to three open-time refusal classes — NotFound ("not now, try others"), Declined ("will not serve this hash this fetch"), and Unfunded ("not at the current deposit/signer capability") — plus the existing mid-stream VoucherRejected. It then rewires every side of the paid-pull path to that smaller vocabulary: the node maps each finer ServeRejectReason to one class (keeping the detail only in per-reason metrics, and speaking Unfunded only to a proven requester), the client classifies refusals so one node's private policy can no longer end a fetch for everyone, and funding recovery is reworked so a lane never tops up itself — only the exhausted candidate set runs one bounded recovery step per newly-verified byte. It also adds credential-slot key swapping, owed-tail (option B) span tracking so a resumed lane re-bills delivered-but-unpaid bytes, and bundle-pull re-run on a replaced pool. The reactive_topup metric is renamed to recovery_step, and the ADRs/docs are updated to match. This closes the #2338 hang where a drained capability looked like a cache miss and retried until timeout.
Changes:
- Reduce
StreamErrortoNotFound/Declined/Unfunded/VoucherRejected; map node serve-reject reasons onto the three classes and gateUnfundedbehind requester proof. - Rework client funding recovery (exhausted-set-driven step, progress rule, owed-tail re-billing, credential slots) and add pool-replacement re-run in bundle pull.
- Rename
reactive_topupmetrics torecovery_step, add thepool_closingserve-reject metric, and update ADRs 005/039/003 (and dependents) plus the runbook.
| File | Description |
|---|---|
crates/protocol/src/client.rs |
Collapses StreamError to the three open-time refusal classes; rewrites the enum/field docs accordingly. |
crates/protocol/src/client/tests.rs |
Updates frozen variant-order and domain-split tests to the new variant set. |
crates/protocol/tests/snapshots/public_api__public_api.snap |
Regenerated public-API snapshot for the reduced enum. |
crates/node/src/handlers/client/mod.rs |
Maps each ServeRejectReason to one wire class; adds PoolClosing. |
crates/node/src/handlers/client/dispatch.rs |
Adds pool-closing and capability-expiry admission gates (proven ⇒ Unfunded, else NotFound). |
crates/node/src/node_origin/ranged_pull.rs |
Adds Unfunded run outcome and exhausted-set recover() driving FundingNeeded. |
crates/node/src/metrics.rs |
Adds serve_stream_rejected_pool_closing counter; renames reactive_topup → recovery_step. |
crates/client/src/fault.rs |
Rewrites classify() so only local faults/exhausted-set stops are fatal; funding reasons ⇒ Unaffordable. |
crates/client/src/pacer.rs |
Simplifies BudgetPacer to Draw/Done/Refuse; removes self top-up state. |
crates/client/src/ledger.rs |
Adds owed-tail note_unpaid/take_unpaid/merge_spans for re-billing delivered-but-unpaid spans. |
crates/incentive/src/pool_open_error.rs |
Adds PoolNotOpen error marker and is_pool_not_open revert detection. |
crates/client/src/buyer_pool.rs |
Adds pool_accepts_funds gas-estimate probe and PoolNotOpen handling in top_up. |
crates/cli/src/commands/bundle_pull.rs |
Adds replaced_pool/merge_passes to re-run a bundle pull once on a replaced pool. |
crates/cli/src/commands/cli_sources.rs |
Adds credentials() building a zero-wait credential slot seeded with prior per-signer spend. |
docs/runbook.md, ADRs (005/039/003/011/…) |
Rewrites refusal/funding-recovery prose and metric names to the new model. |
🧠 Review effort: Balanced
Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.
# Conflicts: # adr/003-payments.md # adr/005-protocol.md # crates/common/src/cli/fetch.rs
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Bundle entries share one RecoveryGate and one PeerHealth, but each entry judged a sibling's step only by its own deposit view. Three paths ended the whole pull "funding needed" while a sibling's step had already answered it: - A sibling's settle step leaves the deposit where it was, so a caller blocked on the step lock saw no raise and hit the progress rule. The gate now counts top-up and settle steps; a caller that has seen fewer takes one more pass and no step. It also keeps the deposit the last step reached, so a caller whose view lags a top-up's credit takes it. - swap_step took the step before it checked the generation, so the second of two concurrent delegated callers got NoProgress. It now hands a sibling's swap on without a step. - An entry that built no lane exhausted at deposit zero, against a source a sibling priced out at the real deposit. It stepped at zero, and its own CliSources held no pool id, so the run's free step failed with "no payment lane is built". The step now runs at the deposit the source was priced out at, and RunFunding holds the pool id for the run. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…olNotOpen A fill that waits on a sibling's recovery top-up turned its error into a plain anyhow string, so a PoolNotOpen revert reached every waiter as a local fault while only the fill that spawned the top-up replaced the pool. A waiter now joins the replacement open and reports the new pool. The "every joined topUp failed" error keeps the marker too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- PoolExhausted and SignerCapExhausted: the open-time equivalent is Unfunded to a proven requester, not NotFound (protocol docs, ADR 005). - Unfunded parks a source until a recovery step; it does not remove it (protocol docs, ADR 037). - Recovery::ToppedUp covers the settle step; Unavailable no longer claims a full pool. - FillOutcome, MissPath, the pool-open LocalPullFault rationale and the negative-cache comment name the classes the node actually sends. - ADR 039: the node pull leg refuses with NotFound; a partial holder's Declined bars pull-through only. - ADR 011 links the VoucherRejected semantics section by name; the unpaid span is at most one credit window; drop the stale "seven reasons" counts. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A node answers a request on a Closed pool, or on a pool it has no record of, with NotFound: it cannot tell either from an RPC fault or a lagging chain view. Neither buyer read its own pool before reuse, so a pool the owner key closed elsewhere, or that anyone reclaimed, failed every fetch as not-found and never reached a recovery step. - The CLI reads its tracked pool once per run, before the first lane build, and adopts or opens another pool when the chain shows it Closing or Closed. A failed read, or a pool with no record yet, keeps the row, so a lagging RPC never escrows a second deposit. - The node's hourly reclaim sweep drops the row of a pool someone else already reclaimed. - ADR 005 moves no-record and Closed pools to the NotFound row; ADR 003 says the buyer reuses its pool only while it is open. ADR 003 and architecture.md also scope the "adds funds only through the recovery step" claim to refusals: the low-water refill at a lane build reads only the buyer's own pool, so no node can start it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…opped drive - A wire Declined, or a voucher rejection that acts as one, removes the node from that hash only (ADR 005). It also cooled the node in the PeerHealth every bundle entry shares, and stamped a failure in its peer-store record. A node that leaves the hash now does neither; a partial holder's pull-through bar still cools, which backs off a holder that declines every block. - pool_accepts_funds read any estimate failure but PoolNotOpen as open, with no log, so an RPC fault on a closing pool settled instead of replacing it. It now reads the pool's status as a fallback, and warns with both errors when that read fails too. - drive took the lane's owed spans at its start and put them back only on an error. The node's pull leg drops a drive on cancel, which lost the spans. An OwedSpans guard now notes them back on any end before billing reaches them, from the failed gap's paid frontier on an error and from the gap in flight on a drop, as the scheduler's cancel does. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rdict - A source that declined this blob no longer counts as priced out: a top-up cannot help it, so a set where it is the only priced-out source ends not-found instead of running a funding step. - One rule, CredentialView::funding_cause, names why a delegated fetch needs a new capability. The acquire loop lacked the first open's "a cap with nothing left is spent" clause, so with no work priced yet it named the wrong cause. - CredentialSlot::new and swap refuse a key the capability does not name (CredentialMismatch); every voucher it signed would be refused. - with_swap_wait sets the wait on the shared slot instead of forking a new one, so a clone taken before it keeps watching the same slot. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… gaps - The ranged pull's recovery seam returns why a step lets no source be asked again. A step that failed on this node's own fault ends the assembly RecoveryFailed, not "funding needed ... no recovery step can raise it", which sent operators the wrong way. The outcome-to-result mapping moves into assembly_result. - node_step names which of "no byte verified" and "the step could not add funds" ended a fill. - The CLI warns when a buyer-store read fails while it seeds a delegated key's recorded spend (which then counts from zero) or sizes a settle step's deposit (which then is estimated). - Tests: next_pass runs a replaced pool's work again at most once and never for a stdout stream; both full-closing-pool tests now prove the replacement open ran; the wire-mapping test lists every NotFound reason; a block only an Unfunded source covers takes a recovery step. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…trics (#104) * feat(monitoring): follow decdn's refusal classes and recovery-step metrics decdn/decdn#2354 renames the node's reactive top-up counters to recovery step counters, adds a pool-closing serve refusal counter, and drops the post-eviction probe metric. The delivery and node dashboards follow. Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(monitoring): describe the refusal panels by decdn's three wire classes decdn#2354 replaced the per-reason refusal codes with NotFound, Declined and Unfunded, so the two "Serve refusals by reason" descriptions named codes the node no longer signs. Map each reason to its class, as ServeRejectReason::wire_error does. Drop the stale sibling count from "Unattributed stream failures" (it said 29; the expression subtracts 31, and the node's INBOUND_FAILURE_REASONS test holds the list). Describe the pull leg's pool plumbing panel, and log the change in the chart CHANGELOG. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Ant Somers <[email protected]>
Why
One node's refusal could end a fetch for the whole network. An operator's local origin denylist answers
OriginBlacklisted, and the client maps that toFault::Fatal(Command)incrates/client/src/fault.rs, so one operator's private policy stopped the fetch everywhere. A node's private floorMcould also drive client top-ups. And refusals that look like misses made a drained capability hang the CLI (#2338).Closes #2338.
What
1. ADR (58fd872, 3c39503)
EvictedSinceProbewas never slash evidence. The ADR text and the Rust doc comment that implied it are fixed.architecture.mdfollow the new classes.Closedpool, answersNotFound: the node cannot tell either from an RPC fault or a lagging chain view.Unfundedcovers aClosingpool. ADR 003 says the buyer reuses its pool only while it is open (ac3ac2b).2. Wire classes (e59969e)
StreamErrorcarriesNotFound(not now, try others),Declined(this node will not serve this hash during this fetch) andUnfunded(this node will not serve at the current pool deposit or signer capability).Overloaded,BlobTooLarge,InternalError,EvictedSinceProbe,OriginBlacklisted,HashBlacklistedandInsufficientDepositleave the wire.VoucherRejected { reason, bundle }stays for the watermark self-heal.3. Node serve mapping (ae79abc)
ServeRejectReasonmaps to one class. The finer reasons stay in the node's per-reason metrics.NotFound.Unfundedis spoken only to a proven requester. Anyone else getsNotFound, so pool and signer state stay unmappable.4. Client classification and exhausted-set rules (ef97f52, e76091f, a7dcef7)
Declinedremoves the node for that hash only. In a bundle pull the node stays a candidate for the other entries.Unfundedparks the node at the current funding until a recovery step. The recovery state spans the whole pull.Unfunded. Other unhealable voucher rejections act asDeclined.Unfunded;Declined;5. Funding recovery (aeded86)
topUprevertsPoolNotOpen, it opens a new pool, makes it current in the local store and runs the remaining work against it. The old pool is never reopened or reclaimed.CredentialSlotin the SDK holds the key and itsdcap1capability, and the application can swap both at any time.FundingEvent::RunningLow { headroom, projected_need, expires_at }locally, with no chain read.FundingNeeded::NewCapability { pool, cause }. If the capability still covers the work, it ends at once withFundingNeeded::PublisherPool { pool }.6. Review fixes (fd49997, a8c2930)
topUp(1), with no transaction sent.PoolNotOpenopens a replacement. Anything else settles: the step returns the current deposit, and the settle window asks the stale nodes again.7. Second review round
A multi-agent review (code, silent failures, tests, comments, types) found these. Each fix has a test that fails when the fix is taken out.
RunFundingholds the pool id for the run.NoProgress. The gate now counts its top-up and settle steps and keeps the deposit it reached, so a caller that has not seen a step gets one more pass and takes no step of its own.swap_steptook the step before it checked the generation, so the second of two concurrent delegated callers ended needing a new capability. It now hands a sibling's swap on.PoolNotOpenjoins the replacement open instead of failing as a local fault.ClosingorClosedone. A failed read, or no record yet, keeps the row, so a lagging RPC never escrows a second deposit. The node's reclaim sweep drops a pool someone else reclaimed.Declinedthat removes a node from a hash no longer cools it in the health the bundle's entries share, or stamps its peer-store record.pool_accepts_fundsfalls back to a status read when thetopUp(1)estimate fails for another reason, and warns when both fail.drive(the node's pull leg cancels it) notes its owed spans back through a drop guard.RecoveryFailed, not "funding needed".CredentialSlot::newandswaprefuse a key the capability does not name (CredentialMismatch).with_swap_waitsets the wait on the shared slot instead of forking it.CredentialView::funding_cause, names the capability cause for the first open and the acquire loop.NotFoundfor open-time funding refusals, removal onUnfunded, or "funds only through recovery" now match the code.8. Metric rename (a8c2930)
decdn_node_pull_reactive_topup_totaldecdn_node_pull_recovery_step_totaldecdn_node_pull_reactive_topup_refused_totaldecdn_node_pull_recovery_step_refused_totalMerge
Merged with
mainat cdd1db5 (#2369), then at 6e92b21 (e9bf9a4). Wheremainedited a shim this branch deletes, the deletion stands. #2374's write-once capability wording is merged into ADR 003 § Revocation, ADR 005 and the--capabilityhelp.Testing
cargo fmt --all -- --checkcargo clippy --workspace --all-targets --all-features: no warnings.RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-itemscargo nextest run --workspace --exclude decdn-e2epassed 4709, andcargo nextest run -p decdn-e2e --features anvil-e2epassed 98.cargo nextest run -p decdn-client -p decdn-cli -p decdn-node: 3194 passed.cargo nextest run -p decdn-e2e --features anvil-e2eforcli_fetch_topup,cli_fetch_multi_source,cli_fetch_delegatedandcli_pool_reclaim_precheck: 7 passed. The full anvil suite was not rerun.decdn-clientpublic_apisnapshot regenerated forCredentialMismatchand the fallibleCredentialSlot::new/swap.Key new tests:
no_verified_byte_since_the_last_step_ends_funding_neededverified_bytes_since_the_last_step_allow_anothera_long_pull_recovers_again_after_verified_progressthe_same_lane_bills_its_owed_tail_after_a_funding_refusala_new_lane_resumes_at_the_delivered_frontier_and_owes_nothinga_fetch_finished_by_other_lanes_leaves_the_owed_span_unpaidthe_resumed_leg_does_not_re_pay_for_delivered_bytes(node)a_full_open_pool_settles_without_a_top_up(CLI and node)a_full_closing_pool_is_replaced(CLI and node)a_full_pool_refused_by_a_stale_upstream_settles_then_is_servedconcurrent_steps_share_one_recovery_top_upa_recovery_step_shares_a_siblings_landed_top_upa_swap_mid_stream_retires_the_old_lane_paid_and_resumes_under_the_new_keya_swap_inside_the_wait_resumes_the_fetchno_swap_inside_the_wait_ends_needing_a_new_capabilitya_pool_refusal_under_a_healthy_capability_names_the_publisher_poolspend_recorded_at_another_provider_counts_toward_the_caprunning_low_fires_below_the_work_plus_one_credit_windowa_delegated_first_open_ends_with_a_typed_funding_neededa_first_open_sees_a_sibling_entrys_stepre_delivered_bytes_report_no_progressan_entry_with_no_lane_takes_a_siblings_top_up,an_entry_with_no_lane_steps_at_the_siblings_deposita_siblings_settle_step_answers_a_caller_that_has_not_seen_it,concurrent_callers_share_one_top_up,concurrent_callers_share_one_swapfills_waiting_on_a_top_up_into_a_closing_pool_join_its_replacement,the_reclaim_sweep_drops_a_pool_someone_else_reclaimeda_tracked_pool_is_reused_only_while_the_chain_shows_it_opena_decline_does_not_cool_the_node_for_a_sibling_entry,a_declined_source_priced_out_too_takes_no_funding_stepa_dropped_drive_keeps_its_owed_span,an_unreadable_estimate_falls_back_to_the_pools_statusa_key_its_capability_does_not_name_is_refused,one_rule_names_the_capability_causea_replaced_pool_runs_the_work_again_at_most_once,a_block_only_an_unfunded_source_covers_takes_a_recovery_step,stacked_markers_classify_in_a_fixed_orderFollow-ups
probe_post_evictionquery;pool_closingpanel;decdn fetch -o -does not rerun on a replaced pool. It ends, naming the new pool.NotFoundfrom upstreams with no lane on it, until they refuseUnfundedor the sweep reclaims the pool after its dispute window.signer_cap_exhaustedcounter;VoucherRejectedcan travel mid-stream;#[doc(hidden)] pubRecoveryGatesurface the node uses;Closingpool.🤖 Generated with Claude Code