In a scenario where ParaA
wants to send a message to ParaB
(ParaA -> ParaB
), various steps and data structures come into play.
- Better understand an efficient implementations of different XCMP approaches(proof sizes, overall onchain benchmarking, code complexity)
- Achieve consensus on an XCMP design and approach to put forward to the community (By showing pros and cons of a few different approaches)
The proofs which are constructed via a Relayer involve a 4 tiered authenticated datastructure using 2 Binary Merkle Trees and 2 MMRs.
- This is one of many MMRs which XCMP messages are stored into. There is a single XCMP message per block so each index can be thought of as the message contents for a particular block.
- MMRab root, MMRac root, etc.: Each receipient which a sender has an open channel with has a dedicated
ChannelMessageMmr
. This each one of theseChannelMessageMmrRoots
are bundled up into a Binary Merkle Tree whos root is put into theDigest
of each Parachains BlockHeader
- Every Leaf of the Beefy Mmr contains a committment every
parachains block header
in the form of aBinaryMerkleRoot
By combining these 4 tiers of Merkle structures together we have a proof which from a single message commitment on some parachain sender X
we can compare it against another parachain receiver Y
. This requires a latest Beefy Root (Which lives on the Polkadot Relaychain) to be inserted into each parachains state for proof verification.
- Sends an XCM message as usual.
- Adds the message as a leaf into one of its message XcmpChannelMessageMmrs.
- The message MMR root gets stored inside the XCMPChannelBinaryMerkleTree.
-
Detection of Destination:
Relayer
module detects a message fromParaA
toParaB
is sent.
-
Proof Construction:
- Constructs 4 tiered MerkleProof
-
Proof Submission:
- Submits proof to
ParaB
's XCMP extrinsic labeledsubmit_xcmp_proof(proof, channel_id)
.
- Submits proof to
Proof Verification:
- Because receipient has the Beefy Mmr Root(The top of the Merkle Path) it can unravel the proof and compare against this root.
- Any parachain that opens a channel with another parachain could potentially run relayer nodes.
- The XCM message sender provides a percentage fee to the relayer.
git clone [email protected]:w3f/xcmp_prototype_playground.git && cd xcmp_prototype_playground
chmod +x build.sh && ./build.sh
cd ../ && \
git clone https://github.com/coax1d/polkadot-sdk/tree/xcmp_customized_sdk && \
cd polkadot-sdk && \
cargo build --release -p polkadot
cd ../xcmp_prototype_playground && \
cp ../polkadot-sdk/target/release/polkadot bin/polkadot && \
cp ../polkadot-sdk/target/release/polkadot-execute-worker bin/polkadot-execute-worker && \
cp ../polkadot-sdk/target/release/polkadot-prepare-worker bin/polkadot-prepare-worker
cd xcmp_prototype_playground
zombienet-macos spawn -p native zombienet/config.toml
./target/release/xcmp_relayer