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: examples/l2/README.md
+52-38Lines changed: 52 additions & 38 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,29 +9,37 @@ After processing the transfers, the vm computes the commitment of the post state
9
9
10
10
Notice a lot of checks that a real L2 should have are missing, since the focus are on the integration of Aligned.
11
11
12
-
## How it works: Step by Step
12
+
## L2 workflow overview
13
13
14
-
This L2 works in two steps. First we need perform the user transfers and prove that state transition inside the zkvm and send it to aligned verification layer (a.k.a fast mode). Then, once our proof has been aggregated by aligned (this happens every 24hs) we need to run the on chain verifier to update the state transition on chain for which we need to retrieve the merkle path for the proof.
14
+
This Layer 2 (L2) system operates in two main steps:
15
15
16
-
### Step 1
16
+
- Off-chain execution and proof generation + verification with Aligned Verification Layer (a.k.a Fast Mode).
17
+
- On-chain state update via proof verification with Aligned aggregation mode.
17
18
18
-
1. Load or initialize the state.
19
-
2. Load user transfers.
20
-
3. Run the zkvm + transfers to perform.
21
-
4. Generate and submit the proof to Aligned.
22
-
5. Store proof binary on disk to be later retrieved by the on chain verifier.
19
+
In Step 1, we execute user transfers and generate a zkVM-based proof of the state transition, which is submitted to Aligned’s verification layer.
23
20
24
-
###Step 2
21
+
In Step 2, once the proof is aggregated (every 24 hours), it is verified on-chain to update the global state.
25
22
26
-
6. Load the proof binary.
27
-
7. Call the smart contract function `updateStateTransition`, which:
28
-
1. Calls `verifyProofInclusion` in the `AlignedProofAggregationService`, which:
29
-
- Computes the proof commitment with the provided `public_inputs` and `program_id`
30
-
- Computes the Merkle Root, using the provided Merkle Proof.
31
-
- Checks the root exists in the aggregation root.
32
-
2. Verifies that the initial_state_root public input matches the on-chain state.
33
-
3. If successful, updates the state root with the post_state_root public input.
34
-
8. If the contract call succeeds, updates the local database.
3.[Docker](https://docs.docker.com/engine/): for SP1 prover
43
51
52
+
## Setup Holeksy
53
+
44
54
#### 1. Create keystore
45
55
46
56
You can use cast to create a local keystore. If you already have one you can skip this step.
@@ -88,7 +98,7 @@ make deploy_contract
88
98
89
99
Save the output contract address.
90
100
91
-
####3. Run L2 program
101
+
### 3. Setup the L2
92
102
93
103
- Generate the base `.env`. For `Holesky` you can run:
94
104
@@ -107,21 +117,9 @@ make gen_env_l2_holesky
107
117
108
118
`make clean_db`
109
119
110
-
- Perform the L2 account updates and prove them in the zkvm:
120
+
Finally [run the l2](#run-the-l2).
111
121
112
-
```shell
113
-
make update_state_transition
114
-
```
115
-
116
-
- Update state transition on chain, you should run this after your proof has been aggregated by aligned (this process happens every 24hs):
117
-
118
-
```shell
119
-
make verify_state_transition_on_chain
120
-
```
121
-
122
-
You should see a transaction receipt in the console and after the stateRoot updated on-chain.
123
-
124
-
### Running it on a local network
122
+
## Setup Localnet
125
123
126
124
You can also run this example on a local devnet. To get started, navigate to the root of the Aligned repository and run:
127
125
@@ -130,8 +128,6 @@ You can also run this example on a local devnet. To get started, navigate to the
130
128
make ethereum_package_start
131
129
# Start the batcher
132
130
make batcher_start_ethereum_package
133
-
# Send proofs to be able to build batches
134
-
make batcher_send_burst_groth16
135
131
```
136
132
137
133
The remaining steps are the same as for other networks, except you'll be using the `devnet` environment. Specifically, generate the `.env` files for `devnet` using:
@@ -148,14 +144,32 @@ By default and to make things simpler, the `.env` will be generated using a dev
148
144
make gen_devnet_owner_wallet
149
145
```
150
146
151
-
Finally, generate the program id with: `make generate_program_id`, copy the address to the generated `.env` and deploy the contract:
147
+
Finally, generate the program id with:
148
+
149
+
````shell
150
+
make generate_program_id
151
+
```
152
+
153
+
Copy the address to the generated `.env` and deploy the contract:
152
154
153
155
```shell
154
156
make deploy_contract
157
+
````
158
+
159
+
Pass the output address in the `.env` and [run the l2](#run-the-l2).
160
+
161
+
## Running the L2
162
+
163
+
- Perform the L2 account updates and prove them in the zkvm:
164
+
165
+
```shell
166
+
make update_state_transition
155
167
```
156
168
157
-
Pass the output address in the `.env` and run the l2:
169
+
- Update state transition on chain, you should run this after your proof has been aggregated by aligned (this process happens every 24hs):
158
170
159
171
```shell
160
-
make run_l2
172
+
make verify_state_transition_on_chain
161
173
```
174
+
175
+
You should see a transaction receipt in the console and after the stateRoot updated on-chain.
0 commit comments