Skip to content

Commit 67bd892

Browse files
Merge pull request 0xPolygon#457 from 0xPolygon/zkevm/state-sync
Update the state sync doc
2 parents 37a573f + 62bcd25 commit 67bd892

File tree

1 file changed

+50
-21
lines changed

1 file changed

+50
-21
lines changed

docs/zkEVM/get-started/state-sync-snapshots.md

Lines changed: 50 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,76 @@
22
comments: true
33
---
44

5-
Use snapshots for quick state syncing.
5+
!!! important
6+
New and streamlined state sync process coming online soon.
67

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).
89

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
1411

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`:
1613

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
2116
```
2217

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:
2419

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
2822

29-
# Let only datatabase running
23+
2. Stop/start the database:
24+
25+
```sh
3026
docker compose stop
3127
docker compose start zkevm-state-db
28+
```
3229

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
3433
docker compose exec -it zkevm-state-db pg_dump -U state_user -v -Fc -s -f /tmp/statedb.schema state_db
3534
docker compose exec -it zkevm-state-db dropdb -U state_user state_db
3635
docker compose exec -it zkevm-state-db createdb -U state_user state_db
3736
docker compose exec -it zkevm-state-db pg_restore -U state_user -v -d state_db /tmp/statedb.schema
37+
```
3838

39-
# Import the backup file into database
39+
4. Import the backup file into the database:
40+
41+
```sh
4042
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:
4146

42-
# Cleanup
47+
```sh
4348
docker compose exec zkevm-state-db rm /tmp/statedb.schema
4449
rm statedb.sql.gz
50+
```
51+
52+
6. Start everything again:
4553

46-
# Start everything
54+
```sh
4755
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)
4868
```
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

Comments
 (0)