ZKX
ZKX
04 May 2024
4 min read

L2 Deep Dive

Table of Contents

1. Introduction
2. Current landscape
2.1 Comparison between the L2s
3. Main differences between Optimistic and Zk-rollups
3.1 Decentralization
3.2 Security
3.3 Scalability
4. Future Trends / Predictions
5. Conclusion

Introduction

In the ever-evolving landscape of Web3, Ethereum’s Layer 2s have emerged as a crucial solution to address the scalability challenges faced by the Ethereum network. As the demand for decentralized applications (DApps) and smart contracts continues to grow, L2s provide a scalable and efficient alternative for processing transactions and executing smart contracts off the Ethereum mainnet.

Layer 2 solutions can be broadly categorized into two main types: Optimistic Rollups and ZK Rollups; within the ZK rollups subset, we also have EVM-compatible ZK rollups, and non-EVM compatible ones such as Starknet.

In this article, we will be diving deeper into the current L2 landscape, the types of Layer 2 solutions, and evaluating their technical differences.

How Layer 2s work

Ethereum Layer 2s aim to scale the network by increasing the speed of transaction confirmation as well as reduce the amount of gas required for each transaction. Transactions are initially executed on the Layer 2 chain, then batched and published to L1 with an updated state, thus reducing the amount of gas required for each transaction. This is because instead of immediately publishing every single transaction on the Ethereum mainnet, only the final transaction data and some cryptographic proof are submitted. These proofs can be used to verify the correctness of the transaction results. This reduces both the execution gas cost and data posting costs.

Current Landscape

There are currently a total of 47 Layer 2 rollups on Ethereum, of which 26 fall under the Optimistic Rollup category, while the other 21 are holding a grand total of $39.5 billion in TVL (source). Total daily transactions on Layer 2s are currently exceeding those on Ethereum mainnet on a typical day (source), and L2 volumes have been increasing through the bear market, evidence of the L2 ecosystem properly maturing in the past months. This is in part due to the launch of many zkEVMs in the past year, as well as the continuous growth of applications on already established existing L2s such as Arbitrum and Optimism.

Base

A particularly worthy mention is Base, an L2 built using the OP Stack, using the same technical infrastructure as Optimism itself. Launched in June 2023, Base has quickly become prominent, especially due to a surge in memecoin transactions since the first quarter of 2024, which has pushed it to third in total value locked (TVL), trailing only Arbitrum and Optimism. Additionally, Base has received support through a grant program from Coinbase, aiding its development and adoption.

Blast

Last but not least, we also have Blast, an L2 that operates as an Optimistic Rollup and was developed by the team behind Blur, a marketplace aimed at professional NFT traders. Blast has attracted attention with its unique native yield feature, where assets transferred from Ethereum automatically generate yield. This yield is derived from depositing stablecoins in MakerDAO and converting Ether into Lido’s stETH.

However, Blast faced controversy for forking and only slightly modifying the Optimism codebase, then changing its license without crediting Optimism in its documentation. Additionally, security concerns have been raised as the Blast deposit contract, which holds $500 million in tokens, is controlled by a 3-of-5 multi-sig setup. Despite these issues, Blast holds a significant position in the market, ranking fourth in total value locked (TVL), just behind Base.

How do they compare?

L2 Comparison

Decentralization

Optimistic Rollups may face certain decentralization challenges in their security model. This stems from their reliance on a limited number of participants who are responsible for challenging any incorrect transaction batches during a specified challenge period. Should these challengers be censored or fail to act, there's a risk that invalid transactions might be erroneously finalized. Most of the sequencing for existing Optimistic rollups are also done by a centralized party, though there are plans to decentralize the sequencers in the future.

ZK-Rollups arguably employ a more robust decentralized security mechanism. They utilize mathematical proofs to validate transactions, which doesn't depend on any external validators. This approach significantly mitigates the risks associated with central points of failure and strengthens the system against censorship, offering a higher level of security and trustworthiness.

Security

Optimistic Rollups, while generally requiring fewer computational resources for transaction verification—thus potentially encouraging wider participation—introduce a delay due to their challenge window. This period, often up to one week, allows transactions to be disputed before they are finalized. Such delays could centralize participation since not all users are willing or able to wait or engage in the dispute process.

Conversely, ZK-Rollups enhance participation by providing faster finality. They achieve this by proving transactions correct through cryptographic means before posting them to the main chain, eliminating the need for a challenge period. This reliance on cryptography over economic incentives or the integrity of specific actors fosters a more trustful and inclusive environment for transaction processing.

Scalability

In contrast, Optimistic Rollups provide improved scalability over Ethereum's main chain but with slower finality due to the fraud proof mechanisms, making them less scalable than ZK-Rollups but potentially easier to implement and manage.

ZK-Rollups offer superior scalability in terms of throughput and finality due to their use of cryptographic proofs that allow for immediate transaction finality and higher data compression. However, this comes at the cost of higher computational demands.

A deeper dive into the main players

