
Author: Nic Lin, TAIPEI Ethereum Meetup person in charge
Original title: “Introduction to Rollup’s Force Inclusion Mechanism”
Just yesterday, a shocking thing was shocked:Ethereum Linea, a second -layer Linea launched by Metamask’s parent company Consensys, has taken the initiative. The official said that the purpose of doing so is to reduce the impact of the Velocore hacking event.This can’t help but remind people of the previous BSC chain (BNB Chain) In order to reduce the loss of hackers, the official actively coordinated the suspension.Whenever people talk about this kind of thing, they are doubtful about the decentralized value advocated by Web3.
certainly,The core cause of the above incident is more about the imperfect infrastructure itself, that is, not enough decentralization: If a chain is decentralized enough, you should not stop if you stop.Due to the unique structure of the second floor of Ethereum,Most layer2 depends on the centralized SequencerAlthough more and more theory of decentralized sorters in recent years, considering the purpose of the existence and structure of the second floor, we can think thatLayer2’s sorter may not be more decentralized, and it may not be comparable to the degree of decentralization of the BSC chain.If this is true, what should we do?
In fact, for the second floor,The most direct harm caused by the sorter is not decentralized is resistance and activity.If there are few entities that handle the transaction, then it has absolute power if it serves you: if you want to reject you, reject you, and you may not help it.How to solve the anti -review problem of Layer2 is obviously an important topic.
In the past few years, the second floor of the major Ethereum has proposed a variety of solutions for anti -censorship issues, such as Loopring and Degate and Starkex’s forced withdrawal and escape capacity, Arbitrum and other OP ROLLUP Force Inclusion.Functions, these methods can generate checks and balances on Sequenceer under certain conditions to prevent their free rejection of any user’s transaction request.
In today’s article, NIC Lin from the Taipei Ethereum Association appeared,I personally experimented with the anti -review trading function of 4 mainstream ROLLUP, and analyzed the mechanism design of the Force Inclusion in the aspects of workflow and operation method.This is particularly valuable for the Ethereum community and large assets to hold huge assets.
Transaction review and Force Inclusion
Censorship Resistance is very important for a blockchain. If the blockchain can be arbitrarily reviewed and rejected the transaction initiated by users, it is no different from a web2 server.Ethereum ’s current transaction anti -review capabilities come from its many Validator. If anyone wants to review the BOB transactions and do not let his transactions be chained, or try to buy most of the Validator in the network, or the entire SPAM network,The junk transactions that are continuously sending the handling fee than BOB to seize the block space.No matter what method, the cost will be very high.
Note: In Ethereum’s current PBS architecture, the cost of reviewing transactions will be reduced a lotYou can refer to the block ratio of the TORNADO CASH transaction with OFAC.The current anti -examination capabilities depends on independent verifications and Relay outside of OFAC and government jurisdiction.
But what about rollup?Rollup does not need a lot of Validator to ensure security. Even if Rollup has only one centralized character to produce blocks, it is as safe as L1.But the ability of security and anti -review is two different things,Even though a rollup and Ethereum are as safe, but only one centralized Sequenceer, you want to review any user’s transactions.
Sequencer can refuse to deal with user transactions, causing user funds to be detained and cannot leave the rollup
Force Inclusion mechanism
Rather than asking Rollup to have a large number of decentralized Sequencer, it is better to directly use L1’s anti -review capabilities:
Originally, Sequencer was to pack the transaction data to the ROLLUP contract of L1. It is better to add a design to the contract.Let users insert the transaction to the ROLLUP contract by themselves. This mechanism is called “Force Inclusion”.As long as Sequence does not review users at the L1 level, it cannot prevent users from being forced to insert transactions at L1.In this way,Rollup can inherit L1’s resistance.
Sequence can not review the user’s L1 transaction, unless it pays a high cost
How should the mandatory transactions come into effect?
If the transaction is directly written into the Rollup contract (that is, the immediately effective) is allowed to be written directly through FORCE Inclusion, then the state of Rollup will change immediately.If the transaction takes effect immediately, the balance of BOB in the latest state will be 1,000 dai, and Carol will 1000 dai.
If force inclusion can directly write the transaction in the Rollup contract and take effect immediately, the state will change immediately
If Sequencer is also collecting transactions in the chain at this time, and sending the next batch of transactions to the ROLLUP contract, transactions that may be forcibly inserted by BOB may be integrated.This kind of problem should be tried to avoid, soRollup generally does not allow the Force Inclusion transaction to take effect immediately. Instead, let users insert the transaction into the waiting queue on L1 and enter the “preparation” state.
When Sequencer packages the chain transaction to the Rollup contract, choose whether to plug in the aforementioned transaction in the trading sequence,If Sequencer has always ignored these transactions in the “preparation” state, after the window period is over, users can force these transactions into the Rollup contract.
Sequence can decide when when “income” waiting in the queue in the queue
Sequencer can still refuse to deal with transactions in the waiting queue
If Sequence refuses for a long time, anyone can forcibly insert the transaction into the Rollup contract through the FORCE Inclusion function after a period of time
Next, we will introduce four well -known ROLLUP Force Inclusion mechanisms such as Optimism, Arbitrum, StarkNet, and ZKSYNC in order.
Optimism’s Force Inclusion mechanism
First introduce the DEPOSIT process of Optimism. This deposit not only refers to depositing money into Optimism, but also includes “sending information sent by users to L2” into L2.After receiving the newly stored message, the L2 node will convert the message into a L2 transaction for execution and send it to the receiver specified by the message.
The user gives L2 from L1 deposit to L2
L1CrossDomainmessenger contract
When a user wants to deposit ETH or ERC-20s to Optimism, he will use the front-end webpage and L1 on the L1L1standardbridgeThe contract interaction, how much the amount to be saved, and which L2 address to receive these assets.
L1standardBridge contract will pass the message to the next levelL1CrossDomainmessengercontract,This contract is mainly used as a component of communication between L1 and L2L1standardbridge communicates through this general communication component and L2StandardBridge on L2 to decide who can cast tokens at L2 or who can unlock the tokens from L1.
If developers need to develop a contract between L1 and L2, he can build on the L1CrossDomainmenger contract.
The user’s message is transmitted from L1 to L2 through the CrossDomainmessenger contract to L2Note: In some pictures of this article, write CrossDomainmessager into CrossChainmessager
OptimismPortal contract
L1CrossDomainmessenger contract will send the message to the bottom layerOptimismPortalContract, OptimismPortal contract will be thrown out after processingTransactionDeposityIncidents, parameters include “people who send messages”, “person who receives messages”, and related execution parameters.
Then L2’sOptimism node will monitor the Transaction DEPOSITED event thrown by OptimismPortal contract and convert the parameters in Event into a L2 transaction.The initiator of this transaction is the “person who sends messages” stated in the transaction deposite event parameter. The transaction receiver is the “person who receives the message” in the event parameters, and other transaction parameters are also from the parameters in the above events.
L2 node will convert OptimISMPORTALEMIT’s transaction defosted event parameters into a L2 transaction
For example, this isA user of 0.01 ETH transactions through L1standardBridge contracts through L1standardBridge.
The sponsors of the message are the L1CrossDomainMessenger contract; the receiver is the L2CROSSDOMAINANGER contract on L2; the content is L1standardBridge received the Bob’s 0.01ETH deposit.After that, some processes will be triggered, such as adding 0.01 ETH to L2StandardBridge, and then transferred to BOB from the latter.
How to trigger
When you want to force the transaction into the ROLLUP contract of Optimism, the effect you want to achieve is to make a “transaction initiated from your L2 address on L2 and the execution of execution” can be implemented smoothly. At this timeYou should use your own L2 address to submit the message directly to the OptimismPortal contract(Note that the OptimismPortal contract is actually on L1, but the address format of OP is the same as the L1 address format.You can directly call the above contract with the L1 account of the same address as the L2 accountTo.
After that, the “initiator” of the transformation of the Transaction Deposite event transformed by the contract will be your L2 account. At this time, the transaction format is consistent with the normal L2 transaction.
From the L2 transaction converted from the Transaction Deposity event, the sponsor will be BOB itself; the receiver is the Uniswap contract;
If you want to call the FORCE Inclusion function of Optimism, you need to call the DEPOSITTRANSACTION function of the OPTIMISMPORTAL contract directly to fill in the parameters you want to execute on L2
I did a simple Force Inclusion experiment,This transaction wants to achieve such a thing: use my address on L2 (0xedc1 … 6909), and comes with a text message of “Force Inclusion”.
This is the L1 transaction that I executes the deposittransaction function through the OptimismPortal contract. You can see that in the transaction deposite incident it thrown, both and to are me.
The value in the remaining OPAQUE DATA column encodes the “How many ETHs Call the DEPOSIT Transaction function”, “How many ETH to send the L2 transaction to the receiver”, “L2 transaction Gaslimit” and “Give L2″”Data of the receiver” and so on.
After decoding the above information, you will get:
“How much ETH is added to the person who calls the deposit transaction”: “:”0, because I don’t save eth to L2 from L1;
“How many ETHs to send by L2 transaction to the receiver”: 5566 (Wei)
“Gaslimit of L2 transaction”: 50000
“Data for L2 receiver”:0x666F72636520696E636C7573696F6E, that is
Then the conversion of L2 trading after the conversion was not long: I transferred the money to my own L2 transaction,The amount is 5566 Wei, and Data is the “Force Inclusion” string.And it can be noted that TXNTYPE (transaction type) in the penultimate line of Other Attributes in the figure shows that it is a system transaction 126 (System), which means that the transaction was not initiated by myself in L2, and it was deposited trading by L1 transaction.The event came from.
Converted L2 transaction
If you want to call the L2 contract with FORCE Inclusion and send different data, it is nothing more than filling the parameters into the previous DEPOSIT Transaction function. Just remember to call the deposit transaction function of the same L2 account as your L2 account to call your own L2 account.In this way, when the DEPOSITED EVENT converts L2 transactions, the sponsors are your L2 account.
Sequencerwindow
The Optimism L2 node mentioned earlier converts the transaction deposite event into L2 transactions. In factOnly Sequence can decide when to convert the aforementioned event into L2 transactions.
When I heard the TransactionDeposity incident, Sequencer may not immediately convert Event into L2 transactions, and there can be a delay. The maximum value of this period is called Sequencewindow.
At present, the Sequence Window on the Optimism main network is 24 hours, that is, when the user deposits a sum of money from L1 or a force inclusion, the worst case is that it was included in the history of L2 trading after 24 hours.
Arbitrum’s Force Inclusion mechanism
In Optimism, the deposit operation of L1 will throw a transaction deposite event. The rest is to wait for Sequencer to include the above operations;However, the operation that occurs in L1 in Arbitrum (saving money or message to L2, etc.) will be in a queue on L1.Instead of throwing an incident simply.
Sequencer will be given a period of time to incorporate the transactions in the above queue into the history of L2 transactions. If the time is not done when the time is reached, then anyone can complete it for Sequencer.
Arbitrum will maintain a Queue in the L1 contract. If Sequence does not actively handle transactions in Queue, time is up to anyone to enforce the transaction in Queue into the history of L2 trading history
In the design of Arbitrum, the operations such as deposits on L1 must be contracts through Delayed Inbox. As the name suggests, the operations here will delay the effect. Another contract is Sequencer Inbox, which is a direct place for Sequencer to upload L2 transactions to L1.Every time Sequence uploads L2 transactions, you can take some transactions to be handled from Delayed Inbox to the history of the transaction from Delayed Inbox.
When Sequencer writes a new transaction, you can take out the transaction from Delayedinbox to write it togetherComplex designs and Fanxiangye’s reference materials
If readers directly refer to the official Arbitrum’s chapters about Sequence and Force Inclusion, you will see how the Force Inclusion operates, and some parameter names and function names:
Users go firstDelayedinboxContract callsendunSignettransactionFunction, if Sequenceer is not included in about 24 hours, the user can callSequencerinboxContractForceInclusionfunction.Then Arbitrum officials did not attach the link of the function to the official website document, and I could only see the corresponding functions in the contract code by themselves.
When you find the SendunSignedtransaction function, you find that you have to fill in the NONCE value and MaxFeepergas value.Which address is NONCE?Which Maxfeepergas is on the Internet?How to fill it out?No file reference, not even Natpsec.Then you will find a bunch of similar functions in the Arbitrum contract:
Sendl1fundedunSignettransaction, SendunSignettractionTofork, SendContr ActtTransaction, Sendl1FundContracttransaction, there are no files tell you how to use these functions, how to use it, parameters, parameters, parameters, parameters, parameters, parameters. How to fill, not even Natpsec.
You tried the parameters and sent the transaction with the mentality of trying to try it. Want to see if you can find the correct usage in a trial and error, but you can find that these functions will use your L1 address as AddressaliasingSENDER was simply a different address when initiating the transaction, so your L2 address motionless.
sendl2message
Later, I accidentally clicking Google Search by accident, only to find that the original Arbitrum itself had a Tutorial program library with a script demonstration.Insteadsendl2messageThe function, and the MESSAGE parameter is brought in to the transaction with the L2 account?
Who knows that “the message to L2 through the Force Inclusion” will be a “L2 transaction with name”?And there is no file and NATSPEC explanation when and how to use this function.
Conclusion: It is more troublesome to manually generate a compulsory transaction of Arbitrum,It is recommended to run Arbitrum SDK in the official Tutorial.ARBITRUM does not have clear developer files and code notes like other Rollup. The lack of use and parameters of many functions leads to the development and use of developers than expected.I also asked ARBITRUM on Arbitrum Discord, but did not get a satisfactory answer.
Asked on Discord, the other party only told me to see Sendl2message, and did not want to explain the functions of other functions (or even the sendunsignedtransaction mentioned in the Force Inclusion document), how to use it, and when.
StarkNet’s forceIinclusion mechanism
Unfortunately, Starknet has no FORCEINCLUSION mechanism.There are only two articles discussed in official forums in the official forum.
Can’t prove a failed transaction
The above reasons are actually because Starknet’s zero -knowledge proof system cannot prove a failed transaction, so the Force Inclusion cannot be allowed.becauseIf someone is malicious (or unintentional) force include a failed, unable to prove a transaction, then StarkNet will directly get stuck: Because after the transaction is forcibly income, Prover must prove the failure transaction, but it cannot prove it.
Starknet expects to introduce the function of failed transactions in version V0.15.0, and it should be further realized to further realize the Force Inclusion mechanism.
ZKSYNC’s forceIinclusion mechanism
ZKSYNC’s L1-& GT; L2 message transmission and Force Inclusion mechanism are all performed through the Requestl2Transaction function of the Mailbox contract, Users specify L2 address, calldata, additional ETH quantity, L2Gaslimit value, etc., Requestl2Transaction will combine these parameters into a L2 transaction, and then put them in priorityQueue, and Sequency will be uploaded to L1 in the transaction packaging (by the transaction packaging (byThe CommitBatches function) shows that by the way, how many transactions should be taken from the priority queue and included in the L2 transaction record.
ZKSYNC is very similar to Optimism in the form of Force Inclusion. They all call the relevant functions with the L2 address (consistent with the L1 address) of the sponsor and fill in the information(Calls, CallData, etc.), instead of filling in a L2 transaction with a signed name like Arbitrum; but in the design, like Arbitrum, they are all in L1 to maintain a queue Queue, and the Sequencer from Queue from QueueMill out of the user directly submitted to the transaction and write it into the history of the transaction.
If you go through the official bridge of ZKSYNC to the deposit ethLike this transaction, it is to call the Requestl2Transaction function of the Mailbox contract,It will put this DEPOSIT ETH L2 transaction into the priority queue and throw a newpriorityRequest eventEssenceBecause the contract encodes L2 transaction data into a string of bytes string, it is not easy to read. If you look at the parameters of this L1 transaction, you will see that the receiver of the L2 in the parameter is also the initiator of the transaction (because it is DEPOSIT for yourself), soAfter a while, this L2 transaction was taken out of the priority queue by Sequeuncer from the priority queue and was included in the history of the transaction.ETH amount brought in ETH transactions.
In the L1Deposit transaction, the sponsor and receiver of the transaction are 0xedc1 … 6909, the amount is 0.03ETH, and the callData is empty.
A 0xedc1 … 6909 will be transferred to your own transaction on L2.
Then, like the compulsory trading function of the previous experiment OP, I called ZKSYNC’s Requestl2TRANSACTION function to send a self -transfer: there was no ETH, CallData brought the Hex encoding of the “Force Inclusion” string.
Then it was converted to a transaction on its own transaction on L2. In the CALLDATA, the hexadecimal string of “Force Inclusion”: 0x6666F726365206E636C7573696F6E.
When Sequencer takes the transaction from PriorityQueue and writes it into the history
Through the Requestl2TransAction function, users can submit the information at L1 with the same L1 account as the L2 address, specify the L2 receiver, the ETH amount with the attached ETH, and the callData.If the user wants to call other contracts and with different data, then fill the parameters one by one into the Requestl2TRANSACTION function.
The function that has not allowed users to be forced to be included
Although the L2 transaction is placed in the priority queue, the waiting period of the L2 transaction is calculated by the way by the L2 transaction, but itAt present, the FORCE Inclusion function that does not allow users to enforce users in ZKSYNC design is equivalent to only half setsEssenceThat is, although there is a “free waiting period”, in fact, “see if Sequence should be income”: Sequence can wait until the expiration is expired to earn, and you can never earn any transactions in the priority queue.
In the future, ZKSYNC should add relevant functions so that users can force the transaction to include the history of L2 transactions when the income period is over but has not been included by Sequeuncer. This is the truly effective Force Inclusion mechanism.
Summarize
L1 relies on a large number of verifications to ensure the “security” and “anti -review capabilities” of the Internet. Because Rollup is written into a transaction because of a few or even a single Sequencer, the anti -examination ability is weaker.thereforeRollup needs a Force Inclusion mechanism to allow users to bypass the Sequencer and write the transaction into history.Avoid being reviewed by the Sequencer, which cannot be used or cannot withdraw funds from the Rollup.
Force Inclusion allows users to force users to write transactions into history, But design in design, “Whether the transaction can insert history immediately and take effect immediately”.If the transaction is allowed to take effect immediately, it will have a negative impact on the Sequencer, because the transactions waiting for income on L2 may be affected by the exchanges of L1 forced income.
thereforeAt present, Rollup’s Force Inclusion mechanism will first let the transaction inserted on L1 enter the waiting state.And let Sequenceer react for a while to choose a transaction in waiting for whether to income.
ZKSYNC and Arbitrum both maintain a queue Queue in L1 to manage the L2 transaction sent by the user from L1 or the message to L2.Arbitrum is called delayedinbox; ZKSYNC is called PriorityQueue
butZKSYNC’s way of sending L2 transactions is more similar to OptimismThey all send messages to L1 with L2 address. After converting into L2 transactions, the initiative will be the L2 address.The function of Optimism sent L2 transactions is called deposittransaction; ZKSYNC is called Requestl2Transaction.Arbitrum generates a complete L2 transaction and signature, and then send it through the Sendl2Message function. Arbitrum will restore the signatures of the L2 transaction through the signature signature on L2.
Starknet does not have the Force Inclusion mechanism yet; ZKSYNC is like a half -set force inclusion—The PriorityQueue and the L2 transaction in each queue has a valid period, but this validity period is currently only decorative. In fact, Sequence can choose L2 transactions in PriorityQueue completely without income.