Skip to content

Latest commit

 

History

History
174 lines (146 loc) · 7.34 KB

5.cosmovisor.md

File metadata and controls

174 lines (146 loc) · 7.34 KB

Cosmovisor instructions for bitcanna-1

In this guide, you will find step-by-step instructions for downloading, compiling, and installing Cosmovisor on your BitCanna node on the MAINNET. We have provided the simplest methods for installation, so you can quickly and easily get Cosmovisor running on your node.

When a new version of the bcnad binary is released and governance has approved for it to take place, instructions on how to implement the upgrade with Cosmovisor are included on the releasepage on GitHub.

If you have any questions or find anything unclear when reading through this guide, don’t hesitate to reach out to us on Discord. Also, if you have any suggestions for improvement, we welcome you to make a pull request!

Let’s get started!

About Cosmovisor

Cosmovisor is a small process manager for Cosmos SDK application binaries to handle chain upgrades. It works for upgrades that has been approved through governance proposals. In a governance proposal the upgrade name and block height is included. If Cosmovisor finds the requirements for this upgrade in the logs of the chain binary, it stops the current binary, switch from the old binary to the new one, and finally restarts the node with the new binary.

This guide will explain how to install Cosmovisor on your node. A full guide about Cosmovisor can be found here.

Step 1. Download or compile Cosmovisor

The easiest option to install Cosmovisor is by downloading the pre-compiled binary. Alternatively, users with more advanced technical knowledge can install Go on their system and compile Cosmovisor from the source. For a full guide to install Go, please refer to this link.

Option 1: Download the pre-compiled Cosmovisor binary:

cd ~
wget https://github.com/BitCannaGlobal/bcna/releases/download/v1.5.3/cosmovisor

Make Cosmovisor executable and move it to the bin directory.

chmod +x ./cosmovisor
sudo mv cosmovisor /usr/local/bin/

Option 2: Download the source code and compile Cosmovisor using Go:

go install cosmossdk.io/tools/cosmovisor/cmd/cosmovisor@latest

Step 2. Setup Cosmovisor

For each upgraded version of bcnad binaries, there needs to be a designated folder which Cosmovisor can point to at the predetermined upgrade block height. For the initial setup of Cosmovisor, we will create a folder named after the most recent upgrade codename.

1.) Prepare your system.

Edit your .profile file to add the required environment variables for Cosmovisor to start.

cd ~
nano $HOME/.profile

Add these lines to the bottom of the file:

export DAEMON_NAME=bcnad
export DAEMON_RESTART_AFTER_UPGRADE=true
export DAEMON_HOME=${HOME}/.bcna
export DAEMON_RESTART_DELAY=30s
export UNSAFE_SKIP_BACKUP=true
export DAEMON_LOG_BUFFER_SIZE=512

#add this to continue to use bcnad for commands, this is optional
PATH="${HOME}/.bcna/cosmovisor/current/bin:$PATH" 

Reload the configuration of your .profile file.

source $HOME/.profile

2.) Start the initial Cosmovisor configuration.

cosmovisor init $(which bcnad)

The output should contain lines similar to these:

11:46AM INF checking on the genesis/bin directory module=cosmovisor
11:46AM INF creating directory (and any parents): "/home/user/.bcna/cosmovisor/genesis/bin" module=cosmovisor
11:46AM INF checking on the genesis/bin executable module=cosmovisor
11:46AM INF copying executable into place: "/home/user/.bcna/cosmovisor/genesis/bin/bcnad" module=cosmovisor
11:46AM INF making sure "/home/user/.bcna/cosmovisor/genesis/bin/bcnad" is executable module=cosmovisor
11:46AM INF checking on the current symlink and creating it if needed module=cosmovisor
11:46AM INF the current symlink points to: "/home/user/.bcna/cosmovisor/genesis/bin/bcnad" module=cosmovisor

3.) Create a designated folder for the latest version of bcnad.

mkdir -p $HOME/.bcna/cosmovisor/upgrades/wakeandbake/bin

4.) Copy the latest version of bcnad to it's designated folder.

cp -r $(which bcnad) $HOME/.bcna/cosmovisor/upgrades/wakeandbake/bin/

5.) Setup the current version link for Cosmovisor.

ln -sfn  ${HOME}/.bcna/cosmovisor/upgrades/wakeandbake ${HOME}/.bcna/cosmovisor/current

6.) To see if everything is OK, run:

ls .bcna/cosmovisor/ -lh

The output should look like this:

total 8.0K
lrwxrwxrwx 1 user user   35 Jun 28 19:05 current -> /home/user/.bcna/cosmovisor/upgrades/wakeandbake
drwxrwxr-x 3 user user 4.0K Jun 28 19:03 genesis
drwxrwxr-x 3 user user 4.0K Jun 28 19:05 upgrades

Step 3. Finish the installation and start Cosmovisor

1.) Create a systemd servicefile for Cosmovisor.

Simply copy and paste everything to create the service unit.

Optionally enable backup, set the folder location, and name the folder.

echo "[Unit]
Description=Cosmovisor BitCanna Service
After=network-online.target
[Service]
User=${USER}
Environment=DAEMON_NAME=bcnad
Environment=DAEMON_RESTART_AFTER_UPGRADE=true
Environment=DAEMON_HOME=${HOME}/.bcna
Environment=UNSAFE_SKIP_BACKUP=true
Environment=DAEMON_RESTART_DELAY=30s
Environment=DAEMON_LOG_BUFFER_SIZE=512
#Optional export DAEMON_DATA_BACKUP_DIR=${HOME}/your_chain_backup_folder
ExecStart=$(which cosmovisor) run start
Restart=always
RestartSec=3
LimitNOFILE=4096
[Install]
WantedBy=multi-user.target
" >cosmovisor.service

2.) Change bcnad service for cosmovisor service.

You can skip the 3rd line if you're doing a clean installation and the bcnadservice doesn't exist.

sudo mv cosmovisor.service /lib/systemd/system/
sudo systemctl daemon-reload
sudo systemctl stop bcnad.service && sudo systemctl disable bcnad.service 
sudo systemctl enable cosmovisor.service && sudo systemctl start cosmovisor.service

3.) Check the logs.** (ctrl + C to stop).

sudo journalctl -fu cosmovisor -o cat

You can speed up the synchronization using a StateSync Server or a snapshot file.

4.) Now let's try Cosmovisor.

If everything is OK, Cosmovisor will take control of the binaries. Instead of bcnad you must use cosmosvisor run in your service related commands.

Show Cosmovisor's version.

cosmovisor run version

It must return v2.0.2

The output should look like this:

20:27PM INF running app args=["version"] module=cosmovisor path=/home/user/.bcna/cosmovisor/upgrades/wakeandbake
2.0.2
  • Show BitCanna version: bcnad version Must show the same version as above
  • Show Cosmovisor sync info and status: cosmovisor run status

5.) Done.

Congratulations, you have installed Cosmovisor on your BitCanna node. Future upgrades of the binary's will be handled by Cosmovisor. Instructions to prepare Cosmovisor for an upcoming chain-upgrade will be provided on the release page. An example can be found here.

Reminder

In the future, you must use the cosmovisor command instead of the bcnad command if you want to perform service related commands.

For example:

  • Start the service: sudo service cosmovisor start
  • Stop the service: sudo service cosmovisor stop
  • Restart the service: sudo service cosmovisor restart
  • Check the logs: sudo journalctl -u cosmovisor -f
tags: cosmovisor, bitcanna