Skip to content

Commit 87c14b3

Browse files
committed
zkEVM, integrate 0xPolygon#47
1 parent 773cefa commit 87c14b3

File tree

27 files changed

+415
-442
lines changed

27 files changed

+415
-442
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
Various Layer 2 solutions aimed at improving the scalability of the Ethereum network, primarily transaction throughput, have been developed over the past years. The ultimate and intended benefit for Ethereum network users is a reduction in gas fees, while maintaining decentralisation and security.
2+
3+
Polygon zkEVM is a Layer 2 Rollup solution that combines data availability and execution verification in Layer 1 of the Ethereum blockchain to ensure L2 state transition security and reliability.
4+
5+
This section will describe the infrastructure that Polygon designed and implemented for its zkEVM, with a focus on providing an overview of the components used in the development of the zkEVM Protocol.
6+
7+
## Components
8+
9+
This section describes the components used in the Polygon zkEVM to enable transaction finality while ensuring the correctness of state transitions.
10+
11+
The three main components of zkEVM protocol are:
12+
13+
- Trusted sequencer
14+
- Trusted aggregator, and
15+
- Consensus Contract (PolygonZkEVM.sol, deployed on L1)
16+
17+
### Trusted sequencer
18+
19+
The Trusted sequencer component is in charge of receiving L2 transactions from users, ordering them, generating batches, and submitting them to the Consensus contract's storage slots in the form of sequences.
20+
21+
The sequencer executes and broadcasts batches of transactions to L2 network nodes in order to achieve fast finality and reduce costs associated with high network usage. That's before even submitting them to L1.
22+
23+
The Trusted sequencer must run a zkEVM node in sequencer mode and be in control of a Consensus Contract-enforced Ethereum account.
24+
25+
### Trusted aggregator
26+
27+
The Trusted aggregator component can compute the L2 State based on batches of L2 transactions executed by the Trusted sequencer.
28+
29+
The main role of the Trusted aggregator, on the other hand, is to take the L2 batches committed by the Trusted sequencer and generate Zero-Knowledge proofs attesting to the batches' computational integrity. These ZK proofs are generated by the aggregator using a special off-chain EVM interpreter.
30+
31+
The Consensus Contract's logic validates the Zero-Knowledge proofs, resulting in the zkEVM inheriting the L1 security. Verification is required before committing new L2 State roots to the Consensus Contract. A verified proof is an irrefutable evidence that a given sequence of batches led to a specific L2 State.
32+
33+
!!!info
34+
L2 State Root
35+
36+
An L2 State root is a concise cryptographic digest of the L2 State. In case you want to read more about State roots, please check out [<ins>this article</ins>](https://ethereum.org/en/developers/docs/scaling/zk-rollups/#state-commitments).
37+
38+
The Trusted aggregator should run a zkEVM node in aggregator mode and must control a specific Ethereum account enforced in a Consensus Contract.
39+
40+
### Consensus contract
41+
42+
The Consensus Contract used by both the Trusted sequencer and the Trusted aggregator in their interactions with L1 is the PolygonZkEVM.sol contract.
43+
44+
The Trusted sequencer can commit batch sequences to L1 and store them in the `PolygonZkEVM.sol` contract, creating a historical repository of sequences.
45+
46+
The `PolygonZkEVM.sol` Contract also enables the aggregator to publicly verify transitions from one L2 State root to the next. The Consensus Contract accomplishes this by validating the aggregator's ZK-proofs, which attest to the proper execution of transaction batches.
47+
48+
## zkEVM node execution modes
49+
50+
zkEVM node is a software package containing all components needed to run zkEVM network. It can be run in three different modes; as a sequencer, an aggregator, or RPC.
51+
52+
### Sequencer mode
53+
54+
In the sequencer mode, the node holds an instance of L2 State, manages batch broadcasting to other L2 network nodes, and has a built-in API to handle L2 user interactions (transaction requests and L2 State queries).
55+
56+
There is also a database to temporarily store transactions that have not yet been ordered and executed (pending transactions pool), as well as all the components required to interact with L1 in order to sequence transaction batches and keep its local L2 State up to date.
57+
58+
### Aggregator mode
59+
60+
In the aggregator mode, the node has all the components needed to execute transaction batches, compute the resulting L2 State and generate the Zero-Knowledge proofs of computational integrity.
61+
62+
Also, has all the components needed to fetch transaction batches committed in L1 by the Trusted sequencer and call the functions to publicly verify the L2 State transitions on L1.
63+
64+
### RPC mode
65+
66+
In the RPC mode, the zKEVM node has a limited functionality. It primarily maintains an up-to-date instance of L2 State, initially with respect to batches broadcast by the Trusted sequencer, and later with sequences of batches fetched from the Consensus Contract.
67+
68+
The node continuously interacts with L1 in order to keep the local L2 State up to date, as well as to check the synchronization of L2 State roots. The default syncing rate for the synchroniser is every 2 seconds, unless stipulated otherwise in the configuration.

docs/zkEVM/architecture/protocol/introduction.md

Lines changed: 0 additions & 68 deletions
This file was deleted.

docs/zkEVM/architecture/protocol/lxly-bridge.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ The LXLY Bridge SC (or [PolygonZkEVMBridgeV2](https://github.com/0xPolygonHermez
66

77
Its modular design capacitates projects to deploy their own rollups and connect them to the Polygon ecosystem.
88

9-
## Ideal Attributes
9+
## Ideal attributes
1010

1111
The LXLY Bridge is deployed in the Polygon ecosystem so as to attain the following features and functionalities;
1212

@@ -31,7 +31,7 @@ Version-1 consists mainly of three (3) smart contracts;
3131

3232
Interaction of these three contracts has been detailed [here](zkevm-bridge/flow-of-assets.md).
3333

34-
### Global Exit Trees Review
34+
### Global exit trees Review
3535

3636
Critical to the design of the LXLY Bridge are Exit Trees and the Global Exit Tree.
3737

@@ -54,7 +54,7 @@ Observe, in the above figure, that the Consensus Contract (PolygonZkEVM.sol) is
5454
- Retrieve the Global Exit Root from the mainnet, and make it available in L2, and
5555
- Update the Exit Tree Root in the Global Exit Tree Root manager.
5656

57-
## LXLY Bridge Version-2 Design
57+
## LXLY bridge version-2 design
5858

5959
Multiple zk-rollups such as zkEVMs, zk-Validiums or zk-VMs, can be created and connected through the same LXLY Bridge.
6060

@@ -78,7 +78,7 @@ Once sequenced batches have been verified, the _Global Exit Tree_ gets updated,
7878

7979
![Figure 2: New version of bridge](../../../img/zkEVM/lxly-2-new-bridge-design.png)
8080

81-
### Rollup Manager's Role
81+
### Rollup manager's role
8282

8383
The Rollup Manager manages the following lists of availability;
8484

@@ -107,7 +107,7 @@ The [Rollup Manager SC](https://github.com/0xPolygonHermez/zkevm-contracts/blob/
107107
- Governance SC invokes the Rollup Manager's `AddNewRollupType()` function,
108108
- Once, a rollup is created, the transfer of assets can be processed in the usual manner.
109109

110-
### Overall Flow of Events
110+
### Overall flow of events
111111

112112
The below diagram captures the following flow of events, most of which are handled by the Rollup Manager SC;
113113

docs/zkEVM/architecture/protocol/malfunction-resistance/aggregator-resistance.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function verifyBatches(
1515
) public ifNotEmergencyState
1616
```
1717

18-
As previously stated, the `verifyBatches` function accepts the same arguments as the `trustedVerifyBatches` function. However, the `verifyBatches` function adds two additional constraints for a sequence to be aggregated, as well as a new L2 State stage called **Pending State**.
18+
As previously stated, the `verifyBatches` function accepts the same arguments as the `trustedVerifyBatches` function. However, the `verifyBatches` function adds two additional constraints for a sequence to be aggregated, as well as a new L2 State stage called Pending State.
1919

2020
Along with the conditions required in the `trustedVerifyBatches` function, the following conditions must also be met in `verifyBatches`:
2121

@@ -41,15 +41,15 @@ struct PendingState {
4141
}
4242
```
4343

44-
Verified batch sequences remain in an intermediate state known as **Pending state**, where their state transition has not yet been consolidated. While in this state, neither the new L2 State root nor the bridge's new `GlobalExitRoot` have been added to the `batchNumToStateRoot` mapping.
44+
Verified batch sequences remain in an intermediate state known as Pending state, where their state transition has not yet been consolidated. While in this state, neither the new L2 State root nor the bridge's new `GlobalExitRoot` have been added to the `batchNumToStateRoot` mapping.
4545

4646
The `lastPendingState` storage variable is used to keep track of the number of pending state transitions that need to be consolidated and serves as the mapping's key of entry. The Aggregator will receive the aggregation reward once the Zero-Knowledge proof has been verified.
4747

4848
The below figure shows the L2 Stages timeline from a batch perspective, and the actions that triggers its inclusion in the next L2 State stage, when a batch sequence is Aggregated through the `verifyBatches` function.
4949

5050
![L2 State stages timeline with pending state](../../../../img/zkEVM/11l2-stages-timeline-pending.png)
5151

52-
The **presence of batch sequences in pending state has no effect on the correct and proper functioning of the protocol**. Non-forced batch sequences are verified before pending ones, and not all sequences enter the pending state.
52+
The presence of batch sequences in pending state has no effect on the correct and proper functioning of the protocol. Non-forced batch sequences are verified before pending ones, and not all sequences enter the pending state.
5353

5454
The storage variable `lastVerifiedBatch` keeps track of the index of the most recently verified and aggregated batch. As a result, even if a batch sequence is pretentiously verified, the index of the last verified batch will be queried via a function called `getLastVerifiedBatch`.
5555

docs/zkEVM/architecture/protocol/malfunction-resistance/emergency-state.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ The following functions will be disabled while in the emergency state:
88
- `sequenceForceBatches`
99
- `proveNonDeterministicPendingState`
1010

11-
As a result, while the contract is in the emergency state, the **Sequencer cannot sequence batches**. Meanwhile, the trusted **Aggregator will be able to consolidate additional state transitions** or override a pending state transition that can be proven to be non-deterministic.
11+
As a result, while the contract is in the emergency state, the Sequencer cannot sequence batches. Meanwhile, the trusted Aggregator will be able to consolidate additional state transitions or override a pending state transition that can be proven to be non-deterministic.
1212

13-
**When the same sequence of batches is successfully verified with two different resulting L2 State root values, a non-deterministic state transition occurs**. This situation could arise if a soundness vulnerability in the verification of the Zero-Knowledge proof of computational integrity is exploited.
13+
When the same sequence of batches is successfully verified with two different resulting L2 State root values, a non-deterministic state transition occurs. This situation could arise if a soundness vulnerability in the verification of the Zero-Knowledge proof of computational integrity is exploited.
1414

1515
## When is the emergency state activated?
1616

17-
The emergency state can only be triggered by **two contract functions**:
17+
The emergency state can only be triggered by two contract functions:
1818

1919
1. It can be directly activated by calling the `activateEmergencyState` function by contract owner.
2020

2121
2. It can also be called by anyone after a `HALT AGGREGATION TIMEOUT` constant delay (of one week) has passed. The timeout begins when the batch corresponding to the `sequencedBatchNum` argument has been sequenced but not yet verified.
2222

23-
This situation directly implies that **no one can aggregate batch sequences**. The objective is to **temporarily stop the protocol until aggregation activity resumes**.
23+
This situation directly implies that no one can aggregate batch sequences. The objective is to temporarily stop the protocol until aggregation activity resumes.
2424

2525
```
2626
function activateEmergencyState(uint64 sequencedBatchNum) external
@@ -64,7 +64,7 @@ function overridePendingState(
6464

6565
To successfully override a pending state, the Trusted Aggregator must submit a proof that will be verified in the same way, as in the `proveNonDeterministicPendingState` function. If the proof is successfully verified, the pending state transition is wiped and a new one is directly consolidated.
6666

67-
To summarize, **the emergency state can only be activated**:
67+
To summarize, the emergency state can only be activated:
6868

6969
- when the contract owner deems it appropriate, or
7070
- when aggregation activity is halted due to a `HALT_AGGREGATION_TIMEOUT`, or

0 commit comments

Comments
 (0)