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/overview.md
+8-8Lines changed: 8 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,14 +16,14 @@ The diagram below is a full and detailed topological overview of the entire Poly
16
16
- Exit root trees: Append-only sparse Merkle trees which record the current and historical state of the system.
17
17
- CDK and zkEVM nodes containing:
18
18
- 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.
Copy file name to clipboardExpand all lines: docs/zkEVM/architecture/high-level/smart-contracts/bridging.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff 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.
2
2
3
3
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.
Copy file name to clipboardExpand all lines: docs/zkEVM/architecture/high-level/smart-contracts/exit-roots.md
+39-40Lines changed: 39 additions & 40 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff 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
4
4
5
5
The global exit tree root of the L1 info tree is, therefore, the source of truth for the whole network.
6
6
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
-

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
-

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
-
47
7
## Rollup local exit trees
48
8
49
9
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(
134
94
- `address destinationAddress`: Address that receives the bridged asset in the destination network.
135
95
- `uint256 leafAmount`: Amount of tokens/ether to bridge.
136
96
- `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
+

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
+

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.
0 commit comments