top of page
Full_Logo_Light.png

Services

SNAPSHOTS

Snapshots enable a fresh node to enter the network by restoring application state from a backup file. Each snapshot comprises a compressed copy of the chain data directory. To maintain compact backup files, the snapshot server undergoes periodic state synchronization.

You need to have lz4 installed in order to extract the snapshot.

sudo apt update

sudo apt install snapd -y

sudo snap install lz4

Begin by stopping the Persistence node so that we can replace the node data with the snapshot.

sudo service persistence stop

Now we create a backup of the ‘priv_validator_state.json’ file, for a validator node this is critical as it indicates the last block you signed.

cp $HOME/.persistenceCore/data/priv_validator_state.json $HOME/.persistenceCore/priv_validator_state.json.backup

Make a backup of the data and wasm. We will replace these from our snapshot.

mv $HOME/.persistenceCore/data $HOME/.persistenceCore/data_bk 

mv $HOME/.persistenceCore/wasm $HOME/.persistenceCore/wasm_bk

We can now download the snapshot and its contents

curl -L http://snapshots.staking4all.org/snapshots/persistence/latest/persistence.tar.lz4 | lz4 -dc - | tar -xf - -C $HOME/.persistenceCore

Now, it's crucial to reinsert the 'priv_validator_state.json' file to its original location to prevent the node from attempting to sign blocks that have already been signed.

cp $HOME/.persistenceCore/priv_validator_state.json.backup $HOME/.persistenceCore/data/priv_validator_state.json

You can now start your node.

sudo service persistence start

sudo service persistence status

Ensure that the node is syncing by reviewing the logs.

sudo journalctl -u persistence -f

You can now remove the backup data, if for some reason it did not work you can revert to your original state by placing the content back.

rm -r $HOME/.persistenceCore/data_bk 

rm -r $HOME/.persistenceCore/wasm_bk

rm $HOME/.persistenceCore/priv_validator_state.json.backup

bottom of page