Understand zkEVM in Three Minutes: The Pearl of Ethereum's Scalability Solution

ChainNews
2021-09-11 20:29:08
Collection
zkSync 2.0 and Hermez both adopt the zkEVM solution to achieve EVM compatibility, and the maturity and application of ZK Rollup will promote the development of zkEVM.

Written by: DeGate, ChainNews

On September 1st, the Ethereum scaling network Arbitrum announced the official launch of its mainnet public test version. At the same time, Optimism had already opened up to some whitelisted applications, marking the official debut of one of the Ethereum L2 scaling solutions—Optimistic Rollup.

Now, let's turn our attention to another L2 scaling solution, ZK Rollup:

On August 31st, zkSync announced the postponement of its 2.0 version launch. Based on zkEVM, zkSync 2.0 is expected to become the first ZK Rollup compatible with EVM;

On August 13th, Polygon announced the acquisition of the Ethereum Layer 2 scaling solution Hermez for $250 million, with Hermez's core technology being its zkEVM solution;

Also on August 13th, the Ethereum Foundation stated in a regular article about the research and development progress of its supported teams that it had funded the establishment of a team for zkEVM research and development over the past few months.

We know that Vitalik has stated that in comparing the two scaling solutions, in the short term, Optimistic Rollups are likely to excel in general EVM computations, but ultimately, in the medium to long term, with the improvement of ZK-SNARK technology, ZK Rollups will prevail in all scenarios. The so-called "improvement of ZK-SNARK technology" mainly refers to the success of zkEVM.

It is evident that zkEVM has become the crown jewel of Ethereum's scaling solutions. The author hopes that through this article, readers can understand the basic principles and current development status of zkEVM.

1. The Role of zkEVM

To understand the role of zkEVM, we need some preliminary knowledge.

Let's start with Ethereum. Essentially, Ethereum is a transaction-based state machine.

Starting from Ethereum's Genesis State, through one block after another of transactions, it transforms into the final state, which is Ethereum's current state, containing all account addresses and their corresponding account states.

Understand zkEVM in three minutes: The jewel of Ethereum's scaling solutionsource: https://ethfans.org/posts/how-does-ethereum-work-anyway

The entity responsible for processing transactions is the EVM, or The Ethereum Virtual Machine. The EVM operates as a stack machine, where programmers write code using high-level languages like Solidity, which is then compiled into EVM bytecode that the EVM can understand, serving as the standard stack operations for executing various EVM instructions, ultimately producing a new state.

Now the question arises: we know that the ZK Rollup solution requires generating zero-knowledge proofs for transactions on Layer 2, which are then sent back to Layer 1 for verification. To generate zero-knowledge proofs, the transaction processing must comply with the specifications of zk circuit proofs.

