Skip to content

feat(bundle): report the bytes a pull paid for beside downloaded - #2443

Merged
yigitdot merged 3 commits into
mainfrom
feat/2377-bundle-pull-paid-bytes
Oct 13, 2026
Merged

yigitdot merged 3 commits into
mainfrom
feat/2377-bundle-pull-paid-bytes

Conversation

@yigitdot

Copy link
Copy Markdown
Contributor

Closes #2377.

Summary

downloaded in the decdn bundle pull summary comes from entry sizes. So a run that pays for bytes twice, or pays for bytes it then drops after a lane fault, prints the same summary as a clean run. This PR adds a figure counted from payment.

  • PoolLedger::paid_bytes (crates/client/src/ledger.rs): the lane bytes the ledger's own vouchers and hash-chain reveals paid for past its seed. A reseed or rebase moves the watermark to the node's figure, not through a proof this ledger sent, so a new Pipeline::baseline shifts by the heal's jump and the jump never counts. An armed voucher whose send is unconfirmed is not counted.
  • LaneLedgers::paid_bytes: the sum over the run's lanes.
  • BundleReport::paid_bytes: a pull's share, computed as the change across the pull. The lanes outlive one pull (manifest fetch, earlier pulls of the same puller). On a pool replacement, the first pass's total is taken before the registry is replaced.
  • CLI: a paid_bytes field in --json, and downloaded X (paid P) → reconstructed Y on the human line. The paid part is left out only when nothing was downloaded or paid.

paid_bytes is wire bytes, so it includes the bao proof overhead. A clean pull shows it slightly above downloaded, and wasted payment shows up as a larger gap.

Wire bytes that arrive but never verify are out of scope. A follow-up issue tracks them.

Tests

  • Ledger unit tests: vouchers and reveals count past the seed, a rejection takes its bytes back, an armed voucher is left out, and a reseed jump and a rebase drop are left out.
  • Registry unit test: the total sums across lanes.
  • CLI: the transfer line shows or omits the paid part, and the JSON carries paid_bytes.
  • e2e (cli_bundle_pull_range_dedup): paid_bytes equals the billed redb watermark delta on a whole-file pull and a range-dedup pull, and is 0 on a whole-file reuse.

Commands run: cargo clippy --workspace --all-targets -D warnings, cargo clippy -p decdn-e2e --features anvil-e2e, cargo nextest run -p decdn-client -p decdn-cli (1606 passed), the cargo doc deny gate, cargo fmt --check, and the e2e binary (8/8 passed run serially).

🤖 Generated with Claude Code

The bundle pull summary's downloaded figure comes from entry sizes, so a
run that paid for bytes twice, or paid for bytes it then dropped after a
lane fault, printed the same summary as a clean run.

PoolLedger::paid_bytes counts what a lane's own vouchers and hash-chain
reveals paid for past its seed, leaving out the jump a reseed or rebase
makes. LaneLedgers::paid_bytes sums it over the run's lanes, and
BundleReport::paid_bytes carries a pull's share to the CLI: a paid_bytes
field in --json and a (paid P) part on the human transfer line.

Closes #2377

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 12, 2026 16:06

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 was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-code-quality

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

Copy link
Copy Markdown

Code Coverage Overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

The overall line coverage in commit 6f38c2c in the feat/2377-bundle-pul... branch remains at 75%, unchanged from commit 21c06e1 in the main branch.

Show a line coverage summary of the most impacted files.
File main 21c06e1 feat/2377-bundle-pul... 6f38c2c +/-
crates/cli/src/...ommands/node.rs 60% 59% -1%
crates/client/src/lib.rs 88% 88% 0%
crates/client/s...undle/engine.rs 61% 61% 0%
crates/cache/src/engine.rs 91% 91% 0%
crates/node/src...gin/pull_leg.rs 85% 85% 0%
crates/client/src/ledgers.rs 100% 100% 0%
crates/node/src...s/client/mod.rs 89% 90% +1%
crates/cli/src/.../bundle_pull.rs 47% 48% +1%
crates/client/src/ledger.rs 97% 98% +1%

Updated October 12, 2026 17:22 UTC

yigitdot and others added 2 commits October 12, 2026 19:30
A rebase below the bytes a run already paid clamped the paid-bytes
baseline at zero, so the figure depended on the lane's seed. A heal down
now sets the baseline to min(baseline, node watermark): claims the node
never accepted leave the count, and claims below the seed that the run
signs again count as its payment.

Also corrects the paid_bytes docs (armed vouchers, failed entries, the
transfer line), documents the report line in appendix-bundles, and adds
tests for the per-pull delta (manifest fetch excluded), a confirmed armed
voucher, a rejected reveal and seed independence after a rebase.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@yigitdot

Copy link
Copy Markdown
Contributor Author

Review follow-up (6f38c2c):

  • Fix: a downward heal now sets the paid-bytes baseline to min(baseline, node watermark). Before, it clamped at zero, so paid_bytes after a rebase depended on the lane's seed. paid_bytes now means the growth of the claim the node can redeem. Claims the node never accepted do not count. Claims below the seed that the run signs again do count.
  • Docs: corrected the armed-voucher, failed-entry and transfer-line wording. adr/appendix-bundles.md now describes the downloaded X (paid P) → reconstructed Y line.
  • Tests:
    • The --hash e2e asserts that the per-pull delta leaves out the manifest fetch.
    • The first pull of the delta-update e2e asserts its paid_bytes.
    • New ledger cases cover seed independence after a rebase, a confirmed armed voucher and a rejected reveal.
  • Known gap: no test covers the pool-replacement second pass (two lines in BundlePuller::run). No bundle e2e triggers a replacement today.

🤖 Generated with Claude Code

@yigitdot
yigitdot merged commit f532cea into main Oct 13, 2026
31 checks passed
@yigitdot
yigitdot deleted the feat/2377-bundle-pull-paid-bytes branch October 13, 2026 05:39
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.

bundle pull: the summary "downloaded" figure comes from file sizes, so wasted or duplicate paid bytes never show

2 participants