You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/zkEVM/architecture/high-level/smart-contracts/exit-roots.md
+35-10Lines changed: 35 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,20 +8,45 @@ The global exit tree root of the L1 info tree is, therefore, the source of truth
8
8
9
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
10
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.
12
12
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.
14
14
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.
17
16
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.
19
18
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
+

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`.
21
39
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
+

23
41
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.
25
50
26
51
## Rollup local exit trees
27
52
@@ -44,7 +69,7 @@ Data from `bridgeAsset()` and `bridgeMessage()` calls on the bridge is stored in
44
69
45
70
## Exit tree for rollups
46
71
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.
48
73
49
74
<center>
50
75
@@ -70,7 +95,7 @@ The L1 info tree is stored in the [PolygonZkEVMGlobalExitRootV2.sol](https://git
70
95
71
96
All subtrees exit roots feed into the leaves of the L1 info tree, which contains the global exit root (GER).
72
97
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.
0 commit comments