Skip to content

Commit 9e13701

Browse files
authored
Merge pull request 0xPolygon#159 from 0xPolygon/empieichO-docs-review
Update zkEVM - EVM vs. zkEVM equiv
2 parents e2d82ae + 4085ee7 commit 9e13701

File tree

2 files changed

+72
-38
lines changed

2 files changed

+72
-38
lines changed

docs/zkEVM/architecture/zknode/index.md

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ Any user can participate in this role, as an RPC node.
3131

3232
Required services and components:
3333

34-
- JSON RPC: can run in a separated instance, and can have multiple instances
35-
- Synchronizer: single instance that can run on a separate instance
36-
- Executor & Merkletree: service that can run on a separate instance
37-
- State DB: Postgres SQL that can be run in a separate instance
34+
- JSON RPC: can run on a separated instance, and can have multiple instances.
35+
- Synchronizer: single instance that can run on a separate instance.
36+
- Executor & Merkletree: service that can run on a separate instance.
37+
- State DB: Postgres SQL that can run on a separate instance.
3838

3939
There must be only one synchronizer, and it's recommended that it must have exclusive access to an executor instance, though not necessarily.
4040

41-
The synchronizer role can be run perfectly in a single instance, but the JSON RPC and executor services can benefit from running in multiple instances, if the performance decreases due to the number of received requests.
41+
The synchronizer role can run perfectly in a single instance, but the JSON RPC and executor services can benefit from running in multiple instances, if the performance decreases due to the number of received requests.
4242

