Optimistic Rollups are Layer-2 scaling solutions that are based on a principle that unless proven fraud, each transaction is genuine. Hence, the scaling solution got its name.
They are different than ZK Rollups whose transactions are only included in the chain after they are verified.
1. Defining Optimistic Rollups
Optimistic Rollups are scaling solutions that help compute Layer-1 transactions by verifying them off the chain. The transactions collected by Optimistic Rollups are computed off-chain which helps in reducing computation cost and therefore computation fees.
But, all the transaction records processed by an optimistic rollup is available on the Layer-1 blockchain (such as Ethereum).
Despite this, the transaction costs are cheaper than actual L1 transactions because Optimistic Rollups write data on Ethereum as “call data“. It is a feature where data input from external sources that call Ethereum functions, are stored.
Optimistic Rollups consider every transaction to be honest and true unless it is challenged with a Proof of Fraud. Since all of the transactions, processed by the rollup are available on-chain, they can be challenged at a later period in time. Challenges that allege a transaction to be fraud can submit a fraud proof on-chain which is then evaluated by the validators. If found to be fraudulent, that transaction is cancelled and funds are reversed.
Optimistic Rollups vs ZK Rollups
These rollups are different than ZK Rollups because in the case of Optimistic Rollups, transactions are available on the chain while ZK Rollups do not store individual transactions data. Further, ZK Rollups verify all the transactions submitted by them, but Optimistic Rollups verify transactions only when a proof of fraud is submitted.
Full Comparison: ZK Rollups vs Optimistic Rollups
2. Working Process
These rollups have a little bit of recursive working process as opposed to ZK rollups with have a linear working model.
Optimistic Rollups interact with L1 blockchains (like Ethereum) with the help of a on-chain smart contract that has been written specifically for the same rollup. The smart contract stores summary of transactions (rollup blocks), state proofs, state updates and store user transactions.
However, the rollup performs computations in an off-chain virtual machine similar to EVM. It is where each transaction is recorded individually before submitting a rollup block on the L1 blockchain.
2.1. Operators Collect User Transactions
Each transaction done on the optimistic rollup is sent to operators. These are nodes that process and bundle up these transactions into a block. The block is then published on L1 blockchain (like Ethereum) as “call data” and not as individual transactions. This helps reducing the size required to store all the transactions on the L1 blockchain.
Anyone can become an operator (node) by providing a collateral amount that can be slashed in case of invalid block.
#Special Operators: Sequencer
A sequencer is a special type of operator in those optimistic rollups where permissionless operators are not allowed. They have higher control over the rollup (Layer2) chain, can submit transactions to the on-chain contract (on L1) and can also change the order of transactions. Transactions from other ordinary nodes and users are kept in a waiting zone (like Mempool) till the sequencer includes them in a new rollup block.
2.2. Operator (Node) Submits Rollups on L1 Blockchain (Ethereum)
A sequencer or a node submits the transactions as a rollup block on the L1 blockchain using “call data”, an memory space in a smart contract. This memory space does not introduce any state changes in the case of Ethereum and therefore does not need any gas fees.
Here, is an example of 11 transactions that were rolled up by an Optimism Sequencer and processed as a single transaction on Ethereum. The hash of the transaction is below.
0x9102bfce17c58b5fc1c974c24b6bb7a924fb5fbd7c4cd2f675911c27422a5591
It cost just 0.0248 ETH in gas fees as opposed to approximately 0.0.273 ETH.
2.3. State Commitments
State commitments are snapshots of the L2 blockchain that are submitted to L1 blockchain to verify that every transaction.
3. Security and Fraud Proofs
The steps noted above were cases where there is no fraud transactions. To weed out fraud transactions the following steps are followed.
3.1. Simple Fraud Proving
3.2. Multi-Round Fraud Proving