Skip to content

proposal: a node proves the blob size, so total_bytes is verified #2879

Closed

Description

@alpergundogdu

Summary

Make total_bytes a verified fact. A node that states a blob size on cdn/client/v1 or cdn/probe/v1 attaches a size proof that the receiver checks against the content hash before it uses the size.

Today every size is a claim. The signed StreamResponse.total_bytes, the probe's total_bytes and an origin's HEAD size are all unverified until a leg happens to reach the true end of the blob. Everything that plans from a size has to defend against a lie.

Why

An unverified size has cost us repeatedly:

#2874 answers this by never trusting a size: the plan starts from one 64 MiB seed and grows from verified bytes, and one lane fetches the tail to prove the claim. That works, and it is about 2,000 lines of planner logic whose only job is to live without a fact that is cheap to prove.

The fact is cheap to prove because BLAKE3 binds the length into the tree. Only the true size verifies a final chunk under the root.

The proposal

  1. A size proof travels with the size. StreamResponse carries it, and so does a ProbeResponse that states a size. A node states no size that it cannot prove.
  2. The receiver verifies it against the content hash, before it plans, allocates, splits, or pays against the size.
  3. A proof depends on the hash alone. It names no node and carries no signature, so any party that holds one can pass it on.
  4. The origin makes it. decdn origin import already computes the outboard, so it can write the proof beside it. A node that pulls a blob keeps the proof it verified from its upstream and can serve the proof before it holds the tail of the blob.

What we gain

What it costs

  • A proof reveals the end of the blob, unpaid. The receiver needs the bytes of the final BLAKE3 chunk to check the length, so a proof carries up to 1 KiB of content. For a blob of 1 KiB or less the proof is the whole blob. The value is about one thousandth of a chunk price for each blob.
  • A wire change to StreamResponse and ProbeResponse, and a new stored artifact at the origin and in the node's cache.
  • A node that holds a blob without its tail needs the proof from somewhere. A partial holder gets it from the upstream it pulled from. An origin-backed node reads the last chunk group from its origin once and keeps the result.
  • Probe responses grow by the size of the proof.

Open decisions

  • Encoding. Two candidates. The first is the existing bao verified-range response for the last chunk group (ADR 038): no new format, up to 16 KiB plus the path. The second descends below the chunk group to the final 1 KiB BLAKE3 chunk: smaller, and it needs the chaining values inside the last group, which the group-level outboard does not store.
  • Probe or stream only. A proof on the probe lets a client plan before it opens a stream. It also makes every probe answer larger.
  • Whether a node may serve without a proof while it fetches one, or must refuse.
  • What happens to refactor(client,node)!: a size claim only picks the verification shape #2874. Several of its fixes do not depend on this and are still needed: num_blocks saturation, the pull-leg plan clamp to the request end and max_blob_size, the Want tail fix (client: cap-0 explicit ranges longer than the 1 TiB sizing ceiling truncate or overfetch #2865), and the cache path where an origin-backed node verifies the last chunk group, which is the generator this proposal needs.

Relation to other work

Activity

  1. added
    design:adr
    area:client
    area:protocol
    on Nov 11, 2026
  2. alpergundogdu commented on Nov 11, 2026

    @alpergundogdu
    ContributorAuthor

    Draft ADR change: #2880. #2874 is converted to draft and on hold until this is decided.

  3. alpergundogdu commented on Nov 11, 2026

    @alpergundogdu
    ContributorAuthor

    Encoding decided: the final 1 KiB BLAKE3 chunk, not the 16 KiB chunk group.

    A throwaway test built the proof with stock bao-tree calls at block size 0 (encode_ranges_validated over the last chunk) and checked it with the stock decoder (decode_ranges). Over 14 sizes from 1 byte to 37 MiB, each proof verified under the true size and under none of about 19 wrong sizes. Measured proofs were 1 byte to 1.7 KiB: the last chunk plus 64 bytes for each level on its path to the root. A 100 GiB blob comes to under 3 KiB.

    So the verifier is one small function in decdn-bao-range that takes the root, the claimed size and the proof, and answers yes or no. The generator needs the hashes inside the last chunk group, which the group-level .obao4 outboard does not store, so it computes them from the last group's bytes.

  4. alpergundogdu commented on Nov 11, 2026

    @alpergundogdu
    ContributorAuthor

    Codec: #2882 adds verify_size_proof and encode_size_proof to decdn-bao-range. It is a draft with no caller yet. The encoder's output matches the stock bao-tree encoder byte for byte over 24 sizes, and it builds the proof from the group-level .obao4 outboard plus the last chunk group, so an origin needs to read at most 16 KiB of the blob.

  5. yigitdot commented on Nov 13, 2026

    @yigitdot
    Contributor

    Implemented by #2885 (merged as a6405f5): every blob size a node states now travels with a size proof that is verified before anything plans, allocates, compares with a cap or pays from it. Closing as completed — the PR's "Implements" reference did not auto-close this.

  6. moved this from Backlog to Done in deCDNon Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:clientarea:protocoldesign:adr

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    • Status
      Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions