How does Arbitrum handle cross-chain messaging and censorship-resistant transactions? What is its cross-chain bridge model?
Written by: Luo Benben, former Arbitrum technical ambassador and geek web3 contributor
In the previous article* “Former Arbitrum Technical Ambassador Interprets Arbitrum’s Component Structure (Part 1)”**, we introduced the sequencer, Validator, Sequencer Inbox contract, Rollup Block, and non-interactive fraud proof in the core components of Arbitrum In today’s article, we will focus on the components related to cross-chain messaging and censorship-resistant transaction entrances among Arbitrum’s core components. *
In the previous article, we mentioned that the Sequencer Inbox contract specifically receives the transaction data package Batch published by the sequencer on Layer1. At the same time, we point out that Sequencer Inbox is also called a fast box, as opposed to a slow box Delayed Inbox (referred to as Inbox). Below, we will provide a detailed explanation of components related to cross-chain messaging such as Delayed Inbox.
Cross-chain transactions can be divided into L1 to L2 (recharge) and L2 to L1 (withdrawal). Note that the recharge and withdrawal mentioned here are not necessarily related to cross-chain assets, but can be messaging that does not directly include assets. So these two words only represent two directions of cross-chain related behaviors.
Compared with pure L2 transactions, cross-chain transactions exchange information in two different systems, L1 and L2, so the process is more complicated.
In addition, what we usually call cross-chain behavior is cross-chain on two unrelated networks using a witness-mode cross-chain bridge. The security of this cross-chain depends on the cross-chain bridge. Operators, theft of cross-chain bridges based on the witness model has occurred frequently in history.
The cross-chain behavior between Rollup and the ETH main network is essentially different from the above-mentioned cross-chain, because the state of Layer2 is determined by the data recorded on Layer1,** as long as you are using the official Rollup The cross-chain bridge is absolutely safe in its operational structure. **
This also highlights the essence of Rollup. It only looks like an independent chain from the user’s perspective, but in fact the so-called “**Layer2” is just a quick display window opened by Rollup to users. Its real chain type The structure is still burned on Layer1. **So, we can think of L2 as half a chain, or “a chain created on Layer1”.
It should be noted that cross-chains are asynchronous and non-atomic. It is impossible to know the result after confirming a transaction like on one chain, nor can it guarantee that something will happen on the other side at a certain point in time. . Therefore, cross-chain may fail due to some soft issues, but as long as the correct means are used, such as Retryable Ticket, hard issues such as fund jams will not occur.
**Retryable tickets are the basic tools used when depositing through the Arbitrum official bridge. ** Both ETH and ERC20 deposits will be used. Its life cycle is divided into three steps:
**1. Submit the ticket on L1. **Use the createRetryableTicket() method in the Delayed Inbox contract to create a recharge ticket and submit it.
**2. Automatic redemption on L2. **In most cases, the sorter can automatically help users pay bills without subsequent manual operations.
**3. Manual redemption on L2. **In some edge cases, such as a sudden surge in gas prices on L2 and insufficient gas prepaid on the ticket, automatic payment cannot be made. At this time, manual operation by the user is required.
Note that if automatic redemption fails, the note needs to be redeemed manually within 7 days, otherwise either the note will be deleted (funds will be permanently lost), or a fee will need to be paid to save the note to renew the lease.
In addition, although the withdrawal process of the Arbitrum official bridge has a certain symmetrical similarity with the recharge behavior, there is no concept of Retryables. On the one hand, it can be understood from the Rollup protocol itself, and on the other hand, we can understand it from some differences:
Cross-chain ERC-20 assets are complex. We can think about several questions:
We are not going to answer all of these questions because they are too complex to unfold. These questions are only used to illustrate the complexity of ERC20 cross-chain.
Currently, many expansion solutions use whitelist + manual list solutions to avoid various complex problems and boundary conditions.
**Arbitrum uses the Gateway system to solve most of the ERC20 cross-chain pain points. **It has the following features:
Let’s take the relatively simple WETH cross-chain as an example to illustrate the necessity of customizing the gateway.
WETH is an ERC20 equivalent of ETH. As the main currency, Ether cannot implement complex functions in many dApps, so an ERC20 equivalent is needed. Transfer some ETH into the WETH contract, they will be locked in the contract, and the same amount of WETH will be generated.
In the same way, WETH can also be destroyed and ETH taken out. Obviously, the number of circulating WETH and locked ETH is always 1:1. **
If we now cross-link WETH directly to L2, we will find some strange problems:
Obviously this violates the design principles of WETH. **Then when WETH is cross-chain, whether it is recharging or withdrawing, it needs to be unwraped into ETH first, then crossed to the other side, and then wrapped into WETH. **This is the role of WETH Gateway.
The same goes for other tokens with more complex logic, which require a more complex and carefully designed Gateway to work properly in a cross-chain environment. Arbitrum’s custom Gateway inherits the cross-chain communication logic of the ordinary Gateway and allows developers to customize cross-chain behavior related to token logic, which can meet most needs.
Corresponding to the fast box, also known as SequencerInbox, is the slow box Inbox (full name Delayed Inbox)**. Why should there be a distinction between speed and slowness? Because the fast box is dedicated to receiving the L2 transaction batch issued by the sequencer, all transactions that have not been preprocessed by the sequencer in the L2 network should not appear in the fast box contract.
**The first function of the slow box is to handle the recharge behavior from L1 to L2. **The user recharges through the slow box, and the sequencer monitors it and then reflects it on L2. Finally, the recharge record will be included in the L2 transaction sequence by the sequencer and submitted to the fast box contract Sequencer Inbox.
In this example, it is not appropriate for users to submit recharge transactions directly to the express box, because transactions submitted to the express box Sequencer Inbox will interfere with the normal transaction sorting of Layer 2, and then affect the work of the sequencer.
The second function of the slow box is to resist censorship. Users directly submit transactions to the slow box contract, and the sorter will generally aggregate them into the fast box within 10 minutes. But if the sorter maliciously ignores your request, the slow box also has a force inclusion function:
If a transaction is submitted to the Delayed Inbox, and after 24 hours, the transaction in the slow box has not been included in the transaction sequence by the sequencer, ** the user can manually trigger the force inclusion function on Layer1, ** to ignore it by the sequencer The transaction requests are forcibly collected into the Sequencer Inbox, and will then be monitored by all Arbitrum One nodes, and will be forcibly included in the Layer 2 transaction sequence. **
As we just mentioned, the data in the fast box is the historical data entity of L2. Therefore, in the case of malicious censorship, the transaction instructions can be finally included in the L2 ledger through the slow box, which covers scenarios such as forced withdrawals and escaping Layer 2. **
It can be seen from this that for transactions in any direction and level, the sequencer will ultimately be unable to permanently review you.
Several core functions of slow box Inbox:
However, it should be noted that the force Inclusion function is actually located in the fast box contract. Just for the convenience of understanding, we will explain it together in the slow box.
Outbox is only related to withdrawals and can be understood as a recording and management system for withdrawals:
Below we will take ETH as an example to fully explain the deposit and withdrawal process. The only difference between ERC20 and Gateway is that it will not be described in detail.
The user calls the depositETH() function of the slow box.
This function will continue to call bridge.enqueueDelayedMessage(), record the message in the bridge contract, and send ETH to the bridge contract. **All ETH recharge funds are kept in the bridge contract, which is equivalent to a recharge address. **
The sequencer monitors the recharge messages in the slow box and reflects the recharge operation to the L2 database. Users can see the assets they have recharged on the L2 network.
The sequencer includes the recharge record into the transaction batch and submits it to the fast box contract on L1.
The user calls the withdrawEth() function of the ArbSys contract on L2 to destroy the corresponding amount of ETH on L2.
The sequencer sends the withdrawal request to the express box.
3 **Validator node creates a new Rollup Block based on the transaction sequence in the fast box, which will contain the above withdrawal transaction. **
After the Rollup Block passes the challenge period and is confirmed, the user can call the Outbox.ute Transaction() function on L1 to prove that the parameters are given by the ArbSys contract mentioned above.
After the Outbox contract is confirmed to be correct, the corresponding amount of ETH in the unlocked bridge will be sent to the user.
**If you use the Optimistic Rollup official bridge to withdraw cash, there will be a problem of waiting for the challenge period. We can use a private third-party cross-chain bridge to circumvent this problem: **
force Inclusion() The force inclusion function is used to resist the review of the sequencer. Any L2 local transaction, L1 to L2 transaction and L2 to L1 transaction can be implemented using this function. The malicious review of the sequencer seriously affects the transaction experience. In most cases, we will choose to withdraw money and leave L2. Therefore, the following uses forced withdrawal as an example to introduce the usage of forceInclusion.
**Recall that in the ETH withdrawal steps, only steps 1 and 2 involve sequencer review, so only these two steps need to be changed: **
End users can withdraw money in Outbox, and the remaining steps are the same as normal withdrawals.
In addition, arbitrum-tutorials also has detailed tutorials on using the Arb SDK to guide users on how to perform L2 local transactions and L2 to L1 transactions through forceInclusion().