Skip to content

transport: handshake protocol-version negotiation (validateProtocolVersion) - #73

Merged
ch4r10t33r merged 1 commit into
mainfrom
feat/protocol-version-64
Jul 3, 2026
Merged

transport: handshake protocol-version negotiation (validateProtocolVersion)#73
ch4r10t33r merged 1 commit into
mainfrom
feat/protocol-version-64

Conversation

@ch4r10t33r

Copy link
Copy Markdown
Collaborator

Closes #64.

Adds wire.bcast_stream.validateProtocolVersion, mirroring ethp2p broadcast/peer.go validateProtocolVersion: a peer version above protocol_v1 is clamped down to it, and anything not equal to protocol_v1 is rejected with error.ProtocolMismatch. Returns the negotiated version.

Previously the Zig handshake wrote/read the version fields but never validated them — the peer's version was decoded and ignored.

What changed

  • wire/bcast_stream.zig: validateProtocolVersion(u32) !u32 + ProtocolMismatch in BcastStreamError.
  • broadcast/engine_quic.zig: finishBcastHandshakeRead now validates h.version on the inbound BCAST handshake before storing the peer id (rejects the connection on mismatch).

Tests

  • Unit: validateProtocolVersion(1) == 1, (2)/(99) clamp to 1, (0)error.ProtocolMismatch.
  • The QUIC handshake tests (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.

…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.
@ch4r10t33r
ch4r10t33r merged commit 28691e9 into main Jul 3, 2026
7 checks passed
@ch4r10t33r
ch4r10t33r deleted the feat/protocol-version-64 branch July 3, 2026 17:22
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: protocol-version negotiation (validateProtocolVersion)

1 participant