Optimistic Rollups

In Optimistic Rollups, transactions are initially executed on the Layer 2 chain, which is faster and more efficient. This is because instead of immediately publishing the results on the Ethereum mainnet, only the transaction data and a cryptographic proof are submitted. These proofs can be used to verify the correctness of the transaction results.

The main idea behind Optimistic Rollups is that the majority of transactions will be valid and will not require any further verification. However, in case of disputes or fraudulent transactions, a challenge period is provided during which anyone can submit a proof of fraud and trigger a verification process. This process involves executing the disputed transactions on the Ethereum mainnet to confirm their validity or identify any discrepancies.

Existing OP rollups are EVM compatible and were relatively less complex to build and release, which is why we saw them launch earlier, and their EVM-equivalence allowing for application developers to easily port their smart contracts to them with minimal fuss. This has resulted in a decently robust and well-established ecosystem on these chains. Familiar examples are Arbitrum and Optimism, which currently make up around 78% of Layer 2 TVL, evidence of a robust DeFi, NFT, and public goods ecosystem that solidifies the case for L2s.

However, a well-known weakness in Optimistic Rollups is it’s 7-day challenge period, within which anyone can submit a proof that disputes the cryptographic proofs that have been sent to Ethereum L1. Before this 7-day challenge period, transactions on OP rollups are assumed to be “correct” (hence the term Optimistic), however this means that true finality will take 7 days, which is not optimal security-wise.

Zk-Rollups

This is where ZK Rollups come into the picture. ZK rollups bundle and validate Layer 2 transactions before submitting a succinct proof to the main blockchain. This results in improved scalability, reduced transaction fees, and faster finality than OP rollups. By generating the zk proof of computation in batches and immediately posting the proofs to the Ethereum blockchain, finality can be essentially guaranteed within a 15-30 minute period (depending on the specific chain).

However, zk proof generation times are still not optimal, due to the relatively large amount of computation power required for generating these proofs. ZK hardware acceleration, maximising the efficiency of proving algorithms, as well as streamlining the whole infrastructure stack will bring us to a place in future where ZK rollups can be performant, fast, and secure.

zkEVMs

zkEVMs, as the name suggests, are a specific type of zk rlloups that retains an EVM-compatible Layer 2, while replacing the batching and proving mechanism with zero knowledge proofs. There are several ways that this can be achieved, aptly outlined in Vitalik’s post on Type-1 to Type-4 zkEVMs, each of them coming with their own pros and cons.

A Type 1 zkEVM essentially retains full EVM-equivalency, however zk proofs will take a very long time to generate, as the original Ethereum execution environment was not originally designed to support verifying zero knowledge proofs, and proving blocks can take up to an hour or more. For example, some hash functions existing currently in Ethereum’s native opcodes are not “zk-friendly”, i.e. easily provable using zero knowledge equations, compared to Poseidon hashes that StarkNet uses, which can be easily broken down into algebraic circuits. Currently, no existing zkEVM that has been launched is Type 1, but much research is currently being done to achieve this.

Type 2 zkEVMs appear to be equivalent on the execution level, but may apply some changes to specific EVM opcodes that are less efficiently provable, and change minor parts of the Ethereum state tree. This improves proving times slightly, but still not to an ideal usable level. Scroll and Polygon Hermez both aim to build a Type 2, however not all functionality of the EVM has been successfully implemented yet.

Type 3 zkEVMs are essentially what projects like Scroll and Polygon have now, with some core functionality such as precompiles converted to a more “zk-provable” form, which makes it slightly less EVM-equivalent, but is what is currently feasible to be launched to mainnet at this stage.

An example of a Type 4 zkEVM would be something like zkSync Era, where a completely new VM has been designed to maximize the efficiency of proving execution with zk algorithms, however this makes it less compatible with existing EVM infrastructure, such as execution clients or debugging frameworks, since they operate mainly through dissecting EVM bytecode. This solution is arguably “easier” to build, since there is more flexibility for the development team to write circuits for the opcodes they choose to adopt.

Going down the list chronologically, zkEVM launches in the past year started with zkSync, leading the pack with their Mainnet Alpha launch in March 2023, which was quickly followed by Polygon’s zkEVM a couple days later, Consensys’s Linea zkEVM in August, and last but certainly not least, Scroll in October 2023. As if there weren’t enough, Immutable also announced plans to build its own zkEVM and Polygon intends to upgrade their existing Polygon PoS chain to a zkEVM Validium as well.

However, traction has been slow for zkEVMs, even though most (if not all) claim to be fully EVM-compatible and developers could, in theory, choose to deploy their existing Solidity smart contracts onto these new chains with minimal changes. Most of these zkEVMs are Type 3, and do not have the full set of capabilities that the current EVM or Optimistic rollups have, while zkSync is a Type 4, implementing its own custom eraVM and does not have 100% of Ethereum opcodes fully mapped yet, at least as of time of writing. Most are working hard towards reaching Type 1 or Type 2 status, but timelines are vague and the issue of long zk-proving times remain, even if they do achieve this status. This results in application developers being hesitant to write and deploy new & innovative applications on these chains, since they are not yet fully fledged, and there is no lack of other EVM chains for developers to choose from that already have established TVL and ecosystem tooling.

