feat(network): v2 peer connection, handshake, and handshaker service - #11276
feat(network): v2 peer connection, handshake, and handshaker service#11276arya2 wants to merge 1 commit into
Conversation
And 13 more auto-invalidated findings. Analyzed six files, diff |
Merge Protections🔴 1 of 1 protections blocking · waiting on ⛓️ dependency
🔴 ⛓️ Depends-On RequirementsWaiting for
This rule is failing.Requirement based on the presence of
|
73ab5f6 to
3665dca
Compare
Carry the version 2 wire formats over QUIC, and connect them to the rest of the node. The transport opens one endpoint on the UDP port of the configured listen address, so a node serves both protocols on the same address: QUIC uses UDP where the legacy protocol uses TCP. Peers are identified by an ephemeral self-signed certificate, the ALPN identifier separates networks, and 0-RTT is never negotiable, so a replayed early-data packet cannot reach the application. The connection service maps the stream layer onto the peer set: each request stream carries one request and its response, announcement streams carry blocks, transactions and addresses, and both sides end up producing an ordinary `peer::Client`. Inbound admission, connection limits, per-IP limits, bans, and handshake nonces are shared with the legacy transport rather than duplicated, so a v2 peer is subject to the same policy. `ConnectionInfo` now records the peer's actual handshake data per transport, instead of synthesizing a legacy `version` message for v2 peers. Both options are off by default: `network.v2_listen` serves the listener, and `network.initial_v2_peers` names peers to dial over QUIC. With them off, nothing about the node changes.
3665dca to
85877a7
Compare
Motivation
Fourth PR of the five-PR stack implementing the draft version 2 Zcash P2P network protocol (zcash/zips#1344). This PR adds the peer connection layer: the application handshake and the connection task that map Zebra's internal request/response protocol onto v2 streams.
Solution
Adds
zebra-network/src/peer/v2/:handshake.rs): the initiator opens the dedicated handshake stream and the peers exchangeinitrecords; version negotiation takes the minimum of the advertised versions, gated on the epoch minimum. Self-connection detection uses the sharedHandshakeNoncespolicy from the first PR of the stack (per-transport nonce set, never evicted on failed handshakes).connection.rs): each outbound internal request opens its own request stream, so requests run concurrently and are cancelled and timed out per stream, with the response-to-request echo check single-sourced for blocks and transactions. Inbound request streams are decoded with bounded buffers, served by the inbound service, and answered on the same stream. Announcements use long-lived unidirectional streams, with outbound announcements dropped rather than queued when the transport applies backpressure.SHORTIDfollow-ups are pure lookups; tables are skipped for peers that requested full transaction IDs.get-addris only answered on inbound connections to impede fingerprinting.service.rs): produces the same peerClienttype as the legacy transport, so v2 peers plug into the peer set unchanged.The modules are
#[allow(dead_code)]-scaffolded until the peer set integration PR consumes them; the attribute is removed in the final PR of the stack.Tests
SHORTIDserving, oversized response scoring, unresponsive-peer disconnection).cargo clippy -p zebra-network --all-targetswarning-free; fullzebra-networksuite passes.Specifications & References
Follow-up Work
p2p-v2-5-peer-set-integration.announce = 1) and full-ID mode are not requested yet.PeerError::V2Protocol/V2Internalvariants should become a structured error enum in a follow-up.AI Disclosure
PR Checklist
type(scope): description