Cross-Domain Overview
This overview provides a detailed walkthrough of the lifecycle of cross-chain transactions, covering deposits, withdrawals, and transaction flows between L1 and L2. The diagram below illustrates the main components and steps involved.
Cross-domain communication in the OP Stack involves moving assets and messages between L1 and L2. Key components, such as bridges, messengers, and portals, ensure these transactions are executed securely and transparently. This page breaks down the lifecycle of a cross-chain transaction into three main flows: Deposit Flow, Transaction Flow (Tx Flow), and Withdrawal Flow.
Deposit Flow
Depositing assets from L1 to L2 follows a structured process that ensures funds are securely transferred and credited to the user's L2 account. The steps are as follows:
-
User Initiation (L1 Standard Bridge): The user initiates a deposit by sending assets (e.g., ETH or tokens) to the L1 Standard Bridge contract. This contract receives the assets and prepares a message to relay to L2.
-
Message Relaying (L1 CrossDomain Messenger): The L1 Standard Bridge sends a message to the L1 CrossDomain Messenger, which is responsible for handling inter-layer communication. The messenger emits a
TransactionDeposited
event to signal the start of the deposit process. -
Processing on L2 (OptimismPortal): The message is received by the OptimismPortal. Here, the deposited assets are held securely until the transaction is finalized. The portal initiates the deposit transaction, updating the user's balance on L2.
-
Finalization (L2 CrossDomain Messenger): The L2 CrossDomain Messenger processes the deposit deriving the message from L1 into the L2. If this is a deposit of ETH or a token the user's account balance will be reflected in their account making the assets available for use on L2.
For a more detailed breakdown of the deposit process, refer to the deposit (opens in a new tab) specs.
Transaction (Tx) Flow
The transaction flow covers the steps involved in cross-domain message passing and state updates between L1 and L2:
-
Message Queuing (L2ToL1MessagePasser): During cross-layer communication, certain messages are queued for processing. The
L2ToL1MessagePasser
prepares these messages for state updates or withdrawals, ensuring they are available for proving and relaying. -
State Reading and Proving (DisputeGameFactory and OptimismPortal): The
DisputeGameFactory
andOptimismPortal
play a critical role in validating L2 state changes on L1. New state proposals are created when someone creates a new dispute game through theDisputeGameFactory
. This proposal includes information about queued messages or state changes that need to be relayed to L1. Users can prove their withdrawals through theOptimismPortal
and then finalize on theOptimismPortal
once the challenge period has passed. -
Message Relay (CrossDomain Messengers): Messages are relayed between the L1 and L2 CrossDomain Messengers as part of transaction execution. This includes updating state or finalizing transactions on the target layer.
Withdrawal Flow
Withdrawing assets from L2 back to L1 involves a multi-step process to ensure the transaction is validated and executed correctly:
-
User Initiation: The withdrawal process starts when the user calls the
withdraw()
function on the L2 Standard Bridge, specifying the amount and asset to be withdrawn. -
Message Relay: The L2 CrossDomain Messenger receives the withdrawal request and relays the message for processing. It may involve queuing the message in the
L2ToL1MessagePasser
for further steps. -
Proving: The withdrawal message is proven using the
DisputeGameFactory
andOptimismPortal
. New state outputs are created as dispute games through theDisputeGameFactory
. TheOptimismPortal
references those dispute games. The user proves the withdrawal on theOptimismPortal
. This step involves reading the state and generating the required proofs during the proving time. -
Finalization (L1 CrossDomain Messenger and L1 Standard Bridge): Once the withdrawal is proven, the user waits for the challenge period to pass. Then they finalize it on the
OptimismPortal
and the message is finalized by the L1 CrossDomain Messenger. The L1 Standard Bridge completes the process by releasing the withdrawn assets to the user's L1 account.
For a more detailed breakdown of the withdrawal process, refer to the withdrawal (opens in a new tab) specs.