L2 to L1 message passing
Overview
L2 to L1 messaging is implemented by L1 transactions triggered by L2. (Asset transfers are based on this mechanism)
Rooch has the ability of multi-chain asset settlement, for different roles of L1 (arbitration chain/settlement chain), the process is the same, both are:
- Initialization transaction: L2 to L1 request is initiated by user in L2. 2. Proof transaction: L2 to L1 request is initiated by user in L2.
- Proof transaction: the user submits a proof of inclusion of the transaction in L1, which proves the change of L2 state. 3.
- Confirmation Transaction: The user submits a transaction confirmation at L1, and L1 executes the L1 transaction requested by L2 after verification.
The core difference between the arbitration/settlement chain in L2 to L1 messaging is the validation mechanism behind it:
- Arbitration chain: L2 is validated by the validation node directly through the arbitration contract on L1. 2. Settlement chain: L2 is validated by L2 through the arbitration contract on L1.
- Settlement Chain: L2 light node contracts assist the validating node to validate through the arbitration contract on L1. (See below for a more detailed description)
Initializing a transaction
-
The user initiates the L2 to L1 request by calling the
call_remote
function inl2_stub
with the following parameters.action
: coded information about the contract call on L1
-
l2_stub
will call thesend_l2_to_l1
function inrooch_transport
to complete the logging of events on L2, with the following parameters:- `msg_sequence
- `msg_sender
action
-
send_l2_to_l1
After completing the check, issue theL2ToL1Event
event with the following parameters:- `msg_sequence
- `msg_sender
action
from
: the originator of thesend_l2_to_l1
. In this case it isl2_stub
.L2ToL1Event_version
: event version number
Prove the transaction
After the root of the L2 block containing the L2ToL1Event
event has been committed to L1, the user can submit a proof transaction.
Proof generation
This is a proof that the L2ToL1Event
Merkle Trie contains a proof, there are multiple ways to generate it, we just need to make sure the root matches the record on L1.
This is done off-chain.
Initiate a proof transaction
Initiate a prove_l2_to_l1
transaction on L1 via rooch_transport
to verify that the proof we generated off-chain matches the L2 output of the record on L1.
Confirm Transaction
At the end of the challenge period, users can submit confirmation transactions.
A finalize_l2_to_l1
transaction is initiated on L1 via rooch_transport
to verify that the proof transaction passed the challenge period successfully. Upon completion of the check, action
is invoked.
Settlement Chain Validation Mechanism
Let's explore the nature of secure settlement by starting with Rollups' causality model, which is as follows for L2 to L1 messaging:
- cause: transaction on L2
- effect: L2 output
- causal (message) medium: proposer
- observer: verifier
For the arbitration chain, we already have a complete fraud proof mechanism, and causality does not rely on observers, so only an honest observer (verifier) is needed to guarantee that the causality has been correctly established.
In order for the settlement chain to be equivalent to the arbitration chain, we need to construct consistent causality, which for the settlement chain implies the following preconditions:
- the same media completion result record: the proposer needs to record the L2 output in the settlement chain
- the same observer to verify the result record: through the L1 light node on the L2 to complete the L1 result record in the L2 confirmation, to realize the verifier's observation.