What Is an Optimistic Rollup?
The system periodically publishes a Merkle root of rollup transactions to update the rollup’s “state” on the underlying main blockchain.
External validators form a network that verifies the correctness of the Merkle roots before the state is updated.
In case of any inconsistencies, validators can submit fraud proofs during the dispute period, leading to a rollback to the previous valid state.
Difference Between ZK Rollup and Optimistic Rollup
Compared to zero-knowledge rollups, optimistic rollups have a drawback concerning the withdrawal time for layer 2 users to move their funds back to the underlying blockchain.
Optimistic rollups rely on external validators to check the Merkle roots for potential cheating before updating the state, so validators must review and challenge layer 2 activities.
The main advantage of optimistic rollups over zero-knowledge equivalents is their support for smart contracts, similar to the underlying smart contract-enabled blockchain.
With native smart contract support within the rollup, launching applications becomes easier without the need for additional development.
If you want to learn more about Optimistic Rollup vs ZK Rollup, you can find further information.
Optimistic Rollups Explained
Optimistic rollups are layer-2 scaling solutions designed to improve Ethereum’s throughput and latency by moving computation and data storage off-chain.
These rollups alleviate the load on the Ethereum mainnet and enhance scalability by processing transactions outside of it.
The key components of an optimistic rollup include:
- A smart contract on Ethereum
- A sequences
- A set of validators
The smart contract governs the interaction between the layer-2 chain and Ethereum.
Acting as a third party, the sequencer collects, orders, and executes transactions on the layer-2 chain.
Validators, forming a group of nodes, monitor the layer-2 chain and submit fraud proofs to the smart contract if they detect any invalid transactions.
To use an optimistic rollup, users deposit funds into the Ethereum smart contract, which locks the funds and emits a deposit event.
The sequencer receives the event and credits the user with equivalent tokens on the layer-2 chain.
Users can freely transact with others who have also deposited funds into the smart contract on the layer-2 chain.
They sign transactions and submit them to the sequencer, who verifies and adds them to a transaction queue.
Batching and Submission by the Sequencer
Periodically, the sequencer batches thousands of queued transactions into a block and submits it to Ethereum as a single transaction.
The block contains minimal data, such as the state root (a Merkle root of the layer-2 chain’s state) and the transaction root (a Merkle root of the transactions in the block).
The smart contract stores these roots and updates its state accordingly.
Sequencer-Published Block Data
The sequencer publishes the full block data off-chain on a decentralized storage network like IPFS or a centralized server.
Validators can access this data and verify that it matches the roots submitted on-chain.
If any discrepancies are found, they can submit a fraud-proof to the smart contract, which reverts the invalid block and penalizes the sequencer.
When a user wants to withdraw funds from the layer-2 chain to Ethereum, they initiate an exit request on the layer-2 chain. The sequencer includes this request in a block and submits it to Ethereum.
Deferring Verification for Efficiency
The smart contract then unlocks the funds and transfers them to the user’s address.
However, a waiting period (usually one week) is required before the withdrawal is finalized, during which anyone can challenge the exit with fraud-proof if it is invalid.
The key feature of optimistic rollups is their assumption that all transactions are valid by default, and they are only verified if fraud-proof is submitted.
This allows for high scalability without compromising security or decentralization.
Types of Optimistic Rollups
Optimistic rollups are not a single protocol but a class of protocols sharing common features and design choices.
These choices include:
- Execution Model: EVM-compatible rollups use the Ethereum Virtual Machine (EVM) as the base layer, enabling them to run any smart contract compatible with Ethereum without modification.
- Data Availability Solution: Decentralized data availability solutions employ a peer-to-peer or decentralized storage network like IPFS to store and distribute full-block data.
- Fraud Proof Mechanism: Interactive fraud-proof mechanisms involve a challenge-response process between the sequencer and validators to verify the validity of a block.
Why Is It Called an “Optimistic” Rollup?
In optimistic rollups, “optimistic” refers to the assumption that all transactions are valid by default.
This means the layer-2 chain does not verify or validate transactions before submitting them to Ethereum unless challenged.
Instead, it relies on economic incentives and fraud proofs to ensure the correctness and security of the system.
Benefits of Optimistic Rollups
- Lower Gas Fees: By moving most computation and data storage off-chain, optimistic rollups reduce gas fees for transactions. They achieve this by batching thousands of transactions into a single block and submitting minimal data on-chain.
- Higher Throughput: Optimistic rollups enhance throughput by processing transactions more quickly and frequently on the layer-2 chain. They can achieve higher transaction speeds and lower confirmation times by avoiding congestion and limitations on the base layer.
- Faster Confirmation Times: Instant confirmations on the layer-2 chain improve transaction latency in optimistic rollups.
- Compatibility With Existing Smart Contracts and Tools: Optimistic rollups are compatible with Ethereum’s existing smart contracts and tools. Developers can use familiar languages, frameworks, libraries, and standards like Solidity, EVM, and ERC-20. Users can also use the same wallets, browsers, and interfaces like MetaMask.
- Security and Decentralization: Optimistic rollups derive their security and decentralization from the base layer by publishing transaction results on-chain and relying on fraud proofs for correctness.
Challenges or Limitations of Optimistic Rollups
- Fraud Proof Delay: There is a period between the on-chain submission of a fraudulent transaction and its reversion through fraud-proof. During this time, the layer-2 chain may be inconsistent with the layer-1 chain, potentially impacting user experience and application security.
- Data Availability Problem: Ensuring full-block data accessibility off-chain for verification or a transaction is challenging. Fraud proofs cannot be generated or submitted if the data is unavailable or corrupted, potentially compromising the system’s security and integrity. Decentralized and centralized data availability solutions can mitigate this problem but have their own pros and cons.
- Sequencer Centralization Risk: Depending on a single entity or a small group of entities to collect, order, and execute layer-2 chain transactions carries the risk of centralization. A malicious or compromised sequencer could censor, reorder, or manipulate transactions, harming users and applications on the rollup. Mitigating sequencer centralization risk can involve using multiple sequencers, randomizing sequencer selection, or allowing users to bypass the sequencer.
- Compatibility Trade-Off: While optimistic rollups are compatible with existing smart contracts and tools on Ethereum, this compatibility comes with a trade-off. By using the same execution model as Ethereum, optimistic rollups inherit some limitations and inefficiencies, such as high gas costs for complex computations or storage operations. Alternative scaling solutions, such as zk-rollups, use a different execution model that can optimize for specific use cases or domains.