Repository navigation
fix(client): take a pinned pull's size from a probe, not a dropped stream - #2634
Merged
Merged
Conversation
…ream (#2619) A fetch pinned with `--node-id` and no known size read its first size claim from the header of a whole-blob paid open, then dropped the stream. The node wrote up to a credit window into it first and counted it in `decdn_bytes_served_total`: in the gateway e2e the node wrote 1.36 times the wire bytes of the pulls. - A known size is the first claim: `ProbeOpts::known_size` carries a manifest entry size (the gateway's `size_cap`), and a bundle entry uses its manifest size. Neither probes. - With no known size, `probe_pinned` probes the pinned node once on `cdn/probe/v1` (2 s, no shed backoff, no direct-path wait) and takes its size as the hint. A failed, unverifiable, non-holder or sizeless answer falls back to the header open; the node stays the only holder. - The bundle engine probes a pinned node for the manifest and for entries without a manifest size. A pinned rediscovery probes nothing. - `decdn_bytes_served_total` is documented as bao wire bytes, the unit payment uses, including frames a requester never pays for. - The gateway and bundle e2es assert the node writes the wire bytes of their pulls and no more. Closes #2619 Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
🟢 Approval recommended
The changes preserve advisory size handling and fallback recovery, with targeted regression coverage and no unresolved blocking findings.
No open issues 🎉
What changed in this PR
This PR reduces wasted traffic during pinned downloads by using a known size or a lightweight probe instead of opening and discarding a paid stream. It preserves the header-open fallback when a probe supplies no usable size.
Changes:
- Uses manifest sizes directly and probes pinned nodes once when the size is unknown.
- Adds regression checks for probe behavior and excess bytes served during gateway and bundle downloads.
- Clarifies that node served-byte metrics count bao wire bytes, including unpaid frames.
| File | Description |
|---|---|
crates/node/src/metrics.rs |
Clarifies served-byte counter documentation. |
crates/e2e/tests/gateway_public.rs |
Checks node wire-byte totals across gateway pulls. |
crates/e2e/tests/cli_bundle_pull_pool_id.rs |
Checks bundle pulls avoid excess served bytes. |
crates/client/src/targets/tests.rs |
Tests pinned probing, known sizes, and hint eligibility. |
crates/client/src/targets.rs |
Adds pinned size probing and known-size selection. |
crates/client/src/quote.rs |
Reuses the relocated pinned-target helper. |
crates/client/src/probe.rs |
Adds answer-only probing without direct-path waiting. |
crates/client/src/lane_sources/tests.rs |
Updates fallback test documentation. |
crates/client/src/lane_sources.rs |
Skips unnecessary probes during pinned rediscovery. |
crates/client/src/bundle/engine.rs |
Probes pinned targets when manifest sizes are unavailable. |
crates/cli/src/commands/fetch.rs |
Passes known sizes into target resolution. |
crates/cli/src/commands/fetch_timings.rs |
Updates probe timing documentation. |
CHANGELOG.md |
Records the download fix and metric clarification. |
adr/appendix-observability.md |
Defines served-byte accounting as bao wire bytes. |
adr/appendix-gateway.md |
Explains gateway versus node byte counters. |
adr/039-multi-source-parallel-fetch.md |
Documents known-size and pinned-probe hint selection. |
Review effort: Balanced
Code coverage overviewLanguages: Rust Rust / code-coverage/cargo-llvm-cov
View coverage of the 9 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. |
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.
What
A fetch pinned with
--node-idand no known size read its first size claim from the header of a whole-blob paid open (LaneSources::open_for_header), then dropped the stream. Before the client's stop arrived, the node wrote up to a credit window into it (about 1 MiB, 2 MiB with banked lane credit) and counted it indecdn_bytes_served_total. #2239 introduced this when it removed the client'sPrimedSourceadoption from #2063.Measured. The issue reported 2.3×; in the
gateway_publice2e I measured 1.36×: the node wrote 36,379,334 bytes for 26,859,715 wire bytes of pulls.decdn_serve_stream_client_declined_totalrose by 8, one per pull including the manifest, and the node's request log shows the(0, 0)opens. The rest is proof overhead (about 0.4%) and range padding.Changes
ProbeOpts::known_sizecarries a manifest entry size, which the gateway passes from itssize_cap. Adecdn getbundle entry uses its manifest size.probe_pinnedprobes the pinned node once oncdn/probe/v1: 2 s timeout, no backoff on a shed probe, no wait for a direct path (probe_answer_once). It takes the reported size as the hint. A failed, unverifiable, non-holder or sizeless answer falls back to the header open, and the node stays the fetch's only holder.pinned_targetmoves fromquote.rstotargets.rsso both use it.decdn_bytes_served_totalis the bao wire bytes the node writes, the unit payment uses (ADR 038 § Payment metering), including frames a requester never pays for. No new series. ADR 039, the gateway appendix and the CHANGELOG are updated to match.Closes #2619
Follow-ups: #2632 (a gateway re-probes for a bare hash's size on every request) and #2633 (the peer-store fast path still uses the header open). #2629 is a flaky test that also fails on
main.Reviewer notes
probe_pinned,resolve_target_nodeandprobed_size_hintincrates/client/src/targets.rs. Then readresolve_entry_targetsinbundle/engine.rsanddiscoverinlane_sources.rs.decdn quote.targetsis#[doc(hidden)], so the newProbeOptsfield leaves thedecdn-clientpublic-API snapshot unchanged;public_apipasses.Verification
pre-commit run --all-files: passed.cargo clippy --workspace --all-targets --all-features -- -D warnings: passed.CARGO_BUILD_WARNINGS=deny cargo doc --workspace --no-deps --document-private-items: passed.cargo nextest run --workspace: 5850 passed. One flaky test passed on retry:decdn-node::client_loopback a_closing_pool_is_unfunded_to_its_lane_and_not_found_to_anyone_else. It covers pool closing and doesn't touch the size claim.--node-id(23 tests), with--retries 0: all passed.gateway_publiccheck (served = pulls' wire bytes, within 16 KiB): failed before the fix (36,379,334 vs 26,859,715) and passes after; measured overhead 384 B. Newcli_bundle_pull_pool_idcheck: fails with the engine change reverted (2,631,838 vs 1,315,919) and passes with it.a_pinned_node_that_sheds_its_probe_stays_the_holder_with_no_hintfails with the retrying probe swapped in (4 probes vs 1).a_pinned_fetch_with_a_known_size_probes_nothingfails with the known-size path disabled.make -C adr check-refs: passed.cargo nextest run -p decdn-client --features public-api-test --test public_api: passed.Checklist:
pre-commit run --all-filesCARGO_BUILD_WARNINGS=deny cargo clippy --workspace --all-targets --all-featurescargo nextest runadr/:make -C adr check-refs;adr/architecture.mddoesn't mention the size claimCHANGELOG.mdentry🤖 Generated with Claude Code