forked from 0xPolygon/polygon-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
165 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,81 @@ | ||
This document provides a comprehensive list of differences between the Ethereum Virtual Machine (EVM) and the Polygon Zero-Knowledge Ethereum Virtual Machine (zkEVM). The list includes supported EIPs, opcodes, and additional changes made to build the zkEVM. | ||
This document provides a comprehensive list of differences between the EVM and the Polygon zkEVM. The list includes supported EIPs, opcodes, and additional changes made when building the Polygon zkEVM. | ||
|
||
### EVM-equivalence | ||
|
||
Polygon zkEVM is designed to be EVM-equivalent rather than just being compatible. | ||
|
||
The difference between EVM-compatibility and EVM-equivalence is that; | ||
|
||
- Solutions that are compatible, enable most of the existing applications to work, but sometimes with code changes. Additionally, compatibility may lead to the breaking of developer toolings. | ||
|
||
- Polygon zkEVM strives for EVM-equivalence which means most applications, tools, and infrastructure built on Ethereum can immediately port over to Polygon zkEVM, with limited to no changes needed. Things are designed to work 100% on day one. | ||
|
||
EVM-equivalence is critical to Polygon zkEVM for several reasons, including the following: | ||
|
||
1. Development teams don't have to make changes to their code, and this eliminates any chance for security vulnerabilities to be introduced. | ||
|
||
2. No code changes, means no need for additional audits. This saves time and money. | ||
|
||
3. Since consolidation of batches and finality of transactions is achieved via smart contracts on Ethereum, Polygon zkEVM benefits from the security of Ethereum. | ||
|
||
4. EVM-equivalence allows Polygon zkEVM to benefit from the already vibrant and active Ethereum community. | ||
|
||
5. It also allows for significant and quick dApp adoption, because applications built on Ethereum are automatically compatible. | ||
|
||
Ultimately, Polygon zkEVM offers developers the exact same UX as on Ethereum, with significantly improved scalability. | ||
|
||
|
||
!!!info | ||
No impact on developer experience | ||
|
||
Note that the following differences have no impact on the developer experience with the zkEVM as compared to the EVM. Gas optimization techniques, interacting with libraries like Web3.js and Ethers.js, and deploying contracts works seamlessly on the zkEVM without any overhead. | ||
Note that the following differences have no impact on the developer experience with the zkEVM as compared to the EVM. Gas optimization techniques, interacting with libraries like Web3.js and Ethers.js, and deploying contracts work seamlessly on the zkEVM without any overhead. | ||
|
||
The following differences have no impact on the developer's experience on the zkEVM compared to the EVM: | ||
|
||
## Opcodes | ||
- Gas optimization techniques. | ||
- Interacting with libraries, like Web3.js and Ethers.js. | ||
- Deploying contracts works seamlessly on the zkEVM without any overhead. | ||
|
||
This section lists the changes we have done with Opcodes in zKEVM as compared to the EVM. | ||
|
||
- **SELFDESTRUCT** → removed and replaced by **SENDALL**. | ||
### Opcodes | ||
|
||
- **EXTCODEHASH** → returns the hash of the contract bytecode from the zkEVM state tree without checking if the account is empty. | ||
Below is a list of the changes we have made with Opcodes in zkEVM in comparison to the EVM. | ||
|
||
- **SELFDESTRUCT** → removed and replaced by **SENDALL**. | ||
|
||
- **DIFFICULTY** → returns "0" instead of a random number as in the EVM. | ||
- **EXTCODEHASH** → returns the hash of the contract bytecode from the zkEVM state tree without checking if the account is empty. | ||
|
||
- **BLOCKHASH** → returns all previous block hashes instead of just the last 256 blocks. | ||
- **DIFFICULTY** → returns "0" instead of a random number as in the EVM. | ||
|
||
> **BLOCKHASH** is the state root at the end of a processable transaction and is stored on the system smart contract. | ||
- **BLOCKHASH** → returns all previous block hashes instead of just the last 256 blocks. | ||
|
||
- **NUMBER** → returns the number of processable transactions. | ||
> **BLOCKHASH** is the state root at the end of a processable transaction and is stored on the system smart contract. | ||
## Precompiled contracts | ||
- **NUMBER** → returns the number of processable transactions. | ||
|
||
The following precompiled contracts are supported in the zkEVM: | ||
|
||
- [**ecRecover**](https://ethereum.github.io/execution-specs/autoapi/ethereum/frontier/vm/precompiled_contracts/ecrecover/index.html) | ||
- [**identity**](https://ethereum.github.io/execution-specs/autoapi/ethereum/frontier/vm/precompiled_contracts/identity/index.html) | ||
### Precompiled contracts | ||
|
||
Among Ethereum's precompiled contracts, the zkEVM currrently supports: **ecRecover** and **identity**. | ||
|
||
Other precompiled contracts have no effect on the zkEVM state tree and are treated as reverts, returning all gas to the previous context and setting the `success` flag to "0". | ||
|
||
Other precompiled contracts have no effect on the zkEVM state tree and are treated as a `revert`, returning all gas to the previous context and setting the `success` flag to "0". | ||
|
||
## Additions | ||
|
||
**zk-counters** → batch resources are available, linked to state-machine components, as a supplementary addition to gas computation. | ||
|
||
|
||
## Other minor differences | ||
|
||
- zkEVM doesn't clean storage when a contract is deployed at an address due to the zkEVM state tree specification. | ||
|
||
- **JUMPDEST** opcode is allowed in push bytes to avoid runtime bytecode analysis. | ||
|
||
- zkEVM doesn't clean storage when a contract is deployed at an address due to the zkEVM state tree specification. | ||
- The zkEVM implements [EIP-3541](https://eips.ethereum.org/EIPS/eip-3541) from the [London hardfork](https://ethereum.org/en/history/#london). | ||
|
||
- **JUMPDEST** opcode is allowed in push bytes to avoid runtime bytecode analysis. | ||
- [EIP-2718](https://eips.ethereum.org/EIPS/eip-2718) which defines **Typed Transaction Envelope**, is not supported | ||
|
||
- The zkEVM implements [EIP-3541](https://eips.ethereum.org/EIPS/eip-3541) from the [London hardfork](https://ethereum.org/en/history/#london). | ||
- [EIP-2930](https://eips.ethereum.org/EIPS/eip-2930), which defines the **Optional Access Lists** transaction type, is not supported. | ||
|
||
- [EIP-2718](https://eips.ethereum.org/EIPS/eip-2718) which defines **Typed Transaction Envelope**, is not supported | ||
- [EIP-2930](https://eips.ethereum.org/EIPS/eip-2930), which defines the **Optional Access Lists** transaction type, is not supported. | ||
- [**BASEFEE**](https://ethereum-org-fork.netlify.app/en/developers/docs/gas#base-fee) opcode is not supported. The zkEVM implements Berlin hardfork, but not the London hardfork. |