Skip to content

feat(protocol,node)!: sender-chosen ChunkData frames and the Tier-1 extension seam - #1804

Merged
thiras merged 4 commits into
mainfrom
feat/1796-sender-choice-frames
Aug 24, 2026
Merged

thiras merged 4 commits into
mainfrom
feat/1796-sender-choice-frames

Conversation

@thiras

@thiras thiras commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Three commits, all pre-launch wire work that stops being cheap the moment v0.1.0 ships binaries to peers that aren't ours.

1. ChunkData frames become sender's choice (#1796)

CHUNK_SIZE pinned every payload at 1,024 bytes, so a served MiB cost 1,024 iterations of validate + copy + postcard encode + QUIC write. The constant tracked iroh-blobs' internal granularity, which ADR 038 superseded with 16 KiB bao chunk groups verified independently of frame boundaries.

This is a spec/code divergence, not an optimization — adr/038:34 already specified 1 MiB framing and the implementation never followed it. CHUNK_SIZE and MessageValidationError::ChunkTooLarge are deleted; a serving node coalesces to the new payment.frame_target_bytes.

The deleted ceiling protected nothing it claimed to: read_frame allocates up to MAX_MESSAGE_SIZE before postcard decode, so the check was always post-allocation.

Two constraints that are not obvious and are now tested:

  • A frame never crosses a CHUNK_BYTES payment boundary. The old size got that free (1,024 divides 1 MiB). At any other size it must be arranged, or the payer settles residuals with a signed voucher per frame instead of releasing one hash-chain preimage per interval. Caught by three loopback failures mid-development.
  • The frame request is capped by the credit window's remaining room. Load-bearing on the cache-miss leg, where the producer is fed by an upstream pull paced against this stream's own served-and-paid frontier — so asking a shut window for a full frame parks on bytes only recouping can unblock. Caught by a 45s wedge.

Folds in #1769: serve_leg re-ramps its credit window per iteration instead of pinning it once, so a cache-miss stream is no longer stuck at stop-and-wait while the hit path ramps for the same client.

2. Tier-1 extension seam on all three ALPNs; probe signatures verified

ADR 013 §Tier 1 defines how an unsigned field is added post-launch without an ALPN bump: it trails the frozen base as a separately-encoded *Ext, decoded two-phase. That seam was built exactly once, for StreamRequestExt. Everywhere else the ADRs described it, the code did something else — ProbeResponse.total_bytes and StreamResponse.error were plain fields embedded between body and slash_sig, and cdn/dht/v1 had no extension at all.

ProbeResponse and StreamResponse are now {body, slash_sig} with their unsigned fields in trailing *Ext structs; dht.rs gains the same seam, wired through the handler. StreamResponse::validate no longer checks ok/error agreement — that rule spans the signed base and the unsigned extension, so it moved to StreamResponseExt::validate(ok); a receiver calls both.

No contract change, verified by contracts/ carrying no diff: SlashJudge is coupled to the signed field set, not the wire encoding.

Separately, ProbeSlashData::verify_signer had no production caller. The requester length-checked slash_sig and never recovered it, so a node could return 65 bytes of anything and be selected on the has_blob and rate_per_mb it claimed. Now verified on the CLI fetch path and the daemon's own provider selection.

Also corrects two ADR 013 claims the code contradicts: the signature is EIP-712 typed data over a field set, not over postcard bytes — which is why an unsigned field's wire position never affected validity.

3. Review fallout

A multi-agent review found ten issues, including one that mattered: the branch did not compile under --features anvil-e2e. Default nextest and clippy --all-targets are both green on those targets; only the anvil e2e job builds them, and it fails before a test runs.

The other substantive one: the cache-miss prefetch rested on an undocumented margin. Measured rather than argued — a 16 KiB request survives, 64 KiB parks. PULL_WINDOW_FLOOR now carries a third chunk group for the prefetch, with a test tying it to the serve side's room floor. Both are hangs when violated, not failed assertions, which is why they are asserted rather than left to a timeout.

Plus: frame_target_bytes above 1 MiB was a silent no-op (now rejected); a wrong slash_judge_address reported "none of the probed nodes hold the blob" (a config fault dressed as missing content); the DHT seam was dead code (now wired, with per-variant typed encoders); and a set of stale invariant docs pointing at validators and doors that no longer hold them.

