Skip to content

Spec 04 Protocol

Amp edited this page Nov 18, 2026 · 1 revision

Spec 04: Protocol

Source: spec/04-protocol.md at commit a9f0d61. The file is the source of truth; this page is a summary.

What the chapter decides

Chapter 04 defines the order-entry protocol between a client and the home that runs the book. It covers UDP transport and ports, the dual send to the sequencer and the data tier, the order of checks in the lane, deadline admission and BUSY, lane classes and pacing, the session life cycle and keys, reliability across loss, failover and epoch handoff, message and response semantics, reject reasons, rate limits and fee classes, and conformance test vectors. The byte layouts live in 01 §6, and this chapter does not change them. The client-side contract: every received packet of 1–10 messages gets the first record of every message, or an explicit reject, within LAT_MAX_NS. The Spec 01 §14 decisions win wherever they differ from this chapter.

Key decisions

  • Transport is UDP over IPv4 with one 16-byte header, up to 10 fixed 16-byte messages and two tags. TCP is rejected because failover and handoff already need application-level sequencing, and TCP adds head-of-line blocking and per-connection cost (P1, §2.1).
  • The destination port selects the lane, so the NIC steers each packet with no software hop (P2, §2.2).
  • Every packet is sent twice with identical logical content: once to the sequencer and once to the session's data home. Two validly tagged copies with different content close the session for equivocation (P3, D1–D6, §2.4).
  • The cheapest checks run first (V0–V11, then M1–M9 per message). An unbound source never costs a SipHash. A bad MAC closes the session only when it comes from the bound address with a matching epoch16 (P4, §3.1, §3.4).
  • Deadline admission (test D) runs before V6. A lane shed is an out-of-stream BUSY for the whole packet, and nothing is applied. A BBO-core shed is an in-stream BUSY at the message's index. Both arrive within LAT_MAX_NS (P11, §3.5).
  • Paced dedicated lanes follow LANE_PACE: the gap between packets is at least lane_ns + 10 + 25 ns. The SDK puts a packet's cancels first (P13, §3.6).
  • pkt_seq is gapless and the lane accepts only expected. A gap gets BAD_SEQ and the client goes back N. Each (session, pkt_seq) executes at most once, across failover and handoff (P5, §5.1–§5.2).
  • resp_seq has one allocator, the lane. TX cores send B-packets in reserved slots and maker fills from a 16-number relative credit (P6, §7.1).
  • Responses are kept in two tiers: a 4 GiB ring per lane on the sequencer and the recovery service on a replica. RESEND_GONE is sent only when both have dropped the range (P8, §5.4).
  • After a failover, a sequencer-change EpochNotice starts the rewind rule: any response at or above its resp_seq is void (§5.6, §7.4).
  • Handoff rules H1–H9: sessions survive the boundary, and packets staged at the new home form the auction window, the only window without a 1 µs answer (§5.7).
  • Execution, durability, finality and settlement are separate attestations, reported in Attest 0x88 at levels 1–3 (P12, §7.5).
  • Rate limits are GCRA buckets on rx_ts, so replicas reproduce every RATE_LIMIT. 04 uses bucket ids 1–7 and 10 uses 8–11 (P10, §9.1).
  • The wire has no version field. The version is fixed at session open, and this chapter is protocol version 2 (§12).

Key numbers

Name Value § Status in the spec
LAT_MAX_NS 1 µs intro, §3.5 hard maximum
MAX_REQ_PAYLOAD / PROTO_RESP_MAX_BYTES 192 B / 280 B §2.3 computed from 01 §6
V6 SipHash-2-4 10 ns (n = 1) to 40 ns (n = 10) §3.1 budget
PROTO_SHED_NS / PROTO_BUSY_TAIL_NS 20 ns / 460 ns §3.5, §14 budget
Worst lane BUSY path 320 + 180 + 20 + 460 = 980 ns §3.5 budget
BBO-core BUSY path 390 ns §3.5 budget
E4 policer (LANE_POLICE_PPS, burst) 40M packets/s, 8 §3.4 from 01 §14.1
PROTO_PACE_MARGIN_NS / PROTO_PACE_JITTER_NS 10 / 25 ns §3.6 budget
RESP_HOT_RING_BYTES / RESP_RETAIN_PKTS 4 GiB per lane / 65,536 per session §5.4 budget
PROTO_MAKER_RANGE / PROTO_MAKER_PKT_NS 16 numbers / 16 ns §7.1 budget
PROTO_REQ_RTO_US, PROTO_REQ_RTO_MAX_MS 200 µs, 20 ms §5.1 budget
PROTO_TIMEOUT_DEFAULT_MS 350 ms §4.8 budget
Linux minimum TCP RTO 200 ms §2.1 vendor (kernel default)

All PROTO_* values are budgets unless marked otherwise. Draft 0.2 has no measured numbers.

Section map

    1. Scope and constraints
    1. Decisions at a glance
    1. Transport
    1. The validation pipeline in the lane
    1. Sessions
    1. Reliability
    1. Messages
    1. Responses
    1. Reject reasons
    1. Rate limits and fee classes
    1. The order as the client sees it
    1. Conformance test vectors
    1. Versioning
    1. Interfaces to other chapters
    1. Local definitions
    1. Requests to 01
    1. Open questions

Where 01 §14 overrides or refines this chapter

  • §14.19 A. This ruling sets the latency contract's scope: REQ-LAT-1 covers received packets, and a packet a policer drops is ingress loss with no response. The chapter's intro, §3.4 (E4) and §3.5 already follow it.
  • §14.19 B. A fill is undone only by a revert before finality or by a CHAIN Bust whose verdict is already final. Settlement never undoes a final fill. §7.3 and §7.5 follow this ruling.
  • §14.19 C. Reject reason 26 DATA_MISSING comes from this ruling (§8).
  • §14.15 item 1 (pacing). 01 says a paced client leaves at least predicted_path_ns between packets. §3.6 paces by lane_ns plus margin and jitter instead, and Request 9 asks 01 to change its wording. 01's text stands until it does.
  • §14.17.5 (maker count). 01 says about 40 makers at index 9. §7.1 and Request 10 compute 18 at 16 ns on three TX cores (Q4).
  • §14.14 (maker numbering). 01 describes a reserved 16-number range. §7.1 treats the range as a relative credit placed by a merge rule, and Request 7 asks 01 to say so.
  • §14.1 (BUSY stream). Request 6 asks 01 to state that a lane BUSY is out of stream and a BBO-core BUSY is in stream, as §3.5 does.

Implemented by

vyrn-wire, vyrn-lane, vyrn-data

Open questions

The chapter lists 12 open questions (Q1–Q12; Q13 and Q14 are settled); see Open Questions.

Clone this wiki locally