broadcast: session reconstruction signaling + disposal (SESS reset 0x01)#71
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #62.
Adds the session lifecycle state machine, aligned with ethp2p
broadcast/session.go/peer_in.go. Previously theChannelPeerReconstructed/PeerCloseStreamevent shapes existed but nothing produced or consumed them, andsessCodeReconstructedwas 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-peermarkPeerCompleted/dropPeer, andmaybeDispose: 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 emitsOnSessionDisposed(completing another Observer callback from broadcast: implement Observer interface callbacks + SessionRole enum #58).sessionDecodenow callssignalReconstructed(no-op for origin).Scope note
SessionRsis transport-agnostic, so the actual per-peer SESS-stream reset with0x01belongs 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)
0x01constant,.originstage,maybeDisposegated on peer completion,disposeSessionemitsOnSessionDisposed,.consuming→ drop-based disposal, thensignalReconstructed→.reconstructeddecoded-branch disposal.Verified on stock Zig 0.16.0:
zig fmt --check,zig build test,zig build test-broadcast(TSan) pass. README updated.