Navigating Layer 2: A deep dive into zkEVM and zkSync
zkEVM is one of the best solutions to solve Ethereum's scalability issue, and zkSync is currently the largest player.
GM anon! You may have heard terms like L2 and zkEVM floating around. But what are they, and why should they matter to you?
Let’s explore the endgame of L2 and zkEVM.
TL;DR
Ethereum is focusing on a rollup-centric roadmap to address its scalability issues using L2 solutions.
Danksharding is set to unleash the full potential of L2s, opening up enormous opportunities.
Despite the higher technical complexity, ZK rollups outperform optimistic rollups in several ways.
zkSync Era, one of the pioneers, has launched its zkEVM mainnet. Notable technological aspects include native account abstraction, strong LLVM compiler, superior data compression, and unique solutions for data availability (zkPorter) and scalability (ZK Stack).
Since the mainnet launch, zkSync Era has seen significant ecosystem growth: 300+ dapps in development and $562M TVL from 1.3M unique depositors.
With $458M in capital raised since its inception and backing from industry leaders, zkSync Era boasts strong resources.
Understanding L2: What is it and why it matters?
We're all aware of Ethereum's scalability issue—it chokes up during usage spikes. A latest example is BAYC's Otherside land sale on May 1, 2022, which sent gas prices soaring to a staggering 78,999 Gwei that day (bear market typically sees gas prices of 20-30 Gwei), and people shelled out >3 ETH just to secure their land.
At its core, the problem lies in Ethereum's limited block space, quantified in "gas" units. Transactions that require more computational power to execute are priced higher in gas units, and gas is converted into ETH via a dynamic gas rate or base fee set by the Ethereum network.
Currently, each Ethereum block can hold up to 30 million gas units. While this maximum block gas limit ensures swift block broadcasting times, it also restricts the number and complexity of transactions over time.
Earlier, Ethereum attempted to solve its scalability issue with sharding (let's refer to this as sharding 1.0), effectively turning Ethereum into 64 parallel-processing shards, much like 64 chains executing blocks simultaneously. But, this design introduced unnecessary complexities—each of the 64 shard blocks had separate proposers and committees that rotated through the validator set, leading to poorer UX and potential attack vectors.
Thanks to the rise of Layer 2 solutions, Ethereum pivoted to a rollup-centric roadmap for scalability. Further, Ethereum researcher Dankrad proposed a new sharding design, popularly known as Danksharding, which will fully unleash rollups' potential.
Rather than sticking to the original 64 shards design, Ethereum now offloads transactions to Layer 2 blockchains, allowing the Layer 1 main chain to focus on ensuring data availability of L2, thereby addressing the limited block space issue.
This is why L2 has been the buzzword of late—it's pivotal to Ethereum's scalability solution, all while preserving decentralization and security.
With Ethereum on course to fully implement danksharding, it's set to unlock L2's full potential, offering immense opportunities.
Understanding the L2 landscape
L2 solutions, essentially solutions that enhance Ethereum's scalability, can be broadly classified into four categories:
Data on-chain vs off-chain
While an L2 solution is a “Layer 2” extension of Ethereum, it's still a standalone blockchain. If the data associated with state changes on L2 is stored off the L1 chain, we must trust the L2 operator to act in good faith as the data is not verifiable, which isn't an ideal setup.
Storing data on-chain makes it verifiable. These are known as rollups, which have gained significant attention due to their better trustless setup.
ZK rollups vs Optimistic rollups
To avoid diving deep into technical jargon, we won't delve into the underlying SNARKs & STARKs technology behind ZK (Zero Knowledge).
In simplified terms, ZK proofs enable Bob to convince Alice that a statement is true without revealing any extra information about the statement.
Imagine Bob demonstrating to Alice (who is colorblind) that he can differentiate between a red ball and a green ball. Alice can label the balls and shuffle them behind her back, and Bob will correctly identify the colors every time, proving he can indeed tell the difference.
Conversely, Fraud Proofs, which are used in Optimistic rollups, operate on the assumption that a statement is true unless challenged and disproven within a specific timeframe.
Now the comparison. Why are ZK rollups gaining traction recently??
Significantly shorter fund withdrawal period. Optimistic rollups (e.g. Arbitrum, Optimism) have a 7-day withdrawal period owing to a 7-day challenge period for any L2 to L1 transaction. Conversely, ZK rollups can process withdrawals rapidly as a withdrawal is considered valid once the validity proof is computed and provided to L1.
Cost efficiency. Optimistic rollups require all L2 transactions to be compressed and committed on-chain, while ZK rollups only need to post transactions relevant for computing the state, making ZK rollup considerably more cost-effective. In other words, more transactions on optimistic rollups will lead to much higher cost, but as the cost of proof generation and posting transaction batches are fixed for ZK rollups, it actually gets more inexpensive for ZK rollups users after achieving certain network effect.
Hyper-scalability. Optimistic rollups cannot increase scalability beyond their current capabilities. However, ZK rollups can potentially boost their scalability to L3 and even L4 using ZK proofs.
Synchronization between ZK rollups and L1. The instant finality achieved by ZK rollups with ZK proofs opens up possibilities for synchronous calls between ZK rollups and L1 Ethereum execution when danksharding is fully implemented. This unlocks possibilities for numerous exiting designs, such as shared L1/L2 liquidity (e.g., dAMM).
ZK rollups and zkEVM
Although ZK rollups hold great potential, their ecosystem growth has been hampered by the complexity of the technology and their initial incompatibility with EVM. This led to the development of zkEVM—a solution aimed at making ZK rollups compatible with Ethereum-based smart contracts.
zkEVM pioneers
March 2023 marked a significant milestone for zkEVM with multiple players, including Scroll, Immutable, Taiko, zkSync, Polygon zkEVM, and Linea, announcing significant advancements and exciting news.
Among these trailblazers, zkSync has already launched its mainnet and demonstrated impressive performance, marking a substantial leap forward for the zkEVM space.
What is zkSync and how does it work?
zkSync is a ZK rollup solution developed by the team at Matter Labs.
Founded in 2018 by Alex Gluchowski and Alex Vlasov, Matter Labs first unveiled zkSync Lite (also refferred to as zkSync 1.0) in Dec 2020. This was a simple ZK rollup designed for payments.
In 2021, they presented the concept of “zkEVM” to the world, leading to the successful launch of their zkEVM mainnet, zkSync Era∎ (also referred to as zkSync 2.0) in Mar 2023.
Since its inception, zkSync Era has demonstrated remarkable growth in terms of bridged assets and users.
So, what sets zkSync Era apart? Let's dive into the technological highlights.
Technological highlights of zkSync Era
Native account abstraction. As stated in our previous research, account abstraction and smart contract wallets will be crucial for mass adoption as they eliminate the need for cumbersome seed phrases, and allow for functionalities like fee payment in any token, automatic / batch transactions, and fee subsidization. While Ethereum has partially implemented ERC-4337 for account abstraction, zkSync Era has supported account abstraction from day one through its own virtual machine.
Strong LLVM compiler. Instead of seeking EVM-equivalence, zkSync Era optimizes its internal virtual machine for ZK performance. However, this doesn't mean compromising on the development environment. zkSync Era has heavily invested in building the first LLVM-based compiler to make developers' tasks as easy as possible. The LLVM compiler is designed for EVM languages (Solidity, Vyper, Yul), and will eventually support other languages such as C++ and Rust.
Superior data compression. Unlike other rollups that post the entire transaction history on L2, zkSync Era only posts the state change, thereby reducing the requirement for block space and consequently, the cost of data availability. Additionally, while optimistic rollups face high gas fees when transactions spike as they have to post all transactions on L1, zkSync only posts the state change, irrespective of the number of transactions.
In addition to the above key technological highlights, zkSync also offers unique solutions in data availability (through zkPorter) and scalability (through ZK Stack), which we’ll cover later.
But first, let’s take a look at how a transaction is done on zkSync.
Transaction lifecycle
The transaction process within zkSync Era comprises several key steps. Here's a glimpse into the lifecycle of a transaction:
Users initiate transactions on L2.
Operators process the transactions, consolidate them into blocks on L2.
Operators group several L2 blocks into a batch and post it on L1.
Operators then compute a ZK proof for the transactions and submit this proof to the L1 smart contract.
Once the validity proof is verified, the transactions are deemed finalized, and the state change is executed/accepted on L1.
A crucial aspect to note here is the quick finalization of L2 transactions on L1. As soon as the validity proof is calculated, submitted, and verified, the transaction reaches finality.
zkSync Era’s data availability evolution - the role of zkPorter
As we have previously noted, the future role of Ethereum L1 will be to ensure data availability for L2. Nonetheless, the limited block space on L1 presents a bottleneck for L2 throughput.
To address this challenge, Matter Labs proposed an off-chain (i.e., off-L1) data availability solution called zkPorter in Apr 2021.
The concept behind zkPorter is straightforward. Rather than posting all the L2 data on L1, which involves gas costs and is limited by L1's block space, Matter Labs suggests creating a separate chain, called zkPorter.
This chain would manage data, significantly reducing transaction costs and boosting transaction throughput. Additionally, accounts on zkPorter can interact seamlessly with accounts or contracts on zkSync Era, enhancing the user experience even further.
But, how can we ensure data availability if it's kept off-chain?
Matter Labs proposes governing this mechanism using a Proof-of-Stake (PoS) system and the zkSync token (indicating that we might anticipate a governance token if Matter Labs implements zkPorter, and which is why the entire community is speculating an airdrop).
zkSync token holders can stake their tokens to become Guardians. These Guardians monitor the state on zkPorter, signing blocks to affirm the data availability of zkPorter accounts. Any data availability failures would result in Guardians being penalized, incentivizing them to maintain reliable data availability.
You may ask - ser, is this setup secure?
While the security of zkPorter is not as robust as that of L1 (since it relies on Guardians for data availability confirmation), it still provides substantial security measures as (1) the rollup aspect maintains the same level of security as L1 and (2) zkPorter's security surpasses that of other PoS systems, as Guardians cannot misappropriate funds - they can only freeze the zkPorter state, making it less appealing to potential attackers.
Additionally, users retain the choice to keep their data available on-chain and remain entirely on the rollup side.
The implementation of zkPorter is expected to further enhance the scalability of zkSync Era.
zkSync’s ambition to rule the zkEVM - ZK Stack
On Jun 26, 2023, zkSync announced ZK Stack, attempting to create the strongest ZK ecosystem.
Zk Stack essentially offers 2 core features:
Hyperchains. Through its open-sourced modular framework, ZK Stack makes it easy for builders to build custom ZK-powered L2/L3 (referred to as Hyperchains), based on the code of zkSync Era.
Hyperbridges. All the Hyperchains are interconnected through Hyperbridges, creating a strong ecosystem.
We know the term “bridge” sounds scary and vulnerable, but unlike other bridging solutions, Hyperbridges are powered by ZK proof, making it secure in a trustless way.
How? Instead of trusting a middleware for cross-chain messaging, we include the state root change of the source chain in a ZKP, which would be sufficient for the destination chain to verify it trustlessly.
A simplified example of bridging tokens from L3 to L2 looks like the below chart:
A bridging transaction is initiated on Hyperchain C (L3), and tokens are burned. The ZKP of the state change is submitted to Hyperchain A (L2).
L2 also submits its state change ZKP to L1.
Given Hyperchain B (L2) has access to L1’s hash, it can verify the ZKP and therefore confirm that the tokens are burned on Hyperchain C. New tokens are minted on Hyperchain B.
Hyperchain B then submit the state change ZKP to L1 again for future reference.
In summary, ZK Stack enables developers to build their sovereign hyperchain easily, gathering a strong ecosystem, and enable great user experience through its native Account Abstraction, and at low cost.
Ok, enough technical trash talk for today, let’s now move on to zkSync’s ecosystem and resources.
Exploring zkSync’s ecosystem and resources
Evaluating the strength of a L2 chain demands an understanding of its ecosystem:
zkSync Era boasts a robust ecosystem with 300+ dApps built upon it.
According to L2BEAT, TVL has surged notably to $562M as of Jul 16, 2023, since its alpha launch on March 24, 2023. Importantly, this growth is due to real ETH-denominated demand and not simply token appreciation. It currently ranks as the 3rd largest L2 in terms of TVL and the largest ZK rollup.
As of Jul 16, 2023, it has garnered a total of 1.3M depositing addresses. (Dune @tomwanhh)
Through a series of funding rounds, Matter Labs has raised a total of $458M. This sum includes a dedicated $200M ecosystem fund in collaboration with BitDAO and $258M of capital from various investors. This substantial capital reserve enables Matter Labs to incentivize early developers and adopters.
Matter Labs enjoys the support of reputable partners and investors, including Blockchain Capital, Dragonfly, Lightspeed, a16z, 1kx, Crypto.com, Consensys, ByBit, OKEx, along with founders and leaders of AAVE, Paraswap, Lido, Gnosis, Aragon, and many others.
Comparison with Polygon zkEVM
Notably, Polygon zkEVM is another zkEVM that has launched its mainnet.
While both being ZK rollups/zkEVMs and planning to introduce a separate data availability chain, there exist important differences in terms of technology and ecosystem that are worth exploring.
Technology
EVM compatibility.
Vitalik has previously defined 4 levels of EVM compatibility: consensus level equivalence (type 1), full bytecode level equivalence (type 2), partial bytecode level equivalence (type 3), and language level equivalence (type 4).
Polygon zkEVM adheres to partial bytecode equivalence (type 3), enabling much of the infrastructure to be directly applied to the L2 and ensuring full compatibility with most Ethereum applications.
On the other hand, zkSync Era operates at the language-level equivalence (type 4). It employs an LLVM-compiler to transform Solidity code into zkSync's custom bytecode, compatible with their virtual machine. The trade-off is that while zkSync Era isn't Ethereum bytecode equivalent, its bytecode is optimized for generating ZK proofs efficiently, leading to shorter proving times and lower barriers for becoming a prover compared to Polygon zkEVM.
Account abstraction.
zkSync Era natively supports account abstraction through its unique virtual machine, while Polygon zkEVM will only provide support via the implementation of ERC-4337.
Validity proof
zkSync Era generates validity proof with SNARK, contrasting with Polygon zkEVM's utilization of STARK.
Ecosystem
Since its launch in March 2023, zkSync Era has rapidly amassed a notable $562M TVL and a total of 1.3M depositors. This could potentially be attributed to user anticipation of a zkSync token airdrop, as suggested in past references, such as the Guardian PoS design in zkPorter.
Conversely, it's expected that Polygon zkEVM will be governed by $MATIC.
Concluding thoughts
Given Ethereum’s rollup-centric roadmap and the implementation of danksharding, we hold a positive outlook on L2 development.
Among L2 solutions, we believe ZK rollups hold significant potential, courtesy of the benefits conferred by ZK proof designs.
zkSync Era as one of the leaders launching zkEVM mainnet has seen a great start with strong growth momentum and definitely a promising zkEVM that worth our attention.
Going forward , we should keep an eye on its performance of native account abstraction, development environment with LLVM-compiler, cost efficiency and its future development zkPorter and ZK Stack.
Useful zkSync links
zkSync Era: https://zksync.io/
zkSync Era docs: https://era.zksync.io/docs/dev/
zkSync Era bridge: https://bridge.zksync.io/
zkSync Era wallet portal: https://portal.zksync.io/
zkSync Era block explorer: https://explorer.zksync.io/
zkSync ecosystem: https://ecosystem.zksync.io/
zkSync Lite: https://lite.zksync.io/
Matter Labs: https://matter-labs.io/
Matter Labs medium: https://blog.matter-labs.io/
Reference
https://blog.matter-labs.io/zkporter-a-breakthrough-in-l2-scaling-ed5e48842fbf
https://coinmarketcap.com/alexandria/article/zksync-era-vs-polygon-zkevm
https://www.galaxy.com/research/insights/zkevms-reach-milestones-but-more-work-lies-ahead/
https://www.galaxy.com/research/whitepapers/zkevms-the-future-of-ethereum-scalability/
https://members.delphidigital.io/reports/the-complete-guide-to-rollups
https://medium.com/amber-group/navigating-zero-knowledge-e944b21af71c
https://blog.matter-labs.io/introducing-the-zk-stack-c24240c2532a
https://hackmd.io/@kalmanlajko/rkgg9GLG5#Zk-Rollups-and-Current-bridging