Skip to content

fix(gossip): pin iroh-gossip frame ceiling to GOSSIP_MAX_FRAME (#660) - #661

Merged
thiras merged 3 commits into
mainfrom
fix/660-gossip-frame-ceiling
May 22, 2026
Merged

thiras merged 3 commits into
mainfrom
fix/660-gossip-frame-ceiling

Conversation

@thiras

@thiras thiras commented May 21, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Pin iroh-gossip's per-actor frame ceiling to GOSSIP_MAX_FRAME = 16 KiB (new constant in decdn-gossip), wired through a build_gossip(endpoint) helper that both the runtime and the regression test call — so dropping the cap from the helper fails the test rather than silently reverting to iroh-gossip's 4 KiB default.
  • Amend ADR 013 with a #### Gossip Framing subsection: distinguishes deCDN's MAX_MESSAGE_SIZE (probe/client ALPNs) from iroh-gossip's per-actor cap, documents the network-coordination invariant (cap is enforced symmetrically; asymmetric tightening silently partitions the swarm per upstream iroh-gossip#131), and explicitly scopes the existing operator-policy note so it doesn't apply to gossip.
  • Add a compile-time const _: () = assert!(MAX_TRAILING_BYTES + envelope + wrappers <= GOSSIP_MAX_FRAME) so future drift on either constant breaks the build at the right line.
  • Correct PR fix(577): trailing-byte padding cap (M3) + probe I/O classification (M1) #659's stale doc-comments in validation.rs that referenced "iroh-gossip's MAX_MESSAGE_SIZE (16 MiB)" — that 16 MiB figure is deCDN's decdn_protocol::framing::MAX_MESSAGE_SIZE and was never iroh-gossip's. Restores the multiplicative-allocation-amplification rationale for the trailing-bytes cap.

Why 16 KiB

Analytical bounds from iroh-gossip 0.98 source:

  • Data-frame floor ≈ 4.4 KiB = ~256 B envelope (NodeAnnounce + 64 B sig + version) + 4 KiB MAX_TRAILING_BYTES + ~64 B plumtree/topic wrappers + 4 B u32 length prefix.
  • HyParView control upper bound ≈ 1.7 KiB for a Shuffle/ShuffleReply at default fanout (7 PeerInfo entries with two-relay AddrInfo).
  • 16 KiB → ~3.7× headroom over the data-frame floor, ~9× over HyParView control, room for future Tier-1 extensions and PeerData growth.

iroh-gossip 0.98's 4 KiB default is insufficient — it can't carry our existing MAX_TRAILING_BYTES extension allowance, making PR #659's M3 padding cap structurally unreachable under default settings.

Test plan

  • cargo build -p decdn-gossip -p decdn-node clean
  • cargo clippy --workspace --all-targets clean
  • cargo fmt --check clean
  • cargo nextest run — 936/936 workspace tests pass
  • New test build_gossip_wires_gossip_max_frame exercises the production wiring seam (asserts Gossip::max_message_size() == GOSSIP_MAX_FRAME via build_gossip)
  • Compile-time const-assert enforces MAX_TRAILING_BYTES + envelope + wrappers <= GOSSIP_MAX_FRAME

Out of scope

  • Full multi-node behavioral test of read_lp rejection: iroh-gossip 0.98 exposes no in-process seam for that path (net::util is pub(crate), WriteError/ReadError not public). Requires the two-Gossip-instance harness deferred alongside other integration tests; the compile-time invariant and wiring test cover the regression vectors that matter for this change.
  • Operator-facing config key for GOSSIP_MAX_FRAME: per the ADR, this is a wire-coordination value, not an operator-tunable.

Closes #660.

🤖 Generated with Claude Code

Wires iroh-gossip's per-actor `max_message_size` to a deCDN-controlled
`GOSSIP_MAX_FRAME = 16 KiB` (ADR 013 §Gossip Framing) via a new
`decdn_gossip::build_gossip` helper used by both the runtime and the
regression test. Replaces the silent reliance on iroh-gossip 0.98's
4 KiB default — too tight to carry our `MAX_TRAILING_BYTES` extension
allowance — and corrects PR #659's stale doc-comments that conflated
deCDN's `MAX_MESSAGE_SIZE` (probe/client ALPNs) with iroh-gossip's
unrelated per-actor cap.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings May 21, 2026 23:57

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 pins iroh-gossip’s per-actor frame size ceiling to a deCDN-controlled constant (GOSSIP_MAX_FRAME = 16 KiB) to bound pre-allocation in iroh-gossip’s framing (read_lp) and prevent regressions back to the upstream 4 KiB default, while documenting the distinction between deCDN ALPN framing and gossip framing.

Changes:

  • Introduces GOSSIP_MAX_FRAME and a build_gossip(endpoint) helper that applies .max_message_size(GOSSIP_MAX_FRAME) and is used by both the node runtime and a regression test.
  • Adds a compile-time invariant ensuring MAX_TRAILING_BYTES + envelope + wrappers <= GOSSIP_MAX_FRAME.
  • Updates ADR 013 with a new “Gossip Framing” subsection clarifying coordination constraints and operator policy scope.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
crates/node/src/runtime/mod.rs Switches runtime gossip actor construction to build_gossip(...) to ensure the frame ceiling is always applied.
crates/gossip/src/validation.rs Adds GOSSIP_MAX_FRAME and a const-assert tying trailing-bytes allowance to the gossip frame ceiling; updates related docs/comments.
crates/gossip/src/service.rs Adds build_gossip(endpoint) and a regression test asserting the configured max message size is wired through.
crates/gossip/src/lib.rs Re-exports build_gossip and GOSSIP_MAX_FRAME for consumers (notably decdn-node).
adr/013-schema-evolution.md Documents gossip framing separately from deCDN-owned ALPN framing and clarifies the network-coordination invariant.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/gossip/src/validation.rs Resolved
Comment thread crates/gossip/src/validation.rs Resolved
Comment thread crates/gossip/src/validation.rs Resolved
Comment thread crates/gossip/src/validation.rs Resolved
@github-actions

github-actions Bot commented May 22, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 90.05% (was 90.04%, ▲ +0.01%) — 17091/18979 lines

File Coverage Lines Δ
crates/gossip/src/service.rs 43.92% 159/362 ▲ +3.11%
crates/gossip/src/validation.rs 100.00% 288/288 ● 0.00%
crates/node/src/runtime/mod.rs 51.01% 406/796 ● 0.00%
History
Commit Total Δ vs base
da61eff 90.05% ● 0.00%
5ded708 90.05% ● 0.00%
a13b3ab (HEAD) 90.05% ▲ +0.01%

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request establishes a 16 KiB frame size limit for gossip messages by introducing the GOSSIP_MAX_FRAME constant, which overrides the smaller upstream default. The construction of the iroh-gossip actor is now centralized in a build_gossip helper to ensure this limit is consistently enforced. Additionally, the PR updates ADR 013 documentation, adds a regression test for the new helper, and includes a compile-time assertion to verify that the frame size can accommodate the maximum allowed trailing bytes. I have no feedback to provide.

thiras and others added 2 commits May 22, 2026 03:05
Address PR #661 review comments: switch "defence-in-depth" to
"defense-in-depth" (matches the 10 existing files using American
spelling, e.g. adr/001-network.md) and fix accidental double backticks
around `HyParView` in the network-coordination invariant paragraph.

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

Comment fixes surfaced by the post-fix re-review:

- HyParView control frames ARE topic-scoped — every iroh-gossip wire
  frame carries a TopicId (`iroh_gossip::proto::state::Message<PI>`),
  and iroh-gossip maintains a separate HyParView swarm per topic. The
  prior parenthetical "(which are not topic-scoped)" was the inverse
  of reality. Rephrased to convey the intended point (tightening
  GOSSIP_MAX_FRAME breaks legitimate non-payload frames too).
- "~100× across the gossip fan-out" conflated per-frame size ratio
  (16 KiB / 150 B ≈ 109×) with Plumtree fan-out (eager-peer count).
  Reworded to name them as separate multipliers.
- `AnnounceReject::OversizeTrailingBytes` doc-comment now states the
  4 KiB threshold inline so operators reading the metric label
  don't have to chase `MAX_TRAILING_BYTES`.
- `build_gossip` doc-comment now pins the 4 KiB upstream default to
  iroh-gossip 0.98 so a future minor-version bump that shifts it
  doesn't silently invalidate the comment.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@thiras
thiras merged commit 3f94b97 into main May 22, 2026
19 checks passed
@thiras
thiras deleted the fix/660-gossip-frame-ceiling branch May 22, 2026 00:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gossip: tighter per-ALPN frame ceiling to bound iroh-gossip allocation (#577 M3 follow-up)

2 participants