2023-06-03

What are Zero-Knowledge Rollups

Posted by:

MinhMinh

Web3 developers have a plethora of options when it comes to choosing Ethereum scaling solutions. They can select from various options, including Layer 1 improvements like Ethereum 2.0, Layer 2 chains such as Optimism and Arbitrum, and side chains like Polygon or xDai.

Even within the realm of Layer 2 Ethereum scaling solutions, developers face choices between state channels, optimistic rollups, or zero-knowledge (ZK) rollups.

ZK-rollups have gained popularity as a scaling solution for Ethereum and have the potential to significantly reduce transaction costs and confirmation time. To assist you in selecting the appropriate scaling solution for your decentralized application (dApp), we will explain the distinctions between ZK-rollups and other Layer 2 solutions and delve deeper into ZK technology.

What are Ethereum Layer 2s?

Ethereum Layer 2s are blockchains designed to expedite and reduce the cost of transactions compared to the primary Ethereum chain, all while leveraging the security of Ethereum's execution layer. Layer 2s primarily address the issues of high transaction fees and slow transaction speeds that occur on Ethereum during periods of network congestion when multiple users attempt to utilize the Ethereum network simultaneously.

In essence, most Layer 2 solutions process transactions "off-chain," meaning they are not executed directly on Ethereum, but rather batched into simplified and therefore cheaper transactions that are eventually published on the Ethereum blockchain.

However, the specific mechanisms employed by Layer 2 scaling solutions to securely process, batch, and publish off-chain transactions onto Ethereum depend on the scaling technology being utilized.

Let's examine the three different types of Layer 2 scaling technologies.

What types of Ethereum Layer 2s exist and how do they differ? There are three types of Ethereum Layer 2s that address Ethereum's scalability challenge: state channels, optimistic rollups, and zero-knowledge rollups.

Let's explore the differences among these three types of Layer 2 technologies.

State Channels
State channels are an Ethereum scaling solution that enables users to conduct an unlimited number of off-chain transactions while only requiring them to submit two transactions to the Ethereum network: the initial transaction and the final transaction. Here's how it functions:

The first transaction opens a state channel and "locks" the state. Users carry out transactions off-chain. The resulting state after off-chain transactions are completed is recorded in a second transaction that "closes" the state channel. Examples of Ethereum Layer 2s that utilize state channels include:

  • Connext: A network for fast, trustless, cross-chain applications and communication.
  • Kchannels: Offers a trust-minimized payment channel for Ethereum.
  • Perun: Provides users with an off-chain framework supporting real-time payments.
  • Radien: Enables fast and cost-effective transfer of ERC20 tokens.

Optimistic Rollups
Optimistic rollups involve processing a large volume of transactions by handling computation off-chain and "rolling" them up into a simplified transaction that is subsequently published to Ethereum's execution layer. Optimistic rollups are considered "optimistic" because transactions are presumed valid unless proven false.

Before optimistic rollup transactions are confirmed on Ethereum's main chain, there is a period during which potentially invalid transactions can be disputed by submitting a fraud proof.

Once the dispute period for a fraud proof has ended, all remaining transactions are confirmed on Ethereum.

Since optimistic rollup Layer 2s rely on fraud proofs, the confirmation window tends to increase transaction confirmation times compared to other solutions like Zero-Knowledge rollups.

Examples of Ethereum Layer 2s that utilize optimistic rollups include:
  • Arbitrum: The largest optimistic rollup in terms of total value locked (TVL) ($3.2B) and market share (54.7%)*.

  • Metis: The third-largest optimistic rollup by TVL ($457M) and market share (7.84%)*.

  • Optimism: The second-largest optimistic rollup by TVL ($465M) and market share (7.97%)*.

  • Boba Network: The fourth-largest optimistic rollup by TVL ($187M) and market share (3.22%)*. (*Layer 2 TVL and market share data provided by L2Beat.)

Zero-Knowledge Rollups

Zero-Knowledge Rollups Zero-knowledge rollups (ZK-rollups) are similar to optimistic rollups in that they aggregate a large number of Layer 2 transactions executed off-chain and submit them as a single transaction to Ethereum. However, instead of assuming transactions are valid until proven otherwise, ZK-rollups employ validity proofs to instantly verify the validity of transactions.

Developing EVM-compatible ZK-rollups can be challenging compared to optimistic rollups due to the complexity of the technology and its ability to execute arbitrary code. This is an important consideration when deciding whether to build on a ZK-rollup Layer 2 blockchain or another EVM-compatible blockchain.

Examples of Ethereum Layer 2s that utilize ZK-rollups include:

Starknet: Utilized by dYdX and ImmutableX, the leading decentralized exchange for perpetual contracts on Ethereum. zkSync: Utilized by dApps such as Yearn Finance, FRAX, and Zerion. By understanding the distinctions between these Layer 2 scaling technologies, developers can make informed decisions when selecting the most suitable solution for their dApps.

How do ZK-rollups work? To understand the functioning of ZK-rollups, it is important to grasp the underlying concept of zero-knowledge proofs (ZKPs).

ZKPs provide a way to demonstrate knowledge of something without revealing the actual information. To exemplify this concept, let's take the game of poker. I can prove that I possess a winning hand without disclosing the specific cards by revealing my chips, which indicate a substantial victory. Without knowing the exact cards I hold, everyone can confidently acknowledge that I indeed have a winning hand. This exemplifies the essence of a ZKP.

ZK-rollups leverage ZKPs by consolidating a large number of Layer 2 transactions (off-chain) into a single transaction that is subsequently mined on the Ethereum mainnet. Instead of mining hundreds of transactions individually, they are rolled up into a single transaction.

This consolidated transaction takes the form of a validity proof, known as a succinct, non-interactive argument of knowledge (SNARK) or succinct, transparent argument of knowledge (STARK). SNARKs and STARKs operate on the same principle as cryptographic transaction hashes. While a typical Ethereum transaction consists of multiple components, they can all be represented in a unique transaction hash without revealing the transaction data, as exemplified in the Etherscan transaction hash.

Ultimately, mining this single transaction instead of hundreds of Ethereum transactions is what makes ZK-rollups significantly more cost-effective compared to utilizing Ethereum's Layer 1 chain.

Unlike optimistic rollups, which entail a waiting period for fraud proofs, ZK-rollups allow the receiving smart contract to instantly verify the validity of a ZK-SNARK on-chain. As ZK-SNARKs are verified promptly, funds can be withdrawn on ZK-rollups as soon as the ZK-SNARK transaction is mined on Ethereum (approximately 12 seconds), eliminating the need to wait for days or weeks for the dispute period to conclude.

The presence of validity proofs ensures fraud prevention without manual intervention or verification, as required by fraud proofs. Consequently, transaction confirmation with ZK-rollups is significantly faster and more scalable than with optimistic rollups.

Building dApps with ZK-rollup Technology

Several ZK-rollup solutions are available for developers to explore when building dApps. Some notable options include StarkNet, ZKSync, and Mina Protocol. These solutions provide the necessary infrastructure and tools to leverage ZK-rollup technology and benefit from its cost-efficiency and scalability advantages. By adopting these ZK-rollup solutions, developers can build powerful and robust dApps that can process transactions swiftly and economically on the Ethereum network. Let us know if you are working on building the next generation of dapps using ZK-rollup solution.