Skip to content

Commit a52093f

Browse files
Merge pull request 0xPolygon#511 from 0xPolygon/sc-verifications-1
forgotten updates after review
2 parents 8cde792 + 5b791dc commit a52093f

File tree

7 files changed

+68
-68
lines changed

7 files changed

+68
-68
lines changed
-2.67 KB
Loading

docs/img/learn/innovation-and-design.svg

Lines changed: 15 additions & 18 deletions
Loading

docs/zkEVM/architecture/high-level/overview.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ The diagram below is a full and detailed topological overview of the entire Poly
1616
- Exit root trees: Append-only sparse Merkle trees which record the current and historical state of the system.
1717
- CDK and zkEVM nodes containing:
1818
- JSON RPC client: Exposes the read/write interfaces for interacting with a node/chain.
19-
- Pool database: The pool database records transaction requests coming in from the JSON RPC client and sends them to the sequencer.
20-
- State database: The state database responds to read requests from the JSON RPC client.
21-
- Sequencer: Does the complex job of carefully sequencing transactions as they come in before sending them to the aggregator for batching. See the discussion on [sequencers](../../architecture/index.md#sequencer) for more information.
22-
- Aggregator: Used for aggregating transaction batches to send to the prover. See the discussion on [aggregators](../../architecture/index.md#aggregator) for more information.
23-
- Synchronizer: This component ensures a synchronized state between the node's systems and the L1 outside-world via the Etherman component and the state database.
24-
- Etherman component: The Etherman helps the synchronizer maintain a synchronized state with L1 by communicating with the L1 Ethereum chain via smart contract functions.
25-
- Bridge service component: Provides an API to perform bridge claims, i.e. asset and message transfers between L1/L2 and L2/L2.
26-
- Prover component: System for calculating zero-knowledge proofs on transaction batches.
19+
- Pool database: Records transaction requests coming in from the JSON RPC client and passes them to the sequencer.
20+
- State database: Responds to read requests from the JSON RPC client.
21+
- Sequencer: Does the complex job of fetching transactions and carefully sequencing them before sending them to the aggregator for batching. See the discussion on [sequencers](../../architecture/index.md#sequencer) for more information.
22+
- Aggregator: Aggregates transaction batches to send to the prover. See the discussion on [aggregators](../../architecture/index.md#aggregator) for more information.
23+
- Synchronizer: Ensures a synchronized state between the node's systems and the L1 outside-world via the Etherman component and the state database.
24+
- Etherman: Helps the synchronizer maintain a synchronized state with L1 by communicating with the L1 Ethereum chain via smart contract functions.
25+
- Unified bridge service: Provides an API to perform bridge claims, i.e. asset and message transfers between L1/L2 and L2/L2.
26+
- Prover: System for calculating zero-knowledge proofs on transaction batches.
2727

2828
## What to expect
2929

docs/zkEVM/architecture/high-level/smart-contracts/api/lib/PolygonZkEVMGlobalExitRootBaseStorage.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ Abstract contract required to preserve the storage slots from previous versions.
22

33
## Functions
44

5+
None.
6+
7+
## Variables
8+
59
### `lastRollupExitRoot`
610

711
Rollup root, contains all exit roots of all rollups.

docs/zkEVM/architecture/high-level/smart-contracts/bridging.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
The unified bridge transfers assets and messages between networks (L1, L2) by calling bridge and claim functions on the [PolygonZkEVMBridgeV2.sol](https://github.com/0xPolygonHermez/zkevm-contracts/blob/main/contracts/v2/PolygonZkEVMBridgeV2.sol) contract which can act as an upgradeable proxy via the library imports.
1+
The unified bridge transfers assets and messages between networks (L1, L2) by calling bridge and claim functions on the [PolygonZkEVMBridgeV2.sol](https://github.com/0xPolygonHermez/zkevm-contracts/blob/main/contracts/v2/PolygonZkEVMBridgeV2.sol) contract whose deployment address is an [upgradeable proxy](https://etherscan.io/address/0x2a3DD3EB832aF982ec71669E178424b10Dca2EDe#code). Interaction with the actual contract happens via the proxy.
22

33
This contract is deployed on L1 and there is also one deployed on every L2 network. It communicates closely with an exit root manager contract specific to L1 or L2.
44

docs/zkEVM/architecture/high-level/smart-contracts/exit-roots.md

Lines changed: 39 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,46 +4,6 @@ The Merkle root of an exit tree is known as the exit tree root, and it is the fi
44

55
The global exit tree root of the L1 info tree is, therefore, the source of truth for the whole network.
66

7-
## Updating system state
8-
9-
The system uses a set of [exit tree roots](exit-roots.md) to manage system state. Leaves of the trees point to transaction data such as detailed above.
10-
11-
Adding a new leaf to the tree triggers an update to the exit tree root which then propagates to an update on the global exit tree root.
12-
13-
Using Merkle tree exit roots in this way, referenced by the bridge contracts and accessible to the `PolygonRollupManager` contract with getters, the bridge contract triggers data synchronization across L1 and L2, including at the sequencer and state db level.
14-
15-
The use of two distinct global exit root manager contracts for L1 and L2, as well as separate logic for the sequencing flow and the bridge contract, allows for extensive network interoperability. Meanwhile, all asset transfers can be validated by any L1 and L2 node due to the accessibility of state data.
16-
17-
The exit roots are modified in two key flows; sequencing and bridging.
18-
19-
### Sequencing flow
20-
21-
The `PolygonZkEVMGlobalExitRootV2` contract manages updates to the exit roots on sequencing The contract calls `updateExitRoot(...)` on the `GlobalExitRootManager` during the sequencing flow to add an exit leaf to the relevant exit tree.
22-
23-
![Update exit roots via sequencing flow](../../../../img/cdk/high-level-architecture/update-exit-roots-via-sequencing.png)
24-
25-
1. Initiate update: `PolygonZkEVMEtrog` initiates the update process by calling `updateExitRoots` on `PolygonRollupBaseEtrog`.
26-
2. Retrieve current roots: `PolygonRollupBaseEtrog` retrieves the current local and global exit roots from `PolygonZkEVMGlobalExitRootL2` and `PolygonZkEVMGlobalExitRootV2` respectively.
27-
3. Compute new exit root: `PolygonRollupBaseEtrog` computes the new exit root based on the retrieved local and global exit roots.
28-
4. Update local exit root: `PolygonRollupBaseEtrog` updates the local exit root in `PolygonZkEVMGlobalExitRootL2`.
29-
5. Update global exit root: `PolygonRollupBaseEtrog` updates the global exit root in `PolygonZkEVMGlobalExitRootV2`.
30-
6. Verify updated exit root: `PolygonRollupBaseEtrog` calls `getRollupExitRoot` on `PolygonRollupManager` to verify the updated exit root.
31-
32-
!!! tip "L1 or L2 update"
33-
- If `msg.sender` is the bridge contract, the L1 local exit root is updated.
34-
- If `msg.sender` is the rollup manager, the L2 local exit root is updated.
35-
36-
### Bridging flow
37-
38-
When bridging, the global exit root is updated if the [`forceUpdateGlobalExitRoot`](https://github.com/0xPolygonHermez/zkevm-contracts/blob/main/contracts/v2/PolygonZkEVMBridgeV2.sol#L312) variable is set to `true`.
39-
40-
![Update exit roots via bridging flow](../../../../img/cdk/high-level-architecture/update-exit-roots-via-bridging.png)
41-
42-
1. The user interacts with the `PolygonZkEVMBridgeV2` contract by calling the `bridge()` and `claim()` functions.
43-
2. For both bridge() and claim():
44-
`PolygonZkEVMBridgeV2` calls `updateLocalExitRoot()` on `PolygonZkEVMGlobalExitRootL2`, which updates the local exit root.
45-
3. If `forceUpdateGlobalExitRoot` is set to true, `PolygonZkEVMBridgeV2` calls `updateGlobalExitRoot()` on `PolygonZkEVMGlobalExitRootV2`, which updates the global exit root.
46-
477
## Rollup local exit trees
488

499
The L2 bridge contract manages a special Merkle tree called a local exit tree for each network that participates in bridging and claiming which is updated by the [PolygonZkEVMGlobalExitRootL2.sol](https://github.com/0xPolygonHermez/zkevm-contracts/blob/feature/etrog/contracts/PolygonZkEVMGlobalExitRootL2.sol) contract.
@@ -134,3 +94,42 @@ _addLeaf(
13494
- `address destinationAddress`: Address that receives the bridged asset in the destination network.
13595
- `uint256 leafAmount`: Amount of tokens/ether to bridge.
13696
- `bytes32 keccak256(metadata)`: Hash of the metadata. This metadata contains information about assets transferred or the message payload.
97+
98+
## Updating system state
99+
100+
The system uses a set of [exit tree roots](exit-roots.md) to manage system state. Leaves of the trees point to transaction data such as detailed above.
101+
102+
Adding a new leaf to the tree triggers an update to the exit tree root which then propagates to an update on the global exit tree root.
103+
104+
Using Merkle tree exit roots in this way, referenced by the bridge contracts and accessible to the `PolygonRollupManager` contract with getters, the bridge contract triggers data synchronization across L1 and L2, including at the sequencer and state db level.
105+
106+
The use of two distinct global exit root manager contracts for L1 and L2, as well as separate logic for the sequencing flow and the bridge contract, allows for extensive network interoperability. Meanwhile, all asset transfers can be validated by any L1 and L2 node due to the accessibility of state data.
107+
108+
The exit roots are modified in two key flows; sequencing and bridging.
109+
110+
### Sequencing flow
111+
112+
The `PolygonZkEVMGlobalExitRootV2` contract manages updates to the exit roots on sequencing. The contract calls `updateExitRoot(...)` on the `GlobalExitRootManager` during the sequencing flow to add an exit leaf to the relevant exit tree.
113+
114+
![Update exit roots via sequencing flow](../../../../img/cdk/high-level-architecture/update-exit-roots-via-sequencing.png)
115+
116+
1. Initiate update: `PolygonZkEVMEtrog` initiates the update process by calling `updateExitRoots` on `PolygonRollupBaseEtrog`.
117+
2. Retrieve current roots: `PolygonRollupBaseEtrog` retrieves the current local and global exit roots from `PolygonZkEVMGlobalExitRootL2` and `PolygonZkEVMGlobalExitRootV2` respectively.
118+
3. Compute new exit root: `PolygonRollupBaseEtrog` computes the new exit root based on the retrieved local and global exit roots.
119+
4. Update local exit root: `PolygonRollupBaseEtrog` updates the local exit root in `PolygonZkEVMGlobalExitRootL2`.
120+
5. Update global exit root: `PolygonRollupBaseEtrog` updates the global exit root in `PolygonZkEVMGlobalExitRootV2`.
121+
6. Verify updated exit root: `PolygonRollupBaseEtrog` calls `getRollupExitRoot` on `PolygonRollupManager` to verify the updated exit root.
122+
123+
!!! tip "L1 or L2 update"
124+
- If `msg.sender` is the bridge contract, the L1 local exit root is updated.
125+
- If `msg.sender` is the rollup manager, the L2 local exit root is updated.
126+
127+
### Bridging flow
128+
129+
When bridging, the global exit root is updated if the [`forceUpdateGlobalExitRoot`](https://github.com/0xPolygonHermez/zkevm-contracts/blob/main/contracts/v2/PolygonZkEVMBridgeV2.sol#L312) variable is set to `true`.
130+
131+
![Update exit roots via bridging flow](../../../../img/cdk/high-level-architecture/update-exit-roots-via-bridging.png)
132+
133+
1. The user interacts with the `PolygonZkEVMBridgeV2` contract by calling the `bridge()` function.
134+
2. `PolygonZkEVMBridgeV2` calls `updateLocalExitRoot()` on `PolygonZkEVMGlobalExitRootL2`, which updates the local exit root.
135+
3. If `forceUpdateGlobalExitRoot` is set to true, `PolygonZkEVMBridgeV2` calls `updateGlobalExitRoot()` on `PolygonZkEVMGlobalExitRootV2`, which updates the global exit root.

docs/zkEVM/architecture/high-level/smart-contracts/main-contracts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ It is a lighter-weight version of the global exit root contract mentioned previo
7777

7878
#### Key functionality
7979

80-
- Stores every global exit root in the `globalExitRootMap`. The root of this map is the timestamp.
80+
- Stores every global exit root in the `globalExitRootMap` where keys are global exit roots and values are timestamps.
8181
- Updates the `lastRollupExitRoot` on any bridge call.
8282
- Updates the L2 network and global exit root with the `updateExitRoot(...)` function.
8383

0 commit comments

Comments
 (0)