Hello!

© 2024 Kishan Kumar. All rights reserved.

What are “Rollups” in Crypto?

Rollups are a way of aggregating transactions and processing them off-chain and publishing the result back to the on-chain.

July 15, 2023

Hero

Photo by BoliviaInteligente on Unsplash

Atthe moment, Ethereum is only able to handle around 15 transactions per second; what this means is validators will choose a set of transactions from a transaction pool that is yet to be confirmed, and the way they select these transactions is, in fact, related to their profit. So you have to fight for your transaction to be included because there are only so many transactions that can be processed at a time.

You know, the validators are awarded fees when they include your transaction in a block. Now think from a validator perspective; there are two transactions currently sitting in the transaction pool waiting to be picked up by a validator. One transaction is willing to pay 10$, and the other transaction is only paying 1$ as a fee. Which transaction will you pick?

The $10 dollar one, right? Because if you include this transaction in the block, you’ll get $10 dollars as a fee.

But does this mean my transaction will only be picked up if I set my fees high?

Let me explain this in a simple way. When interacting with the Ethereum network, you usually invoke certain smart contracts . Smart contracts are a set of instructions; think of them as a program. Each instruction will require some computational power. Following is a simple contract in solidity language.

1
2// SPDX-License-Identifier: MIT
3pragma solidity ^0.8.0;
4
5contract HelloWorld {
6  string public message;
7  constructor() {
8    message = "Hello World";
9  }
10  
11  function getMessage() public view returns (string memory) {
12    return message;
13  }
14
15  function setMessage(string memory newMessage) public {
16    message = newMessage;
17  }
18}

If you are a Solidity developer, you can estimate the gas that this contract will require if deployed on EVM.

When you deploy this contract, the first thing that is called is its constructor, which sets the message variable to “Hello World”. This changes the state of the blockchain. Any state change requires fees.Let’s assume that storing a string in a variable costs 1$.

If you want to set the message to something else, let’s say, “Welcome to Kishan’s article”, you’ll need to invoke the setMessage() method in the contract, passing your required message, and that will again require some fees because you are altering the state. Let’s say it required 1$ again.

What if I want to see what the message is? You can simply call getMessage(); this won’t require any fees since it doesn’t change the state. Having explained that, let’s come back to our discussion.

Let’s say, for some reason, your transaction that was currently in the transaction pool invokes this HelloWorld smart contract and sets the message to your name.

Now suppose that a validator picks your transaction hypothetically, he’ll see that you have set the fees to $1, and the invocation of the smart contract itself will take $1. So, he himself got nothing in return. All the fees were used by interacting with the smart contract.Why will he then pick it up? This transaction will get rejected because there is no incentive for the validator to process it and include it in the chain. So you’ll have to try again with greater fees so that you can lure the validator to pick your transaction.

The gas fee can get really competitive when a lot of users are transacting on Ethereum. Yes, you can set the fees manually but beware that might require a lot of time to get confirmed because validators will only pick the transactions that will benefit them. If your transaction is time sensitive, for e.g., you want a trade to close as soon as possible that pose a risk of getting liquidated. In this scenario, you better set the fees as high as possible or use one of the wallets that give you an estimate of fees that will confirm your transaction within seconds. Because saving on gas can result in your entire portfolio getting wiped.

These high fees have held back a lot of crypto enthusiasts to transact on Ethereum, and there are a lot of other layer-1s that have been introduced to address this issue. But they all lack decentralization which is why anyone would shift to web3.

So, is there any solution to this? We want to use the decentralization and security offered by Ethereum but, at the same time, don’t want to lose our pocket with these hefty fees.

One way to address these issues is Rollups, a Layer-2 scaling solution.

Rollups

Rollups are a way of aggregating transactions and processing them off-chain and publishing the result back to the on-chain.

All this off-chain and on-chain might instill doubts in understanding, so let me clarify it a bit more. Think of rollups as a process that can significantly reduce the fees and congestion of the Ethereum blockchain. The way this work is by rolling up (aggregating) together a large batch of transactions and moving them onto an off-chain such as parallel chain, VM, etc. These parallel chains are operated by layer-2 networks such as Arbitrum, zkSync, Optimism, etc.

Who aggregates the transaction?

