Imagine if you wanted to send your family in Alaska a letter. You have your uncle, your aunt, your two cousins, and their dog. If you were crazy, what you would do is write each of them separate letters, put them in separate cards, and then pay the shipping for 5 different letters. If you were smart, you would write them a bunch of letters and try to put them all into one big envelope, then ship that envelope, this way it is more affordable and you aren’t wasting a bunch of extra paper. This example is a bit confusing, but we’ll come back to it later when we explain how Rollups work to scale ethereum.
In this article, we are going to explain how rollups work, what the difference between an Optimistic rollup and a ZKSnark rollup are, and hopefully by the end you’ll understand the benefits of this crazy, difficult-to-understand technology.
Let’s dig in.
What is a Rollup?
A rollup is a scaling solution for blockchains where a large group of transactions are “rolled up” into a single transaction to save energy and space.
I’d love to explain that in simple terms, but even the ethereum.org definition is complicated. In fact, we couldn’t find one youtube video that explained it where we didn’t yawn or have to look at code, and that’s not what this channel is about. So for you to understand how Rollups work, we have to explain some other things first.
Transactions and Data
On the Ethereum network, there are 2 things that can be posted on the blockchain. Transactions and data. Transactions are when you send ethereum from one address to another. This mimics exactly how Bitcoin works.
What makes Ethereum special is that you can also store data on the ethereum network. This data can be anything you like, you can store “Will you marry me” or you can write a whole program in code to be run. When you write a program to be run, that specific data is called a smart contract… and you can check out our whole video on Smart contracts if you’re interested in how they work, but this video is specifically about Rollups.
According to the Ethereum.org website, a rollup is “solutions that perform transaction execution outside the main Ethereum chain, but post final transaction data on the main chain.” Oh yeah, if you don’t know what layer 2 scaling solutions are for, or even what that term means, definitely check out our video on the whole topic for a brief overview. This video is more about the specifics of rollups.
So get this, first we need to know that Ethereum blocks can only hold so much data. For the purposes of this video, let’s say they can only do 100 transactions. This means if there are 100,000 people who want to make transactions, ethereum will pick the top 100 transactions that included the highest fee and include those, otherwise they will have to wait. These fees can be expensive, so each transaction must be important. Remember how I said we could also write data to the blockchain?
Can Data contain Transactions?
So one of those 100 transactions could also be data, instead of a transaction. In that data, we could just write a whole bunch of other transactions. In a sense, if 1 data entry in the block could be 10 transactions, we have now effectively scaled to 1000 transactions per block – by using the data portion instead of the transaction portion.
Rollups are literally rolling up a bunch of transactions and turning them into one piece of data to submit to the blockchain, instead of a bunch of singular entries – which saves a bunch of space. Think back to the intro where I mentioned cramming a bunch of letters that were going to the same place into one big envelope – that is exactly what a rollup is. Instead of having the mail carrier do the work 5 times though, we have them do it once, and this is what allows Ethereum to scale.
Now, right now there are 2 approved ways of doing this. Zksnarks and Optimistic rollups were words we heard over and over when researching Layer 2 Scaling solutions but we had absolutely no idea what they were. Now we do, and for the rest of this video, we are going to explain how each works.
ZKSnark rollups, also called Zero Knowledge Rollups runs a computation off-chain and submits what is called a “validity proof” to the layer 1 blockchain. ZKSnark actually stands for “Zero Knowledge Succinct Non-Interactive Argument of Knowledge” which means absolutely nothing if you’re the target audience of this video. Let’s break down what it’s purpose is, and how it works.
Validity proof basically means someone went through all the transactions in a specific rollup, did some work (very similar to proof-of-work) and then found out they were safe and not fraudulent, then submitted their list of transactions and proof to the true Ethereum layer 1 blockchain. They are basically proof-of-working and proving that the transactions they are submitting are true and good off-chain. In a sense, Ethereum has offloaded some of it’s work to this ZKSNARK checker – which is exactly what a layer 2 scaling solution does. If you break it down, ZKSnark is an acronym
- Zero Knowledge means they don’t actually have to see all the transaction data
- Succinct means short
- Non-interactive means they don’t need to deal with people who verify their work
- Argument of Knowledge, this is the proof they provided that these transactions are good
Some calculations have said that with a little technological tweaks that we don’t have time to mention here, ZK Rollups can hit a scale that is similar to Visa Transactions, which is a huge milestone.
Optimistic Rollups Explained
Optimistic Rollups will actually assume transactions are valid by default (they are optimistic) and approve them all to submit to the main Ethereum chain. Instead of using a validity proof, they use a “fraud proof”, but only when they are challenged.
In short, the optimistic rollups assume everyone is telling the truth. They don’t fact-check and do the work like ZKSnarks do. However, what they post is fact-checkable by other people. Since Eth involves people’s money, we can assume there will always be people checking, that is why this works. If someone goes “hey, that transaction looks fishy” and then proves it was fraudulent, the transaction is reverted and the block validator is actually slashed. Slashed is a technical term which means whoever validated that block will lose some of the stake they initially put up.
One big thing about optimistic rollups is that they can also do smart contracts and transactions involving tokens other than the Ethereum coin transactions. A downside of Optimistic rollups is that Vitalik himself has said “Optimistic Rollups should know they aren’t going to be optimistic rollups forever” which is his way of saying better alternatives may become available, but we don’t have them yet.
As we end this article, we want to make it clear that this was still a pretty high-level overview of how these concepts work. Looking at the code and doing your own research will greatly improve your own understanding, but we hope that our video taught you at least something, if not made you have more questions that you can ask in the comments below that we would love to answer, and even research if we can’t answer.