zkEVM Deep Dive (Polygon, Scroll, StarkWare, and zkSync)

“In the medium to long term, zk rollups will win out in all use cases as zk-SNARK technology improves.” — Vitalik Buterin

zkEVM Deep Dive (Polygon, Scroll, StarkWare, and zkSync)
Image: Alchemy

What is a ZK Rollup?

To understand what a zk rollup is, we need to know 2 core concepts:

  1. Zero-Knowledge Proofs
  2. Rollups

Zero-Knowledge Proofs

A zero-knowledge proof (zk proof) is used to mathematically verify a statement without revealing any information about the statement.

A zk-SNARK is a type of zk proof that stands for "zero-knowledge succinct arguments of knowledge." A zk-SNARK allows a computer to quickly verify the output of a computation. Proofs can be generated much faster than the computation would take to run, which improves the speed of the system. They are useful in cryptography because they allow some inputs of the computation to be hidden.

A common explanation for zk-SNARKs is the "Where's Waldo?" analogy. Imagine you're looking at a Where's Waldo? image and you need to prove to Person X that you found Waldo without revealing Waldo's location. You could cut out the image of Waldo and give it to Person X. That would verify that you found Waldo but would not reveal his hiding location. Zk-SNARKs are similar because they use zk proofs to verify transactions without revealing any extra information.

Rollups

Rollups are the main way that Ethereum developers plan to scale the Ethereum network. Rollups can increase throughput (measured in transactions per second), improve transaction finality speed, and lower transaction fees. They are a type of "layer 2." A layer 2 is a blockchain that runs on top of a layer 1 blockchain.

In short, rollups allow Ethereum to complete more transactions faster and at a lower cost.

Figure 1 | Source: Global X ETFs

A popular analogy for explaining rollups is the "mail" analogy. Imagine you're sending 5 separate letters to 5 people who all live in the same house. You put each of the letters into separate envelopes, pay for 5 stamps, and send them. It would make more sense to put all of the letters into one envelope, pay for one stamp, and send that one envelope to their house. That would allow you to reduce your postage costs and send more letters.

