ethereum / ethereum-org-website

Ethereum.org is a primary online resource for the Ethereum community.
https://ethereum.org/
MIT License
5.05k stars 4.79k forks source link

Video on Ethereum rollups by DeFi Teller #6998

Closed DinaSche closed 8 months ago

DinaSche commented 2 years ago

Ethereum rollups

What are Еthereum Rollups and How Do They Work? Rollups Explained in Simple Terms

ZK Rollups vs Optimistic Rollups. The Difference Between Them Explained in Simple Terms

Tutorial description

In the first video (What are Еthereum Rollups and How Do They Work?), we talk about how Ethereum rollups work and try to cover the topic in more depth than the common statements about rollups packing transactions into batches. We explain what exactly makes rollups solutions fast and reduce the fees. The video concludes by stating that the security of rollup solutions depends on their type. We talk about the types of rollups in our next video on optimistic and zk-rollups (ZK Rollups vs Optimistic Rollups).

Tag your tutorial

LAYER 2, OPTIMISM, SCALING, ROLLUPS, ZK-ROLLUPS

Publication

The videos have been published on the DeFi Teller YouTube channel, as well as on the DeFi Teller website https://www.youtube.com/channel/UC4siZvLkAyiexFyPst1fC7w https://defiteller.guru/video

Skill level

Beginner/Intermediate Our audience is people who are interested in blockchain, have some understanding of the topic and want to dive deeper into it, learn not just the functionality of projects and protocols, but how they are structured. The DeFi Teller project positions itself as a way to do one's due diligence before starting to use a particular solution. -->

Hosted on Ethereum.org or hosted elsewhere?

To be hosted on the ethereum.org website.

For tutorials to be hosted on Ethereum.org: Tutorial Content

Rollups explained in simple terms If you have ever used any services on Ethereum, you should know that you have to pay gas fees for them, and those fees can be quite pricey. That’s happening because Ethereum's data bandwidth is limited, and when the demand is high, the cost of transactions goes up and the speed goes down.

Each transaction consists of bytes and every byte of data costs gas. Ethereum forms transactions into blocks that are gas limited, it means that each block can only house a certain amount of data. In terms of throughput, Ethereum’s speed is currently about 55 transactions per second or TPS.

How can we scale Ethereum without moving everything off-chain? And that's where rollups come in. ​​Rollups are considered one of the safest solutions for scaling Ethereum. This technology leverages Ethereum's security and keeps some data per transaction on-chain, while taking the computation off-chain to Layer-2 protocols. This approach allows to increase throughput up to ~4800 TPS, or ~85 times.

To make this happen, rollups use smart contracts to take transaction computation outside the Ethereum network, then shape them into batches, and publish them back to the network.

Each batch consists of data state of the previous batch, the transactions themselves in a highly compressed form, and updated data state after the transactions have been processed.

And how is compression attained? One of the most important data compression tricks is about signatures, which are required to verify transactions. Instead of one signature per transaction, as on the main network, rollups aggregate many signatures into one, allowing one signature per batch of nearly 100 transactions.

A rollup will still have to pay a gas fee for publishing a batch on-chain, however, batching those transactions together will make this commission fee considerably lower.

For example, if you send ETH from one wallet to another and the current gas price is 100 gwei, that would cost you about $8 in commissions on Ethereum and about $2 on a rollup solution. And if you want to make a trade on Uniswap with the same gas price, on Ethereum you will have to pay approximately $40. While on a rollup, you will pay around $7 for the same transaction.

But then what about security, you may ask - are rollups trustworthy as well? The way rollups verify transactions and make sure no malicious acts get through differentiates them by type. You can learn about the different types of rollups in our video describing zk-rollups and optimistic rollups and the main difference between them.

ZK rollups vs Optimistic rollups - What is the difference There are two different types of rollups - 'Optimistic' and 'Zk-rollups’. Rollup solutions differ in their approach to data validation, namely how they prove to the underlying network - Ethereum, for example - that the computation performed is in fact valid.

​​Rollups are considered one of the safest solutions for scaling Ethereum. This technology increases Ethereum throughput up to ~4800 TPS, or ~85 times. To make this happen, rollups enable third parties, commonly referred to as sequencers, to take calculations to layer 2, shape transactions into batches, and publish them back to the network.

Each batch consists of the data state of the previous batch, the transactions in a highly compressed form, and the updated data state after processing the transactions. These data states are called pre-state root and post-state root.

You can learn more about the rollup architecture and how they deliver data compression in our introductory video on rollups.

But how do sequencers prove to Ethereum that the post-state roots of each batch are valid? The answer to this question illustrates the main difference between Optimistic and ZK-rollups.

ZK-rollups use what is called validity proof. They provide immediate proof to Ethereum that the batches of transactions are correct. To do this, zk-rollups use the concept of ZK-SNARK - a mathematically complex cryptographic proof that all computations in a batch correspond to the post-state root.

Optimistic rollups use the opposite logic, a sort of presumption of innocence, and use the concept of fraud proofs, which means that initially, they assume that all the batches they send to the network are valid. Hence the name - optimistic.

And while zk-rollups rely on cryptographic proofs, optimistic rollups use verifiers to monitor batches coming on-chain and check if they are valid. To be able to submit a batch, a sequencer must put down a large deposit; if that sequencer ever submits a fraudulent batch, that deposit will be partly burned and partly given as a reward to the fraud prover.

Anytime a sequencer publishes a batch, there is a dispute period when any party can present a fraud proof that indicates that the batch is invalid and should be reverted.

How does all this affect the practical application of zk and optimistic rollups? The data verification model determines the amount of time it takes to withdraw assets from rollups back to Ethereum, and the compatibility of rollup networks with Ethereum Virtual Machine, which allows developers to easily migrate their applications from Ethereum to the rollup solution.

The ZK-SNARK proof can be verified by the main network very quickly. That's why if you try to withdraw your funds from a zk-rollup it will be processed right away, while it will take an optimistic rollup about a week or even two because the network participants must be given time to verify the transaction batches.

Because of their mathematical complexity, zk-rollups are not easy to build an application on, let alone make it compatible with Ethereum Virtual Machine. Optimistic rollups, on the other hand, easily allow developers to migrate their applications from layer 1 to rollup almost seamlessly.

While serving the same purpose, different types of rollups are good for different protocols. Optimistic rollups are good for general-purpose EVM computation, while zk-rollups are suitable for simple payments or exchanges. However, assuming that the architecture of zk-rollups will be refined in the future, they are the ones most likely to gain advantage in the long run.

minimalsm commented 2 years ago

Hey @DinaSche, I don't think these make sense as tutorials. Tutorials on ethereum.org are mostly about implementation details relating to creating apps on ethereum.org, whereas this seems like more informational, educational content.

What about somewhere on our scaling docs? https://ethereum.org/en/developers/docs/scaling/

DinaSche commented 2 years ago

Hey @minimalsm , thank you, that would be better, you're absolutely right! Do I have to create a new issue for this?

github-actions[bot] commented 2 years ago

This issue is stale because it has been open 45 days with no activity.

corwintines commented 8 months ago

Thanks for opening this @DinaSche

Going to close this out as stale. If you think it is still relevant and would be good to add please reopen another issue @DinaSche!