Learning Crypto #10: Scaling Solutions Part 2

Perrybiz
3 min readApr 18, 2022

--

Welcome back! Today we will continue discussing more scaling solutions, specifically another ETH Layer 2 scaling solution: Rollups.

There are two main types of rollups:

  1. ZK(zero-knowledge) rollups
  2. Optimistic rollups

But first, let’s explain what a rollup is.

Rollup

A rollup is an off-chain aggregation[1] of transactions inside an Ethereum smart contract. That is right, a rollup is a smart contract. It moves the computation and state store off-chain while keeping the essential data per transaction on-chain. Since only partial data per transaction is stored on-chain and the computation is offloaded, it increases the efficiency of the main chain. The smart contract then publishes just enough data so that the main chain observer can reconstruct, confirm the validity of states(the account balance for each wallet involved in the rollup, for example) and settle them.

Source: https://medium.com/interdax/ethereum-l2-optimistic-and-zk-rollups-dffa58870c93

The rollup does not have its blockchain or consensus mechanism, and it is still part of the network. Hence, rollup solutions can utilise the secure infrastructure provided by the main chain.

Since the rollup itself is a smart contract, it is compatible with EVM. Therefore, developers can easily migrate existing applications to rollups with minimal effort in rewriting the code.

ZK Rollups

A ZK rollup runs an off-chain computation to generate the validity for that batch of aggregated transactions. This proof is a cryptographic proof called “ZK-SNARK”. It proves that the main chain will be in the correct state as the result of executing the current batch, and it can be quickly verified on-chain.

The node that performs this validity check computation is called “Relayer”. It goes through each one of the transactions in the batch and ensures they are not fraudulent. After that, the relayer generates the SNARK proof and sends it to the main chain. The SNARK proof is a hash representing the delta of the main chain state[2]: it compares the blockchain state before and after the rollup, calculates the changes in each wallet’s balance, and then reports only the differences in a verifiable hash to the main chain.

Just in case you are curious, ZK-SNARK stands for:

“Zero-Knowledge Succinct Non-interactive Argument of Knowledge”

Because of the expensive off-chain computation costs, ZK-Rollup is harder to adopt in the short term. However, as there are ongoing improvements for both hardware and software, ZK-Rollup is a preferable layer 2 scaling solution from a long term perspective.

Optimistic rollups

Although ZK-Rollup is better in the long term, the ecosystem needs an immediate and easy-adopted solution to solve the scalability issues. That’s why we have Optimistic Rollups, a more straightforward scaling solution.

Optimistic Rollups assumes that transactions are valid by default(hence, they are called optimistic). However, instead of generating validity proof like ZK-Rollups, Optimistic Rollups only runs the transaction’s computation and execute a “fraud-proof” when they are challenged.

The aggregator aggregates transactions into a smart contract without proving the validity, and the aggregator needs to lock a certain amount of bond before aggregation. After that, users can challenge the aggregator with the fraud-proof if they identify any fraudulent transactions within the challenge period, usually around 1 week. If the fraud is proven, the bond is slashed, and users who identify it can claim it as reward.

As you can see, Optimistic Rollups creates an incentive to ensure that the aggregators are penalised for conducting fraud and users are rewarded for proving fraud.

The downside is obvious — because the challenge period can take around 1 week, the throughput of Optimistic Rollups is relatively low.

ZK vs Optimistic

Vitalik summarised the tradeoffs between the two flavours of rollups, which I think it’s very informative:

Source: https://vitalik.ca/general/2021/01/05/rollup.html

Outro

That’s it for this week! I hope you enjoy the content. Next week, we will discuss another ETH Layer 2 scaling solution: Sidechain.

Reference

[1]https://vitalik.ca/general/2021/01/05/rollup.html

[2]https://docs.ethhub.io/ethereum-roadmap/layer-2-scaling/zk-rollups/

[3]https://youtu.be/bz0y5zUZBaE

[4]https://ethereum.org/en/developers/docs/scaling/

--

--