Bringing Smart Contracts to Layer 2
The Ethereum blockchain has revolutionized decentralized applications through smart contracts, but congestion on its mainnet poses challenges to broader adoption. Layer 2 scaling solutions address this by shifting transaction processing off-chain, but until recently, they lacked support for smart contracts.
Enter zkEVMs: Zero-Knowledge Ethereum Virtual Machines that enable smart contracts on layer 2 while maintaining security. Let’s take a deeper look at zkEVMs, how they work, the challenges faced in building them, examples of currently available systems, and why they represent such an exciting breakthrough.
Key highlights:
- zkEVMs are revolutionizing blockchain scaling by bringing smart contracts to the privacy-preserving world of layer 2 solutions.
- By combining the powerful Ethereum Virtual Machine with zero-knowledge proofs, zkEVMs open the door for completely private yet fully verified smart contract usage.
- Projects like Polygon Hermez and zkSync have already launched mainnets running zkEVM-based contracts. While costs remain high and UX can be rough, advances are being made daily.
How does zkEVM work
To understand zkEVMs, we must first understand how they fit into Ethereum’s layer 2 scaling ecosystem. Ethereum’s layer 1 blockchain is inefficient for high transaction throughput due to constraints like block space and transaction processing speed. Layer 2 solutions address this by batching transactions and processing them off-chain through techniques like optimistic and zero-knowledge rollups.
zkRollups, in particular, utilize zero-knowledge proofs to cryptographically verify transactions without publicly revealing their details. This preserves users’ privacy while allowing trustless validation. However, early zkRollups needed more support for smart contracts since the Ethereum Virtual Machine’s design did not consider proofs. zkEVMs change this by combining the EVM and zero-knowledge proofs.
At a high level, here’s how zkEVMs work:
- A zkEVM runs smart contract code off-chain, transitioning between states just like the mainnet EVM.
- A proving circuit generates zero-knowledge proofs of these state transitions’ validity based on the code, inputs, and new outputs.
- The proofs are submitted to Ethereum, where anyone can validate them without seeing the raw data.
- Once verified, the new application state becomes part of the zkEVM’s EVM-compatible data availability layer.
zkEVMs marry the versatile computation of Ethereum’s EVM with zkRollups’ trustless execution environment and privacy benefits, unlocking smart contracts for scaling. Users enjoy near-instant transactions, while dApps can access the entire Ethereum toolset and ecosystem.
zkEVMs can validate and execute blockchain operations without needing to expose all the details. It’s like saying, “I can prove this transaction or contract is valid and follows the rules, but I won’t show you all the inner workings of it.” Image source: Chainlink
Challenges of building zkEVMs
While zkEVMs opened promising doors, they realized their potential posed major technical challenges. The EVM was never designed with proof, so several aspects conflict with this new paradigm.
For one, the EVM’s stack-based architecture proved difficult to convert to a format compatible with proving. Its special opcodes for error handling also confounded efforts to build verifiable circuits.
Storage was another hurdle, as the EVM’s Merkle Patricia tree clashed with proving needs. Replacing the KECCAK256 hashing function helped but risked breaking infrastructure compatibility.
Most significantly, zero-knowledge proofs demand computationally-intensive operations that drive up costs, especially on-chain. Generating and verifying proofs for each smart contract execution transaction consumed prohibitive resources.
Addressing these issues required rethinking core EVM components and sparking innovations in proofs like optimized circuits and hybrid STARK-SNARK schemes. Much progress has been made, though optimizations continue as the field matures. Perfecting zkEVMs necessitated reconciling two dissimilar yet essential technologies.
Types of zkEVMs
While research continues, several zkEVM systems have already launched, each approaching the technical challenges somewhat differently:
- Polygon Hermez: Leverages a combination of SNARKs and STARKs along with an EVM bytecode interpreter on a zkEVM. Powered by the MATIC token.
- zkSync: Their zkEVM relies on custom zk-opcodes and a register-based virtual machine design. There’s no native token yet, although speculation around an upcoming airdrop launch exists.
- AppliedZKP: An implementation focused on developer ergonomics through Solidity integration.
- Matter Labs ZKSync: Matter Labs uses intermediate representations and an optimizing compiler.
Beyond technical distinctions, these zkEVMs also vary in features, user experience optimizations, and partnership ecosystems. All represent significant milestones in proving EVM compatibility while maintaining practical usability and performance.
Popular zkEVM Projects and Focus Areas
Benefits of zkEVMs
By reconciling Ethereum’s versatile smart contracts with privacy-preserving scaling, zkEVMs promise a wealth of benefits for both users and developers:
- Faster and Cheaper Transactions: With transactions executed off-chain in batches, zkEVMs can process thousands of transactions per second versus Ethereum’s 15 TPS. Gas costs are far lower as well.
- Enhanced Privacy: Users benefit from robust privacy without trusting centralized services, as only cryptographic proofs are revealed on the public blockchain.
- Smart Contract Scaling: dApps gain the ability to scale via layer 2 while retaining core Ethereum benefits like decentralized security.
- Development Continuity: Developers leverage the same Solidity/Vyper languages, tooling, testing frameworks, and vibrant ecosystem of Ethereum.
- Cross-Chain Interoperability: As EVM compatibility improves, bridges may one day allow assets and computations to seamlessly traverse disparate chains.
Widespread adoption of zkEVMs could realize the vision of Ethereum serving as a universal decentralized backplane, with layer 2 networks unleashing its full potential through scalability and privacy. However, challenges remain in proliferating these benefits.
Current status and outlook
While zkEVMs have advanced by leaps and bounds conceptually, major hurdles persist between research and widespread usability at scale. Chief among these are high deployment costs that presently constrain zkEVM usage to niche scenarios and limit overall throughput.
Additionally, integrating complex zkEVM proofs fully into applications introduces UI/UX challenges and risks reducing developer productivity versus more straightforward solutions. However, projects like Manta are working intensively to abstract away this complexity.
Looking ahead, continued optimizations to zkSNARKS/STARKS construction, circuit design, and refining the EVM abstraction layer give hope that costs and usability gaps will steadily recede. Promising developments like zkPorter rollup aggregators may further boost throughputs.
As zkEVM adoption grows, other research avenues like reducing proof sizes, providing advanced cryptography as a cloud service, and using specialized hardware also warrant exploration. Interoperability between networks also remains nascent.
The bottom line
While challenges persist, progress in zkEVMs reveals a future where even massively scaled decentralized applications remain private, low-cost, and fully trusted through smart contracts – goals that seemed inconceivable just years ago. For now, early examples prove the concept works; tomorrow awaits their widespread, user-friendly reality.
If you want to learn more about unique computational use cases that are enabled by blockchain technology, check out our article on Decentralized Physical Infrastructure Networks (DePINs).