Layer 2 Rollups
Layer 2 is a collective term for solutions designed to help scale your application by handling transactions off the Ethereum Mainnet (layer 1) while taking advantage of the robust decentralized security model of Mainnet. Transaction speed suffers when the network is busy, making the user experience poor for certain types of dapps. And as the network gets busier, gas prices increase as transaction senders aim to outbid each other. This can make using Ethereum very expensive.
You should have a good understanding of all the foundational topics and a high-level understanding of Ethereum scaling. Implementing scaling solutions such as rollups is an advanced topic as the technology is less battle-tested and continues to be researched and developed.
- Some use-cases, like blockchain games, make no sense with current transaction times.
- It can be unnecessarily expensive to use blockchain applications.
- Any updates to scalability should not be at the expense of decentralization or security – layer 2 builds on top of Ethereum.
Rollups are solutions that perform transaction execution outside the main Ethereum chain (layer 1) but post transaction data on layer 1. As transaction data is on layer 1, rollups are secured by layer 1. Inheriting the security properties of layer 1 while performing execution outside of layer 1 is a defining characteristic of rollups.
Three simplified properties of rollups are:
- transaction execution outside layer 1
- data or proof-of-transactions is on layer 1
- a rollup smart contract in layer 1 that can enforce correct transaction execution on layer 2 by using the transaction data on layer 1
Rollups require "operators" to stake a bond in the rollup contract. This incentivises operators to verify and execute transactions correctly.
- reducing fees for users
- open participation
- fast transaction throughput
There are two types of rollups with different security models:
- Optimistic rollups: assumes transactions are valid by default and only runs computation, via a fraud proof, in the event of a challenge
- Zero-knowledge rollups: runs computation off-chain and submits a validity proof to the chain
Optimistic rollups sit in parallel to the main Ethereum chain on layer 2. They can offer improvements in scalability because they don't do any computation by default. Instead, after a transaction, they propose the new state to Mainnet or "notarise" the transaction.
With Optimistic rollups, transactions are written to the main Ethereum chain as
calldata, optimising them further by reducing the gas cost.
As computation is the slow, expensive part of using Ethereum, Optimistic rollups can offer up to 10-100x improvements in scalability dependent on the transaction. This number will increase even more with the introduction of shard chains as more data will be available if a transaction is disputed.
Optimistic rollups don't compute the transaction, so there needs to be a mechanism to ensure transactions are legitimate and not fraudulent. This is where fraud proofs come in. If someone notices a fraudulent transaction, the rollup will execute a fraud-proof and run the transaction's computation, using the available state data. This means you may have longer wait times for transaction confirmation than a ZK-rollup because the transaction could get challenged.
The gas you need to run the computation of the fraud proof is even reimbursed. Ben Jones from Optimism describes the bonding system in place:
"anyone who might be able to take an action that you would have to prove fraudulent to secure your funds requires that you post a bond. You basically take some ETH and lock it up and you say "Hey, I promise to tell the truth"... If I don't tell the truth and fraud is proven, this money will be slashed. Not only does some of this money get slashed but some of it will pay for the gas that people spent doing the fraud proof"
So you can see the incentives: participants get penalized for conducting fraud and reimbursed for proving fraud.
|Anything you can do on Ethereum layer 1, you can do with Optimistic rollups as it's EVM and Solidity compatible.||Long wait times for on-chain transaction due to potential fraud challenges.|
|All transaction data is stored on the layer 1 chain, meaning it's secure and decentralized.||An operator can influence transaction ordering.|
Watch Finematics explain optimistic rollups:
Multiple implementations of Optimistic rollups exist that you can integrate into your dapps:
Zero-knowledge rollups (ZK-rollups) bundle (or "roll-up") hundreds of transfers off-chain and generate a cryptographic proof. These proofs can come in the form of SNARKs (succinct non-interactive argument of knowledge) or STARKs (scalable transparent argument of knowledge). SNARKs and STARKs are known as validity proofs and get posted to layer 1.
The ZK-rollup smart contract maintains the state of all transfers on layer 2, and this state can only be updated with a validity proof. This means that ZK-rollups only need the validity proof instead of all transaction data. With a ZK-rollup, validating a block is quicker and cheaper because less data is included.
With a ZK-rollup, there are no delays when moving funds from layer 2 to layer 1 because a validity proof accepted by the ZK-rollup contract has already verified the funds.
Being on layer 2, ZK-rollups can be optimised to reduce transaction size further. For instance, an account is represented by an index rather than an address, which reduces a transaction from 32 bytes to just 4 bytes. Transactions are also written to Ethereum as
calldata, reducing gas.
|Faster finality time since the state is instantly verified once the proofs are sent to the main chain.||Some don't have EVM support.|
|Not vulnerable to the economic attacks that Optimistic rollups can be vulnerable to.||Validity proofs are intense to compute – not worth it for applications with little on-chain activity.|
|Secure and decentralized, since the data that is needed to recover the state is stored on the layer 1 chain.||An operator can influence transaction ordering|
Watch Finematics explain ZK-rollups:
Multiple implementations of ZK-rollups exist that you can integrate into your dapps:
Hybrid solutions exist that combine the best parts of multiple layer 2 technologies, and may offer configurable trade-offs.
- An Incomplete Guide to Rollups
- Optimistic Rollups vs ZK Rollups
- Zero-Knowledge Blockchain Scalability
- Why rollups + data shards are the only sustainable solution for high scalability
- Ethereum-powered ZK-Rollups: World Beaters
- What Are Zero-Knowledge Rollups?
- EthHub on zk-rollups
- [STARKs vs SNARKs] (https://consensys.net/blog/blockchain-explained/zero-knowledge-proofs-starks-vs-snarks/)
- Everything you need to know about Optimistic Rollup
- EthHub on optimistic rollups
- The Essential Guide to Arbitrum
- How does Optimism's Rollup really work?
- OVM Deep Dive
- Adding Hybrid PoS-Rollup Sidechain to Celer’s Coherent Layer-2 Platform on Ethereum
- Volitions: best of all worlds
Know of a community resource that helped you? Edit this page and add it!
Aiutaci con questa pagina
Se conosci l'argomento e vuoi contribuire, modifica questa pagina e condividi un po' del tuo sapere.
Il tuo nome verrà aggiunto ai crediti e aiuterai la community di Ethereum!
Usa questo flessibile modello di documentazione
Domande? Chiedicelo nel canale #content sul nostro server DiscordModifica pagina