transport: handshake protocol-version negotiation (validateProtocolVersion) - #73
Merged
Conversation
…rsion) Adds `wire.bcast_stream.validateProtocolVersion`, mirroring ethp2p `broadcast/peer.go`: a peer version above `protocol_v1` is clamped down to it, and anything not equal to `protocol_v1` is rejected with `error.ProtocolMismatch`. `EngineQuicHost.finishBcastHandshakeRead` now validates `h.version` on the inbound BCAST handshake before accepting the peer, instead of ignoring it. Unit test covers accept-v1, clamp-high, and reject paths; the QUIC handshake tests exercise the wired call. Closes #64.
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 #64.
Adds
wire.bcast_stream.validateProtocolVersion, mirroring ethp2pbroadcast/peer.govalidateProtocolVersion: a peer version aboveprotocol_v1is clamped down to it, and anything not equal toprotocol_v1is rejected witherror.ProtocolMismatch. Returns the negotiated version.Previously the Zig handshake wrote/read the version fields but never validated them — the peer's
versionwas decoded and ignored.What changed
wire/bcast_stream.zig:validateProtocolVersion(u32) !u32+ProtocolMismatchinBcastStreamError.broadcast/engine_quic.zig:finishBcastHandshakeReadnow validatesh.versionon the inbound BCAST handshake before storing the peer id (rejects the connection on mismatch).Tests
validateProtocolVersion(1) == 1,(2)/(99)clamp to1,(0)→error.ProtocolMismatch.quic-transport) exercise the wired call.Verified on stock Zig 0.16.0:
zig fmt --check,zig build test,zig build test-quic. README updated.