Repository navigation
feat(cli,client): decdn get ends with a verifiable pull receipt (#2599) - #2627
Merged
Merged
Conversation
) Every `decdn get` that paid ends with a receipt block, and `--receipt <FILE>` writes the receipt as JSON (`decdn-receipt/1`): per lane, the node's first signed `StreamResponse` for each hash it served and a proof of the lane's claim (the voucher that signs its anchor and the deepest revealed chain preimage). `decdn receipt verify` re-checks every signature offline; `decdn receipt settle` verifies, then records the `PoolRedeemed` event that covers each lane's claim. Collection is opt-in through a `ReceiptEvidence` collector attached to each lane's `PoolLedger`, so node and gateway ledgers keep nothing. The ledger now tracks an amount baseline beside its byte baseline, and a lane's prior watermark is that baseline, so a reseed or rebase never counts as the pull's payment. `adr/appendix-pull-receipts.md` says what a receipt proves, and that it adds no slashing offense or evidence path. Closes #2599 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Code coverage overviewLanguages: Rust Rust / code-coverage/cargo-llvm-cov
View coverage of the 10 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. Updated |
thiras
requested
a balanced review from Copilot
and removed request for
Copilot
October 26, 2026 14:49
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved file-safety, receipt-accounting, and settlement-validation issues can destroy output or produce misleading receipts.
6 open issues
Reject receipt and output path collisions · New Skip receipt finalization for bundle dry runs · New Revalidate retained settlements against the chain · New Record finalized downloaded byte count · New Include failed requested blobs in unlanded output · New Preserve net payments when merging ledgers · New
What changed in this PR
Adds verifiable pull receipts to decdn get, preserving existing node responses and payer signatures without changing the wire protocol or contracts.
Changes:
- Collects receipt evidence and prints a summary after paid downloads, with optional JSON output.
- Adds offline signature verification and on-chain settlement lookup.
- Documents receipt guarantees and privacy limits, with unit and end-to-end coverage.
| File | Description |
|---|---|
| README.md | Documents receipt commands and usage. |
| crates/e2e/tests/cli_receipt.rs | Tests download, verification, and settlement journeys. |
| crates/common/src/cli/receipt.rs | Defines verify and settle arguments. |
| crates/common/src/cli/mod.rs | Registers the receipt command. |
| crates/common/src/cli/get.rs | Adds the --receipt option. |
| crates/client/tests/snapshots/public_api__public_api.snap | Updates the SDK API snapshot. |
| crates/client/src/receipt/tests.rs | Tests collection, accounting, signatures, and serialization. |
| crates/client/src/receipt.rs | Implements receipt collection, schema, and verification. |
| crates/client/src/lib.rs | Captures signed responses and vouchers. |
| crates/client/src/ledger.rs | Exposes receipt evidence and tracks amount baselines. |
| crates/client/src/lanes/tests.rs | Updates lane fixtures for optional evidence. |
| crates/client/src/lanes.rs | Attaches collectors to lane ledgers. |
| crates/client/src/lane_sources/tests.rs | Updates the lane-source fixture. |
| crates/client/src/bundle/engine.rs | Records bundle evidence and landed sizes. |
| crates/client/src/bundle.rs | Adds the receipt collector builder option. |
| crates/cli/src/main.rs | Dispatches receipt commands. |
| crates/cli/src/commands/receipt/tests.rs | Tests receipt output, files, and settlement handling. |
| crates/cli/src/commands/receipt.rs | Implements receipt persistence, display, and commands. |
| crates/cli/src/commands/node/earnings_chain.rs | Exposes scan helpers for reuse. |
| crates/cli/src/commands/node.rs | Makes earnings helpers crate-accessible. |
| crates/cli/src/commands/mod.rs | Exports the receipt command module. |
| crates/cli/src/commands/get.rs | Adds receipt preflight and finalization. |
| crates/cli/src/commands/fetch.rs | Collects evidence during blob fetches. |
| crates/cli/src/commands/civil_time/tests.rs | Tests timestamp formatting and strict parsing. |
| crates/cli/src/commands/civil_time.rs | Adds receipt timestamps and tightens date parsing. |
| crates/cli/src/commands/bundle_pull/tests.rs | Updates bundle fixtures for receipt collection. |
| crates/cli/src/commands/bundle_pull.rs | Passes collectors through bundle pulls. |
| CHANGELOG.md | Records the receipt feature and parser change. |
| adr/Makefile | Includes the receipt appendix in the book. |
| adr/architecture.md | Links the receipt appendix. |
| adr/appendix-pull-receipts.md | Defines receipt evidence, limits, and privacy implications. |
Review effort: Balanced
…nt, sizes, merges - `--receipt` may not name the blob's destination or a bundle entry's; a dry run and a failed run leave an existing receipt alone. - `settle` rebuilds every settlement from the events it scans, so one the file holds and the chain does not show is dropped. - A fetched blob is recorded at the length it verified to, not at the first size claim. - An incomplete pull lists its requested hash in `unlanded` when a node accepted it and it did not land. - Two ledgers on one lane merge to the sum of what each paid, so a reseed in the second never counts as the pull's payment. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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
decdn getends with a pull receipt: what the pull landed, which nodes served it, what it paid, and the signatures that prove it. A receipt is assembled from messages the pull already exchanges, so nothing changes on the wire, in the contracts or in the economics.Block at the end of every paid
get: the hash, the bytes verified and paid, each node and the bytes it was paid for, the USDC and pool, and the start and end times. It goes to stdout, or to stderr when stdout carries data (-o -) or JSON (--json).--receipt <FILE>writes the receipt as JSON (decdn-receipt/1). Per(pool, signer, provider)lane it holds:StreamResponsefor each hash it served;proof: the voucher that signs the lane's anchor, the deepest revealed chain preimage, and the claim the two prove.The path is checked before the pull pays anything. A run that pays nothing writes no receipt, says so, and removes a stale file at that path. A failed or interrupted pull still writes a receipt, marked incomplete, which lists the started blobs that did not land.
decdn receipt verify <FILE>re-checks every signature offline against the receipt's chain id,PaymentPoolandSlashJudge. On a known chain it also checks those contracts against the build's own; on any other chain it says they went unchecked.decdn receipt settle <FILE>verifies first. It then scansPaymentPool.PoolRedeemedfrom an hour before the receipt's start, and records for each lane the redemption that covers its claim, or the highest one short of it.adr/appendix-pull-receipts.mdsays what a receipt proves and what it doesn't. It adds no slashing offense or evidence path, and the appendix covers the privacy cost of publishing one.Closes #2599
Reviewer notes
crates/client/src/receipt.rs(the collector, the schema,verify), thenPoolLedger::proved_frontierand the amount baseline incrates/client/src/ledger.rs.verifyruns rests on a node signature or a payer signature.ReceiptEvidencecollector attaches a slot to each lane'sPoolLedger, set throughLaneDeps::evidenceorBundlePullerBuilder::receipt_evidence. Onlydecdn getsets one, so the node's long-lived upstream ledgers and the gateway keep nothing./_receipt/<id>page is left to gateway: hosted public HTTP gateway at<ns>.decdn.linkthat pays a pool behind the scenes #2593.getprints more lines. The block adds lines to stdout after the existing summary line.verifyon a newer build; the error names the mismatched contract.node earnings --since.node::earnings_chainbecomepub(crate)so thatsettlecan reuse them.Verification
pre-commit runon every changed file (cargo-deny reports the existingcrypto-bigint/ctutilsadvisories, non-blocking)cargo clippy --workspace --all-targets --all-features -- -D warningscargo nextest run -p decdn-client -p decdn-cli -p decdn-common -p decdn-node: 4515 passedcargo nextest run -p decdn-e2e --features anvil-e2e -E 'binary(/^cli_/) | binary(/^gateway_/) | binary(smoke)': 32 passed, including the newcli_receipt. It covers:get --receipt, thenverify;-o -for a blob and for one entry (two ledgers merged into one lane);settleafter the node's own redemption.decdn-client:.snapregenerated and re-checkedadr/:make -C adr check-refs check-book-list, appendix registered inarchitecture.mdand the book listCARGO_BUILD_WARNINGS=deny cargo doc --workspace --no-deps --document-private-itemsCHANGELOG.mdentry🤖 Generated with Claude Code