Aggregation is done by an entity called a rollup operator, whose primary job is to collect transactions from different users and execute them on an off-chain environment. Again, off-chain can mean a lot of things depending upon the implementation, such as a virtual machine, a sidechain, or other layer-2 protocol.

Once it has executed the transactions, it submits the aggregated data(rollup block) to the Ethereum chain as calldata, along with proof that it has executed it correctly. Till here, we are clear, but what is calldata?

Think of calldata as a special type of data that can be stored on Ethereum without being executed or affecting its state.

Rollup operators need to pay a fee to the Ethereum validator for including the calldata in a block. Once it has been included; The rollup operator monitors the rollup contract (explained in the next section) for any challenges or disputes from other users or validators. If there are any disputes, it responds accordingly.

Who verifies it?

A rollup contract is responsible for verifying the transaction data and proofs present in the calldata submitted by our rollup operator. It is a smart contracts that is deployed on Ethereum that manages the state and logic of the rollup.

A rollup contract receives the transaction data and proofs from the rollup operator as calldata, verifies them, updates the state of the rollups, and emits an event for any state changes.

How does it work?

Let’s combine all that we have learned and summarize it using an example:

  1. Let’s say you want to send 1 ETH to your friend Ram using a rollup.
  2. You specify the Ram’s address and the amount to be sent in your wallet and sign the transaction.
  3. After that, you submit the transaction to a rollup operator, who is responsible for aggregating transactions from different users and executing them off-chain execution environment.
  4. The rollup operator will then bundle your transaction with other transactions in a so-called rollup block and submit it to the Ethereum chain as calldata. It then pays the fees to the validators for including it in the block.
  5. Now, depending on the type of rollup, the rollup operator may need to submit proof or an additional assertion of the validity of the rollup block along with the calldata.
  6. Having done that, the rollup block is then processed by the rollup contract, which is a smart contract deployed on the Ethereum chain that manages the state and logic of the rollup. The contract verifies the proof or assertion, updates the state of the rollup users, and emits an event for any state changes.
  7. Finally, Ram receives 1 ETH from you in his rollup account.

Type of Rollups

Optimistic Rollups

Optimistic rollups are optimistic. What I mean is they assume that every transaction in the batch is valid. But there is a catch. They give a grace period where a user or a validator who thinks the transaction is invalid can challenge it by submitting a fraud-proof. The Ethereum mainnet then verifies it, and if the challenge is successful, the rollup block is rejected, and the dishonest operator is heavily penalized.

If there is no dispute after the grace period has ended, the transaction batch is anchored to the Ethereum, and the state changes it includes are finalized.

Though it provides increased scalability and reduced gas fees, it comes with a delay in transaction finality because one has to wait for the grace period.

You might see on some centralized exchanges that the number of confirmation required to send or receive ETH is significantly higher in case of rollups. For comparison, usually 6-10 confirmations are required if you use ETH network, but if you decide to use Optimism, the same transaction will require 100 confirmation.

There are two major horses in the race:

  1. Arbitrum
  2. Optimism

zK rollups

I have written a detailed article explaining zk-rollups which you can refer to. Anyways, I’d give you a brief overview of what it is and how it works.

Zk rollups: How to join the zero-knowledge movement and scale Ethereum to the next level

Zero-knowledge (Zk) rollups are a layer 2 scaling solution that increases throughput on Ethereum by moving computation and state storage off-chain. It can process thousands of transactions in a batch and then post minimal summary data to Mainnet.

zk rollups, unlike optimistic rollups, assume every transaction is invalid until proven valid. It uses “zero-knowledge proofs” to validate the authenticity of the transaction. Once it goes through all the transactions in the batch, it sends a single transaction back to Ethereum, along with the proof that the rollup contract can easily verify.

It is more secure as compared to an Optimistic rollup. Since there is no grace period, the transactions have instant finality since the validity is already proven via cryptographic proof. However, generating the proof requires significant computation power and expertise to implement it. This can increase the complexity compared to Optimistic rollups.

Two major horses in the race are:

  1. Polygon zkEVM
  2. zkSync-Era
.   .   .

Thank you for taking the time to read this article.

.   .   .

The 0xkishan Newsletter

Subscribe to the newsletter to learn more about the decentralized web, AI and technology.

Comments on this article

Please be respectful!

© 2024 Kishan Kumar. All rights reserved.