Table of Contents
- RFC-0177: JAM-Ready Snowbridge Message Commitments
RFC-0177: JAM-Ready Snowbridge Message Commitments
| Start Date | 2026-11-19 |
| Description | A dependency for JAM: commit to all Snowbridge V2 outbound messages in a Merkle Mountain Range whose root is in every Bridge Hub header, so P→E messages no longer depend on every Bridge Hub header being provable. |
| Authors | Snowbridge team |
Summary
Snowbridge proves a Polkadot→Ethereum (P→E) message by showing that the Bridge Hub header that committed it is in the relay chain's paras.heads at a BEEFY-finalized relay block. That assumes every Bridge Hub header is recorded on the relay chain, which already fails under elastic scaling and is not expected to hold under JAM. Bridge Hub needs this change before it can enable elastic scaling, and Snowbridge needs it before the move to JAM.
The change adds a third commitment to the Bridge Hub header digest, SnowbridgeV2Mmr: the root of a Merkle Mountain Range (MMR) over every V2 message commitment, deposited in every Bridge Hub block. Any one provable Bridge Hub header, normally the latest, can then prove any past V2 message, however Bridge Hub blocks are batched or skipped. The existing V1 and V2 digest items and verification paths are kept. This RFC covers the Bridge Hub pallets and the Ethereum Gateway contracts; relayers are described only where they affect the on-chain interface.
Motivation
How P→E messages are proven today
In every Bridge Hub block that commits outbound V2 messages, snowbridge-pallet-outbound-queue-v2 builds a binary Merkle tree (Keccak256, sorted pairs, compatible with OpenZeppelin MerkleProof) over the ABI-encoded messages. It adds the tree's root to the header as DigestItem::Other(SnowbridgeDigestItem::SnowbridgeV2(root)). V1 does the same with SnowbridgeDigestItem::Snowbridge(root).
To dispatch a message on Ethereum, Gateway.v2_submit checks this chain of proofs (Verification.verifyCommitment):
- The message is a leaf of the per-block messages tree, whose root is
commitment. commitmentappears in the digest of a supplied Bridge HubParachainHeader.keccak256(paraId_le ++ compact(len) ++ encode(header)), the SCALE encoding of(ParaId, HeadData), is a leaf of the parachain heads Merkle tree. That tree's root is theleaf_extraof a relay chain BEEFY MMR leaf (ParaHeadsRootProvider, built fromParas::sorted_para_heads()plus whitelisted parathreads).- That MMR leaf is in the relay chain MMR whose root,
latestMMRRoot, is held byBeefyClient.
Step 3 requires the header holding the commitment to be the head stored in paras.heads at some relay block. paras.heads is overwritten every time a candidate is enacted (note_new_head), so it only holds the latest head in each relay block.
Why this breaks under elastic scaling and JAM
With elastic scaling (BLOCK_PROCESSING_VELOCITY > 1), Bridge Hub headers can stay out of paras.heads in two ways:
- Several candidates per relay block. Several cores include Bridge Hub candidates in the same relay block, and
paras.headskeeps only the last head. - Several blocks per candidate. One PoV can carry several Bridge Hub blocks (
ParachainBlockDatawith multiple blocks). Only the last block's head is enacted, even on a single core.
In both cases the earlier blocks are finalized, because they are ancestors of a finalized head, but their headers never appear in paras.heads, so step 3 cannot be done for them. Any V1 or V2 message committed in such a block is stuck: valid and finalized, but not provable on Ethereum. This is one reason Polkadot Bridge Hub still runs at velocity 1.
JAM generalises the same pattern. This RFC does not assume that every Bridge Hub header will be recorded somewhere an Ethereum light client can prove against, only that some recent Bridge Hub commitment will be. E→P delivery uses the Ethereum beacon light client and is unaffected.
Requirements
- Every V2 message committed on Bridge Hub MUST be provable on Ethereum from any later Bridge Hub header that is provable through the BEEFY light client, even if the header of the block that committed the message is not.
- Proof cost on Ethereum SHOULD grow at most logarithmically with the number of commitments, and SHOULD NOT depend on how many Bridge Hub blocks were skipped.
- Existing V1 and V2 commitments and their verification paths MUST keep working, so the change can be rolled out without a flag day.
- Ethereum MUST NOT need to verify Substrate-specific hashing (Blake2) or trie proofs.
- The commitment SHOULD be a single 32-byte root that can be carried by whatever proof JAM provides, without changing the message proof format.
Stakeholders
- Snowbridge maintainers, who implement and operate the Bridge Hub and Gateway changes.
- JAM implementers and the Polkadot Fellowship, who need Snowbridge to survive the JAM migration and elastic scaling on Bridge Hub.
- Snowbridge relayers, Bridge Hub collators and RPC providers: relayers build a new P→E proof shape from historical events and state that nodes must serve.
- Snowbridge users and integrators, who get lower P→E latency once Bridge Hub can use elastic scaling.
- Polkadot OpenGov, which approves the Bridge Hub runtime upgrade and the Gateway upgrade.
Socialization: so far this design has only been discussed within the Snowbridge team. We especially want feedback from JAM implementers on the assumptions in JAM assumptions, and from Bridge Hub collators on the elastic scaling rollout.
Explanation
The key words "MUST", "MUST NOT", "SHOULD", "SHOULD NOT" and "MAY" are to be interpreted as described in RFC 2119.
Overview
message ──(per-block merkle proof, unchanged)──▶ messagesRoot_k (block k, maybe skipped)
messagesRoot_k ──▶ MMR leaf_k ──(MMR proof)──▶ mmrRoot_n (block n ≥ k, in paras.heads)
mmrRoot_n ∈ digest(header_n) ──(paras heads proof + BEEFY MMR proof, unchanged)──▶ BeefyClient
The Bridge Hub MMR adds one link between the existing per-block messages tree and the existing header proof.
Bridge Hub changes
New digest item
snowbridge_core::digest_item::SnowbridgeDigestItem gets a new variant:
#![allow(unused)] fn main() { pub enum SnowbridgeDigestItem { #[codec(index = 0)] Snowbridge(H256), #[codec(index = 1)] SnowbridgeV2(H256), /// Root of the MMR over all Snowbridge V2 message commitments. #[codec(index = 2)] SnowbridgeV2Mmr(H256), } }
It is added as DigestItem::Other, like the existing variants. Its encoding is 0x02 ++ mmr_root, 33 bytes, so the Ethereum digest scan can tell it apart from V1 (0x00) and V2 (0x01).
MMR maintained by the outbound queue
snowbridge-pallet-outbound-queue-v2 keeps an append-only MMR. Each leaf stands for one Bridge Hub block that committed V2 messages.
-
Leaf content. The leaf for block
kisleaf_k = keccak256(abi.encodePacked(uint8 version, bytes32 messagesRoot))with
version = 0andmessagesRootthe same root that is put in theSnowbridgeV2digest of blockk. The 33-byte preimage is a version byte, for future leaf formats, followed by the root. The leaf holds no block number or position, because the Gateway never uses them (see Proof soundness). TheMessagesCommittedToMmrevent gives relayers the block for each leaf. A test vector will be added to this RFC with the reference implementation. -
Hashing and node merging. The MMR merge, peak bagging and leaf hash MUST use Keccak256 directly, whatever the pallet's configured
T::Hashingis. They MUST use the same node merging and peak bagging as the relay chain BEEFY MMR. That meansmmr-lib'smerge(left, right) = H(left ++ right)and right-to-left peak bagging,merge_peaks(right, left) = H(right ++ left). Proofs then reduce to an ordered list of siblings with order bits, which the existingMMRProof.sollibrary already checks for the BEEFY MMR. The pallet implements the peaks-only append itself, sincepallet-mmr'sMergeis private;mmr-libSHOULD be used as a test oracle. A cross-check test vector against the relay chain BEEFY MMR is required. -
Append rule. In
commit(), when at least one message was committed in the block (count > 0), the pallet appendsleaf_kto the MMR after buildingmessagesRoot. Blocks without messages do not add a leaf. Followingmmr-lib, the root of a one-leaf MMR is the leaf itself, and with a single peak the root is that peak. No root exists while the MMR is empty, and no zero root is ever deposited. -
Root in every block. From the first appended leaf on,
on_finalizeMUST addSnowbridgeV2Mmr(mmr_root)to the header digest of every Bridge Hub block, including blocks that commit no messages. Whichever header ends up inparas.headsthen carries the current root, and proves every earlier commitment. If the root were only added in blocks with messages, a quiet block could become the provable head and the problem would come back. The root MUST also be added on every early-return path, while outbound processing is halted (RFC-0166), and in blocks running multi-block migrations. -
Ordering within a block. If block
kappends a leaf, the root added to blockk's digest MUST already includeleaf_k. That way messages committed in a head block can be proven against that same head. So the append happens incommit(), which runs fromon_finalize, before the digest is added. -
On-chain storage. The pallet stores:
MmrLeafCount: u64.MmrPeaks: the current peaks,popcount(leaf_count)hashes. That is at most 64 for au64count, and about 20 in practice.MmrRoot: H256: the bagged root, recomputed only on append.
At the end of every block,
MmrPeaks.len() == popcount(MmrLeafCount)andMmrRoot == bag(MmrPeaks)MUST hold. MMR storage MUST NOT be reset or migrated. A future leaf format change appends new-version leaves to the same MMR. Inner nodes are not stored on-chain and are not written to the offchain database (see Proof generation). -
Events. A new event
MessagesCommittedToMmr { block_number, leaf_index, messages_root, mmr_root, prev_leaf_block }is emitted when a leaf is appended.prev_leaf_blockis the block number of the previous leaf,Nonefor leaf 0. It is kept in aMmrLastLeafBlockstorage value. With it, relayers can walk the leaf history backwards from any block without scanning every block. The existingMessagesCommittedevent stays the same, so indexers that use it are not affected.
Proof generation
The MMR is fully determined by the ordered list of messagesRoot values in finalized MessagesCommittedToMmr events. The normative way to generate an MMR proof is to rebuild the MMR from those events, up to the anchor block's leaf count, and derive the proof from it. Only finalized events are used, so Bridge Hub forks do not matter. Rebuilding is cheap: one Keccak per node, and the number of leaves is the number of message-carrying blocks.
We do not reuse pallet-mmr's offchain indexing model. It writes nodes under fork-specific temporary keys and depends on the mmr-gadget client task to canonicalize them after finality. That task assumes one leaf per block and is only wired into relay chain nodes, not into cumulus or omni-node collators. Making it work with sparse leaves on Bridge Hub nodes would be a client change with little benefit over rebuilding from events.
To let relayers check a rebuild, OutboundQueueV2Api is bumped to the next api_version and gets:
#![allow(unused)] fn main() { /// Leaf count and root of the outbound message MMR at the queried block's state. fn mmr_state() -> MmrState; // struct MmrState { leaf_count: u64, root: H256 } }
A relayer queries mmr_state at the anchor block and compares it with its rebuilt MMR before submitting. The existing prove_message(leaf_index) is unchanged and still has to be called at the committing block k's state, because Messages is cleared in the next block's on_initialize. Events are stored in state, so rebuilding and prove_message both need historical state. Relayers MUST have access to an archive node or an equivalent indexer covering the history since activation. Under elastic scaling the default pruning window of 256 blocks covers only a few minutes.
Weight and PoV
Appending a leaf costs at most ⌊log2(leaves)⌋ + 1 Keccak merges plus bagging, and a read and write of the peaks (about 640 bytes in practice, 2 KiB at most). A block without messages reads MmrRoot (32 bytes) and adds the digest. The commit() and on_initialize weights will need re-benchmarking. Each Bridge Hub header grows by 35 bytes (digest item tag, compact length, variant byte, hash); Ethereum costs are under Performance.
Ethereum changes
Verification library
-
Add
DIGEST_ITEM_OTHER_SNOWBRIDGE_V2_MMR = 0x02. -
Replace the
bool isV2parameter ofverifyCommitmentandisCommitmentInHeaderDigestwithbytes1 digestKind, the expected variant byte. The Gateway's_verifyCommitmentis updated to pass0x00,0x01or0x02. The scan still requireskind == DIGEST_ITEM_OTHER,data.length == 33and an exact variant byte match, so variants cannot be confused. -
Add the proof type:
struct MessagesMMRProof { // Sibling hashes from the leaf up to the bagged MMR root bytes32[] proof; // Order bitfield, same semantics as BeefyClient MMR proofs uint256 proofOrder; } -
Reuse the simplified MMR proof scheme
BeefyClientalready uses: a flat list of sibling hashes and an order bitfield, folded byMMRProof.sol. Relayers produce it from anmmr-libproof with the same conversion they use for BEEFY MMR leaf proofs. The only contract change isMMRProof.computeRoot(leafHash, proof, proofOrder) returns (bytes32), which folds the proof and returns the result. The existingverifyLeafProofbecomes a wrapper around it. TheMAXIMUM_PROOF_SIZElimit still applies.
Gateway
Add a new entry point next to v2_submit:
function v2_submitMMR(
InboundMessageV2 calldata message,
bytes32[] calldata leafProof, // message -> messagesRoot (unchanged format)
Verification.MessagesMMRProof calldata mmrProof, // messagesRoot -> mmrRoot
Verification.Proof calldata headerProof, // mmrRoot -> BEEFY (unchanged format)
bytes32 rewardAddress
) external nonreentrant;
It MUST:
- Apply every pre-dispatch check that
v2_submitapplies, in the same order. The Gateway checks from RFC-0166 (emergency pause) and RFC-0167 (circuit breakers), and any per-message state they keep, are defined in those RFCs. Those RFCs need to coverv2_submitMMRas well asv2_submit, and SHOULD key any per-message state bymessage.nonce, never by roots, headers or proof data, and enforce a drop by marking the nonce as used, so a transfer dropped on one path cannot be released through the other. - Revert with
InvalidNonceifmessage.nonceis already set ininboundNonce, then set it. The bitmap is the onev2_submituses, so a message can be dispatched only once whichever path is used. - Compute
messagesRoot = MerkleProof.processProof(leafProof, keccak256(abi.encode(message))), asv2_submitdoes. - Compute
mmrLeaf = keccak256(abi.encodePacked(uint8(0), messagesRoot))andmmrRoot = MMRProof.computeRoot(mmrLeaf, mmrProof.proof, mmrProof.proofOrder). - Check that
mmrRootis inheaderProof.header's digest as variant0x02, and that the header is finalized byBeefyClient, usingVerification.verifyCommitment. Revert withInvalidProofotherwise. - Dispatch and emit
InboundMessageDispatchedexactly asv2_submitdoes.
After the proof check, both entry points share the same dispatch code. IGatewayV2 gets the new function, and the change ships as a normal Gateway logic upgrade with no new storage slots.
Proof soundness
The Gateway only needs to know that a message is authentic. It never uses where the message sits in either tree, and it deduplicates dispatch by nonce. So the MMR does not need to separate leaves from inner nodes, and it does not need to commit to its size or leaf count.
The two proofs together form one chain of H(acc ‖ sibling) steps, starting at keccak256(abi.encode(message)) and ending at the root in the digest. Every value on a chain that ends at an honest root must be an honest node, unless someone finds a Keccak256 collision. So the starting hash must equal some honest hash X. Every inner node of both trees, and every bagged peak, has a 64-byte preimage. The ABI encoding of an InboundMessage is always at least 192 bytes. So X must be an honest message leaf, and the message is an honest message, unless someone finds a Keccak256 collision. Collision resistance, not just second-preimage resistance, is the property relied on, because an attacker can choose the contents of honest messages. A relayer can shorten or reshape the path, for example by treating an inner node as a leaf. That only proves an honest message at a misleading position, and nothing reads the position. Unused high bits of proofOrder make the calldata malleable for the same reason.
This argument holds only while two rules hold:
-
The Gateway MUST NOT give any meaning to where a leaf sits: its index, the block it came from, or the shape of its path. A committed message can be revoked only by its nonce.
-
Every Keccak256 input in the message tree, the MMR and the peak bagging MUST be exactly one of:
- the ABI encoding of an
InboundMessage, which is at least 192 bytes and a multiple of 32; - exactly 64 bytes, two child hashes;
- exactly 33 bytes,
0x00 ‖ messagesRoot.
A new message format or leaf version MUST keep its preimage length out of the other two classes. For example,
abi.encode(uint8, bytes32)is 64 bytes and would break the rule, which is why the leaf usesencodePacked. - the ABI encoding of an
The leaf's version byte is not needed for soundness. It is there for versioning, and as an extra safeguard. If a future feature needs positions, for example consistency proofs between cached roots or leaf ordering, it MUST introduce a new leaf or root version that separates leaves from nodes and commits to the leaf count.
JAM assumptions
This RFC makes the message proof independent of how Bridge Hub heads are recorded. On Ethereum, v2_submitMMR splits into a message part (leafProof, mmrProof) and an outer part (headerProof). Moving to JAM is expected to replace only the outer part, as long as JAM offers a light-client-provable commitment that either:
- attests a Bridge Hub header, whose digest then carries
SnowbridgeV2Mmr, or - can be made to carry the MMR root directly, for example as a service output.
If JAM only exposes a Bridge Hub state root, the root can be read from the MmrRoot storage item, but that needs a trie proof on Ethereum, which the requirements above rule out. In that case a small follow-up change to how the root is carried would be needed. The MMR, leaf format and message proof would stay the same. Confirming which of these JAM will offer is an unresolved question for JAM implementers.
V1 messages
V1 is deprecated and gets no MMR commitment. V1 messages committed in a header that is skipped under elastic scaling would be unprovable. V1 Gateway nonces are sequential per channel, so one unprovable V1 message would also block every later message on that channel.
This RFC assumes the V1 path is fully deprecated before elastic scaling or JAM is enabled on Bridge Hub. Every V1 channel, including the primary governance channel, is set to a paused operating mode, all committed V1 messages are delivered, and no new V1 messages can be committed. The V1 pallets may stay in the runtime. Governance commands, including the Gateway Upgrade and SetOperatingMode, go through snowbridge-pallet-system-v2, which already provides upgrade and set_operating_mode. The V1 outbound queue's own halt exempts the primary governance channel, so the deprecation has to close that channel too. The Snowbridge (V1) digest item can be removed then, or in a later upgrade.
Rollout
- Testnet. Deploy everything below on Westend (and Paseo) first, including an elastic scaling trial on the testnet Bridge Hub.
- Bridge Hub runtime upgrade. Adds the MMR and starts adding
SnowbridgeV2Mmrto every header. Existing digests are unchanged. Elastic scaling stays off. - Gateway upgrade. Adds
v2_submitMMR. This can go before or after step 2. Until step 2 is live there is no MMR digest, so the new path cannot succeed. - Relayers use
v2_submitMMRfor a message if and only if its committing block emittedMessagesCommittedToMmrand the Gateway exposesv2_submitMMR. Otherwise they usev2_submit, which always works for messages committed while elastic scaling is off. - V1 fully deprecated (see above).
- Enable elastic scaling on Bridge Hub, and later JAM.
This RFC assumes every relayer, including those that deliver governance and emergency commands, has been updated to v2_submitMMR, and the Bridge Hub and Gateway changes are deployed, before step 6. After that, any P→E message, including an emergency SetOperatingMode or an Upgrade, can land in a skipped block and only be deliverable through v2_submitMMR.
No migration of existing state is needed. The MMR starts empty, and leaf 0 is the first block after activation that commits messages.
Alternatives considered
A pallet-mmr instance
Bridge Hub could run a second pallet-mmr instance with Keccak hashing. Its leaf would be the previous block's V2 messagesRoot (or zero) plus the block number, and its OnNewRoot hook would add the root to the digest. The hook is documented for exactly this. Advantages: it reuses audited append, peak and weight code, and the existing historical generate_proof API. Disadvantages:
- Latency.
pallet-mmrappends inon_initializeusing data from the parent block. A message committed in blockkis only covered by the root in blockk + 1, so a head block's own messages cannot be proven against that head. - Per-block cost. It appends a leaf in every block, including empty ones. With elastic scaling that is several times the block rate, compared with one leaf per message-carrying block. On Ethereum this only makes proofs about
log2(blocks / messageBlocks)hashes longer, roughly 1–3k gas, but on Bridge Hub it adds Keccak work and PoV in every block. - Proof serving. See Proof generation.
A dedicated MMR avoids the extra block of latency and the work in empty blocks, at the cost of a small new implementation. We prefer this trade-off, but it is a close one.
Walking parent hashes back from a provable head
Instead of adding an MMR, the Gateway could accept a chain of Bridge Hub headers [h_k, h_k+1, …, h_n]. Here h_k contains the existing SnowbridgeV2 commitment, h_n is a head provable in paras.heads (the nearest later relay block where Bridge Hub's head changed), and each h_i+1.parentHash == blake2_256(SCALE(h_i)). The contract would check the links and then verify h_n with the existing header proof.
Advantages:
- No Bridge Hub runtime change, no new digest and no new state. The change is contained in the Gateway.
- Relayers already fetch and encode Bridge Hub headers.
Disadvantages:
- Cost grows with the number of skipped headers. Each extra header is about 250–600 bytes of SCALE header, which becomes more once ABI-encoded as calldata. It also needs SCALE re-encoding and a Blake2b-256 hash done through the
BLAKE2Fprecompile (EIP-152). That is roughly 10–15k gas per header, mostly calldata and re-encoding; theBLAKE2Fcompressions themselves are cheap. With elastic scaling the gap is usuallyvelocity - 1headers, but there is no hard bound: missed inclusions and JAM's head recording can make it larger. - Blake2b-256 on the EVM. This needs a correct Blake2b implementation on top of
BLAKE2F, which is new security-critical code. - Exact header re-encoding. Every skipped header has to be SCALE-encoded exactly on Ethereum, including every digest item kind that can appear.
encodeDigestItemreverts on unknown kinds, so a future digest kind on Bridge Hub would break P→E delivery until a Gateway upgrade. Today this only affects the one committing header. With walk-back it affects every header in the gap. - Unbounded under JAM. Walk-back can prove against any later header, but only at a cost linear in the gap, and under JAM the gap has no known bound.
Walk-back remains a workable fallback if Bridge Hub runtime changes are not wanted, or as a short-term measure.
Other options
- Storage proofs. Proving the commitment from Bridge Hub state through a storage proof needs Blake2 trie proofs on Ethereum.
- Relay chain changes. Having the relay chain record every included candidate head in the BEEFY leaf is a relay chain change outside Snowbridge's scope, and does not carry over to JAM.
- Committing only in the last block of a bundle. This would fix the several-blocks-per-PoV case, but not the several-candidates-per-relay-block case.
- Caching verified MMR roots on Ethereum. The Gateway could verify a header and BEEFY proof once, store its
mmrRoot, and accept later submissions with only the message proof and MMR proof. Complementary; see Future Directions.
Drawbacks
- More Bridge Hub state and header size. A few hundred bytes of peaks and root in state, and 35 bytes in every header, which every P→E submission pays for (see Performance).
- Bigger P→E proofs. A
v2_submitMMRcall carries at most⌊log2(leaves)⌋ + 2extra hashes (see Performance). - Proof generation needs history. Relayers need the full history of
MessagesCommittedToMmrevents and historical state for the committing block, from an archive node or an indexer. This is a new operational dependency. - Two V2 submit paths. For a while the Gateway accepts both the legacy and the MMR proof. They share the nonce bitmap, so this is safe, but it is more code to audit, and other Gateway features (RFC-0166, RFC-0167) have to cover both paths.
Testing, Security, and Privacy
Testing
- Pallet unit tests:
- a leaf is appended only when
count > 0; - the
SnowbridgeV2Mmrdigest is in every block after the first leaf, exactly once, including blocks without messages, blocks where message processing yielded onMaxMessagesPerBlock, halted blocks, multi-block migration blocks and runtime upgrade blocks; - the peak and root invariants hold at the end of every block;
- the root in block
kincludesleaf_k; - the root matches a reference
mmr-libKeccak MMR for every size from 1 to 2049, and a relay chain BEEFY MMR test vector; mmr_statematches an MMR rebuilt from events;- weight bounds hold at large leaf counts.
- a leaf is appended only when
- Cross-language test vectors: Rust-generated (message, leaf proof, MMR proof, header) fixtures, checked by Foundry tests against
VerificationandGateway.v2_submitMMR, as already done for the BEEFY and V2 commitment fixtures. - Foundry tests:
- valid proofs dispatch;
- a wrong digest variant, a wrong leaf version, a wrong order bitfield or an oversized proof is rejected;
- a message dispatched through
v2_submitcannot be replayed throughv2_submitMMR, and the other way round; - edge cases: a one-message block with a one-leaf MMR (both proofs empty), a leaf in the first peak and a leaf in the last peak;
- aliasing fuzzing: starting the proof at an inner node, an MMR leaf or a
messagesRooteither reverts or dispatches an honest message.
- Integration (zombienet): run Bridge Hub with elastic scaling (velocity > 1), commit messages in blocks known to be skipped from
paras.heads, and relay them end to end using a later anchor header. This includes proofs rebuilt from events across a Bridge Hub runtime upgrade. - Fork tests of the upgraded Gateway against mainnet state, as for previous Gateway upgrades.
Security
- Trust assumptions do not change. The MMR root is in a Bridge Hub header that is finalized through BEEFY, the same root of trust as today. Anything committed under that root was produced by Bridge Hub's state transition function, which validators check, in a block that is an ancestor of, or the same as, the finalized head. Under elastic scaling,
validate_blockexecutes every block in a candidate and each candidate is approval-checked, so skipped blocks are validated too. - Assumptions shared with the existing paths:
- The relay chain leaves para heads shorter than 64 bytes out of the para heads root (
MIN_PARA_HEAD_LEN). The para heads tree has no leaf/node separation, so this filter is what stops a 64-byte head being passed off as an inner node. Any JAM outer proof MUST keep an equivalent separation. - Bridge Hub head data is exactly the SCALE-encoded header, with no custom validation head data.
- Bridge Hub stays inside the relay chain's
MAX_PARA_HEADSlimit. Verification.encodeDigestItemsupports every digest kind that can appear in an anchor header, including the pre-runtime items added by elastic scaling.
- The relay chain leaves para heads shorter than 64 bytes out of the para heads root (
- Forgery, replay and revocation. Forging a message needs a Keccak256 collision; replay is prevented by the shared nonce bitmap; a committed message stays provable from any later anchor, as today through the BEEFY MMR history, and can be revoked only by nonce. See Proof soundness and Gateway.
- Digest invariant. Any runtime-deposited
DigestItem::Otherof 33 bytes starting with0x02is treated as an MMR root. Only the runtime can deposit digest logs, and no other Bridge Hub pallet produces such an item today. Future pallets MUST NOT produce one. - Liveness. A bug that leaves the root out of some blocks only hurts liveness (relayers wait for or pick a header that has it), not safety.
- Implementation pitfalls. The node merging and peak bagging order on Bridge Hub must match what relayers turn into
proofOrder. A mismatch fails safe (proofs are rejected) but stops P→E delivery, so the cross-language fixtures are required before release.
Privacy
No impact. All committed data is already public.
Performance, Ergonomics, and Compatibility
Performance
- Bridge Hub, blocks with messages: O(log n) extra work per block.
- Bridge Hub, blocks without messages: one 32-byte storage read and a 35-byte digest.
- Ethereum, MMR proof: with 10⁴ to 10⁶ leaves the extra proof is about 15 to 22 hashes, about 8–15k gas of calldata and hashing over
v2_submit, independent of how many Bridge Hub blocks were skipped. V2 has had about 28,000 transfers since launch, so 10⁴–10⁵ leaves is the realistic range for years. - Ethereum, header: the 35-byte digest item adds about 1.5–3k gas to both
v2_submitandv2_submitMMR, including the digest scan and header re-encoding. - All gas figures will be re-measured against the Ethereum gas schedule in force at deployment.
Ergonomics
End users and integrators see no change. Relayers get a new proof shape and a new way to build it (rebuild from events, check against mmr_state). They can always anchor to the most recently finalized Bridge Hub head they can prove, without looking for the exact header that committed a message.
Compatibility
SnowbridgeDigestItemgets a new variant at index 2. Existing variants and their encoding do not change.- Decoders that match on the prefix byte, including the current Gateway and the Snowbridge relayer, ignore the new variant. Rust tooling that decodes every
DigestItem::OtherasSnowbridgeDigestItemwith an older version of the type will get a decode error on0x02. It needs updating or should skip unknown variants. v2_submit, theSnowbridgeV2digest and the V1 path keep working.InboundMessageDispatchedis unchanged, so delivery receipts and rewards on Bridge Hub are not affected.- The new pallet event is additive. The runtime API gets a version bump with one added method.
Prior Art and References
- The relay chain BEEFY MMR (
pallet-mmr,pallet-beefy-mmr,mmr-gadget) and its Ethereum verifierMMRProof.solin the Snowbridge contracts, which this RFC reuses. - Merkle Mountain Ranges: Peter Todd, "Merkle Mountain Ranges", and
mmr-libas used bysp-mmr-primitives. - JAM Gray Paper, for the JAM execution model this RFC prepares Snowbridge for.
- Elastic scaling: RFC-0103, Introduce core index commitment and the Polkadot SDK elastic scaling guide.
- Snowbridge V2 outbound queue:
bridges/snowbridge/pallets/outbound-queue-v2in the Polkadot SDK.
Unresolved Questions
- JAM outer proof. Will JAM offer a light-client-provable commitment that attests a Bridge Hub header, or that can carry a service-defined 32-byte root? This decides whether "only
headerProofchanges" holds (see JAM assumptions). We are asking JAM implementers to confirm. - Dedicated MMR or
pallet-mmrinstance. See Alternatives considered. - On-chain inner nodes. Should inner nodes also be kept on-chain (about two hashes per leaf), so a runtime API can serve proofs directly and relayers need no event history? At realistic volume this is a few MB, but it is unbounded state growth. The draft keeps only peaks and root on-chain.
- Single combined proof. OZ sorted-pair hashing is
H(min ‖ max), which can be expressed as order bits. If the MMR leaf weremessagesRootitself, without the version prefix,leafProofandmmrProofwould merge into one simplified proof checked by the existingMMRProof.verifyLeafProofagainst the root read from the digest. This is equally sound (see Proof soundness) and has a simpler interface, but it gives up the leaf version byte. - Retiring legacy paths. Once V1 is closed and all relayers use the MMR path, should the
SnowbridgeandSnowbridgeV2digest items andv1_submit/v2_submitbe retired? Keeping them is cheap, but removing them shrinks the audit surface.
Future Directions and Related Material
- Anchor caching and batching on Ethereum. The Gateway could store verified MMR roots, so later submissions skip the header and BEEFY proofs, and could accept several messages under one anchor in a single call.
- Related RFCs: RFC-0166, Snowbridge Emergency Pause Pallet and RFC-0167, Snowbridge Circuit Breakers, whose Gateway checks must cover
v2_submitMMR(see Gateway).