Skip to main content
The QUIC transport layer in Palyra provides a high-performance, secure, and multiplexed communication channel between the central daemon (palyrad) and various nodes or CLI clients. This layer is primarily implemented in the palyra-transport-quic crate, leveraging the quinn implementation of the QUIC protocol and rustls for TLS 1.3 security.

Architecture and Stack

The transport stack is designed to provide mTLS (mutual TLS) by default, ensuring that both the server and the client are cryptographically identified using certificates issued by the Palyra internal Certificate Authority (CA).

Core Components

Transport Configuration

The system uses a set of default limits to ensure stability and prevent resource exhaustion:
ParameterDefault ValueDescription
PROTOCOL_VERSION1Internal versioning for the QUIC framing protocol crates/palyra-transport-quic/src/lib.rs#12.
DEFAULT_MAX_FRAME_BYTES512 KBMaximum size for a single application-level frame crates/palyra-transport-quic/src/lib.rs#13.
handshake_timeout10sMaximum time allowed for TLS/QUIC handshake crates/palyra-transport-quic/src/lib.rs#28.
idle_timeout30sConnection timeout if no data is exchanged crates/palyra-transport-quic/src/lib.rs#29.
max_concurrent_bidi_streams32Limit on simultaneous bidirectional streams per connection crates/palyra-transport-quic/src/lib.rs#31.

Connection Lifecycle and Data Flow

The following diagram illustrates the flow from endpoint binding to stream handling within the palyra-daemon.

QUIC Server Initialization and Request Flow

Sources: crates/palyra-daemon/src/quic_runtime.rs#62-80, crates/palyra-daemon/src/quic_runtime.rs#92-120, crates/palyra-daemon/src/quic_runtime.rs#124-142.

Security and mTLS Integration

The transport layer consumes identities generated by the palyra-identity crate. It supports revocation-aware verification to ensure that compromised or decommissioned devices cannot reconnect.

Revocation-Aware Verification

The RevocationAwareClientVerifier wraps the standard rustls verifier. During the verify_client_cert call, it checks the certificate’s SHA-256 fingerprint against a RevocationIndex crates/palyra-identity/src/mtls.rs#63-72. Sources: crates/palyra-identity/src/mtls.rs#93-105, crates/palyra-transport-quic/src/lib.rs#38-44, crates/palyra-transport-quic/src/lib.rs#120-134.

mTLS Enforcement Modes

The daemon can be configured with varying levels of strictness regarding client certificates:
  1. Mandatory mTLS: Clients must provide a valid certificate signed by the Gateway CA. This is the default for node RPC services crates/palyra-identity/src/lib.rs#28.
  2. Insecure Opt-out: Used primarily for initial pairing or local development where mTLS is explicitly disabled via configuration crates/palyra-daemon/tests/node_rpc_mtls.rs#121-125.

Framing and Multiplexing

QUIC provides native multiplexing, but Palyra adds a lightweight framing layer on top of bidirectional streams. This allows for structured request/response patterns and event streaming within a single QUIC connection.

Request/Response Protocol

Requests are serialized as JSON and wrapped in a frame. The QuicRuntimeRequest includes:

Event Streaming and Resumption

For methods like node.stream_events, the server sends a sequence of QuicRuntimeResponse frames. If a connection drops, the client can reconnect and provide a resume_from sequence number. The server then skips acknowledged events and resumes from resume_from + 1 crates/palyra-daemon/src/quic_runtime.rs#180-195.

Frame I/O Functions

The palyra-transport-quic crate provides helper functions for reading and writing frames with size limits:

Error Handling and Fallback

The transport layer defines a comprehensive error set in QuicTransportError crates/palyra-transport-quic/src/lib.rs#81-118. Key error scenarios handled include: Sources: crates/palyra-transport-quic/src/lib.rs#81-118, crates/palyra-transport-quic/tests/transport.rs#46-140.