Skip to content

Commit 0810671

Browse files
a bunch more content
1 parent c58376f commit 0810671

16 files changed

+226
-166
lines changed

docs/cdk/agglayer/agglayer-go.md

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ The Agglayer Golang service is a web service designed to receive zero-knowledge
55
!!! warning
66
This service is now deprecating in favor of the more robust and efficient [Rust implementation](agglayer-rs.md).
77

8+
## Architecture
9+
10+
The AggLayer Golang architecture supports interactions with multiple CDK chains for ZKP verification.
11+
12+
It uses PostgreSQL database for storage and interacts with both L1 and L2 chains through configured RPC nodes.
13+
14+
[pic-here]
15+
816
## Get started
917

1018
### Run locally with Docker
@@ -21,28 +29,6 @@ The Agglayer Golang service is a web service designed to receive zero-knowledge
2129
make run-docker
2230
```
2331

24-
### Configure key signing
25-
26-
1. Install `polygon-cli`:
27-
28-
```bash
29-
go install github.com/maticnetwork/polygon-cli@latest
30-
```
31-
32-
2. Create a new signature:
33-
34-
```bash
35-
polygon-cli signer create --kms GCP --gcp-project-id gcp-project --key-id mykey-tmp
36-
```
37-
38-
3. Install `gcloud` CLI and set up ADC:
39-
40-
```bash
41-
gcloud auth application-default login
42-
```
43-
44-
4. Configure `KMSKeyName` in `agglayer.toml`.
45-
4632
## Production set up
4733

4834
1. Ensure only one instance of Agglayer is running at a time.
@@ -75,16 +61,34 @@ The Agglayer Golang service is a web service designed to receive zero-knowledge
7561
go install .
7662
```
7763

64+
### Configure key signing
65+
66+
1. Install `polygon-cli`:
67+
68+
```bash
69+
go install github.com/maticnetwork/polygon-cli@latest
70+
```
71+
72+
2. Create a new signature:
73+
74+
```bash
75+
polygon-cli signer create --kms GCP --gcp-project-id gcp-project --key-id mykey-tmp
76+
```
77+
78+
3. Install `gcloud` CLI and set up ADC:
79+
80+
```bash
81+
gcloud auth application-default login
82+
```
83+
84+
4. Configure `KMSKeyName` in `agglayer.toml`.
85+
7886
### Configure `agglayer.toml`
7987

8088
* `[FullNodeRPCs]` to point to the corresponding L2 full node.
8189
* `[L1]` to point to the corresponding L1 chain.
8290
* `[DB]` section with the managed database details.
8391

84-
## Architecture
85-
86-
Agglayer's architecture includes interactions with multiple CDK chains for ZKP verification. It uses PostgresDB for storage and interacts with both L1 and L2 chains through configured RPC nodes.
87-
8892
## API
8993

9094
Refer to the `cmd` and `client` directories for API implementation details. Documentation and specific API routes can be generated from these sources.

docs/cdk/agglayer/agglayer-rs.md

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,22 @@ AggLayer is a Rust-based web service designed to enhance interoperability among
44

55
The service verifies the soundness of proofs from various CDK chains before forwarding them to L1 for verification.
66

7-
It replaces the previous [Golang implementation](agglayer-go.md)
7+
It replaces the previous [Golang implementation](agglayer-go.md).
88

99
## Architecture
1010

1111
### Components
1212

13-
1. Aggregator: Receives and verifies zk-proofs.
14-
15-
2. Verifier: Confirms the soundness of proofs before submitting them to L1.
13+
- Aggregator: Receives and verifies zk-proofs.
14+
- Verifier: Confirms the soundness of proofs before submitting them to L1.
1615

1716
### Data flow
1817

19-
1. Input: Proofs from various CDK chains.
20-
2. Processing: Verification of proofs.
21-
3. Output: Verified proofs sent to L1.
18+
- Input: Proofs from various CDK chains.
19+
- Processing: Verification of proofs.
20+
- Output: Verified proofs sent to L1.
21+
22+
[pic-here]
2223

2324
## Getting started
2425

@@ -36,17 +37,17 @@ It replaces the previous [Golang implementation](agglayer-go.md)
3637

3738
1. Clone the repository:
3839

39-
```sh
40-
git clone https://github.com/AggLayer/agglayer-rs.git
41-
cd agglayer-rs
42-
```
40+
```sh
41+
git clone https://github.com/AggLayer/agglayer-rs.git
42+
cd agglayer-rs
43+
```
4344