User-experience wise, applications on some of these zkEVMs seem to work similarly to existing OP chains, some even with slightly faster transaction execution speeds, which is a good sign of progress in this new innovation.

Starknet

A black horse in the Layer 2 zk-rollup space is Starknet, standing out from the zk-rollup crowd with a completely new architecture built from the ground up, with the goal of supporting native zk proofs and expanding the capabilities of Ethereum mainnet. It utilizes zk-STARKs, which are a quantum-secure and do not require a trusted setup, to generate proofs for transactions on the Starknet L2. It natively supports features such as account abstraction, which was only implemented as ERC-4337 on Ethereum mainnet in 2023, 8 years after its initial launch.

This novel architecture, despite all its upsides, unfortunately (or fortunately for some) results in the chain being very different from the EVM (that all other L2s try to emulate), with Starkware’s Cairo VM requiring a completely new set of developer tooling, all the way from clients and provers to smart contracts themselves. The Starkware team is constantly innovating and iterating the chain as it runs, kind of adopting the “move fast and break things” mindset, which eventually in the long run is ideal for attaining its goal of becoming a performant, decentralised, and secure all-purpose Layer 2.

Starknet’s ecosystem projects are noticeably unique from those on EVM Layer 2s/alt-EVM chains, as we see more novel applications being built that attempt to make the most out of StarkNet’s features and performance capabilities. One example is the existence of fully on-chain games on StarkNet, such as Influence and LootRealms. However, with each mainnet upgrade (that happened at least once every two months on average in 2023), or improvements in it’s base infrastructure, application developers building on StarkNet need to regularly update their code, or in some cases rewrite them completely, to keep up to date with the latest StarkNet versions. The most notable change was the migration from Cairo 0.x to Cairo 1.0 in March 2023. The Cairo language was built by the Starkware team initially with the goal of optimizing the generation of STARK proofs, and was later improved to make writing smart contracts more developer-friendly; Cairo 1.0 is now essentially as abstracted as other common smart contract languages such as Solidity and Rust.

StarkNet is very likely to have the potential to be a major player in the Layer 2 space in the long term, with proven speed and execution using its StarkEx technology in applications such as IMX and dYdX. These applications built on StarkEx were performant due to the limited number of functions required to be optimised on these specific applications, however Starkware’s main challenge now is bringing the same scalability and efficiency to its general purpose Cairo VM on StarkNet. Great efforts have been placed in developer engagement by the Starknet team, as evidenced by their growing ecosystem, however the network is still not at its optimal state currently, and still has a ways to go before the tooling and underlying infrastructure is stable enough to inspire sufficient confidence among EVM developers to potentially make the shift to building on Starknet.

Projects that do not mind the higher technical overhead and wish to push the boundaries of computation, scalability, and utilise features that were previously unfeasible (or just impossible) on existing Layer 2 chains, will be ones that choose Starknet as its base of operations.

Future Developments / Outlook

With the inclusion of EIP-4844 in the recent Dencun update, batched data from Layer 2s can be posted onto Ethereum mainnet in a more efficient and cheaper way, providing gas savings for users and bringing us one step closer to fulfilling Ethereum’s rollup-centric future.

There has also been a recently growing trend towards Layer 3s, such as Kakarot, which aims to build an EVM layer on top of StarkNet to reduce friction for developers building applications on StarkNet, and zkLink, which aims to build a general purpose omnichain Layer 3 that is able to merge the liquidity and capabilities of multiple Layer 2s into one platform.

Data availability solutions such as Celestia and EigenDA, together with Rollups-as-a-Service protocols such as AltLayer and Conduit, will reduce both the technical and financial barriers to entry for teams to spin up new Layer 2 (or Layer 3) chains, and we may see the emergence of more applications deciding to build their own appchains to maximize user experience and efficiency. Restaking services such as EigenLayer and Babylon would also help bootstrap these new networks.

Conclusion

In the long-run, we will likely see a shift from TVL being largely on Optimistic roll-ups to ZK rollups, as ZK hardware acceleration develops and proving algorithms mature, making transactions on zk-rollups feasibly provable for mass usage. Optimism itself is also working towards implementing zk-proving capabilities in the OP Stack, supported by Risc Zero and O(1) Labs.

The upcoming bull market will be a long-awaited (and interesting) stress test for Layer 2s, especially the zkEVMs that have been launched in the bear, as well as StarkNet, as it gradually matures and grows closer to a fully-fledged, stable zk-rollup. Claims will be refuted, and anything less than the truth will be exposed. Teams that are able to grasp the intricacies of managing all facets of growing a successful chain, from iterating on the technology, engaging developers, and retaining users, will be the ones that come out on the other side.


X | Discord | Telegram | Website