Repository navigation
Closed
Description
Refines #1791 item 1. Instead of replacing the 1 KiB frame size with another fixed number, ChunkData becomes variable-size, sender's choice, bounded above only by the framing layer.
Current state
CHUNK_SIZE = 1024(crates/protocol/src/client.rs:49) is the exact payload size of everyChunkDataexcept the final one. The sender re-chops the bao export at it (ChunkFramer,crates/node/src/handlers/client/delivery.rs:63-113); the receiver rejects anything larger at decode (ChunkData::new→MessageValidationError::ChunkTooLarge, the only constructor, gated viaTryFrom<ChunkDataWire>).- The constant's stated rationale — "matches iroh-blobs' internal 1024-byte chunk granularity" — is vestigial since ADR 038: the payload is the bao interleaved verified stream, framing boundaries are explicitly independent of chunk-group boundaries, the codec is the sole verifier, and
delivery.rs:26notes the 16 KiB chunk group does not line up withCHUNK_SIZE. The alignment buys nothing; it forces 1,024 frames (and their per-frame validate/copy/encode/write costs) per MiB served — comically small against multi-hundred-GB transfer targets.
Decision
- Payload bounds:
1..at the protocol level.ChunkData::newkeeps only the non-empty check (the ADR 005 §Non-empty chunk progress invariant is unchanged and load-bearing).MessageValidationError::ChunkTooLargeis deleted; the effective ceiling is the framing layer'sMAX_MESSAGE_SIZE(16 MiB,crates/protocol/src/framing.rs:32), enforced where it already is. - Frame size is sender policy, not protocol. In practice frames stay well under the payment cadence:
CHUNK_BYTES(1 MiB) is the proof interval, and delivery is paced by the credit window — a not-yet-ramped lane's window is one chunk, so a sender naturally sizes frames at or below the window remaining. The serving node picks a target coalescing size locally (theChunkFramerthreshold becomes a node-local constant rather than a wire constant); nothing is negotiated and nothing new travels the wire. - Receiver is size-agnostic. Payment (cumulative byte counter crossing
CHUNK_BYTESboundaries), verification (bao decoder fed from the reassembled stream), and the partial-final-chunk rule all generalize: "the final chunk MAY be smaller" dissolves into "every frame carries 1.. bytes, sender's choice". - Known trade-off, accepted: whole-frame inactivity stall detection gets coarser as frames get larger; that detector is too crude regardless of this change and is tracked separately (see the byte-progress stall-detection issue, linked below once filed).
Work
crates/protocol: relaxChunkData::new/validateto non-empty only; deleteCHUNK_SIZEandChunkTooLarge; update the struct/constructor docs and the discriminant/bounds tests.crates/node:ChunkFramercoalesces to a node-local target size and emits whole buffers (no split cap); the equivalent miss-path frame production inserve_encoder/serve_legfollows the same rule.crates/client-pull: remove theCHUNK_SIZEassumptions in comments/logic (lib.rs:2150,:2585); confirm the receive path is size-agnostic.- Tests that chop wire bytes at
CHUNK_SIZEswitch to a local helper constant (any size is now a valid sender choice). - ADR 005: rewrite the
cdn/client/v1diagram note ("1024-byte chunks"), §Partial final chunk, and the Tradeoffs line about the 1024-byte granularity; state that framing is sender's choice, independent of verification and payment boundaries, bounded by the message-size cap. ADR 038's wire-format wording is checked for consistency.
Pre-launch wire policy applies (CLAUDE.md): in-place change, both sides in the same PR, no compatibility shim — after first deployment this same change is a Tier-3 ALPN bump, which is why it lands now.
Activity
alpergundogdu commentedon Aug 24, 2026
Decision on the node-local sender policy (work item 2): the default coalescing target is 1 MiB — matching
CHUNK_BYTES, the payment cadence — with the effective frame size naturally smaller whenever the credit-window remaining is smaller (an unramped lane's window is one chunk, so early frames are window-sized). The target is node configuration, not a wire constant; nothing is negotiated.Generated by Claude Code
alpergundogdu commentedon Aug 24, 2026
Implementation note from a pre-work read-through: there are two frame producers to change, not one.
ChunkFramer(crates/node/src/handlers/client/delivery.rs:36, cut atCHUNK_SIZEinnext_frame,:88-112).CoherentFrameProducer::next_frame(crates/node/src/handlers/client/serve_encoder.rs:286-305), which re-cuts the coherent bao encode's channel output atCHUNK_SIZEthe same way.Both should coalesce to the same node-local 1 MiB default (clamped by credit-window remaining). The receive side (
crates/client-pull/src/lib.rs:2147-2169) is already size-agnostic — it only counts cumulative wire bytes against the promised total — so the client needs comment updates only, as the work list assumes.Generated by Claude Code