Rollups work similarly to the "mail" analogy because they take, say, 2,000 transactions (2,000 letters) and put them into a single batch (a single envelope). That batch is then sent (mailed) to Ethereum (the recipient's house), where the transaction data is stored as a single Ethereum transaction. The result is higher TPS, quicker finality, and lower transaction fees.

For more info on rollups, I recommend Vitalik Buterin's An Incomplete Guide to Rollups and Delphi Digital's The Complete Guide to Rollups.

A zk rollup (zero-knowledge rollup) is a type of rollup that uses zero-knowledge proofs to verify transactions.

Why ZK Rollups?

Ethereum has 2 main problems:

  1. It has a (low) throughput of 15-45 transactions per second (TPS).
  2. It has expensive transaction fees when the network is congested.

Between January 2021 and May 2022, the average Ethereum transaction fee was roughly $40. On May 1, 2022, the average transaction fee was $196.63, according to Cointelegraph.

The solution to Ethereum's low TPS and expensive transaction fees is layer 2s, like zk rollups and optimistic rollups.

The main competition for zk rollups is optimistic rollups, a type of rollup that uses fraud proofs instead of zero-knowledge proofs. Zk rollups have improved speed and privacy when compared to optimistic rollups, but they are more technically difficult to implement. The previous implementations of zk rollups have limited functionality. They can (largely) only do token transfers and swaps. But zk rollup technology is improving with the development of sharding (and zkEVMs, which we'll cover in the next section). Figure 2 shows the potential future of sharding technology, where rollup block data is split up over time between shards.

Figure 2 | Source: vitalik.ca
“In the medium to long term, zk rollups will win out in all use cases as zk-SNARK technology improves.” — Vitalik Buterin, co-founder of Ethereum

Zk rollups are the key to Ethereum scaling over the long term. The technical team at Scroll, a leading layer 2 project, has said that zk rollups are as secure as the Ethereum layer 1 and have the fastest finality of any layer 2 scaling solution. Additionally, Vitalik Buterin has said that rollups are essential to scaling TPS:

  • Ethereum has 15-45 TPS.
  • Ethereum with zk rollups will have 1,000-4,000 TPS.
  • Ethereum post-merge with zk rollups will have 25,000-100,000 TPS.
Figure 3 | Source: Vitalik Buterin

To get to the endgame of Ethereum scalability and functionality, we need the next generation of zk rollup technology, zkEVMs.

What is a zkEVM?

To understand what a zkEVM is, we need to understand one more core concept: The Ethereum Virtual Machine.

The Ethereum Virtual Machine (EVM)

In short, the Ethereum Virtual Machine (EVM) is a decentralized cloud computer that runs the Ethereum network and processes smart contracts. The EVM is the runtime environment for Ethereum. It's a standard set of rules and software packages, rather than a single piece of hardware or software. It was initially defined in the Ethereum Yellow Paper and is updated through Ethereum Improvement Proposals (EIPs), like EIP1559. When the EVM is run on many different computers, the result is a cohesive but decentralized blockchain network. In this case, the network is the Ethereum mainnet, but there are other EVM-compatible mainnets and testnets, like Avalanche and Fantom. A mainnet is a fully functional blockchain that is available to the public, as opposed to a testnet, which is used for testing new projects and updates.

For a zk rollup to work well with the EVM, Solidity code, and Ethereum developer tools, it must be compatible with the EVM. Previous zk rollup implementations were not EVM-compatible, so they were incompatible with many Ethereum decentralized applications (dApps) and developer tools.

A zkEVM is a type of zk rollup that is EVM-compatible.

zkEVM Analysis Frameworks

ZkEVM projects all have a similar goal – to create developer and user experiences that are exactly like Ethereum. There are 4 top zkEVM projects taking different approaches with unique tradeoffs. Some are more developer-friendly. Some are easier to maintain. Some finalize transactions faster. Some have lower transaction fees. In this section, we will cover 3 different frameworks to help us understand the differences between zkEVM projects.

"Level" zkEVM Analysis Framework

Scroll’s Luozhu Zhang and Toghrul Maharramov have an analysis framework where there are 3 levels of zkEVM compatibility:

  1. Consensus level. (Developer-friendly.) Commonly called a "true" zkEVM.
  2. Bytecode level. (Developer-friendly.) Commonly called EVM-equivalent.
  3. Language level. (Not developer-friendly.) Commonly called EVM-compatible.
Figure 4 | Source: Luozhu Zhang

Figure 5 shows how language level zkEVMs transpile Solidity code. Language level zkEVMs, like StarkNet and zkSync, take Solidity, Vyper, or Yul code and transpile it into a zk-friendly language like Cario or Zinc.

Figure 5 | Source: Luozhu Zhang

Bytecode level zkEVMs do not transpile Solidity code into another coding language and should be able to use common Ethereum developer tools (like Hardhat and Foundry), libraries (like ethers.js), wallets (like MetaMask), marketplaces, and debuggers. Language level zkEVMs, in contrast, may not be compatible.

"Type" zkEVM Analysis Framework

Vitalik Buterin has an analysis framework that identifies 4 or 5 types of zkEVMs.

Figure 6 | Source: vitalik.ca

We need to know what a zkEVM "prover" is to understand Vitalik's framework. The prover is the part of the code that generates zk proofs. Improving prover times would decrease the time it takes to finalize a transaction.

Vitalik Buterin's zkEVM analysis framework:

  • Type 1: Fully Ethereum-equivalent. All Solidity smart contracts and developer tools will work flawlessly.
  • Type 2: Fully EVM-equivalent. Similar to Type 1, but has some modifications to improve prover time and developer-friendliness.
  • Type 2.5: The same as Type 2 except prover times are improved by increasing transaction fees.
  • Type 3: Almost EVM-equivalent. The key difference between Type 2 and Type 3 is that smart contracts may require rewriting to run properly.
  • Type 4: High-level-language-equivalent. The key difference between Type 3 and Type 4 is that smart contracts will likely require rewriting and common Ethereum developer tools may not be compatible.

"True" zkEVM Analysis Framework

Messari research analysts, Tom Dunleavy and Eshita Nandini, have a different zkEVM analysis framework. The standard for a "true" zkEVM is determined by how the bytecode is executed. If it is executed directly, it is a "true" zkEVM. If the bytecode is interpreted before it is executed, it is not a "true" zkEVM.

Top zkEVM Teams and Projects

Polygon (Polygon zkEVM), Scroll, StarkWare (StarkNet), and Matter Labs (zkSync 2.0) are the leading zkEVM development teams and projects.

Figure 7 shows the process that Solidity code must go through before running on each project's zkEVM. It is broken up into 3 levels on the "y-axis," similar to Luozhu Zhang's zkEVM analysis framework.

Figure 7, Polygon Hermez is now Polygon zkEVM* | Source: Immutable X

Polygon

Polygon is a leading layer 2 development team that offers multiple scaling solutions for Ethereum. Polygon uses many different technologies to scale Ethereum like zk and optimistic rollups, sidechains, a data availability layer, and a blockchain SDK. The most widely adopted is Polygon’s Proof of Stake (PoS) sidechain, which uses staked coins and validators to verify transactions.

Figure 8 | Source: Polygon
  • Polygon PoS: an EVM-compatible Proof of Stake sidechain. (Live)
  • Polygon zkEVM: an open-source zk rollup focused on EVM-equivalence. (Public Testnet)
  • Polygon Avail: a standalone layer 2 chain focused on data availability. (Development)
  • Polygon Nightfall: a privacy-focused rollup chain using both zk and optimistic rollups. (Mainnet Beta)
  • Polygon Miden: a zk-STARK rollup. (Development)
  • Polygon Zero: a zk rollup chain focused on scalability. (Development)

The most important of Polygon’s scaling solutions are Polygon PoS and Polygon zkEVM.

Polygon Proof of Stake (PoS)

Polygon Proof of Stake launched in 2017 and is now the most used layer 2 on Ethereum. The PoS sidechain is EVM-compatible and uses the Plasma bridging framework. It currently handles almost all of Polygon’s transactions, has a throughput of 7,000 TPS, and has a 2s block time. It's roughly 10,000x lower cost than transacting on Ethereum and the average transaction is less than 1 cent. Its main downside is that its security is poor compared to rollups.

Polygon zkEVM

Polygon is currently developing its zk rollup infrastructure. In Q3 2022, they raised $450 million and committed $1 billion to develop multiple zk rollup scaling solutions.

In August 2021, Polygon acquired the Hermez Network, a layer 2 zk rollup project, and integrated it into their product lineup as Polygon Hermez. In July 2022, they rebranded Polygon Hermez to Polygon zkEVM.

Polygon zkEVM is an open-source layer 2 rollup with a throughput of 2,000 TPS. It is currently at the public testnet stage of development. Over 2,000 transactions can be batched and put onto the Ethereum layer 1 as a single transaction. The Polygon zkEVM launched a public testnet on October 10, 2022. The mainnet zkEVM is expected to launch in early 2023.

Polygon zkEVM (as well as StarkNet and zkSync 2.0) has promised data availability volition in the future. Volition gives the user the ability to choose the degree to which their data is stored on-chain or off-chain. There are different use cases where it can be useful to control data availability. Figure 9 contrasts volition with other data availability solutions.

Figure 9 | Source: StarkWare

Analysis Frameworks Results:

Figure 10

Scroll

Scroll is a layer 2 zkEVM scaling solution. There is a pre-alpha testnet with over 10,000 users testing demo forks of dApps. Scroll released an update on October 9, 2022, which allows developers to deploy smart contracts using Ethereum developer tools (like Hardhat and Foundry) and Ethereum smart contracts will work without rewriting code. The update also adds support for ERC-20, ERC-721, and ERC-1155 standards. Scroll will soon release a testnet version open to the public.

Analysis Frameworks Results:

Figure 11

StarkWare

StarkWare is one of few zkEVM teams using zk-STARKs rather than zk-SNARKs. Zk-STARKs make transactions more secure but higher in fees. They also have larger batch sizes, faster proving, and are post-quantum secure (meaning they cannot be cracked by a quantum computer). StarkWare has 2 projects, StarkNet and StarkEx.

StarkNet

StarkNet is a layer 2 zkEVM scaling solution. StarkNet Alpha launched on the Ethereum mainnet in November 2021.

“StarkNet provides Ethereum-level composability – facilitating easy development and innovation.” — StarkWare

StarkWare claims to have solved composability but its critics would disagree. StarkWare uses the Warp transpiler to transform Solidity code into Cairo. Transpiling works for EVM compatibility, but there are some known Solidity features that are not supported on StarkNet. A full list of the unsupported features can be found on Nethermind's GitHub under the "Unsupported Solidity Features" section. StarkWare is creating its own APIs and JavaScript libraries, which will require tools to manually add StarkNet compatibility.

Analysis Frameworks Results:

Figure 12

StarkEx

StarkEx is a layer 2 scaling solution made specifically for NFT trading, derivative trading, spot trading, payments, DeFi pooling, and automated market makers (AMMs). It can be thought of as a permissioned version of StarkNet. "Permissioned" means it's tailor-made to work for certain dApps that are given permission to use the network.

zkSync

Matter Labs launched zkSync 1.0 in June 2020. It's a non-EVM-compatible zk rollup layer 2. This version of zkSync was able to scale to 300 TPS. In a later update, zkSync 1.1 increased throughput to 3,000 TPS.

zkSync 2.0

ZkSync 2.0 is a zkEVM layer 2 scaling solution. It launched on the Ethereum mainnet on October 28, 2022. The network is currently only accessible to the Matter Labs team and it will not be public until they are confident that it is running properly. In late 2022 or early 2023, after zkSync 2.0 has been tested, the alpha will fully launch and anyone will be able to use it. If all goes well during the testing phase, Matter Labs will be the first to deploy a working zkEVM on the Ethereum mainnet.

"ZkSync's zk rollup technology combined with Ethereum 2.0 data sharding is the endgame, hitting 100,000+ TPS without sacrifices [in programmability, security, scalability, or decentralization]." — Matter Labs

Matter Labs claims that zkSync 2.0 has near-frictionless porting of Ethereum dApps. That means that developers can port their Solidity code onto zkSync with minimal changes. Matter Labs' critics would say that zkSync 2.0 is not as developer-friendly as they claim and that common Ethereum developer tools may not be compatible.

One benefit of Matter Labs' zkEVM approach is that they can add unique non-EVM-compatible features or build new features from EIPs before they launch on Ethereum. One of these features is that users can pay transaction fees in any ERC-20 token, like USDC, DAI, ETH, LINK, or WBTC. This greatly improves the user experience when you have to pay a transaction fee but don't have any of the native token.

Analysis Frameworks Results:

Figure 13

Key Differences

Every zkEVM project is currently marketing itself as the most developer-friendly to try to attract developers to their platform. They're projecting the 3+ year goal for their projects and claiming that they will have that functionality soon.

Luozhu Zhang zkEVM Analysis Framework Results

Polygon and Scroll are bytecode level (developer-friendly). With these projects, there is no transpiler step. The smart contracts written in Solidity are not converted before being transpiled and interpreted.

StarkNet and zkSync 2.0 are language level (not developer-friendly). For zkSync 2.0, smart contracts written in Solidity will run, but zkSync will transpile the code into Yul, another coding language. StarkNet will transpile code into Cairo.

Vitalik Buterin zkEVM Analysis Framework Results

  • Polygon zkEVM is Type 2 or 3
  • Scroll is Type 2
  • StarkNet is Type 4
  • zkSync 2.0 is Type 4

A lower number means it is more Ethereum-equivalent, but Alex Connolly, co-founder and CTO of Immutable X has said, "It is crucial to understand that none of the [zkEVM] approaches are inherently superior — it’s a categorization, not a hierarchy. They all make different tradeoffs: easier to build, maintain and upgrade, more performant, more easily compatible with existing tools. Ultimately, the leading rollup will also be determined by better distribution and marketing, rather than pure technical capability."

Messari zkEVM Analysis Framework Results

Using Messari's framework, Scroll is the only "true" zkEVM. Scroll is the most EVM-equivalent, followed by Polygon zkEVM, zkSync 2.0, and StarkNet (in that order). Polygon zkEVM is closer to a "true" zkEVM than zkSync or StarkNet, but it may execute code slightly differently than the EVM. This is because it has micro opcode that runs before the Solidity code is compiled into bytecode.

Overview

Figure 14

There are many other zkEVM analysis frameworks and opinions. Scroll’s co-founder, Sandy Peng, has said that there isn’t a consensus on definitions for EVM equivalence and compatibility.

I think that over the long term, the differences between zkEVMs will diminish as:

  1. Each project develops ways to improve developer-friendliness.
  2. Ethereum releases updates that make it more zk rollup-friendly.

Which Project Will Win?

Justin Drake, a researcher for the Ethereum Foundation, has said, “It turns out that in this space, oftentimes it is not just about technology. Sometimes, it’s the network effects – the culture of the community – that is actually the most important thing.”

An example of network effects is the Apple App Store. Developers want to publish their apps on the Apple App Store even though it is unstable and randomly rejects apps. The Google Play Store is more developer-friendly, but developers favor Apple's platform because it has the most active users.

Polygon is like the Apple App Store of web3, it has strong network effects. Polygon PoS has more daily active addresses than any other layer 2 – over 350,000 at the time of writing, according to Nansen. They can easily be converted into Polygon zkEVM users.

I believe Polygon will remain the dominant layer 2 scaling solution for Ethereum unless a competitor can make a product that's 10x better for developers and users. Polygon has the network effects, investors, cash, technical team, brand, and community to win.

I also believe that there will be multiple winners. Other chains will be used for different use cases or as backups. It could look something like Figure 15, where there are multiple layer 2 rollups connected by bridges.

Figure 15 | Source: vitalik.ca

Sources and Further Reading

General Sources ⇅

  1. Vitalik Buterin's Incomplete Guide to Rollups: https://vitalik.ca/general/2021/01/05/rollup.html
  2. A complete guide to rollups: https://members.delphidigital.io/reports/the-complete-guide-to-rollups/
  3. Vitalik Buterin's zkEVM analysis framework: https://vitalik.ca/general/2022/08/04/zkevm.html
  4. Scroll's Luozhu Zhang on zkEVM types: https://threadreaderapp.com/thread/1538166119785111552.html or https://twitter.com/luozhuzhang/status/1538166119785111552?lang=en 
  5. https://vitalik.ca/general/2021/12/06/endgame.html
  6. https://ethereum.org/en/developers/docs/evm/
  7. https://ethereum.org/en/zero-knowledge-proofs/
  8. https://vitalik.ca/general/2021/01/26/snarks.html
  9. Vitalik's 2016 guide to SNARKs: https://medium.com/@VitalikButerin/quadratic-arithmetic-programs-from-zero-to-hero-f6d558cea649
  10. https://vitalik.ca/general/2017/11/09/starks_part_1.html
  11. https://vitalik.ca/general/2017/11/22/starks_part_2.html
  12. https://vitalik.ca/general/2018/07/21/starks_part_3.html
  13. Vitalik on Bankless Podcast – Rollups: https://youtu.be/wcCHlqgGSH4
  14. Vitalik on Lex Fridman Podcast – Eth 2.0: https://youtu.be/XW0QZmtbjvs
  15. https://blockworks.co/news/defi-is-betting-big-on-zero-knowledge-is-the-technology-ready/
  16. https://www.coindesk.com/tech/2022/07/27/ethereums-rollup-race-what-is-a-true-zkevm/
  17. https://immutablex.medium.com/ground-up-guide-zkevm-evm-compatibility-rollups-787b6e88108e
  18. https://medium.com/ethereum-optimism/introducing-evm-equivalence-5c2021deb306
  19. Data availability – Volition: https://medium.com/starkware/volition-and-the-emerging-data-availability-spectrum-87e8bfa09bb
  20. Eli Ben-Sasson (StarkWare) on different crypto proofs: https://medium.com/starkware/the-cambrian-explosion-of-crypto-proofs-7ac080ac9aed
  21. Jordi Baylina (Polygon zkEVM team) presentation on zkEVMs: https://youtu.be/17d5DG6L2nw

Notable Tweets

A zkEVM analysis framework from Toghrul Maharramov, a Senior Researcher at Scroll:

Scroll's Ye Zhang makes the argument that Polygon may behave differently than the EVM when running Solidity code. Brendan Farmer of Polygon says that Polygon zkEVM will run the same as Scroll in practice:

The co-founder of zkSync calls out the co-founder of Polygon for claiming that Polygon zkEVM is EVM-equivalent:

Alex Gluchowski, the co-founder of zkSync, claims that Matter Labs is intentionally making zkSync 2.0 EVM-compatible rather than EVM-equivalent so that they can make a better developer and user experience with custom features: