Resetting and synchronizing a node
Synchronizing a node
If a node is started for the first time, it will synchronize to the latest block height of the network, starting from the genesis block. The synchronization from the genesis block can take a significant amount of time, depending on how many blocks have to be synchronized from the genesis block, in order to reach the latest block height of the network.
To speed up the process, a snapshot of the blockchain can be used. A snapshot is basically a database export of the blockchain from a certain time period, that contains all blocks and transactions which have been added to the blockchain so far.
Downloading a snapshot
Official snapshots are stored and can be downloaded via the following URL: https://snapshots.lisk.com.
-
Snapshots for the Lisk Mainnet: https://snapshots.lisk.com/mainnet/
-
Snapshots for the Lisk Testnet: https://snapshots.lisk.com/testnet/
The Lisk Core CLI provides a command blockchain:download
, which supports downloading the correct snapshot. It also verifies the correct download by verifying the checksum of the snapshot.
$ lisk-core blockchain:download --help Download snapshot from <URL>. USAGE $ lisk-core blockchain:download OPTIONS -n, --network=network [default: mainnet] Default network config to use. Environment variable "LISK_NETWORK" can also be used. -o, --output=output Directory path to specify where the snapshot is downloaded. By default, it outputs the files to the current working directory. -u, --url=url The url to the snapshot. EXAMPLES download download --network betanet download --url https://snapshots.lisk.io/mainnet/blockchain.db.tar.gz --output ./downloads
How to download a snapshot of the Lisk blockchain:
Importing a snapshot
Stop Lisk Core before importing the snapshot:
pm2 delete lisk-core
Import the snapshot to Lisk Core, by using the blockchain:import
command:
lisk-core blockchain:import ./path/to/blockchain.db.tar.gz --force
Now start Lisk Core again:
pm2 start pm2.conf.json
After Lisk Core has now started, it will begin the synchronization process from the block height of the snapshot to the current height of the blockchain.
A command reference can be viewed by adding the --help
parameter:
$ lisk-core blockchain:import --help Import from <FILE>. USAGE $ lisk-core blockchain:import FILEPATH ARGUMENTS FILEPATH Path to the gzipped blockchain data. OPTIONS -d, --data-path=data-path Specifies which data path the application should use. Environment variable "LISK_DATA_PATH" can also be used. -f, --force Delete and overwrite existing blockchain data EXAMPLES blockchain:import ./path/to/blockchain.db.tar.gz blockchain:import ./path/to/blockchain.db.tar.gz --data-path ./lisk/ blockchain:import ./path/to/blockchain.db.tar.gz --data-path ./lisk/ --force
Creating own snapshots
To create your own snapshots of the blockchain, use the blockchain:export
command:
lisk-core blockchain:export --output ./my/path/
A command reference can be viewed by adding the --help
parameter:
$ lisk-core blockchain:export --help Export to <FILE>. USAGE $ lisk-core blockchain:export OPTIONS -d, --data-path=data-path Directory path to specify where the node data is stored. Environment variable "LISK_DATA_PATH" can also be used. -o, --output=output The output directory. Default will set to current working directory. EXAMPLES blockchain:export blockchain:export --data-path ./data --output ./my/path/
Resetting the blockchain data
In case the blockchain should synchronize from the genesis block, it is possible to simply reset the existing blockchain data with the blockchain:reset
command:
lisk-core blockchain:reset
A command reference can be viewed by adding the --help
parameter:
$ lisk-core blockchain:reset --help Reset the blockchain data. USAGE $ lisk-core blockchain:reset OPTIONS -d, --data-path=data-path Directory path to specify where node data is stored. Environment variable "LISK_DATA_PATH" can also be used. -y, --yes Skip confirmation prompt. EXAMPLES blockchain:reset blockchain:reset --data-path ./lisk blockchain:reset --yes