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