|
| 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 → `make init-prover-<sp1|risc0|exec> # GPU=true`. |
| 45 | + |
| 46 | +After this initialization we should have the prover running in `dev_mode` → No real proofs. |
| 47 | + |
| 48 | +## GPU mode |
| 49 | + |
| 50 | +**Steps for Ubuntu 22.04 with Nvidia A4000:** |
| 51 | + |
| 52 | +1. Install `docker` → 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 → 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). |
0 commit comments