|
2 | 2 | comments: true |
3 | 3 | --- |
4 | 4 |
|
5 | | -Use snapshots for quick state syncing. |
| 5 | +Follow the instructions below to run a fast state sync on a database using the relevant snapshot, file name given in the [snapshots section](#snapshots). |
6 | 6 |
|
7 | | -Find the zkEVM mainnet snapshots at the below urls. |
| 7 | +## Sync a database |
8 | 8 |
|
9 | | - ```bash |
10 | | - https://zkevm-mai.s3.eu-west-1.amazonaws.com/mainnet-bridgedb.sql.gz (315MB) |
11 | | - https://zkevm-mai.s3.eu-west-1.amazonaws.com/mainnet-statedb.sql.gz (6GB) |
12 | | - https://zkevm-mai.s3.eu-west-1.amazonaws.com/mainnet-hashdb.sql.gz (160GB) |
13 | | - ``` |
14 | | - |
15 | | -Find the testnet snapshots at the below urls. |
| 9 | +1. Retrieve the back up file: |
16 | 10 |
|
17 | | - ```bash |
18 | | - https://zkevm-pub.s3.eu-west-1.amazonaws.com/testnet-bridgedb.sql.gz (312MB) |
19 | | - https://zkevm-pub.s3.eu-west-1.amazonaws.com/testnet-statedb.sql.gz (1.9GB) |
20 | | - https://zkevm-pub.s3.eu-west-1.amazonaws.com/testnet-hashdb.sql.gz (49GB) |
| 11 | + ```sh |
| 12 | + curl <snapshot-file> -o statedb.sql.gz |
21 | 13 | ``` |
22 | 14 |
|
23 | | -Follow the next instructions to sync state. Be sure to 'curl' snapshots for the correct network, that is, mainnet or testnet. |
24 | | - |
25 | | -```bash |
26 | | - # Retrieve backup file |
27 | | - curl https://zkevm-pub.s3.eu-west-1.amazonaws.com/testnet-statedb.sql.gz -o statedb.sql.gz |
28 | | - |
29 | | - # Let only datatabase running |
| 15 | +2. Stop/start the database: |
| 16 | + |
| 17 | + ```sh |
30 | 18 | docker compose stop |
31 | 19 | docker compose start zkevm-state-db |
| 20 | + ``` |
32 | 21 |
|
33 | | - # Remove data from database, keeping schema (the backup is raw COPY) |
| 22 | +3. Remove data from the database, keeping the schema, and a raw backup copy: |
| 23 | + |
| 24 | + ```sh |
34 | 25 | docker compose exec -it zkevm-state-db pg_dump -U state_user -v -Fc -s -f /tmp/statedb.schema state_db |
35 | 26 | docker compose exec -it zkevm-state-db dropdb -U state_user state_db |
36 | 27 | docker compose exec -it zkevm-state-db createdb -U state_user state_db |
37 | 28 | docker compose exec -it zkevm-state-db pg_restore -U state_user -v -d state_db /tmp/statedb.schema |
| 29 | + ``` |
| 30 | + |
| 31 | +4. Import the backup file into database: |
38 | 32 |
|
39 | | - # Import the backup file into database |
| 33 | + ```sh |
40 | 34 | gunzip -c statedb.sql.gz | docker compose exec -T zkevm-state-db psql -U state_user -d state_db |
| 35 | + ``` |
| 36 | + |
| 37 | +5. Clean up |
41 | 38 |
|
42 | | - # Cleanup |
| 39 | + ```sh |
43 | 40 | docker compose exec zkevm-state-db rm /tmp/statedb.schema |
44 | 41 | rm statedb.sql.gz |
| 42 | + ``` |
| 43 | + |
| 44 | +6. Start everything again |
45 | 45 |
|
46 | | - # Start everything |
| 46 | + ```sh |
47 | 47 | docker compose up -d |
| 48 | + ``` |
| 49 | + |
| 50 | +## Snapshots |
| 51 | + |
| 52 | +The snapshot for the bridge, state, and hash databases are given below for mainnet and testnet. |
| 53 | + |
| 54 | +### Mainnet |
| 55 | + |
| 56 | +```bash |
| 57 | +https://zkevm-mai.s3.eu-west-1.amazonaws.com/mainnet-bridgedb.sql.gz (315MB) |
| 58 | +https://zkevm-mai.s3.eu-west-1.amazonaws.com/mainnet-statedb.sql.gz (6GB) |
| 59 | +https://zkevm-mai.s3.eu-west-1.amazonaws.com/mainnet-hashdb.sql.gz (160GB) |
48 | 60 | ``` |
| 61 | + |
| 62 | +### Testnet |
| 63 | + |
| 64 | +```bash |
| 65 | +https://zkevm-pub.s3.eu-west-1.amazonaws.com/testnet-bridgedb.sql.gz (312MB) |
| 66 | +https://zkevm-pub.s3.eu-west-1.amazonaws.com/testnet-statedb.sql.gz (1.9GB) |
| 67 | +https://zkevm-pub.s3.eu-west-1.amazonaws.com/testnet-hashdb.sql.gz (49GB) |
| 68 | +``` |
| 69 | + |
| 70 | + |
0 commit comments