SpecMsg: Design Parachain Communication#12226
Conversation
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
|
All GitHub workflows were cancelled due to failure one of the required jobs. |
eskimor
left a comment
There was a problem hiding this comment.
General approach is very sensible. Some notes:
- We need to be able to verify messages - verify that the are coming from a block, authored by an actual authority and later also that it was acknowledged.
- While we should not over-engineer, some considerations on how this scales with many parachains would be good.
- Security & Speed considerations: Especially with regards to DHT.
| collators of different parachains is not possible due to different genesis hashes and sync protocols. | ||
|
|
||
| To enable off-chain communicaiton between collators, a dedicated P2P network is created. | ||
| This **Speculative Messaging Network** includes collators from al parachains that opt into |
There was a problem hiding this comment.
Typo. Other than that, I like the approach!
|
|
||
| To obtain the bootnodes of the Speculative Messaging Network, a relay chain side peer: | ||
| - Queries the DHT for providers under the key `sha256(concat("spec-msg", epoch randomness))`, obtaining 20 peer IDs | ||
| - For each peerID, it sends a request-response over `/paranode` with the `spec-msg` key, and obtains a list of multiaddresses |
There was a problem hiding this comment.
Do we really need separate entries? Can't we derive the endpoint from the already existing boot node entries?
There was a problem hiding this comment.
So, there is no separate spec-msg DHT registration. Instead, we reuse the existing para_id || epoch_randomness provider records that every parachain node already advertises under RFC 0008, avoiding the need to maintain a second sha256("spec-msg", ...) registration.
The only change is a backwards-compatible extension to the /paranode response:
- The request remains unchanged and is still keyed solely by para_id.
- The response gains an optional
spec_msg_addrsfield containing the node's /spec-msg/* listen addresses (or an empty value if the node does not participate in the spec-msg network).
Because the protocol uses proto2 semantics, older nodes simply ignore the additional field. As a result, no protocol version bump is required, and there is no need for a second lookup key or alternative input format to disambiguate registrations.
Please correct me if I'm wrong.
| These keys allow Parachain A to map out collator addresses and verify peer integrity. | ||
|
|
||
| The `SignedCollatorAuthorityRecord` guarantees that communication stirctly happens with legitimate collators | ||
| of Parachain B, preventing eclipse attacks where malicious peers impersonate collators to drop or manipulate |
There was a problem hiding this comment.
We should get the messages via a standardized runtime API via a light-client and prove the correctness, with regards to a block authored by an actual authority. The peer we connect to should not be able to do anything worse than not serving. We can not trust the data, just because we authorized the peer - we need to verify.
Later we will also need to verify, not only that the messages are coming from an actual block, but also that this block was acknowledged. This will be a later phase, just mentioning it, in case it is relevant for making decisions: Light-client access & acknowledgment signature fetching needs to be possible and efficient.
There was a problem hiding this comment.
My understanding is that this implies two additional requirements:
- The sender's block header must be added to
MessageBatch. - The sender's Aura authority set must be fetched cross-chain and verified via a relay-anchored storage proof (via
/spec-msg/light/2, similar to theaudidiscovery set is obtained).
The receiver can then verifies authorship of that included header by:
- extracting the slot from the header;
- fetch + verify the Aura authority set (relay-anchored proof);
- derive the expected author = authorities[slot % authorities.len()];
- verify the sr25519 seal over the pre-seal header hash against that expected author's public key.
My concern here is that it's substantially heavier than the current MMR self-check, and on the hottest speculative path it introduces non-trivial work. That may simply be the trade-off, however — the cost of enforcing the guarantee that a node cannot “do worse than refusing to serve”.
|
So, the cross-chain collator discovery reuses Substrate's existing authority-discovery — its record format, signing, and verification logic — and adds two pieces around it:
Prerequisite: participating parachains run Please correct me if I've misunderstood any part of this. |
This PR extends the design of speculative messaging to clarify parachain communication.
In summary:
Inside the SpecMsg network:
Markdown Rendering:
Parachain Communication
Parachain collators operating on different peer-to-peer (P2P) networks need a way to exchange messages off-chain.
The relay chain only processes message commitments, not the messages themselves. Direct communication between
collators of different parachains is not possible due to different genesis hashes and sync protocols.
To enable off-chain communicaiton between collators, a dedicated P2P network is created.
This Speculative Messaging Network includes collators from al parachains that opt into
speculative messaging.
Alternative architectures were considered:
as well as new protocols for message exchange between collators.
well with the number of parachains.
By deploying a single network backend for the entire speculative messaging work, we keep the relay chain side
changes to a minimum (needed for JAM compatibility) and we can leverage the existing bootnodes on DHT
mechanism for collator discovery.
The Speculative Messaging Network exposes the following protocols:
/spec-msg/kadfor peer discovery./spec-msg/identifyand/spec-msg/pingfor obtaining peer addresses and keeping connections alive./spec-msg/exchangefor exchanging messages between collators./spec-msg/light/2for fetching authority discovery keys of other collators.Parachains outside a trust domain, or those that don't wish to participate can simply ignore the Speculative Messaging
Network and not register themselves in the DHT.
Bootnodes for the Speculative Messaging Network
The architecture leverages the existing bootnodes on DHT mechanism on the relay chain side.
For more info, see RFC 08.
Typically, relay chain peers of parachains advertise themselves as providers under the key
para ID || epoch randomnessin the relay chain DHT. Only the 20 closest peer IDs to this key are kept as providers, and the provider set is updated on every epoch change.
Similarly, relay chain peers of collators advertise themselves as providers in the relay chain DHT.
This utilizes the
ADD_PROVIDERmechanism of the Kademlia DHT.The routing key is defined as
sha256(concat("spec-msg", epoch randomness)), where the epoch randomness has thesame semantics of the RFC 08, and can be obtained by calling
BabeApi_currentEpoch.This extracts the relay chain side peer IDs of the 20 closest peers to the speculative messaging key.
To obtain the actual bootnode addresses, the
/paranoderequest-response is extended in a backwards compatible way.Originally, this request accepted a SCALE-compact-encoded
para IDand returned a list of bootnode multiaddressesfor that parchain. The protocol is extended to support the SCALE-compact-encoded
spec-msgkey as input,and the response is a list of multiaddresses of the collators that are bootnodes for the Speculative Messaging Network.
To obtain the bootnodes of the Speculative Messaging Network, a relay chain side peer:
sha256(concat("spec-msg", epoch randomness)), obtaining 20 peer IDs/paranodewith thespec-msgkey, and obtains a list of multiaddressesfor the collators that are bootnodes for the Speculative Messaging Network.
Speculative Messaging Network
Once a collator obtains the bootnode list from the relay chain, it spawns a dedicated network backend for the
Speculative Messaging Network and connects to the bootnodes. Because the network connects collators from
all parachains, collators from Parachain A must establish communication with collators from Parachain B.
Peers register themself in the Speculative Messaging DHT as providers under the key
para ID || randomness,exactly as bootnodes on the relay chain DHT do using the
ADD_PROVIDERmechanism.This allows collators to quickly discover 20 closest peers. These peers serve as explicit entry points to
validate collators and fetch their authority discovery keys.
Separately to the
ADD_PROVIDERmechanism, collators publish theirSignedCollatorAuthorityRecordrecords into the DHT,using the
PUT_VALUEkademlia mechanism. This ensures collators can discover the addresses of other collators and verify their integrity, strengthening the trust model for collators.This mechanism mirrors the authority discovery on the relay chain for validators.
The
SignedCollatorAuthorityRecordrecord has the following format:Trust Model for Collators
For Parachain A to securely exchange messages with Parachain B, it must first obtain Parachain B's discovery keys.
These keys allow Parachain A to map out collator addresses and verify peer integrity.
The
SignedCollatorAuthorityRecordguarantees that communication stirctly happens with legitimate collatorsof Parachain B, preventing eclipse attacks where malicious peers impersonate collators to drop or manipulate
messages.
Parachain A relies on light-client similar approach to fetch the discovery key from Parachain B:
paras::Heads::get(Para B). This storage entry is located at relay_well_known_keys::para_head(Para B).state_rootof the block.twox_128("AuthorityDiscovery") ++ twox_128("Keys").para ID || randomnesskey./spec-msg/light/2which includesRemoteReadRequest { block, keys }protobuf encoded.RemoteReadResponsecontaining a storage proof.state_root(step 2), crafted key (step 3), and the provided storage proof (step 6).Once verified, parachain A knows the authority keys of parachain B and starts
GET_VALUEkademlia requests to fetch the multiaddresses of the collators on the Speculative Messaging Network. With the multiaddresses, parachain A can establish direct communication with parachain B's collators over the/spec-msg/exchangeprotocol.