Expand description
Primitives for the Speculative Messaging protocol.
A sender parachain keeps each outgoing stream as an MMR and commits all stream roots as one
StreamsRoot (a keyed trie). Messages travel between collators; the relay chain only checks
that each receiver’s Requires matches a sender’s Provides.
The relay-visible types (StreamsRoot, RequiresSet) are in polkadot-primitives. This crate
has the parachain-side types and the off-chain wire format.
Re-exports§
pub use channel::ChannelId;pub use channel::ChannelPhase;pub use channel::InChannelState;pub use channel::OutChannelState;pub use channel::RegisterRead;pub use flow_control::Register;pub use flow_control::SpecMsgKind;pub use flow_control::SpecMsgSignal;pub use flow_control::WindowGrant;pub use inherent::ConsumeItem;pub use inherent::ConsumedStream;pub use inherent::MessagingInherentData;pub use inherent::Payload;pub use inherent::INHERENT_IDENTIFIER;pub use lift::build_requires;pub use lift::build_requires_entry;pub use lift::stitch;pub use lift::ConsumptionRecord;pub use lift::Interval;pub use lift::LiftError;pub use lift::LiftsBySource;pub use lift::MMRExtensionProof;pub use lift::MmrInclusionProof;pub use lift::ProofError;pub use lift::RequiresLift;pub use lift::SourceStreams;pub use lift::TreeInclusionProof;pub use message::leaf_hash;pub use message::verify_event;pub use message::verify_exchange;pub use message::verify_messages;pub use message::EventRequest;pub use message::EventResponse;pub use message::ExchangeRequest;pub use message::ExchangeResponse;pub use message::ExchangeVerified;pub use message::MessagesRequest;pub use message::MessagesResponse;pub use message::VerifiedEvent;pub use message::VerifyError;pub use message::MAX_MESSAGES_PER_RESPONSE;pub use message::MAX_SPECULATIVE_MESSAGE_LEN;pub use mmr::FrontierFull;pub use mmr::MessagePosition;pub use mmr::MmrFrontier;pub use mmr::MmrRoot;pub use stream::PrivateKind;pub use stream::StreamId;pub use stream::STREAM_ID_LEN;pub use streams_root::StreamProof;
Modules§
- channel
- Channel state primitives: the key and the two per-direction states the messaging
pallet keeps in
OutChannels/InChannelsand returns from the runtime API’sout_channels()/in_channels(). - flow_
control - Channel flow-control types: the sender’s channel-stream leaf payload
(
SpecMsgKind/SpecMsgSignal) and the receiver’s out-of-band confirmationRegisterwith its advisoryWindowGrant. The pallet owns the logic: windowing, version enforcement, channel storage, the accept extrinsic. - inherent
- The node/runtime consumption interface: what the runtime asks the node to fetch
(
ConsumedStream, via theconsumed_streams()runtime API) and what the node delivers in the messaging inherent (MessagingInherentData/ConsumeItem). - lift
- Requires-lift and consumption-record primitives.
- message
- Off-chain wire types and their verifiers.
- mmr
- MMR primitives for the Speculative Messaging protocol.
- stream
StreamId: the parachain-structured stream key.- streams_
root StreamsRoot: the sender’s stream commitment.
Structs§
- Streams
Root - The sender’s per-block stream commitment root. Defined relay-side and re-exported here.
Root of a sender’s stream commitment tree: a compact binary trie keyed by the 8-byte
StreamIdencoding, with the streams’ MMR roots as leaves.
Constants§
- INNER_
TAG - MMR inner node.
- LEAF_
TAG - MMR leaf.
- LEAF_
VERSION - Leaf preimage version. Versions are hash-disjoint, so the layout can change without old leaves colliding with new ones.
- PEAK_
TAG - MMR peak bagging.
- ROOT_
TAG - Stream root:
H(ROOT_TAG ++ leaf_count[8, LE] ++ bag(peaks)[32])(mmr::MmrRoot::from_bag). Binding the count stops a peer from presenting the same peaks at a forged position. The empty MMR has no peaks to bag; its root is the count-0 case, with a zero bag (mmr::empty_root). - SPMS_
ENGINE_ ID - Engine id of the header digest carrying a block’s
StreamsRoot, deposited only by blocks that send. - TREE_
INNER_ TAG - Commitment-tree inner node:
H(TREE_INNER_TAG ++ split_bit ++ left[32] ++ right[32]). - TREE_
LEAF_ TAG - Commitment-tree leaf:
H(TREE_LEAF_TAG ++ key[8] ++ stream_root[32]).
Type Aliases§
- Spec
Hasher - The hash function for all of speculative messaging: leaves, MMR merges, stream and commitment-tree roots. A protocol constant. Changing it is a consensus break, so nothing here is generic over it.