4343
- [`zkEVM RPC endpoints`](https://github.com/0xPolygonHermez/zkevm-node/blob/develop/docs/json-rpc-endpoints.md)
4444
- [`zkEVM RPC Custom endpoints documentation`](https://github.com/0xPolygonHermez/zkevm-node/blob/develop/docs/zkEVM-custom-endpoints.md)
@@ -49,27 +49,26 @@ This role can only be performed by a single entity. This is enforced in the smar
4949

5050
Required services and components:
5151

52-
- JSON RPC: can run in a separated instance, and can have multiple instances
53-
- Sequencer & Synchronizer: single instance that needs to run together
54-
- Executor & Merkletree: service that can run on a separate instance
55-
- Pool DB: Postgres SQL that can be run in a separate instance
56-
- State DB: Postgres SQL that can be run in a separate instance
52+
- JSON RPC: can run on a separated instance, and can have multiple instances.
53+
- Sequencer & synchronizer: single instance that needs to run them together.
54+
- Executor & Merkletree: service that can run on a separate instance.
55+
- Pool DB: Postgres SQL that can run on a separate instance.
56+
- State DB: Postgres SQL that can run on a separate instance.
5757

58-
Note that the JSON RPC is required to receive transactions. It's recommended that the JSON RPC runs on separated instances, and potentially more than one (depending on the load of the network). It's also recommended that the JSON RPC and the Sequencer don't share the same executor instance, to make sure that the sequencer has exclusive access to an executor
58+
Note that the JSON RPC is required to receive transactions. It's recommended that the JSON RPC runs on separated instances, and potentially more than one (depending on the load of the network). It's also recommended that the JSON RPC and the sequencer don't share the same executor instance, to make sure that the sequencer has exclusive access to an executor
5959

6060
### Aggregator
6161

6262
This role can be performed by anyone.
6363

6464
Required services and components:
6565

66-
- Synchronizer: single instance that can run on a separated instance
67-
- Executor & Merkletree: service that can run on a separate instance
68-
- State DB: Postgres SQL that can be run in a separate instance
69-
- Aggregator: single instance that can run on a separated instance
70-
- Prover: single instance that can run on a separated instance
71-
- Executor: single instance that can run on a separated instance
66+
- Synchronizer: single instance that can run on a separate instance.
67+
- Executor & Merkletree: service that can run on a separate instance.
68+
- State DB: Postgres SQL that can be run on a separate instance.
69+
- Aggregator: single instance that can run on a separate instance.
70+
- Prover: single instance that can run on a separate instance.
71+
- Executor: single instance that can run on a separate instance.
7272

7373
It's recommended that the prover is run on a separate instance, as it has important hardware requirements. On the other hand, all the other components can run on a single instance.
7474

75-

docs/zkEVM/spec/evm-differences.md

Lines changed: 55 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,81 @@
1-
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.
1+
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.
2+
3+
### EVM-equivalence
4+
5+
Polygon zkEVM is designed to be EVM-equivalent rather than just compatible.
6+
7+
The difference between EVM-compatibility and EVM-equivalence is that;
8+
9+
- Solutions that are compatible support most of the existing applications, but sometimes with code changes. Additionally, compatibility may lead to breaking developer tooling.
10+
11+
- 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.
12+
13+
EVM-equivalence is critical to Polygon zkEVM for several reasons, including the following:
14+
15+
1. Development teams don't have to make changes to their code, and this eliminates the possibility of introducing new security vulnerabilities.
16+
17+
2. No code changes means no need for additional audits. This saves time and money.
18+
19+
3. Since consolidation of batches and finality of transactions is achieved via smart contracts on Ethereum, Polygon zkEVM benefits from the security of Ethereum.
20+
21+
4. EVM-equivalence allows Polygon zkEVM to benefit from the already vibrant and active Ethereum community.
22+
23+
5. It also allows for significant and quick dApp adoption, because applications built on Ethereum are automatically compatible.
24+
25+
Ultimately, Polygon zkEVM offers developers the same UX as on Ethereum, with significantly improved scalability.
26+
227

328
!!!info
429
No impact on developer experience
530

6-
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.
31+
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.
32+
33+
The following differences have no impact on the developer's experience on the zkEVM compared to the EVM:
734

8-
## Opcodes
35+
- Gas optimization techniques.
36+
- Interacting with libraries, like Web3.js and Ethers.js.
37+
- Deploying contracts seamlessly on the zkEVM without any overhead.
938

10-
This section lists the changes we have done with Opcodes in zKEVM as compared to the EVM.
1139

12-
- **SELFDESTRUCT** → removed and replaced by **SENDALL**.
40+
### Opcodes
1341

14-
- **EXTCODEHASH** → returns the hash of the contract bytecode from the zkEVM state tree without checking if the account is empty.
42+
Below is a list of the changes we have made to opcodes in zkEVM in comparison to the EVM.
43+
44+
- **SELFDESTRUCT** → removed and replaced by **SENDALL**.
1545

16-
- **DIFFICULTY** → returns "0" instead of a random number as in the EVM.
46+
- `EXTCODEHASH` returns the hash of the contract bytecode from the zkEVM state tree without checking if the account is empty.
1747

18-
- **BLOCKHASH** → returns all previous block hashes instead of just the last 256 blocks.
48+
- **DIFFICULTY** → returns "0" instead of a random number as in the EVM.
1949

20-
> **BLOCKHASH** is the state root at the end of a processable transaction and is stored on the system smart contract.
50+
- **BLOCKHASH** → returns all previous block hashes instead of just the last 256 blocks.
2151

22-
- **NUMBER** → returns the number of processable transactions.
52+
> **BLOCKHASH** is the state root at the end of a processable transaction and is stored on the system smart contract.
2353
24-
## Precompiled contracts
54+
- **NUMBER** → returns the number of processable transactions.
2555

26-
The following precompiled contracts are supported in the zkEVM:
2756

28-
- [**ecRecover**](https://ethereum.github.io/execution-specs/autoapi/ethereum/frontier/vm/precompiled_contracts/ecrecover/index.html)
29-
- [**identity**](https://ethereum.github.io/execution-specs/autoapi/ethereum/frontier/vm/precompiled_contracts/identity/index.html)
57+
### Precompiled contracts
58+
59+
Among Ethereum's precompiled contracts, the zkEVM currrently supports: [`ecRecover`](https://www.evm.codes/precompiled?fork=shanghai) and [`identity`](https://www.evm.codes/precompiled?fork=shanghai).
60+
61+
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".
3062

31-
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".
3263

3364
## Additions
3465

3566
**zk-counters** → batch resources are available, linked to state-machine components, as a supplementary addition to gas computation.
3667

68+
3769
## Other minor differences
70+
71+
- zkEVM doesn't clean storage when a contract is deployed at an address due to the zkEVM state tree specification.
72+
73+
- `JUMPDEST` is allowed in push bytes to avoid runtime bytecode analysis.
3874

39-
- zkEVM doesn't clean storage when a contract is deployed at an address due to the zkEVM state tree specification.
75+
- The zkEVM implements [EIP-3541](https://eips.ethereum.org/EIPS/eip-3541) from the [London hardfork](https://ethereum.org/en/history/#london).
4076

41-
- **JUMPDEST** opcode is allowed in push bytes to avoid runtime bytecode analysis.
77+
- [EIP-2718](https://eips.ethereum.org/EIPS/eip-2718) which defines the Typed Transaction Envelope, is not supported
4278

43-
- The zkEVM implements [EIP-3541](https://eips.ethereum.org/EIPS/eip-3541) from the [London hardfork](https://ethereum.org/en/history/#london).
79+
- [EIP-2930](https://eips.ethereum.org/EIPS/eip-2930), which defines the Optional Access Lists transaction type, is not supported.
4480

45-
- [EIP-2718](https://eips.ethereum.org/EIPS/eip-2718) which defines **Typed Transaction Envelope**, is not supported
46-
- [EIP-2930](https://eips.ethereum.org/EIPS/eip-2930), which defines the **Optional Access Lists** transaction type, is not supported.
81+
- [`BASEFEE`](https://ethereum-org-fork.netlify.app/en/developers/docs/gas#base-fee) opcode is not supported. The zkEVM implements the Berlin hardfork, but not the London hardfork.

0 commit comments

Comments
 (0)