Checkpoints
Checkpoints in nodes serve as specific reference points within the blockchain, allowing nodes to synchronize more efficiently when joining or rejoining the network. Instead of processing the entire blockchain from the genesis block, nodes can start from a known, validated state. Below is a detailed guide on how to set up checkpoints.
Syncing a node from a checkpoint
Assuming that you have already completed setup node section.
For prototestnet network, you should have zq2-prototestnet.toml
and the start_node.sh
script, which is generated by the setup node guide.
Step by step guide to do checkpoint configuration
- Ensure that you are in directory
/my/dir/zq2
that you created before during the setup. -
Download the checkpoints file:
Here are the steps for downloading the latest checkpoint file.- Visit the public checkpoint url , where you will see an XML file.
- Look for the
<key>
tag, which indicates the checkpoint file's name. The checkpoint file followsblock_num.dat
format. For eg000291600.dat
. - Copy the file name from the topmost
key. This file contains the latest checkpoint data. - If you prefer to sync from an older checkpoint, copy the desired file from the
previous/
directory. You can skip this step if you have already decided to sync from the latest checkpoint. - To download, replace
in the URL with the appropriate block number: - For the latest checkpoint file:
https://checkpoints.zq2-prototestnet.zilliqa.com/<block_num.dat>
- For an older file:
https://checkpoints.zq2-prototestnet.zilliqa.com/previous/<block_num.dat>
- For the latest checkpoint file:
- Use
wget
or paste the link in your browser to download the file to the/my/dir/zq2
directory:NOTE : We recommend that node operators use the latest checkpoint file to speed up the syncing process.wget https://checkpoints.zq2-prototestnet.zilliqa.com/<block_num.dat>
-
Configure Checkpoints in zq2-prototestnet.toml file:
Open thezq2-prototestnet.toml
file and add the following lines to enable checkpoint settings:[nodes.load_checkpoint] file = "xxxxx..." # File name of the checkpoint block. for eg: 3000.dat hash = "xxxxx..." # Block hash corresponding to the file block (Remove '0x' prefix from hash if present)
file
: This parameter specifies the name of the checkpoint or block number file, which can be obtained from the public GCS bucket. It’s recommended to download the latest checkpoint file from this source.
hash
: The hash is used to verify the validity of the state data and ensure that no tampering has occurred. You can obtain the block hash corresponding to the checkpoint height from the public explorer. For example, if the downloaded checkpoint file is 3000, you can use theeth_getBlockByNumber
API to query the block hash:Alternatively, you can retrieve the block hash directly from the public explorer by searching for the block number.curl --request POST --url https://api.zq2-prototestnet.zilliqa.com/ \ --header 'Content-Type: application/json' \ --data '{"method":"eth_getBlockByNumber","params":["0xBB8",false],"id":1,"jsonrpc":"2.0"}' \ | grep -o '"hash":"[^"]*"' | awk -F':' '{print $2}' | tr -d '"'
By this stage, your checkpoints configuration should be set up in thezq2-prototestnet.toml
file. - Launch the node
Now the node is ready to launch. Follow the instructions in the Start the Node section to start your node.