Skip to content

Commit 035ceb7

Browse files
update the state sync doc
1 parent d686a7d commit 035ceb7

File tree

1 file changed

+46
-24
lines changed

1 file changed

+46
-24
lines changed

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

Lines changed: 46 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,69 @@
22
comments: true
33
---
44

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

7-
Find the zkEVM mainnet snapshots at the below urls.
7+
## Sync a database
88

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

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
2113
```
2214

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
3018
docker compose stop
3119
docker compose start zkevm-state-db
20+
```
3221

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
3425
docker compose exec -it zkevm-state-db pg_dump -U state_user -v -Fc -s -f /tmp/statedb.schema state_db
3526
docker compose exec -it zkevm-state-db dropdb -U state_user state_db
3627
docker compose exec -it zkevm-state-db createdb -U state_user state_db
3728
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:
3832

39-
# Import the backup file into database
33+
```sh
4034
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
4138

42-
# Cleanup
39+
```sh
4340
docker compose exec zkevm-state-db rm /tmp/statedb.schema
4441
rm statedb.sql.gz
42+
```
43+
44+
6. Start everything again
4545

46-
# Start everything
46+
```sh
4747
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)
4860
```
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

Comments
 (0)