However, at the design inception of EVM, it was clearly not considered to support zero-knowledge proofs (after all, that was 6 or 7 years ago, when zero-knowledge proofs had not entered most people's view), which is the significance of zkEVM: a virtual machine that runs on ZK Rollup networks, is compatible with EVM, and is friendly to zero-knowledge proofs.

2. Two Implementation Strategies

Currently, there are mainly two implementation strategies for zkEVM:

  1. Directly support the existing instruction set of EVM, fully compatible with the Solidity instruction set. This approach is used by Hermez and the Ethereum Foundation's zkEVM.

  2. Redesign a virtual machine that is friendly to zero-knowledge proofs while adapting EVM development tools to maintain compatibility with Solidity. This approach is primarily used by zkSync;

For the first strategy, since it fully supports the existing instruction set of EVM, it uses the same compiler as EVM, thus being naturally compatible with the existing ecosystem and development tools, while also better inheriting Ethereum's security model.

For the second strategy, since it is not constrained by the original EVM instruction set, it can more flexibly compile code into an instruction set that is more friendly to zero-knowledge proofs, while also freeing itself from the arduous and heavy work required to maintain compatibility with all existing EVM instruction sets.

In summary, the first strategy offers better compatibility and higher security but requires more work; the second strategy is more flexible and requires less work but demands extra effort in adaptation.

3. Comparison of Major Solutions

Hermez zkEVM

Hermez adopts the first strategy, translating all EVM instruction sets into intermediate instructions (micro opcodes).

As is well known, EVM has some variable-length instructions, such as CALL, EXP, CREATE, etc., which are inherently unfriendly to zk circuit proofs. Using intermediate instructions can express the logic of these instructions more favorably. Intermediate instructions are executed in uVM, which employs a large number of cryptographic tools to achieve zk completeness and uses the Plookup algorithm to enhance proof and verification efficiency.

Understand zkEVM in three minutes: The jewel of Ethereum's scaling solution

Another highlight of Hermez zkEVM's implementation is that it simultaneously uses two proof systems. Specifically, it generates a STARK proof and then uses PLONK or Groth16 to generate a proof for this STARK proof and verify it on Layer 1. This process is akin to a proof of a proof.

The reason for this approach is that although STARK is excellent, its proof size is large, leading to significant overhead during on-chain verification, while Groth16 or PLONK has smaller proof sizes and faster verification speeds. This combination of both, leveraging their respective strengths, easily evokes the scenario of using asymmetric and symmetric encryption algorithms together.

AppliedZKP zkEVM

AppliedZKP zkEVM, like Hermez, adopts the first strategy.

AppliedZKP employs the concept of data bus (Bus Mapping), separating storage and computation. Based on the correct storage data extracted by Bus Mapping, State proof ensures data consistency, while EVM proof verifies the correctness of the computation logic.

Understand zkEVM in three minutes: The jewel of Ethereum's scaling solution

The specific process is as follows:

  1. EVM reads the required relevant state through Bus Mapping, which consists of Storage, Memory, and Stack;
  2. EVM executes the opcode;
  3. EVM writes back the new state through Bus Mapping;
  4. During this process, State proof is responsible for the consistency and correctness of the Bus Mapping read/write information, while EVM proof ensures the correctness of EVM's execution of the opcode.

zkSync EVM

Unlike Hermez and AppliedZKP, zkSync has chosen the second strategy. zkSync's zkEVM is not a replica of EVM but is newly designed to run 99% of Solidity contracts and ensure they work correctly in various situations (including rollbacks and exceptions). At the same time, zkEVM can efficiently generate zero-knowledge proofs in circuits.

zkSync EVM uses TinyRAM to implement a standard instruction set, while instructions that consume a lot of gas, such as SHA256/keccak, are specially implemented in its circuit. Finally, recursive aggregation technology is used to combine all proofs into one to enhance efficiency.

Understand zkEVM in three minutes: The jewel of Ethereum's scaling solutionsource: https://medium.com/matter-labs/zksync-2-0-hello-ethereum-ca48588de179

zkSync has also developed two front-end compilers for zkEVM: Yul and Zinc. Yul is an intermediate Solidity representation that can be compiled into bytecode for different backends; Zinc is a language developed based on Rust for smart contracts and general zero-knowledge proof circuits. This provides developers with greater choice.

At the same time, when building its own compiler, zkSync chose LLVM, the most advanced compiler framework for producing industrial-grade products, to ensure that the compiler is sufficiently complete and has all classic optimizations.

4. In Conclusion

With the continuous efforts of multiple excellent teams, zkEVM technology has matured significantly and is expected to be implemented in about six months. By then, the ZK Rollup scaling solution compatible with EVM will surely shine.

Today, blockchain technology is entering an unprecedented era of great debate. From the competition among public chains to the competition among Ethereum scaling solutions, and even down to specific scaling solutions, different project teams are competing vigorously. I am very fortunate to be part of this vibrant era of blockchain technology.

References:

1. How Ethereum Works

2. zkSync 2.0: Hello Ethereum!

3. Episode 175: zkEVM & zkPorter with Matter Labs

4. Episode 194: zkEVM with Jordi & David from Hermez

5. Exploring Popular zkEVM Solutions: AppliedZKP, Matter Labs, Hermez, and Sin7Y

6. Technical Interpretation of Hermez's zkEVM Design Approach

7. Technical Interpretation of AppliedZKP's zkEVM Design Approach

ChainCatcher reminds readers to view blockchain rationally, enhance risk awareness, and be cautious of various virtual token issuances and speculations. All content on this site is solely market information or related party opinions, and does not constitute any form of investment advice. If you find sensitive information in the content, please click "Report", and we will handle it promptly.
ChainCatcher Building the Web3 world with innovators