2020 was the year demand for Ethereum increased with the rise of NFT and DeFi projects. The increase in network activity caused network congestion and higher transaction fees creating a stronger need for scalability – faster and cheaper transactions.
Layer 2 blockchains with additional improvements like Zero-knowledge rollups (ZK-Rollups) are promising solutions.
Ethereum Layer 2 blockchains
Ethereum Layer Two solutions are blockchains designed to process transactions faster and cheaper while leveraging the security of Plasma (Ethereum’s base layer).
Layer 2 blockchains increase scalability with lower gas fees, especially during network congestions. Most Layer 2 solutions process transactions off-chain, i.e., not on Ethereum, and compile those transactions into one cheaper transaction that gets recorded on the Ethereum mainnet.
There are three different types of Layer 2 scaling technologies:
- State Channels: allow users to make unlimited transactions off-chain while only submitting two transactions on-chain: the first and last transaction.
- Optimistic Rollups: process a large volume of transactions off-chain by “rolling” them into a simpler transaction that gets added to Ethereum’s main chain. Optimistic Rollups are considered “optimistic” because the network considers the transactions valid until proven false – fraud proofs.
- Zero-Knowledge Rollups: ZK-Rollups are similar to optimistic rollups in that they combine many transactions and submit them as one.
This article focuses on ZK-Rollups. Let’s delve into what they are and how they work.
Introduction to ZK-Rollups
ZK-Rollup is an Ethereum layer two solution that increases scalability by mass transfer processing in single transactions. Where Plasma creates one transaction record per transfer, ZK-Rollups bundle hundreds of transactions into a single transaction. The smart contract then verifies all the transfers held in that transaction block without proof.
Diagram showing how rollup transactions are represented on the blockchain
The approach reduces the computing and storage required for validating transactions as the blockchain doesn’t need to know the actual transaction data.
How do ZK-Rollups work?
ZK-Rollups consists of two types of users: transactors and relayers. Transactors create transactions, which are broadcast to the network. Each transaction data includes a “to” and “from” address, transaction value, transfer fee, and nonce (number only used once).
A deposit or withdrawal occurs if the transaction value is greater or less than zero.
Relayers collect a large number of transfers into a rollup transaction. This single transaction is the validity proof the blockchain needs and is known as a succinct, non-interactive argument of knowledge (SNARK) or succinct, transparent argument of knowledge (STARK).
SNARKs and STARKs are the same as cryptographic transaction hashes. This means SNARKs can represent all the transactions in a unique hash without revealing the transaction data, as seen below.
An example transaction hash.
Each SNARK compares the blockchain before the transfers to a snapshot of the blockchain after the transfers (I.e., wallet values). After validation, the changes are recorded on the mainnet. Anyone can be a relayer, so long as they have stakes in the smart contract. Staking prevents the relayer from tampering or withholding the rollup.
Unlike optimistic rollups that force transactions to queue for fraud proofs, ZK-SNARKs are instantly verified on Ethereum if the transaction proof is valid.
Ultimately, validating this transaction instead of hundreds of Ethereum transactions makes ZK-Rollups cheaper than Ethereum’s Layer 1.
What are the Pros and Cons of ZK-Rollups?
- Each transaction has reduced fees per user.
- ZK-Rollups are faster than layer 1 transactions
- ZK-Rollups contain less data which increases throughput and scalability in the network
- ZK-Rollups do not require fraud-proof verifications like Optimistic Rollup, which can delay withdrawals by up to two weeks
- Validating ZK-rollup transactions require data optimization to get maximum throughput.
- Quantum computing poses a threat as it can be used to ‘guess’ the correct SNARK proof hash faster than the encryption protocol.
- The security scheme assumes unverifiable trust that bad actors can manipulate.
The State of ZK-Rollups
Rollups significantly impact DeFi, which is why projects are working to provide better rollup transactions. For example, Polygon launched Miden, its scaling solution, which comes with its virtual machine. In addition, Loopring and zkSync use ZK-rollups to scale their exchange protocols.
Furthermore, cryptocurrencies using ZK-Rollups like Zcash are becoming increasingly popular among developers and traders due to their faster and cheaper transaction processing.
However, it is important to note that users can apply these solutions in other areas besides DeFi and payment systems like NFTs.