Repository navigation
fix(node,client,cli): keep the credit ramp across back-to-back pulls and widen bundle lanes - #2176
Merged
Merged
Conversation
…and widen bundle lanes (#2168, #2169) #2168: a range-deduped bundle entry served through a cold two-leg miss pulled its complement (147 runs, median 11.6 MiB) at about 1 MiB/s. - Node: every new `cdn/client/v1` stream restarted the credit window at the one-chunk floor, on the serve loop and on the pull leg's `RampPacer`. Each lane now keeps an in-memory ramp-credit pool (`handlers/client/ramp.rs`). A stream takes the whole pool when it starts and uses `carried + own paid` as its ramp input on the serve loop, the cache-hit loop, the pull-leg `RampPacer.paid_carried` and the handshake `PrimeLeg`. A stream that ends fully paid returns `carried + own paid` just before `StreamEnd`; any other end forfeits it, so a payer that abandons stream after stream gets no more unpaid bytes than `paid / credit_ramp_divisor` plus one floor per stream. The pool caps at `credit_max × credit_ramp_divisor`, is never persisted, and the deposit guard and floor reservations still price the floor. - Client: `bundle pull` sized each provider lane once from the permits free at drive start. `RangeLane.grow` (`LaneGrowth`) lets `drive_range_lanes` add gap workers mid-drive, and bundle pull's `LaneGrant` hands it freed permits without waiting, up to `--max-lane-streams`. - Client: after a proof write fails, `terminal_after_write_failure` now reads past the `ChunkData` the node sent ahead of its `StreamError`. Any opening window wider than one frame (a carried ramp, or `credit_ramp_divisor = 0`) otherwise turned an `UnderFold` rejection into a transport error. A `StreamEnd` behind skipped data confirms nothing. #2169: a reveal whose send fails locally cannot reach the node — the ledger counts a reveal only after quinn accepted its whole frame. The trailing watermark comes from a payer process that exits after it sends reveals and before it persists them (a second Ctrl-C, SIGKILL, a timeout), e.g. a bundle pull that already persisted earlier entries on the same chain. ADR 003 and the lane/voucher docs now name that path, and a loopback test drives it with real reveals. ADRs 003, 005 and 037 describe the lane ramp-credit pool; ADR 005's "pauses all streams collectively" claim now matches the per-stream window the code enforces. Tests: ramp pool units (take/cap/return/forfeit/conservation), a handler test for an empty loaded lane, RampPacer and PrimeLeg carried-credit cases, a `client_loopback` back-to-back stream that opens at ~4 MiB unpaid where a fresh lane gets one chunk (fails without the carry), a `drive_range_lanes` growth test, a `LaneGrant` test, and the #2169 exit-before-persist heal test (which fails without the drain fix). Closes #2168 Closes #2169 Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Unbounded recovery draining and wire/content credit mismatches remain unresolved.
Review effort: Lite
Findings: 1
Open (2)
What changed in this PR
This PR preserves ramp credit across back-to-back pulls, widens bundle lanes dynamically, and improves recovery after failed voucher writes.
Changes:
- Adds per-lane credit pooling with forfeiture rules.
- Adds dynamic bundle lane growth.
- Updates recovery handling, tests, documentation, and changelog.
| File | Reviewed changes |
|---|---|
crates/node/tests/client_loopback.rs |
Adds ramp and persistence-recovery regression tests. |
crates/node/src/node_origin/pull_leg.rs |
Applies carried credit to pull pacing; wire/content units need conversion. |
crates/node/src/handlers/client/window.rs |
Passes carried credit into request windows; unit mismatch remains. |
crates/node/src/handlers/client/voucher.rs |
Updates lane initialization and related documentation. |
crates/node/src/handlers/client/serve_leg.rs |
Applies and returns ramp credit. |
crates/node/src/handlers/client/ramp.rs |
Implements lane ramp-credit pooling. |
crates/node/src/handlers/client/mod.rs |
Stores and exposes credit pools. |
crates/node/src/handlers/client/dispatch.rs |
Documents floor interaction. |
crates/node/src/handlers/client/delivery.rs |
Applies and returns credit for cache hits. |
crates/incentive/src/lane.rs |
Updates payment and under-fold documentation. |
crates/incentive/src/credit.rs |
Documents carried ramp input. |
crates/client/tests/snapshots/public_api__public_api.snap |
Updates the public API snapshot. |
crates/client/src/pacer.rs |
Adds carried credit to pacing; unit conversion and documentation remain unresolved. |
crates/client/src/lib.rs |
Adds recovery draining; skipped frames lack bounded byte validation. |
crates/client/src/driver.rs |
Supports dynamically growing range lanes. |
crates/cli/src/commands/fetch.rs |
Threads lane-growth hooks through fetch lanes. |
crates/cli/src/commands/bundle_pull.rs |
Grants dynamically released provider permits. |
crates/cache/src/fill_session.rs |
Documents carried credit and content frontiers. |
CHANGELOG.md |
Records fixes for issues #2168 and #2169. |
adr/037-regional-proxy-warming.md |
Updates pull-through ramp behavior. |
adr/005-protocol.md |
Corrects per-stream window documentation. |
adr/003-payments.md |
Specifies credit pooling and forfeiture. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Code Coverage OverviewLanguages: Rust Rust / code-coverage/cargo-llvm-covThe overall line coverage in commit 734dd46 in the Show a line coverage summary of the most impacted files.
Updated |
…l on carried content Review follow-up on #2176. - The recovery read that passes over in-flight ChunkData after a failed proof write now holds those frames to the request's promised wire length and the received-byte ceiling, the same limits next_chunk applies. A peer that sends past them fails the recovery read instead of streaming until the 5 s bound. - The pull leg's RampPacer and PrimeLeg paced on the carried ramp credit in wire bytes against content frontiers. They now take RampCarry::carried_content, which removes 1/128 for the bao parent nodes (at most 64 bytes per 16 KiB group), so the pull never runs past its content window. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…re-delivery refusals Review follow-up on #2176. - The lane ramp-credit pool counts paid content bytes. A fully paid stream returns the aligned content of its request, not its wire count. Content never exceeds the wire that paid for it, so the pool never overstates revenue, and the pull leg's RampPacer uses it with no derate. The 1/128 derate did not hold for small ranges, whose bao encoding carries the ancestor parents of the range. - A stream the node refuses before its first byte (no upstream, a withdrawn fill, a failed spawn) returns its carry whole. Only a stream that ends unpaid after its first byte forfeits it. - The recovery drain keeps the received-byte ceiling typed as BlobTooLarge, which is terminal, instead of folding it into the write error, and names the bound that tripped. - LaneGrowth hooks receive the number of waiting gaps, and the driver never adds more workers than that. - ADR 003/037 and CHANGELOG: per-stream stop wording, "unless another stream took the pool first", content units, the pre-delivery return. Tests: loopback tests for a mid-blob proof-write failure that reads past in-flight frames to the typed rejection, and for a StreamEnd behind skipped frames failing the leg (both fail without the drain); an abandoned stream forfeiting its lane's ramp (fails if abandonment returns the carry); a pre-delivery refusal returning the carry. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Sep 27, 2026
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
#2168: a range-deduped bundle entry served through a cold two-leg miss pulled its complement at ~1 MiB/s.
crates/node/src/handlers/client/ramp.rs). Every new stream restarted the credit window at the 1 MiB floor, on both the serve loop and the pull-legRampPacer. Now:carried + own paid. This covers the serve loop, the cache-hit loop,RampPacer.paid_carriedandPrimeLeg.carried + own paidbeforeStreamEnd. Any other end forfeits the credit, so abandoning streams one after another cannot recycle it.credit_max × divisor, is kept in memory only, and resets on restart.RangeLane.grow(LaneGrowth) letsdrive_range_lanesadd gap workers. Bundle pull'sLaneGranthands it freed per-provider permits without waiting, up to--max-lane-streams.ChunkDataalready in flight ahead of the node'sStreamError. Any opening window wider than one frame used to turn anUnderFoldheal into a transport error: a carried ramp does this, andcredit_ramp_divisor = 0already did.#2169: the suspected path (a reveal whose send fails locally but still reaches the node) is unreachable.
PoolLedger::metercounts a reveal only after quinn accepted its whole frame.process::exit), SIGKILL, or a timeout during a bundle pull that already persisted earlier entries on the same chain.ADRs 003, 005 and 037 now describe the pool and its forfeit rule. ADR 005's claim that the node pauses all of a lane's streams together is corrected to the per-stream window the code enforces.
Test plan
cargo clippy --workspace --all-targets -D warnings,cargo doc -D warnings, pre-commitcargo nextest run -p decdn-client -p decdn-node -p decdn-cli -p decdn-incentive -p decdn-cache: 3377 passed before the review fix;-p decdn-client -p decdn-node -p decdn-clirerun after it: 2627 passed-p decdn-e2e --features anvil-e2e): 69 passeda_back_to_back_stream_opens_at_the_lanes_banked_rampfails without the carry (1 MiB vs 4.2 MiB unpaid)a_process_that_exits_before_its_last_persist_heals_in_one_rejectionfails without the drain fixbundle pull --hash 9194000d… --namespace 1. Expect entry7cbb4846…well above 1 MiB/s, and bclserve_streamlegs above the floor from the second run on. Watchdecdn_serve_stream_voucher_rejected_total.Closes #2168
Closes #2169
🤖 Generated with Claude Code