Skip to content

node: add turnkey BroadcastNode Host wrapper - #79

Merged
ch4r10t33r merged 1 commit into
mainfrom
feat/broadcast-node-host
Jul 14, 2026
Merged

node: add turnkey BroadcastNode Host wrapper#79
ch4r10t33r merged 1 commit into
mainfrom
feat/broadcast-node-host

Conversation

@ch4r10t33r

Copy link
Copy Markdown
Collaborator

What

Adds src/node/broadcast_host.zig — a turnkey, poll-driven BroadcastNode Host that packages the QUIC RS-broadcast assembly which until now existed only as test sequences in transport/eth_ec_quic_enabled.zig.

A raw EngineQuicHost bridges one inbound peer's SESS/CHUNK streams into an Engine; everything else (bind, dial, the BCAST handshake, the peer map, the poll loop, the outbound send, and the decode-and-deliver trigger) was left to the caller. BroadcastNode fills those gaps:

  • bind + connect + BCAST handshake — owns a QUIC listen endpoint (server) and a dial endpoint (client); connect/acceptInbound complete the QUIC handshake then run the BCAST handshake exchange and capture the remote peer id.
  • peer map + tick(now_ms) — single-threaded poll loop: pump QUIC, accept inbound, advance handshakes, decode+deliver, GC. No goroutines/tickers, matching the library's synchronous port style.
  • publish — RS-encodes the payload, sends the SESS session_open (preamble) then the RS shard chunks to each ready peer.
  • decode-and-deliver — polls progress(), calls sessionDecode when a relay session has enough shards, and hands the FullMessage to the channel's Subscription. Origin sessions are skipped (no self-delivery).

Test

Loopback self-interop test (registered under the test-quic CI job): node A publishes a message and node B reconstructs the identical payload over real QUIC. Verified locally with the 0.16.0 toolchain (test-quic 59/59 green; default zig build clean; zig fmt --check clean).

Scope / limitations

Deliberately experimental, mirroring the parallel-broadcast adapter pattern:

  • The outbound path is single-peer-correct — the RS emit planner tags each dispatch with a target peer, but SendRsChunkFn is peer-agnostic, so one sessionDrainOutboundOverQuic call fans one session to one connection.
  • No multi-peer shard routing, peer authentication, or peer-disconnect events.
  • The co_poll_ep hook exists for in-process loopback tests; real deployments pass null (each process pumps its own socket via tick).

Package the QUIC RS-broadcast assembly that previously existed only as test
sequences in `transport/eth_ec_quic_enabled.zig` into a reusable, poll-driven
Host (`src/node/broadcast_host.zig`).

`BroadcastNode` owns a QUIC listen endpoint, a dial endpoint, a
`broadcast.Engine`, a per-peer `EngineQuicHost`, and a per-channel
`Subscription`, and fills the gaps a raw `EngineQuicHost` leaves to the caller:

  - bind (listen) + connect (dial) + the BCAST handshake exchange,
  - a peer map and a single-threaded `tick(now_ms)` poll loop,
  - the outbound SESS session_open + RS chunk send on publish,
  - the decode-and-deliver trigger (poll `progress()`, `sessionDecode`,
    hand the FullMessage to the channel `Subscription`), and periodic GC.

Includes a loopback self-interop test: node A publishes a message and node B
reconstructs the identical payload over real QUIC. Registered under the
`test-quic` CI job (`ci_root_quic.zig`).

Scope: the outbound path is single-peer-correct (the emit planner tags each
dispatch with a peer, but `SendRsChunkFn` is peer-agnostic). Multi-peer
routing, peer authentication, and peer-disconnect events are out of scope.
@ch4r10t33r
ch4r10t33r merged commit d695065 into main Jul 14, 2026
7 checks passed
@ch4r10t33r
ch4r10t33r deleted the feat/broadcast-node-host branch July 14, 2026 16:18
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.

1 participant