Skip to content

broadcast: session reconstruction signaling + disposal (SESS reset 0x01)#71

Merged
ch4r10t33r merged 1 commit into
mainfrom
feat/session-lifecycle-62
Jul 3, 2026
Merged

broadcast: session reconstruction signaling + disposal (SESS reset 0x01)#71
ch4r10t33r merged 1 commit into
mainfrom
feat/session-lifecycle-62

Conversation

@ch4r10t33r

Copy link
Copy Markdown
Collaborator

Closes #62.

Adds the session lifecycle state machine, aligned with ethp2p broadcast/session.go / peer_in.go. Previously the ChannelPeerReconstructed / PeerCloseStream event shapes existed but nothing produced or consumed them, and sessCodeReconstructed was undefined.

What it does

  • SessionStage (consuming / decoding / reconstructed / origin) with meaningful ordering — isDecoded() == stage >= reconstructed.
  • sessCodeReconstructed = 0x01 — the QUIC application error code a peer's SESS stream is reset with once reconstructed.
  • signalReconstructed, per-peer markPeerCompleted / dropPeer, and maybeDispose: not-decoded → dispose when all peers dropped; decoded → dispose when every still-attached peer completed; peerless sessions left for TTL cleanup.
  • ChannelRs.disposeSession — removes + frees the session and emits OnSessionDisposed (completing another Observer callback from broadcast: implement Observer interface callbacks + SessionRole enum #58). sessionDecode now calls signalReconstructed (no-op for origin).

Scope note

SessionRs is transport-agnostic, so the actual per-peer SESS-stream reset with 0x01 belongs in the QUIC transport (engine_quic) when it observes reconstruction — a follow-up. This PR lands the state machine, disposal, observer emission, and the wire constant.

Tests (leak-checked)

  • stage ordering + 0x01 constant,
  • origin session: .origin stage, maybeDispose gated on peer completion, disposeSession emits OnSessionDisposed,
  • relay session: .consuming → drop-based disposal, then signalReconstructed.reconstructed decoded-branch disposal.

Verified on stock Zig 0.16.0: zig fmt --check, zig build test, zig build test-broadcast (TSan) pass. README updated.

Adds the session lifecycle state machine, aligned with ethp2p
`broadcast/session.go`:
  - `SessionStage` (consuming/decoding/reconstructed/origin) with ordering
    semantics (`isDecoded` == stage >= reconstructed),
  - `sessCodeReconstructed = 0x01` — the QUIC app error code a peer's SESS
    stream is reset with once reconstructed (`broadcast/peer_in.go`),
  - `signalReconstructed`, per-peer `markPeerCompleted`/`dropPeer`, and
    `maybeDispose` (not-decoded → all peers dropped; decoded → all
    attached peers completed; peerless sessions left for TTL cleanup),
  - `ChannelRs.disposeSession` — removes + frees the session and emits
    `OnSessionDisposed` (completing another Observer callback from #58).

`sessionDecode` now calls `signalReconstructed` (no-op for origin).
Origin sessions start at `.origin`, relay sessions at `.consuming`.

The actual per-peer SESS-stream reset with 0x01 is emitted by the QUIC
transport when it observes reconstruction — a transport wiring follow-up,
since `SessionRs` is transport-agnostic.

Tests: stage ordering + reset-code constant, origin disposal gated on
peer completion (with `OnSessionDisposed` emit), and relay
consuming→reconstructed + drop-based disposal — all leak-checked.
README implementation-status table updated.

Closes #62.
@ch4r10t33r ch4r10t33r merged commit af349e9 into main Jul 3, 2026
7 checks passed
@ch4r10t33r ch4r10t33r deleted the feat/session-lifecycle-62 branch July 3, 2026 15:08
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.

broadcast: session reconstruction signaling + disposal (SESS reset 0x01)

1 participant