Not done, deliberately

  • fix(node): serve_leg hoists its credit window once and never re-ramps #1769's re-ramp has no regression test. Two attempts failed for the same structural reason: on the miss path the serve window is always coupled to the upstream pull window, since a node can only front bytes it has itself fetched and paid for. No client-side observable isolates the serve-side window. A guard needs either control of the upstream pacer or the window derivation extracted from both loops. The half-built fixture was reverted rather than left timing-dependent.
  • Widening MAX_CHAIN_LENGTH to u16 — ADR 003 already weighed and rejected it, and PaymentPool's uint8 cast is the only bound on the on-chain keccak walk, so widening needs a new explicit bound or the walk reaches ~4.2M gas. ADR 003 now records that argument, which it did not previously state.

Verification

2,976 tests pass; clippy clean on default and --features anvil-e2e (CI omits the latter); cargo doc clean; public-API snapshot regenerated; contracts/ carries no diff.

Closes #1796
Closes #1769
Refs #1791

🤖 Generated with Claude Code

https://claude.ai/code/session_013RT61oBVimX8KSZ4q2viV7

thiras and others added 3 commits August 24, 2026 19:23
`CHUNK_SIZE` pinned every `ChunkData` payload at 1,024 bytes, so a served MiB
cost 1,024 iterations of validate + copy + postcard encode + QUIC write. The
constant tracked iroh-blobs' internal granularity, which ADR 038 superseded
with 16 KiB bao chunk groups verified independently of frame boundaries. ADR
038 already specified 1 MiB framing; the implementation never followed it.

`ChunkData` is now bounded only as non-empty, with the framing layer's 16 MiB
`MAX_MESSAGE_SIZE` as the effective ceiling. `CHUNK_SIZE` and
`MessageValidationError::ChunkTooLarge` are deleted. A serving node coalesces
to the new `payment.frame_target_bytes` (default 1 MiB).

The deleted ceiling protected nothing it claimed to: `read_frame` allocates up
to `MAX_MESSAGE_SIZE` before postcard decode, and `ChunkData::new` only runs
during decode, so the check was always post-allocation.

A frame never crosses a `CHUNK_BYTES` payment boundary. The old size got that
for free (1,024 divides 1 MiB); at any other size it must be arranged, or the
payer settles a residual with a signed voucher per frame instead of releasing
one hash-chain preimage per interval. The frame request is also capped by the
credit window's remaining room — load-bearing on the miss leg, where the
producer is fed by an upstream pull paced against this stream's own
served-and-paid frontier, so asking a closed window for a full frame parks on
bytes only recouping can unblock.

Also in scope:

- `encode_chunk_frame` in `decdn-protocol` encodes a frame body straight from
  its payload, one copy instead of two (#1791 item 2, partial — the remaining
  copy needs the vectored-write path in item 3). Byte-identical to the generic
  encoder, pinned by an agreement test and an exact-byte golden vector.
