Skip to content

Commit 0972864

Browse files
authored
Merge branch 'main' into empieichO-docs-review
2 parents 3d95a5d + 264ade4 commit 0972864

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2137
-121
lines changed
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
The LxLy bridge is the native bridging infrastructure for all CDK chains. The way it works is each individual CDK chain deploys an instance of the LxLy bridge that connects to an L1 (Ethereum by default) by deploying contracts that carry out deposit and withdrawal of assets, along with escrow management. These contracts are managed by node operators corresponding to the respective CDK chains.
2+
3+
This changes as the AggLayer v1 goes online, and introduces an upgrade to the existing LxLy architecture in the form of a _unified instance_ of the LxLy bridge that multiple chains can connect to.
4+
5+
## What's the "unified" bridge?
6+
7+
AggLayer envisions a scalability solution that leverages shared state and unified liquidity across multiple ZK-powered chains within the Polygon ecosystem, all powered by the CDK infrastructure.
8+
9+
!!! tip "What's AggLayer?"
10+
11+
Want to learn more about what AggLayer is and what it looks to achieve? Check out [the AggLayer documentation in the Learn space](../../learn/agglayer.md).
12+
13+
All of this cool infrastructure needs a unified channel for easy transmission of assets and messages between the multiple chains connected via the AggLayer. And this is where the unified bridge comes into play. It allows all chains to take advantage of the AggLayer's unified liquidity, lower transaction costs, and more.
14+
15+
!!! tip "Lxly vs unified bridging TL;DR"
16+
17+
- **LxLy bridge:** A ZK bridge that supports asset and message transfers between a zkEVM system and the L1, typically Ethereum.
18+
- **Unified bridge:** A specific instance of an LxLy bridge that allows several chains to connect to it. This instance is specific to the AggLayer v1.
19+
20+
The new unified model of the LxLy bridge introduced as a part of the AggLayer v1 infrastructure has one significant difference from the existing LxLy bridge: any asset bridged onto a CDK chain using the unified bridge is held by the **Unified Escrow** (also referred to as the **Master Escrow**) contract instead of a dedicated bridge contract.
21+
22+
Due to the shared nature of the bridge, chain operators will not have admin access to the funds locked in the master escrow contract, including the funds that belong to their own network.
23+
24+
The ability to manage bridge reserves is crucial to implement staking/restaking and other similar use cases, and is managed by the respective chain operators. How does the unified bridge address this?
25+
26+
## Introducing "Stake the Bridge"
27+
28+
Stake the Bridge, or **STB**, is a feature that lets CDK chain operators maintain control over the assets that are deposited to their respective networks.
29+
30+
### Design and implementation
31+
32+
On L1, CDK chains enable STB for an asset by deploying STB contracts on L1 to create an alternative [`L1Escrow`](https://github.com/pyk/zkevm-stb/blob/main/src/L1Escrow.sol) account that holds the asset, and allows the CDK chain operator to manage this token reserve.
33+
34+
On L2 (the CDK chain), there are three components needed to make this work:
35+
36+
- [`L2Token`](https://github.com/pyk/zkevm-stb/blob/main/src/L2Token.sol), which is a natively deployed ERC20 contract.
37+
- [`L2Escrow`](https://github.com/pyk/zkevm-stb/blob/main/src/L2Escrow.sol), a contract that manages the L2Token's supply.
38+
- [`L2TokenConverter`](https://github.com/pyk/zkevm-stb/blob/main/src/L2TokenConverter.sol), the contract that enables converting bridge-wrapped tokens to natively-minted tokens on L2.
39+
40+
!!! info
41+
42+
Each token needs to have its own set of STB contracts that perform the functions described above.
43+
44+
Let's briefly go over the specific actions and characteristics of each STB contract on L1 and L2.
45+
46+
#### `L1Escrow`
47+
48+
- Defines staking strategies to contribute to network security, or achieve other goals.
49+
- Sending token issuance messages to `L2Escrow`.
50+
- Fulfilling redemption messages from `L2Escrow`.
51+
52+
#### `L2Escrow`
53+
54+
- Receives minting instructions from `L1Escrow` via the unified bridge upon token deposit, and prompts `L2Token` contract to mint assets to a given address on L2.
55+
- Burns the native asset on L2 and sends minting instructions to `L1Escrow` to release assets on L1.
56+
57+
#### `L2Token`
58+
59+
- Natively mints L2 tokens and sends them to a designated address.
60+
- Interfaces with the `L2TokenConverter` contract.
61+
62+
#### `L2TokenConverter`
63+
64+
- Supports 1:1 conversion between the STB minted native tokens, and the bridged tokens minted by depositing tokens to LxLy bridge directly on L1.
65+
- Doesn't have a default cap on the token volume that can be converted, but it can be added by chain operators as necessary.
66+
- An asset can have multiple token converters that can have different properties.
67+
68+
## Roles and responsibilities
69+
70+
There are three roles, each of which performs specific actions to manage the STB system:
71+
72+
- Admin: Can upgrade and pause the system.
73+
- Escrow manager: Can withdraw token backing from the respective escrow contract to stake using the `managerWithdraw()` function and contribute to network security, or achieve other goals.
74+
- Risk manager: Can invoke `setIssuanceCap()` multiple times to increase or reduce the issuance cap.
75+
76+
## STB transaction flow vs. existing LxLy flow
77+
78+
With the STB contracts set up on L1 and L2 for a particular CDK chain, the bridging UX for a user doesn't differ from what it would be if they were carrying it out using the existing LxLy bridge. Let's consider an example using the following tokens:
79+
80+
- USDC - L1
81+
- USDC.e - L2
82+
- LxLy USDC
83+
84+
![](../../img/cdk/stb-1.png)
85+
86+
The diagram above illustrates the following flow:
87+
88+
1. A user initiates a USDC deposit from L1 to L2.
89+
2. Instead of being deposited directly to the unified bridge, the USDC is deposited into the STB `L1Escrow` contract.
90+
3. The STB `L1Escrow` locks the USDC and passes a message to the unified messenger containing the user’s address and amount of USDC being bridged.
91+
4. The `Messenger` contract validates the message and then sends it to the STB `L2Escrow`.
92+
5. The STB `L2Escrow` receives the message and mints USDC.e from the `L2Token` contract.
93+
6. The USDC.e is sent to the user's address on L2.
94+
95+
### Native token conversion
96+
97+
With the introduction of STB, there are now two ways to deposit tokens to an L2 CDK chain, and two distinct resultant tokens:
98+
99+
- The STB flow involves locking tokens in the L1Escrow contract, which is followed by the minting of USDC.e on L2.
100+
- On the other hand, if the tokens are deposited directly into the LxLy bridge contract, it results in the minting of LxLy USDC on L2.
101+
102+
The `L2TokenConverter` facilitates conversion between USDC.e and LxLy USDC. The way it works is by locking (`Deposit` function) either of the tokens in the converter contract, and then sending (`Withdraw` function) the equivalent amount of the other token to the user's wallet.
103+
104+
## Using the STB contracts
105+
106+
The STB contracts grant chain operators control over the token backing in the escrow contracts for all the chains that connect to the Polygon ecosystem via the AggLayer.
107+
108+
!!! warning
109+
110+
Polygon Labs **does not** manage or facilitate the staking of the assets locked in the escrow contracts. Any decision to implement any staking strategies and contribute to network security, or otherwise, is completely at the discretion of the chain operators.
111+
112+
Bridging tokens to L2 CDK chains using the STB contracts is ideal for the following use cases:
113+
114+
- Tokens that need to implement staking/restaking or other mechanisms, or strategies.
115+
- Tokens that need to implement custom L2 functionality.
116+
- Tokens that possess native issuance capabilities.
117+
118+
Want to start testing with STB? The contracts are still being audited, but are ready to use on testnets, and can be found here: https://github.com/pyk/zkevm-stb.

docs/cdk/concepts/dac.md

Lines changed: 0 additions & 6 deletions
This file was deleted.

docs/cdk/concepts/rollup.md

Lines changed: 0 additions & 6 deletions
This file was deleted.

docs/cdk/concepts/validium.md

Lines changed: 0 additions & 4 deletions
This file was deleted.

docs/cdk/get-started/quickstart-validium.md

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This quick start guide shows you how to set up a CDK validium on your local mach
1111
- Explorers L1, L2
1212
- JSON RPC explorer
1313
- L2 gas pricer
14-
- DAC: data availability service, dac setup committee
14+
- DAC: data availability service
1515
- zkEVM bridge service and UI
1616

1717
!!! note
@@ -51,22 +51,16 @@ cp .env.example .env
5151

5252
## 2. Launch validium locally
5353

54-
2.1 Pull the required Docker images from Docker Hub:
55-
56-
```bash
57-
sudo docker-compose pull
58-
```
59-
60-
2.2 After pulling the images, start your local CDK validium:
54+
2.1 Start your local CDK validium:
6155

6256
```bash
6357
sudo make run
6458
```
6559

66-
2.3 To ensure all services are running properly, check the status of each container:
60+
2.2 To ensure all services are running properly, check the status of each container:
6761

6862
```bash
69-
docker-compose ps
63+
docker compose ps
7064
```
7165

7266
You should see the following output:
@@ -77,14 +71,14 @@ You should see the following output:
7771
```shell
7872
Name Command State Ports
7973
----------------------------------------------------------------------------------------------------------------------------------------------
80-
cdk-validium-aggregator /bin/sh -c /app/cdk-validi ... Up 0.0.0.0:50081->50081/tcp,:::50081->50081/tcp, 8123/tcp,
74+
zkevm-aggregator /bin/sh -c /app/cdk-validi ... Up 0.0.0.0:50081->50081/tcp,:::50081->50081/tcp, 8123/tcp,
8175
0.0.0.0:9093->9091/tcp,:::9093->9091/tcp
82-
cdk-validium-approve /bin/sh -c /app/cdk-validi ... Exit 0
83-
cdk-validium-data-availability /bin/sh -c /app/cdk-data-a ... Up 0.0.0.0:8444->8444/tcp,:::8444->8444/tcp
84-
cdk-validium-data-node-db docker-entrypoint.sh postg ... Up (healthy) 0.0.0.0:5444->5432/tcp,:::5444->5432/tcp
85-
cdk-validium-eth-tx-manager /bin/sh -c /app/cdk-validi ... Up 8123/tcp, 0.0.0.0:9094->9091/tcp,:::9094->9091/tcp
86-
cdk-validium-event-db docker-entrypoint.sh postg ... Up 0.0.0.0:5435->5432/tcp,:::5435->5432/tcp
87-
cdk-validium-explorer-json-rpc /bin/sh -c /app/cdk-validi ... Up 8123/tcp, 0.0.0.0:8124->8124/tcp,:::8124->8124/tcp,
76+
zkevm-approve /bin/sh -c /app/cdk-validi ... Exit 0
77+
zkevm-data-availability /bin/sh -c /app/cdk-data-a ... Up 0.0.0.0:8444->8444/tcp,:::8444->8444/tcp
78+
zkevm-data-node-db docker-entrypoint.sh postg ... Up (healthy) 0.0.0.0:5444->5432/tcp,:::5444->5432/tcp
79+
zkevm-eth-tx-manager /bin/sh -c /app/cdk-validi ... Up 8123/tcp, 0.0.0.0:9094->9091/tcp,:::9094->9091/tcp
80+
zkevm-event-db docker-entrypoint.sh postg ... Up 0.0.0.0:5435->5432/tcp,:::5435->5432/tcp
81+
zkevm-explorer-json-rpc /bin/sh -c /app/cdk-validi ... Up 8123/tcp, 0.0.0.0:8124->8124/tcp,:::8124->8124/tcp,
8882
0.0.0.0:8134->8134/tcp,:::8134->8134/tcp
8983
explorer-sig-provider ./sig-provider-serv ... Up 0.0.0.0:8151->8050/tcp
9084
visualizer-proxy /docker-entrypoint ... Up 80/tcp, 0.0.0.0:8083->8081/tcp
@@ -101,23 +95,22 @@ explorer-stats-db-l2 docker-entrypoint.s ... Up
10195
explorer-frontend-l2 sh -c 'bin/blocksco ... Up 0.0.0.0:3001->3000/tcp
10296
explorer-backend-l2 sh -c 'bin/blocksco ... Up 0.0.0.0:4001->4000/tcp
10397
explorer-backend-l2-db docker-entrypoint.sh postg ... Up 0.0.0.0:5437->5432/tcp
104-
cdk-validium-json-rpc /bin/sh -c /app/cdk-validi ... Up 0.0.0.0:8123->8123/tcp,:::8123->8123/tcp,
98+
zkevm-json-rpc /bin/sh -c /app/cdk-validi ... Up 0.0.0.0:8123->8123/tcp,:::8123->8123/tcp,
10599
0.0.0.0:8133->8133/tcp,:::8133->8133/tcp,
106100
0.0.0.0:9091->9091/tcp,:::9091->9091/tcp
107-
cdk-validium-l2gaspricer /bin/sh -c /app/cdk-validi ... Up 8123/tcp
108-
cdk-validium-mock-l1-network geth --http --http.api adm ... Up 30303/tcp, 30303/udp,
101+
zkevm-l2gaspricer /bin/sh -c /app/cdk-validi ... Up 8123/tcp
102+
zkevm-mock-l1-network geth --http --http.api adm ... Up 30303/tcp, 30303/udp,
109103
0.0.0.0:8545->8545/tcp,:::8545->8545/tcp,
110104
0.0.0.0:8546->8546/tcp,:::8546->8546/tcp
111-
cdk-validium-pool-db docker-entrypoint.sh postg ... Up 0.0.0.0:5433->5432/tcp,:::5433->5432/tcp
112-
cdk-validium-prover zkProver -c /usr/src/app/c ... Up 0.0.0.0:50052->50052/tcp,:::50052->50052/tcp,
105+
zkevm-pool-db docker-entrypoint.sh postg ... Up 0.0.0.0:5433->5432/tcp,:::5433->5432/tcp
106+
zkevm-prover zkProver -c /usr/src/app/c ... Up 0.0.0.0:50052->50052/tcp,:::50052->50052/tcp,
113107
0.0.0.0:50061->50061/tcp,:::50061->50061/tcp,
114108
0.0.0.0:50071->50071/tcp,:::50071->50071/tcp
115-
cdk-validium-sequence-sender /bin/sh -c /app/cdk-validi ... Up 8123/tcp
116-
cdk-validium-sequencer /bin/sh -c /app/cdk-validi ... Up 0.0.0.0:6060->6060/tcp,:::6060->6060/tcp, 8123/tcp,
109+
zkevm-sequence-sender /bin/sh -c /app/cdk-validi ... Up 8123/tcp
110+
zkevm-sequencer /bin/sh -c /app/cdk-validi ... Up 0.0.0.0:6060->6060/tcp,:::6060->6060/tcp, 8123/tcp,
117111
0.0.0.0:9092->9091/tcp,:::9092->9091/tcp
118-
cdk-validium-state-db docker-entrypoint.sh postg ... Up 0.0.0.0:5432->5432/tcp,:::5432->5432/tcp
119-
cdk-validium-sync /bin/sh -c /app/cdk-validi ... Up 8123/tcp
120-
dac-setup-committee docker-entrypoint.sh npm r ... Exit 0
112+
zkevm-state-db docker-entrypoint.sh postg ... Up 0.0.0.0:5432->5432/tcp,:::5432->5432/tcp
113+
zkevm-sync /bin/sh -c /app/cdk-validi ... Up 8123/tcp
121114
zkevm-bridge-db docker-entrypoint.sh postg ... Up 0.0.0.0:5438->5432/tcp,:::5438->5432/tcp
122115
zkevm-bridge-service /bin/sh -c /app/zkevm-brid ... Up 0.0.0.0:8080->8080/tcp,:::8080->8080/tcp,
123116
0.0.0.0:9090->9090/tcp,:::9090->9090/tcp
@@ -126,16 +119,16 @@ zkevm-bridge-ui /bin/sh /app/scripts/deploy.sh Up
126119

127120
</details>
128121

129-
2.3.1 If a service isn't running (i.e. it is in `Exit 1` state), investigate further using the logs:
122+
2.2.1 If a service isn't running (i.e. it is in `Exit 1` state), investigate further using the logs:
130123

131124
```bash
132-
sudo docker-compose logs <container_name>
125+
sudo docker compose logs <container_name>
133126
```
134127

135128
!!! info
136129
Find the `<container_name>` in the log output.
137130

138-
2.4 Useful commands
131+
2.3 Useful commands
139132

140133
To stop CDK validium, use:
141134

@@ -146,9 +139,18 @@ sudo make stop
146139
To restart all services:
147140

148141
```bash
149-
sudo make restart
142+
sudo make run-resume
150143
```
151144

145+
To check all running or exited services, use:
146+
147+
```bash
148+
sudo make ps
149+
sudo make ps-exited
150+
```
151+
152+
In this guide, the L2 is launched that allows gasless transactions. To enable transaction gas, you need to first bridge fund from the L1 to the L2 under gasless mode, then run `sudo make gasless off`, stop and restart the services.
153+
152154
!!! note
153155
This local deployment runs on an L1 Geth instance.
154156

0 commit comments

Comments
 (0)