|
5 | 5 | //! # Overview
|
6 | 6 | //!
|
7 | 7 | //! Messages come either from sibling parachains via XCM, or BridgeHub itself
|
8 |
| -//! via the `snowbridge-pallet-system`: |
| 8 | +//! via the `snowbridge-pallet-system-v2`: |
9 | 9 | //!
|
10 | 10 | //! 1. `snowbridge_outbound_queue_primitives::v2::EthereumBlobExporter::deliver`
|
11 |
| -//! 2. `snowbridge_pallet_system::Pallet::send_v2` |
| 11 | +//! 2. `snowbridge_pallet_system_v2::Pallet::send` |
12 | 12 | //!
|
13 | 13 | //! The message submission pipeline works like this:
|
14 | 14 | //! 1. The message is first validated via the implementation for
|
15 | 15 | //! [`snowbridge_outbound_queue_primitives::v2::SendMessage::validate`]
|
16 | 16 | //! 2. The message is then enqueued for later processing via the implementation for
|
17 | 17 | //! [`snowbridge_outbound_queue_primitives::v2::SendMessage::deliver`]
|
18 | 18 | //! 3. The underlying message queue is implemented by [`Config::MessageQueue`]
|
19 |
| -//! 4. The message queue delivers messages back to this pallet via the implementation for |
| 19 | +//! 4. The message queue delivers messages to this pallet via the implementation for |
20 | 20 | //! [`frame_support::traits::ProcessMessage::process_message`]
|
21 |
| -//! 5. The message is processed in `Pallet::do_process_message`: a. Assigned a nonce b. ABI-encoded, |
22 |
| -//! hashed, and stored in the `MessageLeaves` vector |
23 |
| -//! 6. At the end of the block, a merkle root is constructed from all the leaves in `MessageLeaves`. |
| 21 | +//! 5. The message is processed in `Pallet::do_process_message`: |
| 22 | +//! a. Convert to `OutboundMessage`, and stored into the `Messages` vector storage |
| 23 | +//! b. ABI-encoded the OutboundMessage, with commited hash stored into the `MessageLeaves` storage |
| 24 | +//! c. Generate `PendingOrder` with assigned nonce and fee attach, stored into the `PendingOrders` |
| 25 | +//! map storage, with nonce as the key |
| 26 | +//! d. Increment nonce and update the `Nonce` storage |
| 27 | +//! 6. At the end of the block, a merkle root is constructed from all the leaves in `MessageLeaves`, |
| 28 | +//! then `MessageLeaves` is dropped so that it is never committed to storage or included in PoV. |
24 | 29 | //! 7. This merkle root is inserted into the parachain header as a digest item
|
25 |
| -//! 8. Offchain relayers are able to relay the message to Ethereum after: a. Generating a merkle |
26 |
| -//! proof for the committed message using the `prove_message` runtime API b. Reading the actual |
27 |
| -//! message content from the `Messages` vector in storage |
28 |
| -//! |
29 |
| -//! On the Ethereum side, the message root is ultimately the thing being |
30 |
| -//! verified by the Polkadot light client. |
| 30 | +//! 8. Offchain relayers are able to relay the message to Ethereum after: |
| 31 | +//! a. Generating a merkle proof for the committed message using the `prove_message` runtime API |
| 32 | +//! b. Reading the actual message content from the `Messages` vector in storage |
| 33 | +//! 9. On the Ethereum side, the message root is ultimately the thing being verified by the Beefy |
| 34 | +//! light client. When the message has been verified and executed, the relayer will call the |
| 35 | +//! extrinsic `submit_delivery_proof` work the way as follows: |
| 36 | +//! a. Verify the message with proof for a transaction receipt containing the event log, |
| 37 | +//! same as the inbound queue verification flow |
| 38 | +//! b. Fetch the pending order by nonce of the message, pay reward with fee attached in the order |
| 39 | +//! c. Remove the order from `PendingOrders` map storage by nonce |
31 | 40 | //!
|
32 | 41 | //! # Message Priorities
|
33 | 42 | //!
|
|
38 | 47 | //! # Extrinsics
|
39 | 48 | //!
|
40 | 49 | //! * [`Call::set_operating_mode`]: Set the operating mode
|
| 50 | +//! * [`Call::submit_delivery_proof`]: Submit delivery proof |
41 | 51 | //!
|
42 | 52 | //! # Runtime API
|
43 | 53 | //!
|
@@ -334,7 +344,7 @@ pub mod pallet {
|
334 | 344 | let nonce = Nonce::<T>::get();
|
335 | 345 |
|
336 | 346 | // Decode bytes into Message and
|
337 |
| - // a. Convert to InboundMessage and save into Messages |
| 347 | + // a. Convert to OutboundMessage and save into Messages |
338 | 348 | // b. Convert to committed hash and save into MessageLeaves
|
339 | 349 | // c. Save nonce&fee into PendingOrders
|
340 | 350 | let message: Message = Message::decode(&mut message).map_err(|_| Corrupt)?;
|
@@ -367,12 +377,12 @@ pub mod pallet {
|
367 | 377 | <T as Config>::Hashing::hash(&committed_message.abi_encode());
|
368 | 378 | MessageLeaves::<T>::append(message_abi_encoded_hash);
|
369 | 379 |
|
370 |
| - let inbound_message = OutboundMessage { |
| 380 | + let outbound_message = OutboundMessage { |
371 | 381 | origin: message.origin,
|
372 | 382 | nonce,
|
373 | 383 | commands: commands.try_into().map_err(|_| Corrupt)?,
|
374 | 384 | };
|
375 |
| - Messages::<T>::append(Box::new(inbound_message)); |
| 385 | + Messages::<T>::append(Box::new(outbound_message)); |
376 | 386 |
|
377 | 387 | let order = PendingOrder {
|
378 | 388 | nonce,
|
|
0 commit comments