|
| 1 | +This quick start guide shows you how to deploy a CDK rollup (zkevm-node) environment on your local machine that sets up and runs the following components: |
| 2 | + |
| 3 | +- zkEVM node databases |
| 4 | +- Explorer databases |
| 5 | +- L1 network |
| 6 | +- Prover |
| 7 | +- zkEVM node components |
| 8 | +- Explorers |
| 9 | + |
1 | 10 | !!! note |
2 | | - - The documentation describes standard deployments. |
| 11 | + - The documentation describes standard deployments. |
3 | 12 | - Edit the configuration files to implement your own custom setups. |
4 | 13 |
|
5 | | -## Run a CDK rollup locally |
| 14 | +## Prerequisites |
| 15 | + |
| 16 | +### Hardware |
| 17 | + |
| 18 | +- A Linux-based OS (e.g., Ubuntu Server 22.04 LTS). |
| 19 | +- At least 16GB RAM with a 4-core CPU. |
| 20 | +- An AMD64 architecture system. |
| 21 | + |
| 22 | +!!! warning |
| 23 | + - Currently the executor/prover does not run on ARM-powered Macs. |
| 24 | + - For Windows users, WSL/WSL2 use is not recommended. |
| 25 | + |
| 26 | +### Software |
| 27 | + |
| 28 | +- [`go`](https://go.dev/doc/install) <sub>version 1.21</sub> |
| 29 | +- [`Docker`](https://www.docker.com/get-started) |
| 30 | +- [`Docker Compose`](https://docs.docker.com/compose/install/) |
| 31 | + |
| 32 | +## 1. Clone the repo |
| 33 | + |
| 34 | +```sh |
| 35 | +git clone https://github.com/0xPolygonHermez/zkevm-node.git |
| 36 | +cd zkevm-node |
| 37 | +``` |
| 38 | + |
| 39 | +## 2. Build the Docker image |
| 40 | + |
| 41 | +```bash |
| 42 | +make build-docker |
| 43 | +``` |
| 44 | + |
| 45 | +!!! warning |
| 46 | + - Rerun this command every time there is a code-change. |
| 47 | + |
| 48 | +## 3. Test the environment |
| 49 | + |
| 50 | +`zkevm-node` provides commands that allow you to interact with smart contracts, run components, create encryption files, and print out debug information. |
| 51 | + |
| 52 | +!!! warning |
| 53 | + - All the data is stored inside Docker containers. |
| 54 | + - You will lose all the data whenever you remove the container. |
| 55 | + |
| 56 | +### 3.1 Run the environment |
| 57 | + |
| 58 | +The `test/` directory contains scripts and files for developing and debugging. |
| 59 | + |
| 60 | +```bash |
| 61 | +cd test/ |
| 62 | +``` |
| 63 | + |
| 64 | +Then: |
| 65 | + |
| 66 | +```bash |
| 67 | +make run |
| 68 | +``` |
| 69 | + |
| 70 | +The `make run` command spins up the containers that run the environment, but nothing else. This means that the L2 has no data yet. |
| 71 | + |
| 72 | +### 3.2 Test with data |
| 73 | + |
| 74 | +Test a use case from the [test with sample data](#4-test-with-sample-data) section. |
| 75 | + |
| 76 | +### 3.3 Stop the environment |
| 77 | + |
| 78 | +```bash |
| 79 | +make stop |
| 80 | +``` |
| 81 | + |
| 82 | +### 3.4 Restart the environment |
| 83 | + |
| 84 | +```bash |
| 85 | +make restart |
| 86 | +``` |
| 87 | + |
| 88 | +## 4. Test with sample data |
| 89 | + |
| 90 | +### 4.1 Add example transactions and smart contracts |
| 91 | + |
| 92 | +```bash |
| 93 | +make deploy-sc |
| 94 | +``` |
| 95 | + |
| 96 | +### 4.2 Deploy a full Uniswap environment |
| 97 | + |
| 98 | +```bash |
| 99 | +make deploy-uniswap |
| 100 | +``` |
| 101 | + |
| 102 | +### 4.3 Grant the Pol smart contract a set amount of tokens |
| 103 | + |
| 104 | +```bash |
| 105 | +make run-approve-pol |
| 106 | +``` |
| 107 | + |
| 108 | +## 5. Set up MetaMask |
| 109 | + |
| 110 | +!!! info |
| 111 | + MetaMask requires the network to be running during set up. |
| 112 | + |
| 113 | +To configure MetaMask to use your local environment, make sure the network is running and follow these steps. |
| 114 | + |
| 115 | +- Log in to your MetaMask wallet. |
| 116 | +- Click your account picture and then on **Settings**. |
| 117 | +- On the left menu, click **Networks**. |
| 118 | +- Click the **Add Network** button. |
| 119 | +- Enter the following L2 network information: |
| 120 | + 1. `Network name:` Polygon zkEVM - local |
| 121 | + 2. `New RPC URL:` <http://localhost:8123> |
| 122 | + 3. `Chain ID:` 1001 |
| 123 | + 4. `Currency symbol:` ETH |
| 124 | + 5. `Block explorer URL:` <http://localhost:4000> |
| 125 | +- Click **Save**. |
| 126 | +- Click the **Add Network** button, |
| 127 | +- Enter the following L1 network information: |
| 128 | + 1. `Network name:` Geth - local |
| 129 | + 2. `New RPC URL:` <http://localhost:8545> |
| 130 | + 3. `Chain ID:` 1337 |
| 131 | + 4. `Currency symbol:` ETH |
| 132 | +- Click **Save**. |
| 133 | + |
| 134 | +## Environment configurations |
| 135 | + |
| 136 | +Access the running components using the following details. |
| 137 | + |
| 138 | +### Databases |
| 139 | + |
| 140 | +#### zkEVM node *state* database |
| 141 | + |
| 142 | +- `Type:` Postgres DB |
| 143 | +- `User:` state_user |
| 144 | +- `Password:` state_password |
| 145 | +- `Database:` state-db |
| 146 | +- `Host:` localhost |
| 147 | +- `Port:` 5432 |
| 148 | +- `URL:` <postgres://state_user:srare_password@localhost:5432/state-db> |
| 149 | + |
| 150 | +#### zkEVM node *pool* database |
| 151 | + |
| 152 | +- `Type:` Postgres DB |
| 153 | +- `User:` pool_user |
| 154 | +- `Password:` pool_password |
| 155 | +- `Database:` pool_db |
| 156 | +- `Host:` localhost |
| 157 | +- `Port:` 5433 |
| 158 | +- `URL:` <postgres://pool_user:pool_password@localhost:5433/pool_db> |
| 159 | + |
| 160 | +#### zkEVM node *JSON-RPC* database |
| 161 | + |
| 162 | +- `Type:` Postgres DB |
| 163 | +- `User:` rpc_user |
| 164 | +- `Password:` rpc_password |
| 165 | +- `Database:` rpc_db |
| 166 | +- `Host:` localhost |
| 167 | +- `Port:` 5434 |
| 168 | +- `URL:` <postgres://rpc_user:rpc_password@localhost:5434/rpc_db> |
| 169 | + |
| 170 | +#### Explorer L1 database |
| 171 | + |
| 172 | +- `Type:` Postgres DB |
| 173 | +- `User:` l1_explorer_user |
| 174 | +- `Password:` l1_explorer_password |
| 175 | +- `Database:` l1_explorer_db |
| 176 | +- `Host:` localhost |
| 177 | +- `Port:` 5435 |
| 178 | +- `URL:` <postgres://l1_explorer_user:l1_explorer_password@localhost:5435/l1_explorer_db> |
| 179 | + |
| 180 | +#### Explorer L2 database |
| 181 | + |
| 182 | +- `Type:` Postgres DB |
| 183 | +- `User:` l2_explorer_user |
| 184 | +- `Password:` l2_explorer_password |
| 185 | +- `Database:` l2_explorer_db |
| 186 | +- `Host:` localhost |
| 187 | +- `Port:` 5436 |
| 188 | +- `URL:` <postgres://l2_explorer_user:l2_explorer_password@localhost:5436/l2_explorer_db> |
| 189 | + |
| 190 | +### Networks |
| 191 | + |
| 192 | +#### L1 network |
| 193 | + |
| 194 | +- `Type:` Geth |
| 195 | +- `Host:` localhost |
| 196 | +- `Port:` 8545 |
| 197 | +- `URL:` <http://localhost:8545> |
| 198 | + |
| 199 | +#### zkEVM node |
| 200 | + |
| 201 | +- `Type:` JSON RPC |
| 202 | +- `Host:` localhost |
| 203 | +- `Port:` 8123 |
| 204 | +- `URL:` <http://localhost:8123> |
| 205 | + |
| 206 | +### Explorers |
| 207 | + |
| 208 | +#### Explorer L1 |
| 209 | + |
| 210 | +- `Type:` Web |
| 211 | +- `Host:` localhost |
| 212 | +- `Port:` 4000 |
| 213 | +- `URL:` <http://localhost:4000> |
| 214 | + |
| 215 | +#### Explorer L2 |
| 216 | + |
| 217 | +- `Type:` Web |
| 218 | +- `Host:` localhost |
| 219 | +- `Port:` 4001 |
| 220 | +- `URL:` <http://localhost:4001> |
| 221 | + |
| 222 | +#### Prover |
| 223 | + |
| 224 | +- `Type:` Mock |
| 225 | +- `Host:` localhost |
| 226 | +- `Port:` Depending on the prover image, if it's mock or not: |
| 227 | + - Prod prover: 50052 for Prover, 50061 for Merkle Tree, 50071 for Executor |
| 228 | + - Mock prover: 43061 for MT, 43071 for Executor |
| 229 | +- `URL:` <http://localhost:50001> |
| 230 | + |
| 231 | +### Environment addresses |
| 232 | + |
| 233 | +The following addresses are configured into the running environment. |
| 234 | + |
| 235 | +#### L1 addresses |
| 236 | + |
| 237 | +| Address | Description | |
| 238 | +|---|---| |
| 239 | +| 0x8dAF17A20c9DBA35f005b6324F493785D239719d | Polygon zkEVM | |
| 240 | +| 0x40E0576c0A7dff9dc460B29ba73e79aBf73dD2a9 | Polygon bridge | |
| 241 | +| 0x5FbDB2315678afecb367f032d93F642f64180aa3 | Pol token | |
| 242 | +| 0x8A791620dd6260079BF849Dc5567aDC3F2FdC318 | Polygon GlobalExitRootManager | |
| 243 | +| 0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e | Polygon RollupManager | |
| 244 | + |
| 245 | +#### Deployer account |
| 246 | + |
| 247 | +| Address | Private Key | |
| 248 | +|---|---| |
| 249 | +| 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 | 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 | |
| 250 | + |
| 251 | +#### Sequencer account |
| 252 | + |
| 253 | +| Address | Private Key | |
| 254 | +|---|---| |
| 255 | +| 0x617b3a3528F9cDd6630fd3301B9c8911F7Bf063D | 0x28b2b0318721be8c8339199172cd7cc8f5e273800a35616ec893083a4b32c02e | |
| 256 | + |
| 257 | +#### Aggregator account |
| 258 | + |
| 259 | +| Address | Private Key | |
| 260 | +|---|---| |
| 261 | +| 0x70997970C51812dc3A010C7d01b50e0d17dc79C8 | 0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d | |
| 262 | + |
| 263 | +### Test accounts with funds |
6 | 264 |
|
7 | | -The following link takes you to a quickstart guide for deploying a CDK rollup on your local machine. |
| 265 | +The environment also provides a bunch of test accounts that contain funds. |
8 | 266 |
|
9 | | -[https://github.com/0xPolygonHermez/zkevm-node/blob/develop/docs/running_local.md](https://github.com/0xPolygonHermez/zkevm-node/blob/develop/docs/running_local.md) |
| 267 | +| Address | Private Key | |
| 268 | +|---|---| |
| 269 | +| 0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC | 0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a | |
| 270 | +| 0x90F79bf6EB2c4f870365E785982E1f101E93b906 | 0x7c852118294e51e653712a81e05800f419141751be58f605c371e15141b007a6 | |
| 271 | +| 0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65 | 0x47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a | |
| 272 | +| 0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc | 0x8b3a350cf5c34c9194ca85829a2df0ec3153be0318b5e2d3348e872092edffba | |
| 273 | +| 0x976EA74026E726554dB657fA54763abd0C3a0aa9 | 0x92db14e403b83dfe3df233f83dfa3a0d7096f21ca9b0d6d6b8d88b2b4ec1564e | |
| 274 | +| 0x14dC79964da2C08b23698B3D3cc7Ca32193d9955 | 0x4bbbf85ce3377467afe5d46f804f221813b2bb87f24d81f60f1fcdbf7cbf4356 | |
| 275 | +| 0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f | 0xdbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97 | |
| 276 | +| 0xa0Ee7A142d267C1f36714E4a8F75612F20a79720 | 0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6 | |
| 277 | +| 0xBcd4042DE499D14e55001CcbB24a551F3b954096 | 0xf214f2b2cd398c806f84e317254e0f0b801d0643303237d97a22a48e01628897 | |
| 278 | +| 0x71bE63f3384f5fb98995898A86B02Fb2426c5788 | 0x701b615bbdfb9de65240bc28bd21bbc0d996645a3dd57e7b12bc2bdf6f192c82 | |
| 279 | +| 0xFABB0ac9d68B0B445fB7357272Ff202C5651694a | 0xa267530f49f8280200edf313ee7af6b827f2a8bce2897751d06a843f644967b1 | |
| 280 | +| 0x1CBd3b2770909D4e10f157cABC84C7264073C9Ec | 0x47c99abed3324a2707c28affff1267e45918ec8c3f20b8aa892e8b065d2942dd | |
| 281 | +| 0xdF3e18d64BC6A983f673Ab319CCaE4f1a57C7097 | 0xc526ee95bf44d8fc405a158bb884d9d1238d99f0612e9f33d006bb0789009aaa | |
| 282 | +| 0xcd3B766CCDd6AE721141F452C550Ca635964ce71 | 0x8166f546bab6da521a8369cab06c5d2b9e46670292d85c875ee9ec20e84ffb61 | |
| 283 | +| 0x2546BcD3c84621e976D8185a91A922aE77ECEc30 | 0xea6c44ac03bff858b476bba40716402b03e41b8e97e276d1baec7c37d42484a0 | |
| 284 | +| 0xbDA5747bFD65F08deb54cb465eB87D40e51B197E | 0x689af8efa8c651a91ad287602527f3af2fe9f6501a7ac4b061667b5a93e037fd | |
| 285 | +| 0xdD2FD4581271e230360230F9337D5c0430Bf44C0 | 0xde9be858da4a475276426320d5e9262ecfc3ba460bfac56360bfa6c4c28b4ee0 | |
| 286 | +| 0x8626f6940E2eb28930eFb4CeF49B2d1F2C9C1199 | 0xdf57089febbacf7ba0bc227dafbffa9fc08a93fdc68e1e42411a14efcf23656e | |
0 commit comments