Expand description
Off-chain wire types and their verifiers.
The relay chain decodes none of this; it only matches the StreamsRoot commitments in the UMP
signals. But the two ends of each protocol are different chains’ collators, so the encodings and
the envelope variant indices are part of the wire format.
leaf_hashturns a payload into an MMR leaf. A message is a bounded payload keyed byStreamId; source, stream and position are structural, so there is no message struct.- Fetch:
MessagesRequest/MessagesResponse, verified byverify_messagesagainst aStreamsRootthe requester has already verified. Theextension+tree_proofcheck is the same one the requires-lift performs. - Event read:
EventRequest/EventResponse, the single-leaf read of anAck/Broadcast/Privatestream, verified byverify_event. - Envelope:
ExchangeRequest/ExchangeResponsemultiplex both over/spec-msg/exchange, verified byverify_exchange, which also binds the response variant to the request’s. Variant indices are frozen.
Structs§
- Event
Request - Request for a single event of a lossy stream (
Ack/Broadcast/Private), verified under a chosenStreamsRoot. The server either serves or fails; nothing is resolved server-side. - Event
Response - Response carrying one event leaf and the proofs placing it under the requested
StreamsRoot. Nothing is trusted.underfixes the stream’s leaf count, so the head is the leaf atcount - 1; an old leaf cannot be served as the head. - Messages
Request - Request for a range of a stream’s messages, verified under a chosen
StreamsRoot. - Messages
Response - Response: payloads from
baseon, plus the proofs binding them and everything before them to the requestedStreamsRoot. Nothing is trusted; fabricated peaks, payloads or proofs cannot reproduce a committed root.
Enums§
- Exchange
Request - The
/spec-msg/exchangerequest envelope. Variant indices are frozen; foreign implementations decode by them. - Exchange
Response - The
/spec-msg/exchangeresponse envelope. No error variant: a server that cannot serve refuses at the transport level. - Exchange
Verified - Verified outcome of an
ExchangeResponse: a fetch, or aVerifiedEvent. - Verified
Event - Outcome of verifying an
EventResponse. A head read yields the streamMmrFrontier, which lossy consumption records as its interval endpoint; a positional read yields none, since an inclusion proof reconstructs a root, not a frontier. - Verify
Error - Why verifying an off-chain response failed.
RootMismatchis benign (retry under a fresher root); the rest indicate a malformed or forged response.
Constants§
- MAX_
MESSAGES_ PER_ RESPONSE - Maximum payloads in one
MessagesResponse, enforced at decode. The byte budget does not bound the count: an empty payload costs one wire byte and no budget, yet is hashed into a leaf, so without this bound one response could carry millions. A consumer fetches the rest under a later request. - MAX_
SPECULATIVE_ MESSAGE_ LEN - Maximum size in bytes of a single speculative message payload.
Functions§
- leaf_
hash - Hash a payload into a stream MMR leaf:
H(LEAF_TAG ++ leaf_version ++ payload). Source, stream and position are structural and not in the preimage. Versions are hash-disjoint, so only the correct one reproduces a committed root. - verify_
event - Verify an
EventResponseagainst itsEventRequest:req.atselects head (None) or leafk, so a head response is never accepted for a positional request or vice versa. OnOk,resp.payloadis verified. The public entry for event reads. - verify_
exchange - Verify a
/spec-msg/exchangeresponse against its request. The variants must match (VariantMismatchotherwise); then dispatches toverify_messagesorverify_event. The top-level public entry. - verify_
messages - Verify a
MessagesResponseagainst itsMessagesRequest:resp.base == req.start, total payload bytes withinreq.max_bytes(0means proofs only), then the payloads underreq.stream/req.under. OnOk,resp.payloadsare verified. The public entry for the fetch protocol.