Skip to content

Commit 0de8d3d

Browse files
updates after SME review
1 parent 0b8334a commit 0de8d3d

File tree

3 files changed

+35
-10
lines changed

3 files changed

+35
-10
lines changed
217 KB
Loading
270 KB
Loading

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

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,45 @@ The global exit tree root of the L1 info tree is, therefore, the source of truth
88

99
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.
1010

11-
The `PolygonRollupManager.sol` contract calls `updateExitRoot(...)` on the `GlobalExitRootManager` during the sequencing flow to add an exit leaf to the relevant exit tree.
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.
1212

13-
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`.
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.
1414

15-
- If `msg.sender` is the bridge contract, the L1 local exit root is updated.
16-
- If `msg.sender` is the rollup manager, the L2 local exit root is updated.
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.
1716

18-
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.
17+
The exit roots are modified in two key flows; sequencing and bridging.
1918

20-
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.
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`.
2139

22-
The use of two distinct global exit root manager contracts for L1 and L2, as well as separate logic for the bridge contract and each of these global exit root managers, allows for extensive network interoperability.
40+
![Update exit roots via bridging flow](../../../../img/cdk/high-level-architecture/update-exit-roots-via-bridging.png)
2341

24-
Meanwhile, all asset transfers can be validated by any L1 and L2 node due to the accessibility of state data.
42+
1. User initiates a bridging transaction by interacting with the `PolygonZkEVMBridgeV2` contract.
43+
2. The `PolygonZkEVMBridgeV2` contract handles the bridging request and forwards it to the `PolygonRollupManager`.
44+
3. The `PolygonRollupManager` updates the local exit root in the `PolygonZkEVMGlobalExitRootL2` contract.
45+
4. The `PolygonZkEVMGlobalExitRootL2` contract confirms that the local exit root has been updated and notifies the `PolygonRollupManager`.
46+
5. The `PolygonRollupManager` then updates the global exit root in the `PolygonZkEVMGlobalExitRootV2` contract.
47+
6. The `PolygonZkEVMGlobalExitRootV2` contract confirms that the global exit root has been updated and notifies the `PolygonRollupManager`.
48+
7. The `PolygonRollupManager` completes the bridging process and notifies the `PolygonZkEVMBridgeV2`.
49+
8. The `PolygonZkEVMBridgeV2` informs the iuser that the bridging transaction is completed.
2550

2651
## Rollup local exit trees
2752

@@ -44,7 +69,7 @@ Data from `bridgeAsset()` and `bridgeMessage()` calls on the bridge is stored in
4469

4570
## Exit tree for rollups
4671

47-
The roots of the L2 local exit trees feed into a single exit tree that manages state from all participating L2 rollups.
72+
The roots of the L2 local exit trees feed into a single exit tree that manages state from all participating L2 rollups. The state lives in the L1 realm and is accessed at sequencing time.
4873

4974
<center>
5075

@@ -70,7 +95,7 @@ The L1 info tree is stored in the [PolygonZkEVMGlobalExitRootV2.sol](https://git
7095

7196
All subtrees exit roots feed into the leaves of the L1 info tree, which contains the global exit root (GER).
7297

73-
The GER is the fingerprint of the information stored in all trees, and thus represents the true state of the system.
98+
The GER is the fingerprint of the information stored in all trees, and thus represents the global state of the system.
7499

75100
<center>
76101

0 commit comments

Comments
 (0)