Sync from genesis
A beacon node can also start from the very first state of the chain, the genesis state, and replay every block since. That takes days on mainnet, compared with minutes checkpoint sync.
A checkpoint-synced node follows the same chain and runs validators just as well. Syncing from genesis only costs you time, unless one of the reasons below applies.
When to sync from genesis
- You need the historical states. Checkpoint sync with
--enable-backfillbrings back old blocks, but not the states before the checkpoint. An archive node that answers queries about any past slot needs them. - You don't want to take your starting point from another node. The node checks every block from genesis onward itself, instead of trusting a provider for a recent state.
On proof of stake, a node that's been offline longer than the weak subjectivity period, a few weeks on mainnet, can't tell the real chain from a fake one built with old validator keys. A node syncing from genesis is in that position. Pass --weak-subjectivity-checkpoint with a recent block_root:epoch you got from a source you trust, and the node stops if the chain it syncs doesn't contain it.
Before you begin
- A beacon node with an empty data directory. If it already holds a database, the node carries on from there.
- A connected execution client, with the folder layout from Connect your execution client.
Start the node
-
Download the genesis state. Prysm ships the mainnet genesis state, but not the testnet ones. Get
genesis.sszfrom the eth-clients/mainnet repository, next to the network's other data:curl -L https://github.com/eth-clients/mainnet/raw/main/metadata/genesis.ssz \--output $HOME/ethereum/data/mainnet/genesis.sszcurl.exe -L https://github.com/eth-clients/mainnet/raw/main/metadata/genesis.ssz `--output $HOME\ethereum\data\mainnet\genesis.sszThe file is about 150 MB.
The file is about 3 MB.
-
Start the beacon node. From the
consensusfolder:./prysm.sh beacon-chain \--mainnet \--datadir=$HOME/ethereum/data/mainnet/beacon \--execution-endpoint=http://localhost:8551 \--jwt-secret=$HOME/ethereum/data/jwt.hex.\prysm.bat beacon-chain `--mainnet `--datadir=$HOME\ethereum\data\mainnet\beacon `--execution-endpoint=http://localhost:8551 `--jwt-secret=$HOME\ethereum\data\jwt.hex./prysm.sh beacon-chain \--mainnet \--datadir=$HOME/ethereum/data/mainnet/beacon \--execution-endpoint=$HOME/ethereum/data/mainnet/execution/geth.ipc.\prysm.bat beacon-chain `--mainnet `--datadir=$HOME\ethereum\data\mainnet\beacon `--execution-endpoint=\\.\pipe\geth.ipc./prysm.sh beacon-chain \--mainnet \--datadir=$HOME/ethereum/data/mainnet/beacon \--execution-endpoint=http://localhost:8551 \--jwt-secret=$HOME/ethereum/data/jwt.hex \--genesis-state=$HOME/ethereum/data/mainnet/genesis.ssz.\prysm.bat beacon-chain `--mainnet `--datadir=$HOME\ethereum\data\mainnet\beacon `--execution-endpoint=http://localhost:8551 `--jwt-secret=$HOME\ethereum\data\jwt.hex `--genesis-state=$HOME\ethereum\data\mainnet\genesis.ssz./prysm.sh beacon-chain \--mainnet \--datadir=$HOME/ethereum/data/mainnet/beacon \--execution-endpoint=$HOME/ethereum/data/mainnet/execution/geth.ipc \--genesis-state=$HOME/ethereum/data/mainnet/genesis.ssz.\prysm.bat beacon-chain `--mainnet `--datadir=$HOME\ethereum\data\mainnet\beacon `--execution-endpoint=\\.\pipe\geth.ipc `--genesis-state=$HOME\ethereum\data\mainnet\genesis.sszRunning validators? Also add:
--postpone-shutdown-for-proposalsWhen you stop or restart the beacon node, it then waits until your validators' upcoming block proposals are done. Refer to the Don't restart just before a proposal page.
-
Watch the logs. Once it has peers, the node logs its progress every few seconds:
INFO initial-sync: Processing blocks batchSize=… blocksPerSecond=… estimatedTimeRemaining=… latestProcessedSlot/currentSlot=…/… peers=… startingFrom=0x…estimatedTimeRemainingtells you roughly when it will catch up. When it has, Prysm logs:INFO initial-sync: Synced to head of chain
Check that it works
curl -s http://localhost:3500/eth/v1/node/syncing
curl.exe -s http://localhost:3500/eth/v1/node/syncing
While the node syncs, head_slot grows from 0 and sync_distance shrinks. When is_syncing is false, the node is following the chain, and the logs show a Synced new block line for every block.
Troubleshooting
The node started from a checkpoint instead. --checkpoint-sync-url is still in your command or config file. Remove it, stop the node, and start it once with --force-clear-db.
Sync is slow or stalls. Prysm logs:
Waiting for enough suitable peers before syncing
The node needs peers to download blocks from. Check that your peer-to-peer ports are open.