Skip to content

Latest commit

 

History

History
113 lines (84 loc) · 4.5 KB

2.1.statesync.md

File metadata and controls

113 lines (84 loc) · 4.5 KB

State Sync - Client Script

Script to bootstrap the syncing when a new peer/validator joins the network.

The Problem

When a new peer tries to join the live network it can take days to fully synchronise, and this can take up a huge amount of disk space.

The Solution

StateSync is a feature which allows a new node to receive a snapshot of the application state without downloading blocks or going through consensus. Deploying the new State Sync function on StateSync servers could help to boost the synchronizing of new peers/validators. It also reduces the disk space usage.

Bitcanna StateSync servers will include this function in mainnet.

There are two State Sync scripts:

  • To sync a new peer/validator: statesync_client_linux_new.sh
  • To sync an existent peer/validator: statesync_client_linux_backup.sh

Start to sync a new peer/validator

Assuming you're not running a validator or node already:

  1. Install jq and download the script:

    sudo apt install jq
    wget https://raw.githubusercontent.com/BitCannaGlobal/cosmos-statesync_client/main/statesync_client_linux_new.sh
    chmod +x statesync_client_linux_new.sh
    
  2. Then launch the script (CTLR + C to stop it,): Carefully read the instructions displayed on your screen after you run it:

    ./statesync_client_linux_new.sh
    

When your peer is synced, set up a service file if you lack it, or setup Cosmovisor:

At this point you can create a simple BCNA service file, or you can configure Cosmovisor, Cosmovisor works like an upgrade "supervisor" that checks and applies the correct version of the software. As a result you can setup Cosmovisor as a replacement of the bcnad daemon/command line utility and let Cosmovisor handle future upgrades.

So the next step is (one of the following)

  • Skip Cosmovisor and continue with simple system service creation (step 3)
  • Go to Cosmovisor guide and skip this step and following steps of this guide.
  1. Move the binary to the system path:

    sudo mv .bcnad /usr/local/bin/
    
  2. Setup bcnad systemd service (copy and paste all to create the file service):

    cd $HOME
    echo "[Unit]
    Description=BitCanna Node
    After=network-online.target
    [Service]
    User=${USER}
    ExecStart=$(which bcnad) start
    Restart=always
    RestartSec=3
    LimitNOFILE=4096
    [Install]
    WantedBy=multi-user.target
    " >bcnad.service
    
  3. Enable and activate the BCNAD service.

    sudo mv bcnad.service /lib/systemd/system/
    sudo systemctl enable bcnad.service && sudo systemctl start bcnad.service
    
  4. Check the logs to see if it is working:

    sudo journalctl -u bcnad -f
    

If you want to run a validator see this guide:

https://github.com/BitCannaGlobal/bcna/blob/main/README.md#3Create-a-validator

Start to sync an existent peer/validator

Follow this instructions only if you are running currently a validator/peer.

It will reduces the disk space usage. From thousands of GB to MB maintaining your config and validator keys!

Don't start the BitCanna daemon manually, the script will do it for you and will synchronize the whole chain.

Follow the instructions at the screen when the script starts. Press CTRL + C to stop it when you see the peer synced with last block. It could takes some minutes (from 2 to 4 minutes)

If you are running a validator/peer, this script will save space in disk for you, will backup your current data and config folder and resync in several minutes.

Very important, the daemon should be turned off if is not a clean installation and jq tool must be installed in the system.

  1. Install jq and download the script:

    sudo apt install jq
    wget https://raw.githubusercontent.com/BitCannaGlobal/cosmos-statesync_client/main/statesync_client_linux_with_backup.sh
    chmod +x statesync_client_linux_with_backup.sh
    
  2. Then launch the script (CTLR + C to stop it):

    ./statesync_client_linux_with_backup.sh
    
  3. If everything goes right, you can delete the backup folder and the backup configuration

    rm -rf .old_bcna #deletes old folder to save space in hard disk
    rm bcna_folder_backup_* #deletes backed config; you can also save it safely
    
    

DISCLAIMER:

The StateSync script is experimental, run it at your own risk. Make your own backups of the configuration and do not run it before reading and understanding the contents of the script.

tags: doc github