4445
2. Build and run:
4546

46-
```sh
47-
cargo build
48-
cargo run
49-
```
47+
```sh
48+
cargo build
49+
cargo run
50+
```
5051

5152
## How to
5253

@@ -64,32 +65,34 @@ chain_id = "your_chain_id"
6465

6566
1. Run unit tests:
6667

67-
```sh
68-
cargo test
69-
```
68+
```sh
69+
cargo test
70+
```
7071

7172
2. Run integration tests by first ensuring all necessary services are running, then execute:
7273

73-
```sh
74-
cargo test -- --ignored
75-
```
74+
```sh
75+
cargo test -- --ignored
76+
```
7677

7778
## API reference
7879

7980
### Endpoints
8081

81-
1. **Submit proof**:
82-
- **Endpoint**: `/submit_zkp`
83-
- **Method**: POST
84-
- **Payload**:
82+
#### Submit proof
83+
84+
- **Endpoint**: `/submit_zkp`
85+
- **Method**: POST
86+
- **Payload**:
8587

8688
```json
8789
{
8890
"zkp": "base64_encoded_zkp",
8991
"chain_id": "cdk_chain_id"
9092
}
9193
```
92-
- **Response**:
94+
95+
- **Response**:
9396

9497
```json
9598
{

docs/cdk/agglayer/balance-tracking.md

Whitespace-only changes.
Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,75 @@
1-
https://github.com/AggLayer/lxly-bridge-and-call
1+
## Current unified bridge functionality
2+
3+
The unified bridge allows users/contracts to independently bridge an asset or bridge a message between AggLayer connected chains.
4+
5+
More complex operations such as bridge an asset and swap it for another asset, or bridge an asset and deposit it into a vault, require implementing custom logic.
6+
7+
## Interim step
8+
9+
[chain indexer framework ??]
10+
11+
## New bridge and call functionality
12+
13+
The `bridgeAndCall` functionality supports these more complex operations by bridging a token with call data that is executed once bridged. A single call to bridge an asset also sends a message which executes a function.
14+
15+
<center>
16+
![CDK architecture](../../img/cdk/agglayer/bridge-and-call.png)
17+
</center>
18+
19+
## The `bridgeAndCall` function
20+
21+
```solidity
22+
IBridgeAndCall(caller).bridgeAndCall(
23+
token, // the asset to bridge
24+
amount, // how much
25+
optionalPermitData, // instead of using approve
26+
destinationNetwork, // destination chain LxLy id
27+
callAddress, // target contract in the destination chain
28+
fallbackAddress, // in case of call error, fallback receives the asset
29+
callData, // the "message" (function+args)
30+
forceUpdateGlobalExitRoot // true to send this "ASAP"
31+
);
32+
```
33+
34+
The new [`BridgeExtension.sol`](https://github.com/AggLayer/lxly-bridge-and-call/blob/main/src/BridgeExtension.sol) contract exposes the [`bridgeAndCall(...)`](https://github.com/AggLayer/lxly-bridge-and-call/blob/2d83e96ff120fae7f1c8bb1fc1a6cb7f74afa4aa/src/BridgeExtension.sol#L33) function which has the logic for bridging an asset and, at the same time, passing `callData` which includes the logic for receiving the message and making the call to the target contract.
35+
36+
### Requirements and assumptions
37+
38+
- Instances of `BridgeExtension` must have the same address in all chains (because of how `CREATE2` works and we need to pre-compute the `JumpPoint` address).
39+
- This is achieved manually by making sure we deploy the proxy to the same address in all chains.
40+
- Non-manually, we have to keep track of all instances in all supported chains - for all instances of the `BridgeExtension`.
41+
42+
### Bridge and call process flow
43+
44+
#### `BridgeExtension.bridgeAndCall(...)`
45+
46+
1. Check what kind of asset is being bridged (i.e. is it more complex than a fungible asset).
47+
2. Bridge the asset to a precomputed address (the `JumpPoint` address).
48+
3. Create the message with the `callData` (and some additional information).
49+
4. Bridge the message to the destination chain.
50+
51+
#### `claimAsset(...)` and `claimMessage(...)`
52+
53+
1. Claimer performs the claims (`claimAsset` must be executed before `claimMessage` or an error is thrown).
54+
2. `claimAsset` transfers the asset to the `JumpPoint` address.
55+
3. `claimMessage` calls the unified bridge's `BridgeExtension.onMessageReceived(...)` function.
56+
57+
#### `BridgeExtension.onMessageReceived(...)`
58+
59+
1. Decode the message.
60+
2. Instantiate the `JumpPoint` for this execution (the address matches the precomputed one by using the same salt, arguments, and deployer address).
61+
62+
#### `new JumpPoint(...)`
63+
64+
1. Check what kind of asset was bridged.
65+
66+
- If it is an ERC20, approve spending by the target contract.
67+
- Call the target contract with the callData.
68+
- Send the native gas token if it's not an ERC20.
69+
70+
2. In case of error, the asset is sent to a fallback address.
71+
3. `JumpPoint` self-destructs (leaves no trace).
72+
73+
---
74+
75+
For more information, visit the [AggLayer bridge and call repository](https://github.com/AggLayer/lxly-bridge-and-call).

docs/cdk/agglayer/current-state-func.md

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- Balance tracking.
2+
- Decentralization.
3+
- Etc.

docs/cdk/agglayer/overview.md

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
1+
!!! info "Disclaimer"
2+
- Much of the content in this section is discussing technology in development and not ready for release.
3+
- Please check against the main documentation site for any live releases.
4+
- Feel free to experiment with any code in public repos.
15

26
## Welcome to AggLayer documentation
37

4-
AggLayer is an evolving ecosystem of zk-based (zero-knowledge) interacting chains. It addresses the current industry focus on interoperability and shared liquidity.
8+
The culmination of Polygon innovation and design, AggLayer is an evolving ecosystem of zk-based (zero-knowledge) interacting chains. It addresses the current industry focus on interoperability and shared liquidity.
59

6-
AggLayer is a culmination of Polygon innovation and design. While most rollup environments follow a modular approach, where developers pick-and-choose components such as execution and data availability layers for example, the Agglayer vision is uniquely centered around zk-proof technology.
10+
While most rollup environments follow a modular approach, where developers pick-and-choose components such as execution and data availability layers for example, the Agglayer vision is uniquely centered around zk-proof technology.
11+
12+
<center>
13+
![CDK architecture](../../img/cdk/agglayer/mono-modu.png)
14+
</center>
715

816
## AggLayer components
917

18+
AggLayer connects CDK chains and provides a zero-knowledge prover for validity and security.
19+
1020
<center>
1121
![CDK architecture](../../img/cdk/cdk-architecture.png)
1222
</center>
@@ -19,14 +29,14 @@ AggLayer is a culmination of Polygon innovation and design. While most rollup en
1929

2030
### AggLayer
2131

32+
- Running now on the unified bridge technology, AggLayer takes a many-to-many approach to CDK chain interactions which focuses on validity, interoperability, and security.
33+
- It aggregates and batches proofs from multiple CDK chains into a single proof, significantly lowering the verification cost across chains as the ecosystem grows.
34+
2235
<center>
2336
![AggLayer overview](../../img/cdk/agglayer/agg-layer-overview.png)
2437
</center>
2538

26-
- Evolving from the unified bridge technology, AggLayer takes a many-to-many approach to CDK chain interactions which focuses on validity, interoperability, and security.
27-
- It aggregates and batches proofs from multiple CDK chains into a single proof, significantly lowering the verification cost across chains as the ecosystem grows.
28-
- AggLayer ensures seamless and correct ordering of cross-chain transaction execution.
29-
- Implements securely shared liquidity across zk-based chains.
39+
- AggLayer ensures seamless and correct ordering of cross-chain transaction execution and securely-shared liquidity across all zk-based chains.
3040

3141
### Provers
3242

@@ -39,4 +49,10 @@ AggLayer is a culmination of Polygon innovation and design. While most rollup en
3949
![AggLayer overview](../../img/cdk/agglayer/prover.png)
4050
</center>
4151

42-
These documents introduce you to the current unified bridge technology that inspires and underpins AggLayer. We also document some of AggLayer's key technology in development now; such as the Go and Rust libraries, and Plonky prover technology. We also document a little about what the future has in store.
52+
## What to expect
53+
54+
These documents introduce you to the current unified bridge technology that inspires and underpins AggLayer.
55+
56+
We also document some of AggLayer's key technology in development now; such as the Go and Rust libraries, the bridge and call API, and Plonky prover technology.
57+
58+
We also document a little about what the future has in store.

0 commit comments

Comments
 (0)