Zk-rollups are becoming more and more popular among investors and traders seeking quicker and less expensive transaction processing as well as developers looking to improve usability.
An off-chain protocol known as a ZK-rollup chain runs on top of the Ethereum blockchain and is controlled by smart contracts that are executed on the Ethereum blockchain itself.
ZK-rollups are an increasingly popular scaling solution for Ethereum and have the potential to drastically reduce costs and time it takes for transactions to be confirmed. We’ll go in-depth on the ZK technology and discuss how ZK-rollups differ from other Layer 2 scaling solutions in order to assist you in selecting the best one for your dApp.
What Are Zk-Rollups?
A zero-knowledge rollup (zk-rollup) is a layer-2 scaling solution that moves computation and state off-chain into off-chain networks while storing transaction data on-chain on a layer-1 network (for example, Ethereum). State changes are computed off-chain, and then their validity is established on-chain using zero-knowledge proofs.
While inheriting the security of the base-layer (layer-1) network they are connected with for settlement, Zk-rollups significantly boost transaction throughput and aid in lowering transaction costs. Zk-rollups don’t have to post every transaction on-chain; instead, they only need to periodically publish valid batches of layer-2 network transactions that have been bundled up to layer 1. This lets them rely solely on the base layer’s security and censorship resistance for transaction settlement. To lessen the amount of data posted on layer 1, rollups frequently employ data compression techniques.
How Do Zk-Rollups Work?
Zk-rollups increase scalability as instead of having to post all transaction data on-chain, they only need to periodically provide valid bundled-up transaction batches that are executed using off-chain computation. These bundles are then “rolled up” into one summary of the state changes that are verified by the base layer using a validity proof that proves the correctness of the changes using a zero-knowledge proof, demonstrating with mathematical certainty that the state changes proposed by the layer 2 are correct and are the result of the execution of the given batch of transactions.
For data accessibility, settlement, and censorship resistance, Zk-rollups typically rely on the base layer. A smart contract set up on the layer-1 network keeps track of the rollup’s state. A layer-2 operator typically receives a user’s transaction submission on the rollup in order to include it in the following batch of transactions. These operators can take the form of a centrally located object known as a sequencer, which executes transactions, groups them into batches, and submits the batch to the layer-1 network. A proof-of-stake system can also be used with zk-rollups, in which a group of validators who have invested money in a rollup staking contract alternate in their responsibility for executing and bundling transactions.
Zk-Rollup Vs. Optimistic Rollup
Another layer-2 scaling option that differs significantly from a zk-rollup is optimistic rollups. Instead of validity proofs, optimistic rollups use a fraud proof mechanism that allows any user to challenge the outcome of an optimistic rollup execution during a specific time window.
The validity of state changes is cryptographically confirmed in the case of zk-rollups. Optimistic rollups take a different approach because they don’t use validity proofs; instead, they assume transactions are valid until their correctness is questioned. After an optimistic rollup batch is submitted on the base layer, there’s a time window called a challenge period during which anyone can challenge the outcome of a rollup transaction by computing a fraud proof. If the fraud proof is successful, the rollup protocol repeats the transaction and updates the rollup’s state. If optimistic rollup state transitions aren’t challenged by the time the challenge period elapses, the batch of transactions is deemed valid and accepted on the layer 1.
It also means that there is a waiting period (typically seven days) between when funds are submitted for withdrawal and when they are made available on the base chain when withdrawing money using a native bridge from an optimistic rollup to the layer 1. However, optimistic rollups can use liquidity providers that let users withdraw money more quickly in exchange for a small premium as a withdrawal fee in order to avoid the diminished user experience of a protracted waiting period. In order to prevent network spam due to erroneous fraud proofs, optimistic rollups can also make use of a variety of economic incentives and game-theoretic mechanisms.
Because of the relative simplicity of the technology and the marginally reduced likelihood of implementation bugs, optimistic rollups have a head start in terms of adoption due to the complexity and infancy of zero-knowledge proofs. The use of cryptographically verifiable validity proofs, however, makes zk-rollups the preferred long-term solution for scalability, according to their proponents.
Pros and Cons of Zk-Rollups
The total transaction throughput of the smart contract ecosystem can be significantly increased by offloading transaction execution and state from a constrained base layer to a higher-throughput computing environment while retaining the security of the underlying blockchain. The base-layer blockchain is still in charge of the consensus process, which verifies the legitimacy of transactions made by the execution layer. Notably, this means that the layer-1 blockchain’s computational bandwidth is used more effectively because full nodes only need to verify zero-knowledge proofs and store a smaller amount of transaction data instead of having to execute every transaction.
In addition, rollups have crucial security features that let users withdraw money from layer 2 even if the rollup network isn’t functioning properly. Contrary to sidechains or standalone blockchains, where a network failure may result in a significant loss of funds, this type of blockchain is not subject to this risk. Because the fixed cost of proof verification is lower with zk-rollups, user transaction costs are also reduced. Importantly, this implies that because a larger number of users share the consensus costs, they decrease as usage increases. This is a significant benefit not offered by traditional blockchain environments, where user costs increase with usage. Additionally, rollups have a 1-of-n trust model, which means that all that is needed to confirm the accuracy of the off-chain computation is one honest node.
Rollups, on the other hand, might not be as quick or inexpensive as standalone chains because they are ultimately limited by the base layer’s restrictions and its frequently prohibitively expensive blockspace. Zk-rollups can also fragment liquidity in the ecosystem and present challenges to permissionless composability compared to applications that exist on the same base layer. It’s also critical to remember that rollups are more recent than standalone blockchains and may present risks for upgradeability.
What Are Ethereum Layer 2s?
Ethereum Layer 2s are blockchains that take advantage of the security of Ethereum’s execution layer while being faster and less expensive than transactions on the main Ethereum chain. When there is network congestion (many users trying to use the Ethereum network at once), Layer 2s are mainly concerned with resolving high transaction fees and slow transaction speeds that happen on Ethereum.
At a high level, most Layer 2 solutions process transactions “off-chain”, as in, not on Ethereum, and combine those transactions into a single, more straightforward, and consequently less expensive transaction that is recorded on the Ethereum blockchain.
However, the methods Layer 2 scaling solutions employ to securely process, batch, and publish off-chain transactions onto Ethereum depend on the scaling technology they are employing.
What Types of Ethereum Layer 2s Exist and How Are They Different?
State channels, optimistic rollups, and zero-knowledge rollups are three different kinds of Ethereum Layer 2s that assist in resolving the scalability issue with Ethereum.
Let’s examine how these three different kinds of Layer 2 technologies differ from one another.
1. State Channels
State channels are a scalability solution for Ethereum that only requires the first and last transaction to be submitted to the network, allowing users to perform an unlimited number of off-chain transactions.
Here’s how it works:
- The first transaction opens a state channel and “locks” that state.
- Transactions are executed by users off-chain.
- The remaining state after off-chain transactions are complete is recorded in a second transaction that “closes” the state channel.
Examples of Ethereum L2s that leverage state channels include:
- Connext – a network for fast, trustless, cross-chain applications and communication
- Kchannels – offers a trust-minimized payment channel for Ethereum
- Perun – offers user an off-chain framework that supports real-time payments
- Radien – offers a fast, cheap way to transfer ERC20 tokens
2. Optimistic Rollups
Optimistic rollups involve processing a large volume of transactions, handling computation off-chain, and “rolling” them up in a simpler transaction that gets published to the execution layer of Ethereum.
Optimistic rollups are considered “optimistic” because transactions are assumed to be valid until they are proven false.
Potentially invalid transactions have a window of time during which they can be contested by submitting a fraud proof before they are officially confirmed on Ethereum’s main chain.
Once that fraud proof’s dispute period is over, all remaining transactions are confirmed onto Ethereum.
This confirmation window typically increases transaction confirmation times compared to other solutions like Zero-Knowledge rollups because optimistic rollup Layer 2s are designed to use fraud proofs.
Examples of Ethereum L2s that leverage optimistic rollups include:
- Arbitrum – the largest optimistic rollup by TVL ($3.2B) and market share (54.7%)*
- Metis – third largest optimistic rollup by TVL ($457M) and market share (7.84%)*
- Optimism – 2nd largest optimistic rollup by TVL ($465M) and market share (7.97%)*
- Boba Network – 4th largest optimistic rollup by TVL ($187M) and market share (3.22%)*
*Layer 2 TVL and market share data provided by L2Beat.
3. Zero-Knowledge Rollups
In the same way that optimistic rollups combine numerous Layer 2 transactions that were carried out off-chain and submit them as a single transaction onto Ethereum, zero-knowledge rollups (ZK-rollups) do the same.
However, ZK-rollups use validity proofs to immediately demonstrate whether transactions are valid or not, as opposed to assuming that they are valid until proven otherwise.
Compared to optimistic rollups, developing EVM-compatible ZK-rollups is challenging due to the complexity of the technology and its ability to execute arbitrary code.This is something to consider when deciding to build on a ZK-rollup Layer 2 blockchain compared to another EVM-compatible blockchain.
Examples of Ethereum L2s that leverage ZK-rollups include:
- Starknet – used by dYdX and ImmutableX the leading decentralized exchange for perpetual contracts on Ethereum
- zkSync – used by dApps like Yearn Finance, FRAX, and Zerion
Conclusion
Rollups can be of two different types: optimistic and zero-knowledge (ZK). Both have the advantage of significantly reducing transaction costs. The idea is that instead of waiting and paying for each transaction to process independently on Ethereum, dozens and dozens of transactions are recorded on the layer 2 chain, then “rolled up” into a single transaction that is then fed back to the more expensive, slower blockchain. As a result, many users share the cost of that single transaction.