Skip to content

Commit 3af2dba

Browse files
ilitterixqftCopilotilitterijrchatruc
authored
docs(l2): update L2 docs (#5358)
**Motivation** - Update testnet deployment guides (based deployment tbd) - Add how to run prover guides - Update prover docs --------- Co-authored-by: Estéfano Bargas <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: ilitteri <[email protected]> Co-authored-by: Javier Chatruc <[email protected]>
1 parent 7559ed1 commit 3af2dba

27 files changed

+962
-454
lines changed

docs/SUMMARY.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,21 @@
3131
# Ethrex for L2 chains
3232

3333
- [Introduction](./l2/introduction.md)
34-
- [Deploy an L2](./l2/deploy.md)
34+
- [Deploy an L2](./l2/deployment/README.md)
35+
- [Overview](./l2/deployment/overview.md)
36+
- [Deploying a vanilla ethrex L2](./l2/deployment/vanilla.md)
37+
- [Deploying a validium ethrex L2](./l2/deployment/validium.md)
38+
- [Deploying a based ethrex L2](./l2/deployment/based.md)
39+
- [Synchronous Composability PoC](./l2/deployment/synchronous_composability_poc.md)
40+
- [Run a prover](./l2/deployment/prover/README.md)
41+
- [Overview](./l2/deployment/prover/overview.md)
42+
- [Run an ethrex SP1 prover](./l2/deployment/prover/sp1.md)
43+
- [Run an ethrex RISC0 prover](./l2/deployment/prover/risc0.md)
44+
- [Run an ethrex TDX prover](./l2/deployment/prover/tee.md)
45+
- [Run multiple provers](./l2/deployment/prover/multi-prover.md)
3546
- [Monitoring and metrics](./l2/monitoring.md)
3647
- [Admin server](./l2/admin.md)
48+
- [Ethrex <> Aligned](./l2/aligned_integration.md)
3749
- [Architecture](./l2/architecture/README.md)
3850
- [Overview](./l2/architecture/overview.md)
3951
- [Sequencer](./l2/architecture/sequencer.md)
@@ -45,9 +57,13 @@
4557
- [Withdraw assets](./l2/interacting/withdraw.md)
4658
- [Connect a wallet](./l2/interacting/wallet.md)
4759
- [Deploy a contract](./l2/interacting/deploy_contracts.md)
60+
- [Blockscout for ethrex L2](./l2/interacting/blockscout.md)
61+
- [L2 Hub](./l2/interacting/l2_hub.md)
4862
- [Fundamentals](./l2/fundamentals/README.md)
4963
- [State diffs](./l2/fundamentals/state_diffs.md)
5064
- [Block vs StateDiff](./l2/fundamentals/block_vs_state_diff_measurements.md)
65+
- [Data availability](./l2/fundamentals/data_availability.md)
66+
- [Execution witness](./l2/fundamentals/execution_witness.md)
5167
- [Deposits](./l2/fundamentals/deposits.md)
5268
- [Withdrawals](./l2/fundamentals/withdrawals.md)
5369
- [Smart contracts](./l2/fundamentals/contracts.md)
@@ -76,7 +92,10 @@
7692
- [L2](./developers/l2/introduction.md)
7793
- [Ethrex L2 as local development mode](./developers/l2/dev-mode.md)
7894
- [Integration tests](./developers/l2/integration-tests.md)
95+
- [Running the Prover](./developers/l2/prover.md)
7996
- [Generate blobs for the state reconstruction test](./developers/l2/state-reconstruction-blobs.md)
97+
- [Prover](./prover/prover.md)
98+
- [Guest program](./prover/guest_program.md)
8099
- [Rich Accounts](./developers/rich-accounts.md)
81100
- [Debugging solidity with ethrex](./vm/levm/debug.md)
82101
- [Re-execute Ethereum with ethrex](./ethrex_replay/ethrex_replay.md)

docs/developers/l2/prover.md

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
# Running the Prover
2+
3+
This guide provides instructions for setting up and running the Ethrex L2 prover for development and testing purposes.
4+
5+
## Dependencies
6+
7+
Before you begin, ensure you have the following dependencies installed:
8+
9+
- [RISC0](https://dev.risczero.com/api/zkvm/install)
10+
1. `curl -L https://risczero.com/install | bash`
11+
2. `rzup install`
12+
- [SP1](https://docs.succinct.xyz/docs/sp1/introduction)
13+
1. `curl -L https://sp1up.succinct.xyz | bash`
14+
2. `sp1up --version 5.0.8`
15+
- [SOLC](https://docs.soliditylang.org/en/latest/installing-solidity.html)
16+
17+
After installing the toolchains, a quick test can be performed to check if we have everything installed correctly.
18+
19+
### L1 block proving
20+
21+
ethrex-prover is able to generate execution proofs of Ethereum Mainnet/Testnet blocks. An example binary was created for this purpose in `crates/l2/prover/bench`. Refer to its README for usage.
22+
23+
## Dev Mode
24+
25+
To run the blockchain (`proposer`) and prover in conjunction, start the `Prover`, use the following command:
26+
27+
```sh
28+
make init-prover-<sp1|risc0|exec> # optional: GPU=true
29+
```
30+
31+
### Run the whole system with the prover - In one Machine
32+
33+
> [!NOTE]
34+
> Used for development purposes.
35+
36+
1. `cd crates/l2`
37+
2. `make rm-db-l2 && make down`
38+
- It will remove any old database, if present, stored in your computer. The absolute path of SQL is defined by [datadir](https://docs.rs/dirs/latest/dirs/fn.datadir.html).
39+
3. `make init`
40+
- Make sure you have the `solc` compiler installed in your system.
41+
- Init the L1 in a docker container on port `8545`.
42+
- Deploy the needed contracts for the L2 on the L1.
43+
- Start the L2 locally on port `1729`.
44+
4. In a new terminal &rarr; `make init-prover-<sp1|risc0|exec> # GPU=true`.
45+
46+
After this initialization we should have the prover running in `dev_mode` &rarr; No real proofs.
47+
48+
## GPU mode
49+
50+
**Steps for Ubuntu 22.04 with Nvidia A4000:**
51+
52+
1. Install `docker` &rarr; using the [Ubuntu apt repository](https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository)
53+
- Add the `user` you are using to the `docker` group &rarr; command: `sudo usermod -aG docker $USER`. (needs reboot, doing it after CUDA installation)
54+
- `id -nG` after reboot to check if the user is in the group.
55+
2. Install [Rust](https://www.rust-lang.org/tools/install)
56+
3. Install [RISC0](https://dev.risczero.com/api/zkvm/install)
57+
4. Install [CUDA for Ubuntu](https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&Distribution=Ubuntu&target_version=22.04&target_type=deb_local)
58+
- Install `CUDA Toolkit Installer` first. Then the `nvidia-open` drivers.
59+
5. Reboot
60+
6. Run the following commands:
61+
62+
```sh
63+
sudo apt-get install libssl-dev pkg-config libclang-dev clang
64+
echo 'export PATH=/usr/local/cuda/bin:$PATH' >> ~/.bashrc
65+
echo 'export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc
66+
```
67+
68+
### Run the whole system with a GPU Prover
69+
70+
Two separate machines are recommended for running the `Prover` and the `sequencer` to avoid resource contention. However, for development, you can run them in two separate terminals on the same machine.
71+
72+
- **Machine 1 (or Terminal 1)**: For the `Prover` (GPU is recommended).
73+
- **Machine 2 (or Terminal 2)**: For the `sequencer`/L2 node.
74+
75+
1. **`Prover`/`zkvm` Setup**
76+
1. `cd ethrex/crates/l2`
77+
2. You can set the following environment variables to configure the prover:
78+
- `PROVER_CLIENT_PROVER_SERVER_ENDPOINT`: The address of the server where the client will request the proofs from.
79+
- `PROVER_CLIENT_PROVING_TIME_MS`: The amount of time to wait before requesting new data to prove.
80+
3. To start the `Prover`/`zkvm`, run:
81+
```sh
82+
make init-prover-<sp1|risc0|exec> # optional: GPU=true
83+
```
84+
85+
2. **`ProofCoordinator`/`sequencer` Setup**
86+
1. `cd ethrex/crates/l2`
87+
2. Create a `.env` file with the following content:
88+
```env
89+
# Should be the same as ETHREX_COMMITTER_L1_PRIVATE_KEY and ETHREX_WATCHER_L2_PROPOSER_PRIVATE_KEY
90+
ETHREX_DEPLOYER_L1_PRIVATE_KEY=<private_key>
91+
# Should be the same as ETHREX_COMMITTER_L1_PRIVATE_KEY and ETHREX_DEPLOYER_L1_PRIVATE_KEY
92+
ETHREX_WATCHER_L2_PROPOSER_PRIVATE_KEY=<private_key>
93+
# Should be the same as ETHREX_WATCHER_L2_PROPOSER_PRIVATE_KEY and ETHREX_DEPLOYER_L1_PRIVATE_KEY
94+
ETHREX_COMMITTER_L1_PRIVATE_KEY=<private_key>
95+
# Should be different from ETHREX_COMMITTER_L1_PRIVATE_KEY and ETHREX_WATCHER_L2_PROPOSER_PRIVATE_KEY
96+
ETHREX_PROOF_COORDINATOR_L1_PRIVATE_KEY=<private_key>
97+
# Used to handle TCP communication with other servers from any network interface.
98+
ETHREX_PROOF_COORDINATOR_LISTEN_ADDRESS=0.0.0.0
99+
# Set to true to randomize the salt.
100+
ETHREX_DEPLOYER_RANDOMIZE_CONTRACT_DEPLOYMENT=true
101+
# Set to true if you want SP1 proofs to be required
102+
ETHREX_L2_SP1=true
103+
# Check the if the verification contract is present on your preferred network. Don't define this if you want it to be deployed automatically.
104+
ETHREX_DEPLOYER_SP1_VERIFIER_ADDRESS=<address>
105+
# Set to true if you want proofs to be required
106+
ETHREX_L2_RISC0=true
107+
# Check the if the contract is present on your preferred network. You shall deploy it manually if not.
108+
ETHREX_DEPLOYER_RISC0_VERIFIER_ADDRESS=<address>
109+
# Set to any L1 endpoint.
110+
ETHREX_ETH_RPC_URL=<url>
111+
```
112+
3. `source .env`
113+
114+
> [!NOTE]
115+
> Make sure to have funds, if you want to perform a quick test `0.2[ether]` on each account should be enough.
116+
117+
- `Finally`, to start the `proposer`/`l2 node`, run:
118+
- `make rm-db-l2 && make down`
119+
- `make deploy-l1 && make init-l2` (if running a risc0 prover, see the next step before invoking the L1 contract deployer)
120+
121+
- If running with a local L1 (for development), you will need to manually deploy the risc0 contracts by following the instructions [here](https://github.com/risc0/risc0-ethereum/tree/main/contracts/script).
122+
- For a local L1 running with ethrex, we do the following:
123+
124+
1. clone the risc0-ethereum repo
125+
1. edit the `risc0-ethereum/contracts/deployment.toml` file by adding
126+
```toml
127+
[chains.ethrex]
128+
name = "Ethrex local devnet"
129+
id = 9
130+
```
131+
1. export env. variables (we are using an ethrex's rich L1 account)
132+
```bash
133+
export VERIFIER_ESTOP_OWNER="0x4417092b70a3e5f10dc504d0947dd256b965fc62"
134+
export DEPLOYER_PRIVATE_KEY="0x941e103320615d394a55708be13e45994c7d93b932b064dbcb2b511fe3254e2e"
135+
export DEPLOYER_ADDRESS="0x4417092b70a3e5f10dc504d0947dd256b965fc62"
136+
export CHAIN_KEY="ethrex"
137+
export RPC_URL="http://localhost:8545"
138+
139+
export ETHERSCAN_URL="dummy"
140+
export ETHERSCAN_API_KEY="dummy"
141+
```
142+
the last two variables need to be defined with some value even if not used, else the deployment script fails.
143+
1. cd into `risc0-ethereum/`
144+
1. run the deployment script
145+
```bash
146+
bash contracts/script/manage DeployEstopGroth16Verifier --broadcast
147+
```
148+
1. if the deployment was successful you should see the contract address in the output of the command, you will need to pass this as an argument to the L2 contract deployer, or via the `ETHREX_DEPLOYER_RISC0_VERIFIER_ADDRESS=<address>` env. variable.
149+
if you get an error like `risc0-ethereum/contracts/../lib/forge-std/src/Script.sol": No such file or directory (os error 2)`, try to update the git submodules (foundry dependencies) with `git submodule update --init --recursive`.
150+
151+
## Configuration
152+
153+
Configuration is done through environment variables or CLI flags.
154+
You can see a list of available flags by passing `--help` to the CLI, or checkout [CLI](../../CLI.md).

docs/getting-started/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ For other CPU architectures, see the [releases page](https://github.com/lambdacl
103103

104104
- **Interested in deploying your own L2?**
105105

106-
See [L2 rollup deployment](../l2/deploy.md) for launching your own rollup, deploying contracts, and interacting with your L2.
106+
See [L2 rollup deployment](../l2/deployment/overview.md) for launching your own rollup, deploying contracts, and interacting with your L2.
107107

108108
- **Looking to contribute or develop?**
109109

docs/l2/architecture/aligned_mode.md renamed to docs/l2/aligned_integration.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ make build-prover-<sp1/risc0> # optional: GPU=true
2222
This will generate the SP1 ELF program and verification key under:
2323

2424
- `crates/l2/prover/src/guest_program/src/sp1/out/riscv32im-succinct-zkvm-elf`
25-
- `crates/l2/prover/src/guest_program/src/sp1/out/riscv32im-succinct-zkvm-vk`
25+
- `crates/l2/prover/src/guest_program/src/sp1/out/riscv32im-succinct-zkvm-vk-u32`
2626

2727
### 2. Deploying L1 Contracts
2828

@@ -290,15 +290,15 @@ INFO ethrex_l2::sequencer::l1_proof_verifier: Batches verified in OnChainPropose
290290
- Sends proofs to the **Aligned Batcher** instead of the `OnChainProposer` contract.
291291
- Tracks the last proof sent using the rollup store.
292292

293-
![Proof Sender Aligned Mode](../img/aligned_mode_proof_sender.png)
293+
![Proof Sender Aligned Mode](./img/aligned_mode_proof_sender.png)
294294

295295
### Proof Verifier
296296

297297
- Spawned only in Aligned mode.
298298
- Monitors whether the next proof has been aggregated by Aligned.
299299
- Once verified, collects all already aggregated proofs and triggers the advancement of the `OnChainProposer` contract by sending a single transaction.
300300

301-
![Aligned Mode Proof Verifier](../img/aligned_mode_proof_verifier.png)
301+
![Aligned Mode Proof Verifier](./img/aligned_mode_proof_verifier.png)
302302

303303
### OnChainProposer
304304

docs/l2/architecture/overview.md

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -139,41 +139,47 @@ The mechanism for withdrawing funds from L2 back to L1 is explained in detail in
139139

140140
### Batch Commitment
141141

142-
An L2 batch commitment is the hash of the following things:
142+
An L2 batch commitment contains:
143143

144144
- The new L2 state root.
145-
- The state diff hash or polynomial commitments, depending on whether we are using calldata or blobs.
146-
- The Withdrawal logs merkle root.
145+
- The latest block's hash
146+
- The KZG versioned hash of the blobs published by the L2
147+
- The rolling hash of the processed privileged transactions
148+
- The Merkle root of the withdrawal logs
147149

148-
The public input to the proof is then the hash of the previous batch commitment and the new one.
150+
These are committed as public inputs of the zk proof that validates a new L2 state.
149151

150152
## L1 contract checks
151153

152154
### Commit transaction
153155

154-
For the `commit` transaction, the L1 verifier contract receives the following things from the sequencer:
155-
156-
- The L2 batch number to be commited.
157-
- The new L2 state root.
158-
- The Withdrawal logs merkle root.
159-
- The state diffs hash or polynomial commitment scheme accordingly.
156+
For the `commit` transaction, the L1 verifier contract receives the batch commitment, as defined previously, for the new batch.
160157

161158
The contract will then:
162159

163-
- Check that the batch number is the immediate successor of the last batch processed.
164-
- Check that the state diffs are valid, either through hashing or the point evaluation precompile.
160+
- Check that the batch number is the immediate successor of the last committed batch.
161+
- Check that the batch has not been committed already.
162+
- Check that the `lastBlockHash` is not zero.
163+
- If privileged transactions were processed, it checks the submitted hash against the one in the `CommonBridge` contract.
164+
- If withdrawals were processed, it publishes them to the `CommonBridge` contract.
165+
- It checks that a blob was published if the L2 is running as a rollup, or that no blob was published if it's running as a validium.
165166
- Calculate the new batch commitment and store it.
166167

167168
### Verify transaction
168169

169170
On a `verification` transaction, the L1 contract receives the following:
170171

171172
- The batch number.
172-
- The batch proof.
173+
- The RISC-V Zero-Knowledge proof of the batch execution (if enabled).
174+
- The SP1 Zero-Knowledge proof of the batch execution (if enabled).
175+
- The TDX Zero-Knowledge proof of the batch execution (if enabled).
173176

174177
The contract will then:
175178

176-
- Compute the proof public input from the new and previous batch commitments (both are already stored in the contract).
179+
- Check that the batch number is the immediate successor of the last verified batch.
180+
- Check that the batch has been committed.
181+
- It removes the pending transaction hashes from the `CommonBridge` contract.
182+
- It verifies the public data of the proof, checking that the data committed in the `commitBatch` call matches the data in the public inputs of the proof.
177183
- Pass the proof and public inputs to the verifier and assert the proof passes.
178184
- If the proof passes, finalize the L2 state, setting the latest batch as the given one and allowing any withdrawals for that batch to occur.
179185

0 commit comments

Comments
 (0)