Repository navigation
feat!: the size proof is the only statement of a blob size (#2879) - #2885
Conversation
A size proof is the bao encoding of a blob's final BLAKE3 chunk at chunk granularity: one pair of parent hashes for each level on the path from the root, then the chunk. Only the true size verifies a final chunk under the root. verify_size_proof takes the root, a claimed size and a proof and answers yes or no. It is the stock bao-tree decoder over the last chunk, and it allocates nothing that grows with the size. encode_size_proof builds the proof from the group-level .obao4 outboard and the bytes of the last chunk group. The outboard stores no hash below a chunk group, so the encoder hashes the pairs inside the last group from its bytes. It verifies the proof against the root before it returns it. Refs #2879 Co-Authored-By: Claude Fable 5.2 <[email protected]>
A StreamResponse, and a ProbeResponse that states total_bytes, carries a size proof: the final BLAKE3 chunk and its path to the root. The receiver verifies the proof against the content hash before it uses the size. A proof depends on the hash alone, so the origin makes it at import and any node passes it on. Refs #2879 Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Add SizeProof, bounded at MAX_SIZE_PROOF_BYTES at decode, as an extension field of StreamResponseExt and ProbeResponseExt. Raise the probe and client control frame ceilings to 8 KiB to fit a full proof. num_blocks saturates at u32::MAX. encode_outboard builds the size proof in the same pass, and SIZE_PROOF_SUFFIX names its origin object. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A node attaches a size proof to every StreamResponse with ok = true and
to every probe answer that states total_bytes. Nothing plans,
allocates, compares with a cap or pays against a size before its proof
verifies.
- cache: Origin::fetch_size_proof (fs, S3, HTTP); CacheEngine keeps one
verified proof per blob, builds it from the local store or the origin,
and drops it on eviction.
- origin import writes {hex}.sizeproof beside {hex}.obao4.
- node: signs no size it cannot prove; keeps the upstream's verified
proof; probes state a size only with its proof; window pull-through
refuses an offset past the proven size; pull plan is cut to the
request end and max_blob_size (planned_len).
- client: check_size_proof / UnprovenSize (a source fault) on every
open and probe answer; the first paid leg's proof sets the store's
size; Want tail fix (#2865); range clipping past the bound.
- protocol: MAX_STREAM_RESPONSE_FRAME for the response the payer reads.
- cli/gateway: decdn probe shows only a verified size; the gateway's
paid size pull is replaced by a free size lookup.
Refs #2879
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Finish the size-proof ADR text: the max_blob_size paragraphs and probe field in ADR 005, the frame and field tables in ADR 013, the proof format in ADR 038, the size rule in ADR 039, ADR 022 and 037 (criterion 13), and the gateway and bundles appendices. CLAUDE.md names the new crate parts. Refs #2879 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…codec # Conflicts: # CLAUDE.md
A kept proof lives under a named tag on the blob it proves
(decdn-sizeproof-{hex}/{size}/{proof}), with the in-memory memo as a
cache in front. Evicting the blob drops the tag with the blob's other
tags, and the engine deletes the tags of blobs it does not hold at open.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…aude/size-proof-wiring-bc490c # Conflicts: # CLAUDE.md
Co-Authored-By: Claude Opus 5.5 <[email protected]>
….sizeproof
- Delete the client's claim growth: acquire records the first size as
proven before any leg opens; bundle entries always take a proven size
and keep dedup ranges only when the manifest size matches it.
- Known sizes on a host are proven only; a declared size only caps.
- Gateway size lookups open the blob's first byte (one chunk group at
most); a proven size past --max-blob-mb answers 413 before any pull.
- Cache: {H}.sizeproof is mandatory (no outboard-build fallback), origin
reads are single-flight with a negative memo; proof tags point at the
empty blob and exist only while the store tracks the blob.
- Probe: no size, proof or coverage for refused or unprovable hashes;
split request/response frame ceilings.
- origin import writes both siblings before the data object.
- decdn probe fails on an unproven size; tests, ADRs and docs updated.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolve the Streamer store refactor (#2887) against the proven-size acquire: the stream store opens at the proven size with no cap clamp, and the streamer tests keep the caller-supplied store test. Seed e2e origins with their .sizeproof sibling. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Code coverage overviewLanguages: Rust, Solidity Rust / code-coverage/cargo-llvm-cov
View coverage of the 10 most impacted files.
Solidity / code-coverage/forge
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. Updated |
There was a problem hiding this comment.
Note
Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.
🟡 Changes recommended
Approval is blocked because the review evidence identifies multiple lingering documentation/comment inaccuracies about size-proof fallback behavior, which now misdescribe how CacheEngine::size_proof handles missing {H}.sizeproof.
3 open issues
What changed in this PR
Wire-breaking update that makes blob sizes provable end-to-end: whenever a node states a size it includes a bounded size proof, and node/client/cache/CLI verify the proof before using sizes for planning, allocation, caps, or signing.
Changes:
- Add
SizeProofto the protocol, extend probe/stream response extensions withsize_proof, and adjust framing ceilings. - Generate, fetch, cache, and persist
.sizeproofsiblings across bao-range, origins, cache, and node handlers. - Update client fetch/planning/bundles and CLI/gateway behavior to operate only on proven sizes; refresh tests, fixtures, and ADRs accordingly.
| File | Description |
|---|---|
| crates/protocol/tests/snapshots/public_api__public_api.snap | Updates protocol public API snapshot for the new size-proof types/fields and framing ceiling constants. |
| crates/protocol/src/size_proof/tests.rs | Adds tests covering size-proof encoding/decoding limits and defensive length handling. |
| crates/protocol/src/size_proof.rs | Introduces the SizeProof type with bounded decoding and maximum proof-size enforcement. |
| crates/protocol/src/message/tests.rs | Updates message-level tests for probe extensions, wire format, and revised frame ceilings including size proofs. |
| crates/protocol/src/message.rs | Extends probe messaging with size_proof and splits probe frame ceilings into request vs response bounds. |
| crates/protocol/src/lib.rs | Re-exports size-proof APIs and updates crate-level constants/docs for new framing ceilings. |
| crates/protocol/src/framing/tests.rs | Adjusts framing roundtrip tests to include size proofs in probe/response flows. |
| crates/protocol/src/coverage/tests.rs | Adds tests validating saturation behavior for coverage num_blocks calculations. |
| crates/protocol/src/coverage.rs | Changes num_blocks computation to saturate at u32::MAX to avoid overflow/truncation issues. |
| crates/protocol/src/client/tests.rs | Updates client protocol tests and fixtures for stream responses carrying size proofs and updated ceilings. |
| crates/protocol/src/client.rs | Adds StreamResponseExt.size_proof plus stream response frame ceiling constants and related docs. |
| crates/node/tests/support/mod.rs | Updates node test support to seed/register .sizeproof siblings and work with new response ceilings. |
| crates/node/tests/probe_loopback.rs | Updates probe loopback tests to ensure sizes are only stated when accompanied by a valid proof. |
| crates/node/tests/partial_serve.rs | Adjusts partial-serve tests and fixtures to include .sizeproof origin siblings and proven-size expectations. |
| crates/node/tests/origin_range_pull.rs | Updates origin range pull tests to serve/require .sizeproof alongside origin data and outboards. |
| crates/node/tests/node_to_node_pull_through.rs | Updates pull-through tests so upstream responses propagate proven sizes via size proofs. |
| crates/node/src/selection.rs | Updates selection logic/docs to treat size hints as proof-backed rather than trusted declarations. |
| crates/node/src/node_origin/tests.rs | Adds/updates node-origin tests asserting probe-stated sizes are accepted only with valid proofs. |
| crates/node/src/node_origin/ranged_pull/tests.rs | Adds tests for bounded planning behavior (planned_len) under proven-size and cap constraints. |
| crates/node/src/node_origin/ranged_pull.rs | Introduces planned_len and related logic to bound ranged pulls to proven size/cap reach. |
| crates/node/src/node_origin/mod.rs | Updates node-origin behavior to drop or ignore unproven size claims before they influence planning/serve. |
| crates/node/src/node_origin/backend_source.rs | Updates backend source integration to align headers/behavior with the size-proof requirement model. |
| crates/node/src/metrics.rs | Updates metric definitions/documentation to use proven-size terminology and semantics. |
| crates/node/src/handlers/probe.rs | Updates probe handler to include size proofs whenever stating sizes and to respect new request ceilings. |
| crates/node/src/handlers/client/wire.rs | Updates response signing to attach size proofs on successful responses and refuse signing unprovable sizes. |
| crates/node/src/handlers/client/tests.rs | Updates/extends handler tests to validate proof attachment and refusal behavior when proofs are unavailable. |
| crates/node/src/handlers/client/mod.rs | Adjusts client handler docs/flow to reflect proven-size gating and new refusal behavior. |
| crates/node/src/handlers/client/fill.rs | Tightens fill/serve logic so direct/fast paths require an available verified size proof. |
| crates/node/src/handlers/client/dispatch.rs | Updates dispatch to gate origin/local serving and range validation on proven size before signing/serving. |
| crates/node/src/dht/probe_cache.rs | Updates probe-cache handling/documentation to store only proof-backed size information. |
| crates/e2e/tests/pool_floor_ceiling_aggregate.rs | Updates E2E tests to use the new stream-response frame ceiling constant. |
| crates/e2e/tests/gateway_public.rs | Updates gateway E2E coverage for proof-based size learning and revised sizing/accounting behavior. |
| crates/e2e/src/node.rs | Updates E2E node fixture setup to write .sizeproof siblings for origin content. |
| crates/e2e/src/client.rs | Updates E2E client harness to use revised frame ceilings and proven-size behavior. |
| crates/client/tests/snapshots/public_api__public_api.snap | Updates client public API snapshot for new size-proof APIs and removal of claim-growth-related interfaces. |
| crates/client/src/tests.rs | Adds/updates client tests enforcing proof verification before size usage and bound parity with protocol limits. |
| crates/client/src/targets/tests.rs | Updates target-selection tests to ensure probe-derived sizes are retained only when proven by a valid proof. |
| crates/client/src/streamer.rs | Removes claim-growth logic and rewires streaming to record and rely on proven sizes only. |
| crates/client/src/source.rs | Adds size-proof verification/plumbing in source handling, including recording proven sizes into storage. |
| crates/client/src/source_set.rs | Updates source-set behavior and docs so past-end and bounds decisions use proven size. |
| crates/client/src/segment/tests.rs | Updates segment tests for new range canonicalization/clipping behavior under proven-size bounds. |
| crates/client/src/segment.rs | Adjusts segment/range canonicalization to clip to proven bounds and treat tails consistently. |
| crates/client/src/ranged_store/tests.rs | Updates ranged-store tests to cover proven-size recording, replacement, and rejection of unproven sizing. |
| crates/client/src/ranged_store.rs | Adds/updates store APIs to record proven sizes and enforce clamping/behavior based on those bounds. |
| crates/client/src/quote.rs | Updates quoting/census logic and documentation to treat sizes as proof-backed facts. |
| crates/client/src/probe.rs | Clarifies probe verification responsibilities and ensures size proof validation occurs before size use. |
| crates/client/src/lane_sources/tests.rs | Adds/updates tests for first-open/priming flows that learn sizes via proof-backed mechanisms. |
| crates/client/src/lane_sources.rs | Reworks lane source logic to operate on the first proven size (not claim growth) and updates docs. |
| crates/client/src/first_open.rs | Updates first-open logic/docs to learn and store proven size before planning further work. |
| crates/client/src/driver/tests.rs | Updates driver tests to validate propagation and storage of proven sizes from proof-carrying responses. |
| crates/client/src/driver.rs | Updates the driver to record proven size early and prevent planning/allocations based on unproven sizes. |
| crates/client/src/downloader/tests.rs | Updates downloader tests for resume and tail semantics under the proven-size model. |
| crates/client/src/downloader.rs | Updates downloader behavior to use proven-size bounds, including tail range handling and end-clamping. |
| crates/client/src/discovery.rs | Updates discovery logic/docs to store and act on sizes only after proof verification. |
| crates/client/src/coverage_plan/tests.rs | Adds tests ensuring planner work scales with the touched gap blocks rather than total blob size. |
| crates/client/src/coverage_plan.rs | Introduces touched_blocks planning optimization and adjusts coverage planning to use proven size bounds. |
| crates/client/src/bundle/engine/tests.rs | Adds tests enforcing that dedup ranges apply only when manifest declared size matches the proven size. |
| crates/client/src/bundle.rs | Updates bundle semantics so manifest sizes are declared-only and proven size governs fetch/dedup decisions. |
| crates/client/examples/common/mod.rs | Updates example client code to drop or ignore stated sizes that lack a valid size proof. |
| crates/cli/tests/origin_import.rs | Updates origin import tests to ensure .sizeproof is written and verified before data is considered complete. |
| crates/cli/src/commands/probe/tests.rs | Adds tests ensuring decdn probe rejects responses that state sizes without valid proofs. |
| crates/cli/src/commands/probe.rs | Updates decdn probe to require proven stated sizes via explicit size-proof checks. |
| crates/cli/src/commands/origin/tests.rs | Updates origin command tests for .sizeproof sibling creation and --move ordering/resume behavior. |
| crates/cli/src/commands/gateway/worker/tests.rs | Updates gateway worker tests for the new size-learning flow and renamed/requested behavior. |
| crates/cli/src/commands/gateway/worker.rs | Updates gateway worker logic/docs to learn sizes via proof-backed operations rather than a paid size pull. |
| crates/cli/src/commands/fetch/tests.rs | Updates fetch command tests to reflect that known sizes are proven sizes and caps only constrain. |
| crates/cache/src/size_proofs/tests.rs | Adds tests for the in-memory and persisted size-proof memo/tag semantics and lifecycle. |
| crates/cache/src/size_proofs.rs | Implements bounded size-proof memoization and persistence semantics for verified proofs. |
| crates/cache/src/ranged_store.rs | Updates ranged store behavior/comments to match proven-size end clamping and related semantics. |
| crates/cache/src/origin/s3.rs | Updates S3 origin support to fetch .sizeproof siblings and handle size-proof-related error classification. |
| crates/cache/src/origin/mod.rs | Extends the origin abstraction with fetch_size_proof and documents the required .sizeproof behavior. |
| crates/cache/src/origin/http.rs | Updates HTTP origin support to fetch .sizeproof siblings alongside content/outboards as needed. |
| crates/cache/src/origin/fs.rs | Updates filesystem origin support to read .sizeproof siblings and enforce size-proof constraints. |
| crates/cache/src/lib.rs | Wires the new size-proof subsystem into the cache crate and exports the necessary integration points. |
| crates/cache/src/fill_session.rs | Updates fill-session behavior/comments to align with proven-size clamping and no-unproven-size usage. |
| crates/bao-range/src/origin_seed/tests.rs | Adds tests validating .sizeproof generation and that proofs verify true size and reject mismatches. |
| crates/bao-range/src/origin_seed.rs | Updates origin seeding to emit .sizeproof in the same pass as outboard encoding and standardizes naming. |
| crates/bao-range/src/lib.rs | Re-exports size-proof helpers/constants and updates docs to match new proven-size behavior. |
| CLAUDE.md | Updates repository guidance/notes to reflect the proven-size invariant and related crate responsibilities. |
| adr/appendix-gateway.md | Updates the gateway appendix ADR to describe proof-based size learning and the removal of paid size pulls. |
| adr/appendix-bundles.md | Updates the bundles appendix ADR to clarify declared vs proven sizes and dedup applicability rules. |
| adr/039-multi-source-parallel-fetch.md | Updates ADR 039 to replace claim-growth sizing with proven-size-first rules and related planning behavior. |
| adr/038-bao-verified-range-streaming.md | Updates ADR 038 with size-proof format/requirements and cost model notes for origin-cold reads. |
| adr/037-regional-proxy-warming.md | Updates ADR 037 to require/propagate size proofs in proxy warming and pull-through flows. |
| adr/022-content-discovery.md | Updates ADR 022 to treat discovered sizes as proof-backed facts and adjust related rules/wording. |
| adr/013-schema-evolution.md | Updates ADR 013 to document the wire/schema changes, including new ceilings and size-proof fields. |
Review effort: Balanced
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The probe's size and the header's size are both proven against the hash, so they are equal: the first-leg size check and the past-end whole-blob fallback cannot fire for an honest node. A wrong past-end refusal is now the handshake's own fault. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Keep the flag-taking public gateway helper with main's new worker-count argument. Co-Authored-By: Claude Opus 5.5 <[email protected]>
yigitdot
left a comment
There was a problem hiding this comment.
Review: size proof wiring (head 161f4f8c)
Five read-only review passes (code, silent failures, tests, comments/ADRs, type design). Items marked ✔ were re-checked by hand against the source.
Critical
- ✔ Evicting or quarantining
Hash::EMPTYdeletes every size-proof tag.drop_named_tags_for(crates/cache/src/engine.rs:2946) deletes every tag withinfo.hash == hash, and every proof tag points atHash::EMPTY(:4164). The memo still saysstored = true, so nothing rewrites the tags; all proofs are lost at the next restart. Fix: skip names with the size-proof tag prefix in that loop. - ✔ A pulled partial proof never reaches the store.
admit_bao_streamcallsprotect_partial(engine.rs:4626) beforerecord_access(:4634), sotracks()(:4143) is false for a new hash andstore_size_proof_if_heldwrites nothing;partial_protectedthen short-circuits later admits. A restart before any lookup loses the proof.a_kept_proof_survives_a_restartadmits before it keeps the proof (the reverse of production order), so it passes. Fix:record_accessbeforeprotect_partial. - Forged size can exhaust client memory (not hand-verified). A proof binds a size to a hash, not to real content: anyone who builds their own hash can prove ~2^60. With
claim_reachdeleted, a small--rangewindow passes the earlyBlobTooLargecheck (client/src/scheduler.rs:3535), and lanes without a probed bitmap (proxy lanes,lane_sources.rs:987; pinned nodes) buildCoverage::full(u32::MAX)(~512 MiB, ~4.3 G iterations) atscheduler.rs:989/1141/3055. Fix: size coverage and work by request reach, keep the proven size for clipping.
Important
- ✔ Gateway 413 refuses
Rangerequests on large blobs.gateway.rs:2120runsover_blob_capbefore the range parse;curl -r 0-1023on a 10 GiB blob with a 100 MiB cap now gets 413. Conflicts with ADR 005:429 and the gateway module doc. Fix: compare the requested span (or whole blob withoutRange) with the cap. - Orphan sweep can delete every proof. If
iter_hashesfails,seed_access_times_from_storewarns and leavesaccess_timesempty; the sweep then finds nothing tracked.tracks()also maps astatus()error to not-held (engine.rs:1651,4142-4150,4202-4218). Skip the sweep after a failed seed; keep the tag on a status error. - Origin outages are cached as no-proof for 5 s, logged at debug (
engine.rs:4262-4274). A.sizeproofthat fails to verify is skipped with no log. Cache the miss only when every origin answered cleanly; warn on a verify failure. - An origin blob with no
.sizeproofgoes dark silently (dispatch.rs:1166-1170,probe.rs:264-270): no warn, no metric,fault_seenunset; the node pays peers for content its own origin holds. Add a rate-limited warn namingdecdn origin import, plus a metric. - ✔
delete_prefix(..)?runs beforepartial_protected.remove(engine.rs:2920-2933), which breaks the comment right below it ("a delete failure mid-loop still leaves the memo clear"). Move it after the memo clear. - Window pull-through no-proof refusals (
window.rs:329-347,365-370) userespond_error(CacheMiss): they skip therespond_misslog line and ignorefault_seen. The verified-but-not-kept branch deserves anerror!/debug_assert!. - Stale docs that contradict the new behaviour:
node_origin/pull_leg.rs:908-912describes the deleted whole-blob retry and size-mismatch drop.handlers/probe.rs:228-230saysNonemeans unknown but fetchable; the probe now advertises no coverage andhas_blob = false.- ADR 037
:81,:84,:183and ADR 038:45,:85,:105: the origin fallback now needs{H}.sizeproof, otherwise the blob is not served from the origin. streamer.rs:598-603(removed clamp),:643-644(resumed bound no longer wins), theStreamer::opendoc (says the first leg sets the size;acquireproves it at once), and the "claim that may be inflated" comment inacquire.
- ✔
over_blob_capsits between the doc comment oftoo_largeand the fn (gateway.rs:1297-1307), sotoo_largelost its doc.
Test gaps
- Window pull-through
okwith no proof:CacheMissplus reservation released (the scripted upstream innode_origin_pull.rsonly omits the proof on error answers). - Offset at or past the proven size:
RangeNotSatisfiablebefore signing, including the empty blob. - Negative memo expiry after 5 s, with an origin read counter (the current test passes with or without the memo).
- Positive orphan-sweep test (both current assertions expect 0) and the sweep in
tidy_store. origin import --movewrite order: make the sibling write fail and assert the source survives.- Bundle engine path where the manifest size differs from the proven size.
a_blob_past_the_cap_ends_the_itemlacks theopened_bytes == 0assertion its sibling uses;decode_refuses_a_huge_declared_lengthfails in postcard with or without the custom visitor.
Suggestions
- A
ProvenSize(u64)newtype returned bycheck_size_proofand taken byAcquireTarget,IngestStore::prove_sizeandUpstreamPullHeader, so a rawu64cannot reach cap/plan logic. TodayDownloadTarget.total_bytesandStreamer::openhints flow intoprove_sizeunchecked. StreamResponseExt::validate:(ok = true, size_proof: None)is an error. Merge the probetotal_bytes/size_proofpair intoOption<StatedSize>.CacheEngine::size_proofcould returnSizeProof, removing theSizeProof::new(..).ok()rewrap in the node.- Origin proof lookup is not fully single-flight (
engine.rs:4253-4275): the memo insert happens after the per-hash lock is released. - The gateway
learn_sizefallback can pay one chunk group but charges nothing to the allowance. - Unproven probe sizes from peers count as
ProbeDrop::Inconsistentat debug with no peer or hash (node_origin/mod.rs:1708-1710). - ADR wording: 005:174 "one hash at a time" reads node-wide (it is one read per hash); 022:276 and 037:64 drop the extra chunk group of
planned_len; 005:166 "carries" should be "carry"; about 30 code comments cite "ADR 005 § A node proves the blob size", which is a bold paragraph, not a heading. - Leftover claim/unsigned wording:
streamer.rs:81,client/src/lib.rs:2841,driver.rs:847,pull_leg/prime_tests.rs:41, and a few test docs.
Strengths
Every constant matches its comments and ADRs (4,480-byte bound, frame ceilings, 4,808-byte probe answer, memo sizes). The SizeProof bound holds on every constructor. Forged and wrong-size proofs are rejected and tested at the client, probe readers and CLI, and the node never signs an unproven size. Lint, test-placement and present-tense rules are followed, with no compatibility shims.
🤖 Generated with Claude Code
- Evicting the empty blob no longer deletes every size proof tag; the
proof delete runs after the partial-protection memo clear.
- A kept upstream proof reaches the store on the first admit (after
recency is recorded), not only on a later lookup.
- The orphan sweep deletes a tag only for a blob known gone, and skips
entirely after a failed recency seed.
- Origin outages are not remembered as proof misses; a non-verifying
proof warns; a missing {H}.sizeproof warns and counts
decdn_cache_size_proof_origin_missing_total. The origin proof enters
the memo under its per-hash lock.
- Lanes without a probed bitmap cover only up to the requested reach,
so a small window of a huge proven size sizes no huge bitmap.
- The gateway's 413 compares the pulled span, so a Range of a large
blob is served.
- Window no-proof refusals go through respond_miss (unproven_size).
- Stale docs and ADR wording fixed; tests for each fix.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks for the review. Addressed in 280a343:
Not done here: the 🤖 Addressed by Claude Code |
…ans from check_size_proof returns a ProvenSize, the only way to make one outside tests. AcquireTarget, DownloadTarget, FirstClaim, Streamer::open and open_range, IngestStore::prove_size, Probed and the quote census take or hold it, so a raw u64 from a node cannot reach planning, a cap or payment. Tests build sizes with ProvenSize::assume_for_tests (test-util). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
- SizeProof carries its size; StreamResponseBody, ProbeResponseExt and
OriginAttestation drop total_bytes. A StreamResponse's outcome is
Served(SizeProof) or Refused(StreamError), and validate ties it to the
signed ok, so a served response without a proof cannot exist.
- The EIP-712 StreamResponse type drops totalBytes (SlashJudge, the
incentive signer and binding, tests, gas snapshot). Receipts drop the
signed size and the EntrySize fault.
- {H}.sizeproof objects hold the size (8 LE bytes) then the proof; origin
import writes them so.
- A node serves an origin object only under a size its {H}.sizeproof
proves, and advertises in the DHT only coverage it can prove.
- ADRs 005, 013, 014, 022, 037, 038 and frame byte counts updated.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Take main's removal of floor debt (#2873), including its floor-debt tests; keep this branch's proven-size Declined row and imports. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Gas snapshotNo gas changes vs base. |
Co-Authored-By: Claude Opus 5.5 <[email protected]>

Implements #2879: every blob size a node states arrives with a size proof, and nothing plans, allocates, compares with a cap or pays from a size before its proof verifies. Built on the size-proof codec (#2882) and the ADR text of #2880, retargeted to
main.Wire-breaking (
!), and the EIP-712StreamResponsetype changes. No compatibility shim.The size proof is the size
SizeProofcarries the size beside the proof. It is the only place any message states a blob size:total_bytesis gone fromStreamResponseBody(and from the signed EIP-712StreamResponse,SlashJudge.STREAM_RESPONSE_TYPEHASH), fromProbeResponseExt, and from DHTOriginAttestations.StreamResponseExt.outcomeisServed(SizeProof)orRefused(StreamError), andvalidateties it to the signedok: a served response without a proof cannot be built or accepted. The node signs throughsign_served(needs the proof) orsign_refusal.{H}.sizeproofholds the size (8 LE bytes) then the proof;decdn origin importwrites it so. An origin object is served, and advertised in the DHT, only under a size its{H}.sizeproofproves; an object with no size or no proof is never served from the origin. (fix(cache): a present but unsized origin object is no longer memoised as an absence #2867 is closed: the unsized tri-state has no use.)EntrySizefault. Frame sizes: full probe answer 4,807 B; origin attestation 86 B; fullBatchStore61,475 B; fullFindValue16,675 B.SlashJudge: type string andStreamMsgdroptotalBytes; Foundry suite 815 passed, gas snapshot regenerated.What changed
decdn-protocol
SizeProof(opaque bytes, bounded atMAX_SIZE_PROOF_BYTES= 4,480 at decode, with a visitor that refuses a huge declared length before it allocates) andSizeProofTooLong.StreamResponseExt.size_proofandProbeResponseExt.size_proof.MAX_PROBE_REQUEST_FRAME= 1 KiB (what the node reads),MAX_PROBE_FRAME= 8 KiB (the response the requester reads; a full answer is 4,808 B).MAX_STREAM_RESPONSE_FRAME= 8 KiB for the response the payer reads;MAX_CLIENT_CONTROL_FRAMEstays 4 KiB for what the node reads, so the node's reader-buffer bound (ADR 013) does not grow.num_blockssaturates atu32::MAX.decdn-bao-range
SIZE_PROOF_SUFFIX = ".sizeproof";encode_outboardyields the size proof in the same pass.size_proof_from_tail_wirebuilds a proof from a verified export of the last chunk group, and refuses a wire with unused pairs.decdn-cli
origin import{hex}.obao4and{hex}.sizeproofbefore the data object, so a--movecut short keeps its source and the next import finishes it.decdn-cache
CacheEngine::size_proof(hash, size): memo → stored tag → last chunk group in the local store → the origin's{H}.sizeproof. Every proof verifies before it is kept or returned; a wrong size getsNoneand quarantines nothing.{H}.sizeproofis mandatory for an origin object: the outboard-build fallback is gone. Origin lookups are single-flight per hash, with a 5 s negative memo (4,096 entries).decdn-sizeproof-{hex}/{size}/{proof}whose value is the empty blob, so a tag never keeps content alive. Tags are written only while the store tracks the blob; a proof for an unheld blob stays in memory. Eviction, release and quarantine delete them; an orphan sweep runs at open and on every origin rescan.decdn-node
sign_responseattaches the proof on everyok = trueresponse and refuses to sign a size it cannot prove.total_bytes(and coverage) only with a proof and only for a hash it does not refuse; a chain-stale or refused hash costs no proof work.CacheMiss(releasing its reservation), and refuses an offset at or past the proven size withRangeNotSatisfiablebefore signing. Direct serve with no proof answersInternalError.planned_len: the pull leg and the coverage gate plan no further than the request end ormax_blob_size+ one chunk group.decdn-client
ProvenSize:check_size_proofreturns one, and it is the only way to make one outside tests (ProvenSize::assume_for_tests,test-util).AcquireTarget,DownloadTarget,FirstClaim,Streamer::open/open_range,IngestStore::prove_size,Probed, the quote census and the CLI's known sizes take or hold it, so a rawu64from a node cannot reach planning, a cap or payment.check_size_proof+ typedUnprovenSize(a source fault).verify_responsechecks everyok = trueresponse;classify_probeand the node's probe consumer drop an answer whose size has no valid proof.store.prove_size(c0)) before any leg opens;claim_reach,known_endand the growth paths are gone. A resumed record with a different recorded size takes the fresh proven size. A proven size past the cap ends the item before any leg opens.touched_blocks), so its work follows the gap, not the blob size.Wanttail fix (client: cap-0 explicit ranges longer than the 1 TiB sizing ceiling truncate or overfetch #2865): only a zero-length range is a tail; ranges past the size are clipped.ranges_at_proven_size), otherwise the entry fetches whole. A pinned node is always probed for an entry.decdn-cli
decdn probefails on an answer with an unproven size (check_stated_size).decdn get: the host's known sizes hold proven sizes only; a declaredsize_caponly caps.learn_sizeruns asize_onlyfetch whose fallback open is the blob's first byte (one chunk group at most). A raw blob whose proven size passes--max-blob-mbanswers 413 before any pull.ADRs and CLAUDE.md
{H}.sizeproof, empty-blob tags, negative memo), 013 (ceilings), 022, 037, 038 (§ Size proof, origin-cold cost incl.{H}.sizeproof), 039 (size rule; claim growth replaced), appendix-gateway, appendix-bundles; CLAUDE.md crate notes.Decisions taken
{H}.sizeproofis mandatory; an origin object without it is advertised with no size and no coverage.decdn origin importwrites it.SDK contract
The TypeScript and Python contract suites against the real binary do not observe this change (the suites use a 1 GiB allowance and assert
Content-Lengthonly on bundle entries), so neither SDK pin moves. Only the SDK fakes model the removed 16 KiB size-pull charge (fake-gateway.tsprove(),fake_gateway.py_prove); cleaning those is a follow-up in the SDK repos.Tests
New or rewritten: proof decode bound; ceilings; tail-wire padding refusal; cache memo/tag semantics (restart, unheld blob, eviction leaves no tag, wrong size with no quarantine for full and partial holders, origin without
.sizeproof+ negative memo); dedup ranges at the proven size; first-byte size-lookup leg; gateway 413;decdn probeunproven size;origin import --moveorder and resume; probe of a denied held blob and of an origin object without.sizeproof; resumed records and cap tests under proven sizes. Node test origins now carry.sizeprooflike a real import.Results (local, on the merged tree unless noted):
cargo fmt -- --check,cargo clippy --workspace --all-targets --all-features -- -D warnings,CARGO_BUILD_WARNINGS=deny cargo doc --workspace --no-deps --document-private-items: clean.cargo clippy -p decdn-cache --no-default-features --all-targets: clean.cargo nextest run: decdn-client + decdn-cli + decdn-cache 3,050/3,050; decdn-node 1,944/1,944 (1 flaky retry); decdn-protocol + decdn-bao-range pass.--features anvil-e2e): 136/141 before the merge; the 4 real failures were e2e origins without.sizeproof(fixture fixed) and one read a file mid-merge. All 7 affected tests pass after the fix and merge.+MAX_PROBE_REQUEST_FRAME; client+UnprovenSize,+check_size_proof,-Streamer::prove_size.iroh-blobs/aws-sdk-s3.Not covered by a dedicated test
RangeNotSatisfiableat offset == size and for the empty blob, and the wire result of the "no proof" refusals on the window and direct-serve paths (the code paths are covered by the existing gates, not by new loopback tests)..sizeproofread (single-flight); the negative memo has a cache-level test.🤖 Generated with Claude Code