Aider Γ  traduire cette page

🌏

Cette page s'affiche en anglais car nous ne l'avons pas encore traduite. Aidez-nous Γ  traduire son contenu.

Cette page est incomplΓ¨te. Si vous Γͺtes un expert sur le sujet, veuillez Γ©diter cette page et l'enrichir de votre sagesse.

Layer 2 Rollups

Dernière modification: , Invalid DateTime
Edit page

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 which can make 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.

Prerequisites

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.

Why is layer 2 needed?

  • 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

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, this allows rollups to be 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:

  1. transaction execution outside layer 1
  2. data or proof of transactions is on layer 1
  3. 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.

Useful for:

  • reducing fees for users
  • open participation
  • fast transaction throughput

There are two types of rollups with different security models:

  • Zero knowledge rollups: runs computation off-chain and submits a validity proof to the chain
  • 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

Zero knowledge rollups, also known as ZK-rollups, bundle or "roll up" hundreds of transfers off-chain and generates a cryptographic proof, known as a SNARK (succinct non-interactive argument of knowledge). This is known as a validity proof and is posted on 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.

Pros and cons

ProsCons
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.Operator can influence transaction ordering

Use ZK-rollups

Multiple implementations of ZK-rollups exist that you can integrate into your dapps:

Optimistic rollups

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. This is because there will be more data available in the event that a transaction is disputed.

Disputing transactions

Optimistic rollups don't actually compute the transaction, so there needs to be a mechanism in place 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 it could be challenged.

Diagram showing what happens when a fraudulent transaction occurs in an Optimistic rollup in Ethereum

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.

Pros and cons

ProsCons
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.Operator can influence transaction ordering

Use Optimistic rollups

Multiple implementations of Optimistic rollups exist that you can integrate into your dapps:

Hybrid solutions

Hybrid solutions exist that combine the best parts of multiple layer 2 technologies, and may offer configurable trade-offs.

Use Hybrid solutions

Further reading

ZK-rollups

Optimistic rollups

Hybrid solutions

Know of a community resource that helped you? Edit this page and add it!

β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–„β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–„β–‘β–‘β–‘β–‘ β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–Œβ–’β–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–„β–€β–’β–Œβ–‘β–‘β–‘ β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–Œβ–’β–’β–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–„β–€β–’β–’β–’β–β–‘β–‘β–‘ ░░░░░░░▐▄▀▒▒▀▀▀▀▄▄▄▀▒▒▒▒▒▐░░░ β–‘β–‘β–‘β–‘β–‘β–„β–„β–€β–’β–‘β–’β–’β–’β–’β–’β–’β–’β–’β–’β–ˆβ–’β–’β–„β–ˆβ–’β–β–‘β–‘β–‘ β–‘β–‘β–‘β–„β–€β–’β–’β–’β–‘β–‘β–‘β–’β–’β–’β–‘β–‘β–‘β–’β–’β–’β–€β–ˆβ–ˆβ–€β–’β–Œβ–‘β–‘β–‘ β–‘β–‘β–β–’β–’β–’β–„β–„β–’β–’β–’β–’β–‘β–‘β–‘β–’β–’β–’β–’β–’β–’β–’β–€β–„β–’β–’β–Œβ–‘β–‘ β–‘β–‘β–Œβ–‘β–‘β–Œβ–ˆβ–€β–’β–’β–’β–’β–’β–„β–€β–ˆβ–„β–’β–’β–’β–’β–’β–’β–’β–ˆβ–’β–β–‘β–‘ β–‘β–β–‘β–‘β–‘β–’β–’β–’β–’β–’β–’β–’β–’β–Œβ–ˆβ–ˆβ–€β–’β–’β–‘β–‘β–‘β–’β–’β–’β–€β–„β–Œβ–‘ β–‘β–Œβ–‘β–’β–„β–ˆβ–ˆβ–„β–’β–’β–’β–’β–’β–’β–’β–’β–’β–‘β–‘β–‘β–‘β–‘β–‘β–’β–’β–’β–’β–Œβ–‘ β–€β–’β–€β–β–„β–ˆβ–„β–ˆβ–Œβ–„β–‘β–€β–’β–’β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–’β–’β–’β–β–‘ β–β–’β–’β–β–€β–β–€β–’β–‘β–„β–„β–’β–„β–’β–’β–’β–’β–’β–’β–‘β–’β–‘β–’β–‘β–’β–’β–’β–’β–Œ ▐▒▒▒▀▀▄▄▒▒▒▄▒▒▒▒▒▒▒▒░▒░▒░▒▒▐░ β–‘β–Œβ–’β–’β–’β–’β–’β–’β–€β–€β–€β–’β–’β–’β–’β–’β–’β–‘β–’β–‘β–’β–‘β–’β–‘β–’β–’β–’β–Œβ–‘ ░▐▒▒▒▒▒▒▒▒▒▒▒▒▒▒░▒░▒░▒▒▄▒▒▐░░ β–‘β–‘β–€β–„β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–‘β–’β–‘β–’β–‘β–’β–„β–’β–’β–’β–’β–Œβ–‘β–‘ β–‘β–‘β–‘β–‘β–€β–„β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–„β–„β–„β–€β–’β–’β–’β–’β–„β–€β–‘β–‘β–‘ β–‘β–‘β–‘β–‘β–‘β–‘β–€β–„β–„β–„β–„β–„β–„β–€β–€β–€β–’β–’β–’β–’β–’β–„β–„β–€β–‘β–‘β–‘β–‘β–‘ β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–€β–€β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘

Aidez-nous avec cette page

Si vous Γͺtes un expert sur le sujet et que vous souhaitez contribuer, modifiez cette page et enrichissez-la de votre sagesse.

Vous serez crΓ©ditΓ© et vous aiderez la communautΓ© Ethereum !

Utilisez la flexibilité de ce Modèle de documentation

Des questions ? Demandez-nous dans le salon #content de notre Serveur Discord

Modifier la page