Skip to content

Commit 6aca009

Browse files
authored
Merge pull request 0xPolygon#518 from 0xPolygon/empieichO-docs-review
zkEVM docs review: The Architecture low-level section
2 parents 16d2e2d + 97bc877 commit 6aca009

35 files changed

+908
-779
lines changed
Lines changed: 53 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,89 @@
1-
## Introduction (in-development)
1+
The LxLy bridge is an interoperability solution aimed at enabling cross-chain communication among Polygon chains. It facilitates interaction between two L2 chains or between an L2 chain and Ethereum as the L1.
22

3-
The LXLY Bridge is an interoperability solution aimed at enabling cross-chain communication among Polygon chains. It will enable communication between two L2 chains or between an L2 chain and Ethereum as the L1.
4-
5-
The LXLY Bridge SC (or [PolygonZkEVMBridgeV2](https://github.com/0xPolygonHermez/zkevm-contracts/blob/feature/v2ForkID5/contracts/v2/PolygonZkEVMBridgeV2.sol)) is an improved and a more robust version of the [zkEVM Bridge](https://github.com/0xPolygonHermez/zkevm-contracts/blob/feature/v2ForkID5/contracts/PolygonZkEVMBridge.sol) deployed in the Polygon zkEVM mainnet_beta version_.
3+
The LxLy bridge SC (or [PolygonZkEVMBridgeV2](https://github.com/0xPolygonHermez/zkevm-contracts/blob/feature/v2ForkID5/contracts/v2/PolygonZkEVMBridgeV2.sol)) is an improved and a more robust version of the [zkEVM bridge](https://github.com/0xPolygonHermez/zkevm-contracts/blob/feature/v2ForkID5/contracts/PolygonZkEVMBridge.sol) deployed in the Polygon zkEVM mainnet_beta version_.
64

75
Its modular design capacitates projects to deploy their own rollups and connect them to the Polygon ecosystem.
86

97
## Ideal attributes
108

11-
The LXLY Bridge is deployed in the Polygon ecosystem so as to attain the following features and functionalities;
9+
The LxLy bridge is deployed in the Polygon ecosystem to enable the following features and functionalities:
1210

1311
- **Accessibility**: Projects can request creation of a rollup and connect it to the Polygon ecosystem.
14-
- **Unified Liquidity**: All rollups can connect through the same bridge, enabling L2 to L2 bridges.
12+
- **Unified liquidity**: All rollups can connect through the same bridge, enabling L2 to L2 bridges.
1513
- **Polygon CDK**: All the rollups can use the same stack.
16-
- **Rollup-Project Oriented**: Every project can have its own rollup.
17-
- **Cross-Rollup Communication**: All the rollups can communicate using the LxLy bridge.
18-
- **Rollup Upgradability**: All the deployed rollups should be upgradeable in accordance with its own governance mechanism.
14+
- **Rollup-project oriented**: Every project can have its own rollup.
15+
- **Cross-rollup communication**: All the rollups connect and communicate using the LxLy bridge, enabling seamless L2 to L2 bridging.
16+
- **Rollup upgradability**: All the deployed rollups should be upgradeable in accordance with its own governance mechanism.
1917

20-
These functionalities are accomplished by modifying a few key components in the architecture of the zkEVM Bridge Version-1.
18+
These functionalities are accomplished by modifying a few key components in the architecture of the zkEVM bridge version-1.
2119

22-
## zkEVM Bridge Version-1
20+
## zkEVM bridge version-1
2321

24-
Here is a brief review of the zkEVM Bridge's architecture.
22+
Here is a brief review of the zkEVM bridge's architecture.
2523

26-
Version-1 consists mainly of three (3) smart contracts;
24+
Version-1 consists mainly of three (3) smart contracts:
2725

28-
- the Bridge contract ([PolygonZkEVMBridge.sol](https://github.com/0xPolygonHermez/zkevm-contracts/blob/feature/v2ForkID5/contracts/PolygonZkEVMBridge.sol)), which handles transfer of assets and messages between networks.
29-
- the Global Exit Root manager contract ([PolygonZkEVMGlobalExitRoot.sol](https://github.com/0xPolygonHermez/zkevm-contracts/blob/feature/v2ForkID5/contracts/PolygonZkEVMGlobalExitRoot.sol)), which facilitates synchronization of state-info between the L2 and the L1.
30-
- the Polygon zkEVM Consensus contract ([PolygonZkEVM.sol](https://github.com/0xPolygonHermez/zkevm-contracts/blob/feature/v2ForkID5/contracts/PolygonZkEVM.sol)), which handles the sequencing and verification of transactions in the form of batches.
26+
- The bridge contract ([PolygonZkEVMBridge.sol](https://github.com/0xPolygonHermez/zkevm-contracts/blob/feature/v2ForkID5/contracts/PolygonZkEVMBridge.sol)), which handles transfer of assets and messages between networks.
27+
- The global exit root manager contract ([PolygonZkEVMGlobalExitRoot.sol](https://github.com/0xPolygonHermez/zkevm-contracts/blob/feature/v2ForkID5/contracts/PolygonZkEVMGlobalExitRoot.sol)), which facilitates synchronization of state-info between the L2 and the L1.
28+
- The Polygon zkEVM consensus contract ([PolygonZkEVM.sol](https://github.com/0xPolygonHermez/zkevm-contracts/blob/feature/v2ForkID5/contracts/PolygonZkEVM.sol)), which handles the sequencing and verification of transactions in the form of batches.
3129

32-
### Global exit trees Review
30+
### Global exit trees review
3331

34-
Critical to the design of the LXLY Bridge are Exit Trees and the Global Exit Tree.
32+
Critical to the design of the LxLy bridge are exit trees and the global exit tree.
3533

36-
Each chain has a Merkle Tree called an _Exit Tree_, to which a leaf containing data of each asset-transfer is appended. Since such a leaf records data of the asset exiting the chain, it is called an _Exit Leaf_.
34+
Each chain has a Merkle tree called an _exit tree_, to which a leaf containing data of each asset-transfer is appended. Since such a leaf records data of the asset exiting the chain, it is called an _Exit Leaf_.
3735

38-
Another Merkle Tree whose leaves are roots of the various Exit Trees is formed, and it is called the _Global Exit Tree_.
36+
Another Merkle tree whose leaves are roots of the various exit trees is formed, and it is called the _global exit tree_.
3937

40-
The root of the Global Exit Tree is the single source of state-truth communicated between rollups.
38+
The root of the global exit tree is the single source of state-truth communicated between rollups.
4139

42-
It is the Global Exit Root Manager contract's responsibility to update the Global Exit Tree Root and acts as a custodian for the Global Exit Tree's history.
40+
It is the global exit root manager contract's responsibility to update the global exit tree root and acts as a custodian for the global exit tree's history.
4341

44-
A complete transfer of assets in Version-1 involves three smart contracts; the PolygonZkEVM.sol, the PolygonZkEVMBridge.sol and the PolygonZkEVMGlobalExitRoot.sol.
42+
A complete transfer of assets in version-1 involves invoking three smart contracts; `PolygonZkEVM.sol`, `PolygonZkEVMBridge.sol` and `PolygonZkEVMGlobalExitRoot.sol`.
4543

4644
The below figure depicts a _bridge_ of assets and a _claim_ of assets;
4745

4846
![Figure 1: An asset transfer and three Smart Contracts](../../../../img/zkEVM/lxly-1-v1-asset-transfer.png)
4947

50-
Observe, in the above figure, that the Consensus Contract (PolygonZkEVM.sol) is able to;
48+
Observe, in the above figure, that the consensus contract (`PolygonZkEVM.sol`) is able to:
5149

52-
- Retrieve the Global Exit Root from the mainnet, and make it available in L2, and
53-
- Update the Exit Tree Root in the Global Exit Tree Root manager.
50+
- Retrieve the global exit root from the mainnet, and make it available in L2
51+
- Update the exit tree root in the global exit tree root manager.
5452

55-
## LXLY bridge version-2 design
53+
## LxLy bridge version-2 design
5654

57-
Multiple zk-rollups such as zkEVMs, zk-Validiums or zk-VMs, can be created and connected through the same LXLY Bridge.
55+
Multiple ZK rollups such as zkEVMs, zk-Validiums or zk-VMs, can be created and connected through the same LxLy bridge.
5856

59-
Thanks to the introduction of an additional smart contract called the [_Rollup Manager_ SC](https://github.com/0xPolygonHermez/zkevm-contracts/blob/feature/v2ForkID5/contracts/v2/PolygonRollupManager.sol).
57+
Thanks to the introduction of an additional smart contract called the [_rollup manager_](https://github.com/0xPolygonHermez/zkevm-contracts/blob/feature/v2ForkID5/contracts/v2/PolygonRollupManager.sol).
6058

61-
Although the logic for _bridging_ or _claiming_ assets from one network to another remains the same, individual L2 Consensus SC no longer handle verification of their own network's sequenced batches.
59+
Although the logic for _bridging_ or _claiming_ assets from one network to another remains the same, individual L2 consensus contracts no longer handle verification of their own network's sequenced batches.
6260

63-
In the LXLY Bridge context, the _Rollup Manager_ SC verifies sequenced batches from various networks.
61+
In the context of the LxLy bridge, the _rollup manager_ contract verifies sequenced batches from various networks.
6462

65-
In addition to verification of sequenced batches, the _Rollup Manager_ SC also creates consensus contracts for networks connecting via the LXLY Bridge.
63+
In addition to verification of sequenced batches, the _rollup manager_ contract also creates consensus contracts for networks connecting via the LxLy bridge.
6664

6765
### What remains unchanged from version-1?
6866

69-
The strategy to separate the _Bridge logic_ from the _Global Exit Root logic_ remains intact. This is key to achieving interoperability.
67+
The strategy to separate the _bridge logic_ from the _global exit root logic_ remains intact. This is key to achieving interoperability.
7068

71-
Consensus contracts of each connected network handle the sequencing of their own batches, but send the Batch Data to the _Rollup Manager_ SC for verification.
69+
Consensus contracts of each connected network handle the sequencing of their own batches, but send the batch data to the _rollup manager_ contract for verification.
7270

73-
The _Rollup Manager_ SC stores the information of the sequenced batches in the form of a so-called _Accumulated Input Hash_, as in the Version-1 of the zkEVM Bridge.
71+
The _rollup manager_ contract stores the information of the sequenced batches in the form of an _accumulated input hash_, as in the version-1 of the zkEVM bridge.
7472

75-
Once sequenced batches have been verified, the _Global Exit Tree_ gets updated, in an approach similar to the zkEVM Bridge Version-1.
73+
Once sequenced batches have been verified, the _global exit tree_ gets updated, in an approach similar to the zkEVM bridge version-1.
7674

7775
![Figure 2: New version of bridge](../../../../img/zkEVM/lxly-2-new-bridge-design.png)
7876

7977
### Rollup manager's role
8078

81-
The Rollup Manager manages the following lists of availability;
79+
The rollup manager is in charge of the following lists of availability:
8280

83-
- Rollup consensus mechanisms. The list may consist of Consensus contracts such as PolygonZkEVM.sol or zkValidium.sol.
84-
- Verifier contracts. For example, the PolygonZkEVM.sol uses the _Verifier.sol_ SC for verification of batches.
81+
- Rollup consensus mechanisms: The list may consist of consensus contracts such as `PolygonZkEVM.sol` or `zkValidium.sol`.
82+
- Verifier contracts: For example, the `PolygonZkEVM.sol` uses the `Verifier.sol` contract for verification of batches.
8583

86-
Governance SC oversees Consensus mechanisms and Verifiers that can be added to the respective lists.
84+
The governance contract oversees consensus mechanisms and verifiers that can be added to the respective lists.
8785

88-
The [Rollup Manager SC](https://github.com/0xPolygonHermez/zkevm-contracts/blob/feature/v2ForkID5/contracts/v2/PolygonRollupManager.sol) has the relevant function for adding a new rollup;
86+
The [rollup manager contract](https://github.com/0xPolygonHermez/zkevm-contracts/blob/feature/v2ForkID5/contracts/v2/PolygonRollupManager.sol) has the relevant function for adding a new rollup:
8987

9088
```bash
9189
function addNewRollupType(
@@ -98,34 +96,34 @@ The [Rollup Manager SC](https://github.com/0xPolygonHermez/zkevm-contracts/blob/
9896
) ...
9997
```
10098

101-
- In order for a rollup to be created and connected to the LXLY Bridge,
99+
- To create and connect a rollup to the LxLy bridge,
102100

103-
- The developer selects the Consensus and Verifier for the required rollup amongst those available in the Rollup Manager's lists,
101+
- The developer selects the consensus and verifier for the required rollup amongst those available in the rollup manager's lists,
104102
- Requests creation of a rollup with the selected specifications,
105-
- Governance SC invokes the Rollup Manager's `addNewRollupType()` function,
106-
- Once, a rollup is created, the transfer of assets can be processed in the usual manner.
103+
- Governance contract invokes the rollup manager's `addNewRollupType()` function,
104+
- Once a rollup is created, the transfer of assets can be processed in the usual manner.
107105

108106
### Overall flow of events
109107

110-
The below diagram captures the following flow of events, most of which are handled by the Rollup Manager SC;
108+
The following diagram captures the following flow of events, most of which are handled by the rollup manager contract:
111109

112-
- Updating Rollup Manager's lists,
113-
- Creating rollups,
114-
- Sequencing of batches,
115-
- Aggregation or proving of batches,
116-
- Verification of batches,
117-
- Updating the Global Exit Root.
110+
- Updating rollup manager's lists.
111+
- Creating rollups.
112+
- Sequencing of batches.
113+
- Aggregation or proving of batches.
114+
- Verification of batches.
115+
- Updating the global exit root.
118116

119117
![Figure 3: Events flow related to RollupManager.sol](../../../../img/zkEVM/lxly-bridge-diagram.png)
120118

121119
## Conclusion
122120

123-
Although the LXLY Bridge is still in development, it is a central component to Polygon's aggregaton layer which offers multi-chain interoperability.
121+
Although the LxLy bridge is still in development, it is a central component to the AggLayer which offers multi-chain interoperability.
124122

125-
The LXLY Bridge currently works with the Polygon zkEVM as the L2 and the Ethereum network as L1.
123+
The LxLy bridge currently works with the Polygon zkEVM as the L2 and the Ethereum network as L1.
126124

127125
The next step is to enable developers wishing to create a zk-rollup to choose between a zkEVM and a zkValidium rollup.
128126

129127
The idea of handling verification of several networks in a single contract, is a pre-cursor to the ultimate and envisaged _interop layer_ for the Polygon ecosystem.
130128

131-
The code for the LXLY Bridge Version-2 can be found [here](https://github.com/0xPolygonHermez/zkevm-contracts/tree/feature/v2ForkID5/contracts/v2).
129+
The code for the LxLy bridge version-2 can be found [here](https://github.com/0xPolygonHermez/zkevm-contracts/tree/feature/v2ForkID5/contracts/v2).

docs/zkEVM/architecture/protocol/unified-LxLy/ulxly-exit-trees-node.md

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,37 +19,31 @@ The design of the updated global exit tree has two main branches:
1919

2020
![ulxly-mainnet-and-rollup-exit-trees](../../../../img/zkEVM/ulxly-mainnet-and-rollup-exit-trees.png)
2121

22-
## Rollup Identifiers
22+
## Rollup identifiers
2323

2424
Every rollup has a set of distinct identifiers that are essential for its functioning and interaction within the larger network ecosystem.
2525

2626
- The $\texttt{chainID}$ is a unique identifier that distinguishes a rollup from other chains in the Ethereum ecosystem, and it is crucial for preventing replay attacks. See the list of chain IDs of different networks [here](https://chainlist.org/).
2727
- A $\texttt{networkID}$ identifier defines a rollup in the Polygon ecosystem, allowing network participants to uniquely identify and interact with the rollup. The Ethereum mainnet is identified by $\texttt{networkID = 0}$, while the $\texttt{networkID = 1}$ is reserved for the Polygon zkEVM, and so on.
2828
- The $\texttt{rollupIndex}$ is an identifier used to identify a rollup within the rollup tree. The first rollup, being the Polygon zkEVM, has $\texttt{rollupIndex = 0}$. And in general, $\texttt{rollupIndex = networkID - 1}$.
2929

30-
31-
32-
## Global Index
30+
## Global index
3331

3432
When creating and verifying proofs, an index called $\texttt{globalIndex}$ is used to uniquely locate a leaf in the new global exit tree.
3533

36-
A $\texttt{globalIndex}$​​​ is a 256-bit string composed of; unused bits, mainnet flag, rollup index bits and local root index bits.
37-
34+
A $\texttt{globalIndex}$​​​ is a 256-bit string composed of unused bits, mainnet flag, rollup index bits, and local root index bits.
3835

3936
$$
4037
\texttt{globalIndex} = \texttt{(unused bits)_} \texttt{(mainnet flag)_} \texttt{(rollupIndex)_} \texttt{(local root index)}
4138
$$
4239

43-
4440
Starting from the most significant bit, a $\texttt{globalIndex}$ consists of the following bits:
4541

4642
- $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.
4743
- $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$).
4844
- $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$.
4945
- $32$ bits of the local root index: These bits indicate the specific index being pointed at, within each rollup's local exit tree.
5046

51-
52-
5347
The figure below depicts how the $\texttt{globalIndex}$ is interpreted:
5448

5549
- The mainnet exit tree has the $\texttt{globalIndex = X_1_X_3}$, where

docs/zkEVM/architecture/protocol/unified-LxLy/ulxly-interchain-exchanges.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
This covers node configuration parameters, interchange of tokens among chains, and the mention of an issue with CREATE2.
22

3-
### Node Configuration
3+
### Node configuration
44

55
The node configuration for a rollup (or validium) network typically involves specifying various parameters and addresses that are crucial for its operation.
66

@@ -32,12 +32,10 @@ Regarding the creation of the ERC-20 tokens with CREATE2:
3232
- Use $\texttt{salt = 0}$ to create the W-ETH contract.
3333
- Use $\texttt{salt = tokenInfoHash}$ for the rest of the wrapped tokens of the layer with tokenInfoHash defined as the following hash:
3434

35-
3635
$$
3736
\texttt{tokenInfoHash = keccak256(originNetwork, originTokenAddress)}
3837
$$
3938

40-
4139
As a final remark, note that L1 ETH is the only native currency that can be used as a native currency in another layer.
4240

4341
The figure below, illustrates various scenarios of inter-layer exchanges that can occur within the system.

docs/zkEVM/architecture/protocol/unified-LxLy/ulxly-rollupmanager.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ The $\texttt{RollupManager}$ contract has functions; $\texttt{addNewRollupType()
6161

6262
It is not possible to create a new rollup of an obsolete rollup type.
6363

64-
65-
6664
## Rollup data
6765

6866
Although several rollups can be of the same $\texttt{RollupType}$, it's important for each rollup store its state data. This state data is included in a structure called $\texttt{RollupData\{\}}$.
@@ -101,4 +99,3 @@ Below is a schematic representation of the transparent proxy pattern within the
10199
![ulxly-transparent-proxy-pattern](../../../../img/zkEVM/ulxly-transparent-proxy-pattern.png)
102100

103101
Proxies are frequently utilized in Ethereum for upgradability, and the exact usage of proxies in the Polygon zkEVM's upgradability is discussed [here](https://docs.polygon.technology/zkEVM/architecture/protocol/upgradability/).
104-

docs/zkEVM/architecture/protocol/unified-LxLy/ulxly-sequence-verify.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,4 @@ The figure below depicts the verification flow within the rollup manager compone
3333
- Successful verification of a proof is followed by a call to the $\texttt{onVerifyBatches()}$ function.
3434
- At the end of the process, the consensus contract emits the $\texttt{verifyBatches}$ event.
3535

36-
3736
![ulxly-consensus-rollupmanager-aggregator](../../../../img/zkEVM/ulxly-consensus-rollupmanager-aggregator.png)

docs/zkEVM/architecture/protocol/unified-LxLy/ulxly-updating-rollups.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,3 @@ Since the rollup has previously been initialized, the following information need
3838
- The $\texttt{rollupCompatibilityID}$.
3939

4040
Observe that most of these parameters were actually provided by the $\texttt{RollupType}$, but $\texttt{RollupData}$ of already existing rollups is constructed by hand, since they do not follow any rollup type as yet.
41-
42-

0 commit comments

Comments
 (0)