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/agglayer/unified-bridge.md
+2-13Lines changed: 2 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,6 @@ For the **AggLayer**, it is a critical component to facilitate unified experienc
11
11
## Unified Bridge: Data Structure
12
12
13
13
The data structures for the Unified Bridge are as follows:
14
-

15
14
16
15
The AggLayer maintains a merkle tree to record all cross-chain transactions and verify the validity of all cross-chain transactions, ensuring source chain transactions are indeed finalized on the L1 before claiming on the destination chain.
17
16
@@ -23,8 +22,6 @@ All cross-chain transactions using the Unified Bridge are recorded in a Sparse M
23
22
24
23
-`depositCount(Local Root Index)`: The index of the leaf node, per leaf node is a hash of cross-chain transaction such as `bridgeAsset`/`bridgeMessage`.
25
24
26
-

27
-
28
25
### Rollup Exit Root
29
26
30
27
`rollupExitRoot` is the merkle root of all L2s' Local Exit Root. All AggLayer-connected L2s constantly update their Local Exit Root in [`PolygonRollupManager.sol`](https://github.com/0xPolygonHermez/zkevm-contracts/blob/main/contracts/v2/PolygonRollupManager.sol), which updates the Rollup Exit Sparse Merkle Tree.
@@ -33,28 +30,23 @@ For each cross-chain transaction, it is the Source Chain's responsibility to sub
33
30
34
31
Once the RollupManager has updated a `localExitRoot` of an L2, it will then update the `rollupExitRoot` on it, which will then update the `globalExitRoot` in [`PolygonZkEVMGlobalExitRootV2.sol`](https://github.com/0xPolygonHermez/zkevm-contracts/blob/main/contracts/v2/PolygonZkEVMGlobalExitRootV2.sol) on the L1.
35
32
36
-

37
-
38
33
### Mainnet Exit Root
39
34
40
35
`mainnetExitRoot` is functionally the same as the Local Exit Root, but maintained on the L1, which tracks the bridging activities of the L1 to all AggLayer-connected L2s. When the Mainnet Exit Root is updated in the `PolygonZKEVMBridgeV2.sol` contract on the L1, it will then update the `mainnetExitRoot` in the [`PolygonZkEVMGlobalExitRootV2.sol`](https://github.com/0xPolygonHermez/zkevm-contracts/blob/main/contracts/v2/PolygonZkEVMGlobalExitRootV2.sol) on the L1.
41
36
42
-

43
-
44
37
### Global Exit Root, L1 Info Tree, Global Index:
45
38
46
39
`globalExitRoot` is the hash of `rollupExitRoot` and `mainnetExitRoot`. When a new RER or MER is submitted to [`PolygonZkEVMGlobalExitRootV2.sol`](https://github.com/0xPolygonHermez/zkevm-contracts/blob/main/contracts/v2/PolygonZkEVMGlobalExitRootV2.sol), it will append the new GER to the L1 Info Tree. AggLayer-connected chains sync the L1's latest GER by calling the `updateExitRoot` function in the [`PolygonZkEVMGlobalExitRootL2.sol`] contract on L2.
47
40
48
41
`L1InfoTree` is the Sparse Merkle Tree that maintains the GERs. It is a binary tree with a height of 32. The root is updated every time a new GER is submitted.
49
42
50
43
`Global Index` is used to locate the unique leaf in the new global exit tree when creating and verifying the SMT proof. It is a 256-bit string composed of unused bits, mainnet flag, rollup index bits, and local root index bits. Beginning with the most significant, `Global Index` consists of the following bits:
44
+
51
45
-**191 bits of unused bits**: These bits are unused, and can be filled with any value. The best option is to fill them with zeros because zeros are cheaper.
52
46
-**1 bit of mainnet flag**: This single bit serves as a flag indicating whether an exit pertains to a rollup (represented by 0) or the mainnet (indicated by 1).
53
47
-**32 bit of the rollup Index**: These bits indicate the specific rollup being pointed at, within the rollup exit tree. These bits are therefore only used whenever mainnet flag is 0.
54
48
-**32 bits of the local root index**: These bits indicate the specific index being pointed at, within each rollup’s local exit tree.
55
49
56
-

57
-
58
50
## Unified Bridge: Components
59
51
60
52
There are two main components of the Unified Bridge: the on-chain contracts and the off-chain services, along with additional tools to help interact with the Unified Bridge.
@@ -64,6 +56,7 @@ There are two main components of the Unified Bridge: the on-chain contracts and
64
56
The core of the service that acts as the interface for developers to initiate cross-chain transactions and facilitate contract calls on the destination chain if specified. It is deployed on both the source and destination chains.
65
57
66
58
These [contracts](https://github.com/0xPolygonHermez/zkevm-contracts/tree/main/contracts) consist of:
59
+
67
60
-`PolygonZKEVMBridgeV2.sol`: Bridge contract on both L1 and L2, maintains its own LET. It is the access point for all cross-chain transactions, including `bridgeAsset`, `bridgeMessage`, `claimAsset`, and `claimMessage`.
68
61
-`PolygonRollupManager.sol`: Rollup Manager contract on L1, all L2 contracts settle on L1 and update their LET via the Rollup Manager on the L1. Then Rollup Manager updates the RET on L1.
69
62
-`PolygonZkEVMGlobalExitRootV2.sol`: The Global Exit Root contract on the L1 and L2, the root of which is updated each time a new Rollup Exit Root or Mainnet Exit Root is updated.
@@ -110,8 +103,6 @@ These [contracts](https://github.com/0xPolygonHermez/zkevm-contracts/tree/main/c
110
103
- **Claimer**: Any network participant may complete the bridging process by becoming the claimer. The Claim Service can be deployed by dapps, chains, or any individual end-user. There's also an [auto claiming script](https://github.com/0xPolygon/auto-claim-service) which automates the claim process on the destination chain.
111
104
- **[Lxly.js](https://github.com/0xpolygon/lxly.js?tab=readme-ov-file)**: LxLy.js is a javascript library which has all the prebuilt functions for interacting with the unified bridge contracts. It does most of the heavy lifting, including type conversion, formatting, error handling, etc., making it very easy for a developer to invoke the bridge, claim, and other functions required for bridging.
There are two types of bridging transactions on the Unified Bridge.
@@ -348,8 +339,6 @@ There are multiple interfaces and helper contracts, as well as the extension con
348
339
- [`BridgeExtension.sol`](https://github.com/agglayer/lxly-bridge-and-call/blob/755088953ddd2f586a2009ae34a33ae12e60f0eb/src/BridgeExtension.sol): Bridge Extension contract on both L1 and L2 that access the `PolygonZKEVMBridgeV2.sol` contract.
349
340
- [`JumpPoint.sol`](https://github.com/agglayer/lxly-bridge-and-call/blob/755088953ddd2f586a2009ae34a33ae12e60f0eb/src/JumpPoint.sol): Process the Destination Chain asset transfer as well as the contract call.
0 commit comments