- `serve_leg` re-ramps its credit window per iteration instead of pinning it
  once, so a cache-miss stream is no longer stuck at stop-and-wait while the
  hit path ramps for the same client (#1769).

Wire-breaking new-sender-to-old-receiver; both sides change here per the
pre-launch policy.

Closes #1796
Closes #1769
Refs #1791

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013RT61oBVimX8KSZ4q2viV7
…; verify probe signatures

Two requester-side obligations the ADRs state and the code did not meet.

## 1. The Tier-1 extension seam

ADR 013 §Tier 1 defines how an unsigned field is added after launch without an
ALPN bump: it trails the frozen base as a separately-encoded `*Ext` struct,
decoded two-phase. Postcard fills no defaults for absent trailing fields, so a
separate value is the ONLY way to append one — an `Option<T>` added to an
existing struct fails to decode against an older sender that never wrote it.

That seam was built exactly once, for `StreamRequestExt`. Everywhere else the
ADRs described it, the code did something else:

- `ProbeResponse.total_bytes` and `StreamResponse.error` were plain fields
  embedded between `body` and `slash_sig`, despite ADR 013 §295 stating they
  trail `body + signature`.
- `cdn/dht/v1` had no extension at all, despite ADR 013 §10 requiring the
  pattern be uniform across the three ALPNs.

So a new unsigned field on any response was a Tier-3 change, and the window for
fixing that closes at first deployment.

`ProbeResponse` is now `{body, slash_sig}` with `total_bytes` in
`ProbeResponseExt`; `StreamResponse` is `{body, slash_sig}` with `error` in
`StreamResponseExt`. `dht.rs` gains `FindValueResponseExt` and `StoreRequestExt`,
empty today — the seam has to exist before the field does.

`StreamResponse::validate` no longer checks `ok`/`error` agreement, because it
can no longer see `error`. That rule spans the signed base and the unsigned
extension, so it moved to `StreamResponseExt::validate`, which takes `ok`; a
receiver calls both.

No contract change, verified by `contracts/` carrying no diff: `SlashJudge` is
coupled to the signed FIELD SET, not the wire encoding — the challenger
re-encodes the four signed fields as a fresh ABI blob, so an unsigned extension
is invisible on-chain.

Also corrects two ADR 013 claims the code contradicts: the signature is EIP-712
typed data over a field set, not a signature over postcard bytes, which is why
an unsigned field's wire position never affected validity.

## 2. Probe `slash_sig` was never verified

`ProbeSlashData::verify_signer` had no production caller. The requester checked
only the signature's LENGTH, so a node could return 65 bytes of anything and be
selected on the `has_blob` and `rate_per_mb` it claimed — and face nothing for
abandoning a rate it never committed to, since an unrecovered signature is not
evidence of anything.

`decdn_client_pull::probe::verify_probe_response` runs the value invariants, the
echoed-field correlation, and recovery to the candidate's registered operator
address (ADR 014 §1). `fetch` and `bundle pull` call it before a response can
influence candidate order; the address was already on `NodeCandidate`, so this
needs no new chain read.

A failure is requester-local policy: drop the response, skip the candidate, as
for a timeout. It is never scored against the peer — a signature that does not
recover attributes nothing to anyone.

The node's own probe-collection loop (`node_origin`) still does not verify: its
candidate carries no operator address and `StakerSet` exposes no reverse
`NodeId -> address` lookup, though the projection holds the pairs. Left for a
follow-up rather than widened into this change.

## Not done, deliberately

Widening `MAX_CHAIN_LENGTH` to `u16`. ADR 003 already weighed and rejected it,
and the cost is higher than a type change — `PaymentPool`'s `uint8` cast is the
ONLY bound on the on-chain keccak walk, so widening needs a new explicit bound
or the walk reaches ~4.2M gas. ADR 003 now records that argument, which it did
not previously state.

Refs ADR 013, ADR 005, ADR 014

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013RT61oBVimX8KSZ4q2viV7
Ten findings from a multi-agent review of the two preceding commits, plus the
verification gap that let the first one through.

**The anvil-e2e job did not compile.** `pool_floor_credit_bound.rs` still read
`resp.error`, which moved to `StreamResponseExt`. Default `nextest` and
`clippy --all-targets` are both green on it — only the `anvil e2e` job builds
those targets, and it fails before a test runs.

**The cache-miss prefetch rested on an undocumented margin.** A serve leg reads
one frame past its own shut credit window, and on a miss those bytes can only
come from the upstream pull. `PULL_WINDOW_FLOOR` carried two chunk groups, both
of which its liveness invariant already spends on the two roundings between paid
wire and drawable content — so the prefetch was living on whatever those
roundings happened not to use. Measured: a 16 KiB request survives, 64 KiB
parks. The floor now carries a third group for the prefetch and the invariant
says so, with `frame_target_room_floor_matches_the_pull_reservation` pinning the
two sides together. Both are hangs when violated, not failed assertions, which
is why they are asserted rather than left to an integration test's timeout.

**`payment.frame_target_bytes` above 1 MiB was a silent no-op.** `frame_target`
clamps to the payment-chunk remainder, so a frame can never exceed one interval;
the config docs promised a 16 MiB ceiling and the resolver declined an upper
bound on that basis. Now rejected with a message that says why.

**The daemon's own probe path did not verify `slash_sig`.** The preceding commit
wired verification into the CLI and left `node_origin` — which reads
`rate_per_mb` off a probe and then pays the winner — checking only the shape,
while amending ADR 005 to a MUST. `deps.addr_resolver` already resolves the
operator address, so this needed no new plumbing.

**A wrong `slash_judge_address` reported "none of the probed nodes hold the
blob".** Every honest node fails verification under a bad domain, which is a
local misconfiguration wearing the costume of missing content. The two buckets
are now counted and named separately.

**The DHT third of the extension seam was dead code.** Zero callers; the handler
still encoded with `encode_message` and discarded the remainder. Wired through
both paths, and the untyped `encode_dht_message(msg, Option<&[u8]>)` replaced by
per-variant encoders so an extension cannot be attached to the wrong message.

Also: `credit_window`'s doc comment had been orphaned onto `frame_target` by an
insertion between the two; `frame_target` degraded to one-byte frames rather
than surfacing a broken `unvouchered` invariant, and saturated toward
`usize::MAX` — unbounded buffering — on a conversion failure; `is_delivery_side`
had no non-test caller and now backs the mid-stream exclusion it documents; the
`ok`/`error` and `ChunkData` invariant docs pointed at validators and doors that
no longer hold them; ADR 005 and 014 still showed `error?` inline in
`StreamResponse`; and `pool_floor_credit_bound.rs` claimed to exercise
`serve_via_backend_origin`, which it does not — it seeds no outboard, so the lane
degrades to the buffered fill path.

Not fixed, deliberately: #1769's re-ramp still has no regression test. Two
attempts failed for the same structural reason — on the miss path the serve
window is always coupled to the upstream pull window, since a node can only
front bytes it has itself fetched and paid for, so no client-side observable
isolates the serve-side window. A guard needs either control of the upstream
pacer or the window derivation extracted from both loops.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013RT61oBVimX8KSZ4q2viV7
Copilot AI lite review requested due to automatic review settings August 24, 2026 18:26

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.

Pull request overview

This PR makes pre-launch, wire-breaking protocol updates across cdn/client/v1, cdn/probe/v1, and cdn/dht/v1 to (1) remove the fixed 1 KiB ChunkData framing constraint, (2) standardize ADR-013 Tier‑1 “trailing extension” evolution seams across all ALPNs, and (3) ensure probe slash_sig is verified before responses influence provider selection.

Changes:

  • Protocol: remove CHUNK_SIZE / ChunkTooLarge, introduce sender-chosen ChunkData frame sizing, and add fast-path encode_chunk_frame.
  • Protocol: move unsigned fields into trailing *Ext structs with typed encode/parse helpers for probe/client/dht messages; adjust validation accordingly.
  • Node / client-pull / CLI: plumb two-phase decoding/encoding, add probe signature verification to selection paths, and introduce payment.frame_target_bytes with config resolution/validation.

Reviewed changes

Copilot reviewed 47 out of 47 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
crates/protocol/tests/snapshots/public_api__public_api.snap Updates public API snapshot for new *Ext types and encode/parse helpers; removes CHUNK_SIZE.
crates/protocol/src/message.rs Implements ProbeResponseExt and two-phase encode/parse helpers; updates docs and tests.
crates/protocol/src/lib.rs Re-exports new extension types and encode/parse helpers; drops CHUNK_SIZE.
crates/protocol/src/framing.rs Extends framing tests to cover Tier‑1 trailing extension remainder behavior.
crates/protocol/src/dht.rs Adds empty Tier‑1 extension structs and typed encode/parse helpers for DHT variants.
crates/protocol/src/client.rs Removes fixed chunk size, adds StreamResponseExt, adds encode_chunk_frame, and shifts ok/error validation to the extension.
crates/node/tests/support/mod.rs Adds helper to read StreamResponse + trailing StreamResponseExt in tests.
crates/node/tests/sighup_signal.rs Updates test config seed to include frame_target_bytes.
crates/node/tests/probe_warm_reconnect.rs Adapts probe helper return shape to include ProbeResponseExt.
crates/node/tests/probe_loopback.rs Updates probe loopback tests to parse ProbeResponseExt.total_bytes from trailing bytes.
crates/node/tests/origin_range_pull.rs Adjusts refusal assertions for moved StreamResponse.error into trailing extension.
crates/node/tests/node_to_node_pull_through.rs Updates stream open/refusal assertions; adapts hostile upstream fixtures to new encoding/ext.
crates/node/tests/node_origin_pull.rs Updates hostile server fixtures for two-phase probe/stream responses and sender-chosen frame sizing.
crates/node/tests/client_loopback.rs Updates client loopback tests to read StreamResponseExt and to handle two-phase open frames.
crates/node/tests/anvil_bringup_shutdown_e2e.rs Updates e2e config construction to include frame_target_bytes.
crates/node/src/runtime/reload.rs Adds frame_target_bytes to runtime config defaults and restart-required warning text.
crates/node/src/runtime/mod.rs Plumbs payment.frame_target_bytes into ClientHandlerDeps.
crates/node/src/node_origin/mod.rs Verifies probe slash_sig (via verify_probe_response) before a probe result influences selection.
crates/node/src/handlers/probe.rs Encodes probe responses two-phase with ProbeResponseExt trailing bytes.
crates/node/src/handlers/dht.rs Wires DHT Tier‑1 seam: two-phase encode for FindValueResponse and parses store-request ext on read.
crates/node/src/handlers/client/wire.rs Splits signed base vs unsigned extension for StreamResponse; adds a dedicated writer for two-phase responses.
crates/node/src/handlers/client/window.rs Switches open-stage StreamResponse writes to two-phase writer.
crates/node/src/handlers/client/serve_leg.rs Implements per-iteration credit-window re-ramp and frame targeting; uses encode_chunk_frame fast path.
crates/node/src/handlers/client/serve_encoder.rs Updates coherent framing producer to accept caller-provided per-frame targets.
crates/node/src/handlers/client/mod.rs Adds frame_target_bytes to handler deps/state and implements frame_target logic + tests.
crates/node/src/handlers/client/dispatch.rs Switches stream open response to two-phase writer.
crates/node/src/handlers/client/delivery.rs Generalizes framing to variable targets and uses encode_chunk_frame fast path on the cache-hit path.
crates/e2e/tests/pool_floor_credit_bound.rs Updates open-stage parsing to read StreamResponseExt from trailing bytes.
crates/e2e/src/client.rs Adapts probe calls to new (resp, ext, rtt) return shape; adjusts refusal messaging.
crates/common/src/config/types.rs Adds payment.frame_target_bytes to config schema.
crates/common/src/config/resolved.rs Adds resolved frame_target_bytes field.
crates/common/src/config/mod.rs Introduces DEFAULT_FRAME_TARGET_BYTES and validates payment.frame_target_bytes in resolution.
crates/client-pull/src/probe.rs Returns ProbeResponseExt from probes and adds verify_probe_response (invariants + correlation + signature recovery).
crates/client-pull/src/pacer.rs Raises PULL_WINDOW_FLOOR to reserve an extra chunk group for miss-path prefetch; updates liveness test.
crates/client-pull/src/lib.rs Implements two-phase open-stage read + StreamResponseExt validation; updates refusal handling accordingly.
crates/cli/tests/config_validate.rs Updates sample resolved config to include frame_target_bytes.
crates/cli/src/commands/probe.rs Threads ProbeResponseExt into CLI output (total_bytes now comes from the extension).
crates/cli/src/commands/node.rs Updates probe ranking to match new probe return tuple shape.
crates/cli/src/commands/fetch.rs Verifies probe signatures before ordering candidates; improves “none hold blob” vs “unverifiable/misconfig” error reporting.
crates/cli/src/commands/config.rs Documents payment.frame_target_bytes in the default config template.
crates/cli/src/commands/bundle_pull.rs Passes slash domain into probe selection for signature verification.
CHANGELOG.md Documents wire-breaking extension relocation, sender-chosen frames + new config, credit-window re-ramp fix, and probe signature verification.
adr/038-bao-verified-range-streaming.md Updates wire-format text to sender-sized framing (bounded by payment interval).
adr/014-on-chain-verification.md Updates signed-field inventory to reflect base + extension split.
adr/013-schema-evolution.md Clarifies Tier‑1 extension mechanics and notes large ChunkData framing behavior under the cap.
adr/005-protocol.md Updates diagrams and rules for extension split, sender-sized frames, and mandatory probe signature recovery.
adr/003-payments.md Adds explicit rationale about the uint8 cast being the on-chain hash-walk bound.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread crates/protocol/src/client.rs Resolved
Comment thread crates/node/tests/origin_range_pull.rs Resolved
@github-actions

github-actions Bot commented Aug 24, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 81.71% (was 81.66%, ▲ +0.05%) — 65769/80495 lines

File Coverage Lines Δ
crates/cli/src/commands/bundle_pull.rs 49.09% 432/880 ▼ 0.06%
crates/cli/src/commands/config.rs 86.57% 548/633 ▲ +0.04%
crates/cli/src/commands/fetch.rs 34.05% 522/1533 ▼ 0.47%
crates/cli/src/commands/node.rs 77.37% 1012/1308 ● 0.00%
crates/cli/src/commands/probe.rs 76.04% 146/192 ▲ +0.91%
crates/client-pull/src/lib.rs 89.13% 1681/1886 ▼ 0.02%
crates/client-pull/src/pacer.rs 99.06% 211/213 ● 0.00%
crates/client-pull/src/probe.rs 92.07% 151/164 ▲ +3.34%
crates/common/src/config/mod.rs 97.06% 6878/7086 ▼ 0.05%
crates/common/src/config/resolved.rs 100.00% 42/42 ● 0.00%
crates/e2e/src/client.rs 0.00% 0/455 ● 0.00%
crates/node/src/handlers/client/delivery.rs 96.13% 273/284 ▲ +0.44%
crates/node/src/handlers/client/dispatch.rs 85.60% 440/514 ● 0.00%
crates/node/src/handlers/client/mod.rs 92.63% 1521/1642 ▲ +0.48%
crates/node/src/handlers/client/serve_encoder.rs 87.58% 261/298 ▲ +4.03%
crates/node/src/handlers/client/serve_leg.rs 84.18% 149/177 ▲ +0.27%
crates/node/src/handlers/client/window.rs 75.25% 298/396 ▼ 0.12%
crates/node/src/handlers/client/wire.rs 96.48% 137/142 ▼ 1.25%
crates/node/src/handlers/dht.rs 76.66% 289/377 ▼ 0.81%
crates/node/src/handlers/probe.rs 86.50% 269/311 ▼ 0.13%
crates/node/src/node_origin/mod.rs 91.13% 1141/1252 ▼ 0.16%
crates/node/src/runtime/mod.rs 48.24% 1154/2392 ● 0.00%
crates/node/src/runtime/reload.rs 96.54% 1534/1589 ● 0.00%
crates/protocol/src/client.rs 99.32% 879/885 ▲ +0.20%
crates/protocol/src/dht.rs 94.71% 412/435 ▼ 4.29%
crates/protocol/src/framing.rs 98.98% 388/392 ▼ 0.25%
crates/protocol/src/message.rs 99.64% 275/276 ▼ 0.36%
History
Commit Total Δ vs base
a8ab5fc 81.71% ▲ +0.05%
490d5f3 (HEAD) 81.71% ▲ +0.05%

…se extension

Both from review of #1804, both artefacts of edits in the preceding commits.

`ChunkData`'s doc carried "A shorter final frame" twice — a phrase replacement
left the original stub in front of its own replacement.

`origin_range_pull`'s paid-pull fixture still read the open frame with
`read_client_msg`, discarding the trailing `StreamResponseExt`, and asserted
`ok` with a placeholder string that could not name the refusal code. It now
reads two-phase via `read_stream_response`, so a refusal reports the code that
caused it. This fixture was meant to move with its siblings in the extension
commit; the edit did not match and was not re-checked.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013RT61oBVimX8KSZ4q2viV7
@thiras
thiras merged commit 4c46e9b into main Aug 24, 2026
25 checks passed
@thiras
thiras deleted the feat/1796-sender-choice-frames branch August 24, 2026 18:53
thiras added a commit that referenced this pull request Aug 26, 2026
…ites (#1791)

Group D serve-path hot path: the per-MiB cost is per-frame
validation + copies + allocations + QUIC writes. 1 KiB frames were
already lifted to sender-chosen ≤1 MiB in #1804; this finishes items 2
and 3 without a wire change (pre-launch, but byte-identical so no
ALPN bump needed).

- protocol: add CHUNK_DATA_HEADER_MAX / CHUNK_FRAME_HEADERS_MAX,
  encode_chunk_data_header / encode_chunk_frame_headers on a stack
  [u8;11] (framing varint + discriminant + varint(payload_len))
  validated against MAX_MESSAGE_SIZE (new ChunkTooLarge), reusing
  framing::encode_varint_u32; add ChunkTooLarge to
  MessageValidationError; validate encode_chunk_frame as well
  (crates/protocol/src/client.rs, framing.rs, message.rs).

- node: replace BytesMut coalescer with VecDeque<Bytes> queue +
  queued in ChunkFramer (delivery.rs) and CoherentFrameProducer
  (serve_encoder.rs); next_frame_chunks returns Vec<Bytes> slices
  via Bytes::split_to (zero-copy spanning), next_frame kept
  #[cfg(test)] for framing_matches_slice_chunks_at_every_target.

- node: wire.rs add write_chunk_payload{_multi} — header on stack
  (≤11 B) + payload Bytes via SendStream::write_all_chunks
  (noq-1.0.0 vectored, reference-counted). sum(payload_chunks) ==
  total_len checked, empty rejected. serve_leg + delivery loops
  switched to next_frame_chunks + write_chunk_payload_multi; credit
  window accounting unchanged, faulted is now terminal on the miss
  leg (mirrors hit path).

Verified: cargo build/clippy clean, cargo nextest -p decdn-protocol
(145), -p decdn-node lib/framing (4) + client_loopback (110) +
node_to_node (4); vectored header == old postcard+framing bytes
(1 MiB golden via /tmp/vec_test).

Refs #1791
thiras added a commit that referenced this pull request Aug 26, 2026
…ites (#1791)

Group D serve-path hot path: the per-MiB cost is per-frame
validation + copies + allocations + QUIC writes. 1 KiB frames were
already lifted to sender-chosen ≤1 MiB in #1804; this finishes items 2
and 3 without a wire change (pre-launch, but byte-identical so no
ALPN bump needed).

- protocol: add CHUNK_DATA_HEADER_MAX / CHUNK_FRAME_HEADERS_MAX,
  encode_chunk_data_header / encode_chunk_frame_headers on a stack
  [u8;11] (framing varint + discriminant + varint(payload_len))
  validated against MAX_MESSAGE_SIZE (new ChunkTooLarge), reusing
  framing::encode_varint_u32; add ChunkTooLarge to
  MessageValidationError; validate encode_chunk_frame as well
  (crates/protocol/src/client.rs, framing.rs, message.rs).

- node: replace BytesMut coalescer with VecDeque<Bytes> queue +
  queued in ChunkFramer (delivery.rs) and CoherentFrameProducer
  (serve_encoder.rs); next_frame_chunks returns Vec<Bytes> slices
  via Bytes::split_to (zero-copy spanning), next_frame kept
  #[cfg(test)] for framing_matches_slice_chunks_at_every_target.

- node: wire.rs add write_chunk_payload{_multi} — header on stack
  (≤11 B) + payload Bytes via SendStream::write_all_chunks
  (noq-1.0.0 vectored, reference-counted). sum(payload_chunks) ==
  total_len checked, empty rejected. serve_leg + delivery loops
  switched to next_frame_chunks + write_chunk_payload_multi; credit
  window accounting unchanged, faulted is now terminal on the miss
  leg (mirrors hit path).

Verified: cargo build/clippy clean, cargo nextest -p decdn-protocol
(145), -p decdn-node lib/framing (4) + client_loopback (110) +
node_to_node (4); vectored header == old postcard+framing bytes
(1 MiB golden via /tmp/vec_test).

Refs #1791
thiras added a commit that referenced this pull request Aug 26, 2026
…ites (#1791)

Group D serve-path hot path: the per-MiB cost is per-frame
validation + copies + allocations + QUIC writes. 1 KiB frames were
already lifted to sender-chosen ≤1 MiB in #1804; this finishes items 2
and 3 without a wire change (pre-launch, but byte-identical so no
ALPN bump needed).

- protocol: add CHUNK_DATA_HEADER_MAX / CHUNK_FRAME_HEADERS_MAX,
  encode_chunk_data_header / encode_chunk_frame_headers on a stack
  [u8;11] (framing varint + discriminant + varint(payload_len))
  validated against MAX_MESSAGE_SIZE (new ChunkTooLarge), reusing
  framing::encode_varint_u32; add ChunkTooLarge to
  MessageValidationError; validate encode_chunk_frame as well
  (crates/protocol/src/client.rs, framing.rs, message.rs).

- node: replace BytesMut coalescer with VecDeque<Bytes> queue +
  queued in ChunkFramer (delivery.rs) and CoherentFrameProducer
  (serve_encoder.rs); next_frame_chunks returns Vec<Bytes> slices
  via Bytes::split_to (zero-copy spanning), next_frame kept
  #[cfg(test)] for framing_matches_slice_chunks_at_every_target.

- node: wire.rs add write_chunk_payload{_multi} — header on stack
  (≤11 B) + payload Bytes via SendStream::write_all_chunks
  (noq-1.0.0 vectored, reference-counted). sum(payload_chunks) ==
  total_len checked, empty rejected. serve_leg + delivery loops
  switched to next_frame_chunks + write_chunk_payload_multi; credit
  window accounting unchanged, faulted is now terminal on the miss
  leg (mirrors hit path).

Verified: cargo build/clippy clean, cargo nextest -p decdn-protocol
(145), -p decdn-node lib/framing (4) + client_loopback (110) +
node_to_node (4); vectored header == old postcard+framing bytes
(1 MiB golden via /tmp/vec_test).

Refs #1791
thiras added a commit that referenced this pull request Aug 26, 2026
…ites (#1791) (#1828)

* perf(node,protocol): zero-copy ChunkData framing via vectored QUIC writes (#1791)

Group D serve-path hot path: the per-MiB cost is per-frame
validation + copies + allocations + QUIC writes. 1 KiB frames were
already lifted to sender-chosen ≤1 MiB in #1804; this finishes items 2
and 3 without a wire change (pre-launch, but byte-identical so no
ALPN bump needed).

- protocol: add CHUNK_DATA_HEADER_MAX / CHUNK_FRAME_HEADERS_MAX,
  encode_chunk_data_header / encode_chunk_frame_headers on a stack
  [u8;11] (framing varint + discriminant + varint(payload_len))
  validated against MAX_MESSAGE_SIZE (new ChunkTooLarge), reusing
  framing::encode_varint_u32; add ChunkTooLarge to
  MessageValidationError; validate encode_chunk_frame as well
  (crates/protocol/src/client.rs, framing.rs, message.rs).

- node: replace BytesMut coalescer with VecDeque<Bytes> queue +
  queued in ChunkFramer (delivery.rs) and CoherentFrameProducer
  (serve_encoder.rs); next_frame_chunks returns Vec<Bytes> slices
  via Bytes::split_to (zero-copy spanning), next_frame kept
  #[cfg(test)] for framing_matches_slice_chunks_at_every_target.

- node: wire.rs add write_chunk_payload{_multi} — header on stack
  (≤11 B) + payload Bytes via SendStream::write_all_chunks
  (noq-1.0.0 vectored, reference-counted). sum(payload_chunks) ==
  total_len checked, empty rejected. serve_leg + delivery loops
  switched to next_frame_chunks + write_chunk_payload_multi; credit
  window accounting unchanged, faulted is now terminal on the miss
  leg (mirrors hit path).

Verified: cargo build/clippy clean, cargo nextest -p decdn-protocol
(145), -p decdn-node lib/framing (4) + client_loopback (110) +
node_to_node (4); vectored header == old postcard+framing bytes
(1 MiB golden via /tmp/vec_test).

Refs #1791

* fix(protocol): report frame length in ChunkTooLarge and cap encode_chunk_data_header at MAX_MESSAGE_SIZE

* fix(protocol): report frame length in encode_chunk_data_header buffer-guard errors

* fix(node,protocol): close the #1828 review findings on the zero-copy frame path

The vectored path was correct on the wire but had converted several loud
failures into silent ones, and left the invariant docs naming a door the
serve paths no longer use.

- protocol: the ChunkData type doc and MessageValidationError::EmptyChunk
  enumerate every route to a frame body; both now name all three
  encode_chunk_* helpers, and encode_chunk_frame_headers rather than
  encode_chunk_frame as the door the serve paths use. encode_chunk_frame's
  own doc no longer describes a delivery loop that does not call it.
- protocol: encode_chunk_data_header / chunk_frame_postcard_len /
  CHUNK_DATA_HEADER_MAX / encode_varint_u32 are pub(crate) — the node uses
  only CHUNK_FRAME_HEADERS_MAX and encode_chunk_frame_headers. Their guards
  now error rather than write a short header, and the u32 clamp is a
  map_err, so a MAX_MESSAGE_SIZE change cannot turn one into a wrong length
  prefix. The stated buffer maxima say what they actually bound.
- node: chunk_frame_bufs assembles a frame's write buffers as a pure
  function and write_chunk_bufs does only I/O, so serve_leg no longer
  meters a node-side framing fault as node_pull_through_client_abandoned
  (#856). The <= 4 stack fast path is gone: export items are 64 B proof
  nodes and 16 KiB leaves, so a 1 MiB frame spans ~130 chunks and never
  took it, and its guards returned Ok(()) having written nothing.
- node: both framers refuse a zero target instead of answering None, which
  the serve loops read as a fully delivered blob and follow with StreamEnd.
  drain_frame is shared by both rather than duplicated, and reports a
  queued/queue desync rather than an end of blob.
- node: write_chunk_payload is deleted (unused).

Tests: chunk_frame_bufs against encode_chunk_frame + write_frame at 1, 2,
4, 5 and 130 chunks; its length-mismatch and empty refusals; drain_frame
boundaries; a zero target on both framers; CoherentFrameProducer's fault
is terminal (the twin of a_mid_export_fault_propagates); the header golden
test gains the framing-varint boundaries (125/126, 16_381/16_382,
2_097_149/2_097_150) and the 2^21 payload width; EmptyChunk and
ChunkTooLarge at the new doors; chunk_frame_postcard_len against the
encoded header.

Refs #1791

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

---------

Co-authored-by: yigitdot <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants