Skip to content

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

  1. Ensure that you are in directory /my/dir/zq2 that you created before during the setup.
  2. 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 follows block_num.dat format. For eg 000291600.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>
    • Use wget or paste the link in your browser to download the file to the /my/dir/zq2 directory:
      wget https://checkpoints.zq2-prototestnet.zilliqa.com/<block_num.dat>
      
      NOTE : We recommend that node operators use the latest checkpoint file to speed up the syncing process.
  3. Configure Checkpoints in zq2-prototestnet.toml file:
    Open the zq2-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 the eth_getBlockByNumber API to query the block hash:
    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 '"'
    
    Alternatively, you can retrieve the block hash directly from the public explorer by searching for the block number.
    By this stage, your checkpoints configuration should be set up in the zq2-prototestnet.toml file.

  4. Launch the node
    Now the node is ready to launch. Follow the instructions in the Start the Node section to start your node.