Setting up a full node for Bitcanna [bitcanna-1]

Cat Boss
5 min readOct 7, 2021

--

Hello Cat Boss here! We’re going to cut to the chase today and do quick run of how to set up a working full node for Bitcanna who has recently joined the cosmos community!

Just like many of our previous full node tutorials, the setup is pretty similar but we wanted to write a post in support of their network.

At the time of this posting they are on bitcanna-1.

Official documentation from the Bitcanna team can be found: https://github.com/BitCannaGlobal/bcna/blob/main/instructions.md

Create a server

We’ll be using Ubuntu 20.04LTS with 4GB RAM / 2 CPUs/ 80GB storage, a little bit less than the recommended in the official documentation but this can be changed later on as you feel the need to upgrade your server.

Remotely ssh into the server using the CLI and create a new user

By default, if you’re using root we recommend switching to another user because “It defeats the security model that’s been in place for years” (You can read the full response here: https://askubuntu.com/questions/16178/why-is-it-bad-to-log-in-as-root)

To create a new user we will do the following:

adduser <username>
usermod -aG sudo <username>

This will create a new user and give it a sudo role. We can test it by switching to this user and running a sudo command:

su - <username>
sudo ls -la /root

You should see something like the following:

General environment setup

The following will prep your environment by updating / upgrading the system and installing the needed libraries to install the bitcanna binary.

# Update the system
sudo apt update
sudo apt upgrade
# Install git, gcc and make
sudo apt install git build-essential ufw curl jq snapd --yes
# Install Go with Snap
sudo snap install go --classic
# Export environment variables
echo 'export GOPATH="$HOME/go"' >> ~/.profile
echo 'export GOBIN="$GOPATH/bin"' >> ~/.profile
echo 'export PATH="$GOBIN:$PATH"' >> ~/.profile
source ~/.profile

To verify go is installed:

go version

should return something like this

Install bcnad

cd $HOME
git clone https://github.com/BitCannaGlobal/bcna.git
cd bcna
git checkout v1.1
make install

This will make sure you are in the home directory, clone the bcna repo and install the correct version.

To verify your installation you can run bcnad version --long
If you get something like the following, you’ve successfully installed bcnad on your system.

name: bcna
server_name: bcnad
version: "1.1"
commit: 0740c191bf290b9a6a69976c4a90520e6d4fb7ce
build_tags: netgo,ledger
go: go version go1.16.3 darwin/amd64

Initialise your node

Before we initialise your node, we recommend saving the current chain id as bitcanna-1 using the following command.

bcnad config chain-id bitcanna-1

This will default the chain-id flag to bitcanna-1 and save you some time in the future.

To initialise the bitcanna working directory we will run the following:

bcnad init --chain-id bitcanna-1 <your_moniker>

This will generate genesis.json , node_key.json , and priv_validator_key.json in ~/.bcna/config/ .

Download the genesis file

curl https://raw.githubusercontent.com/BitCannaGlobal/bcna/main/genesis.json > ~/.bcna/config/genesis.json

This will replace the genesis file created using bcnad init with the genesis file currently being used in bitcanna-1

Edit config.tolm

In ~./bcna/config/config.tolm we will run the following:

sed -E -i 's/seeds = \".*\"/seeds = \"d6aa4c9f3ccecb0cc52109a95962b4618d69dd3f@seed1.bitcanna.io:26656,23671067d0fd40aec523290585c7d8e91034a771@seed2.bitcanna.io:26656\"/' $HOME/.bcna/config/config.toml

This will add seed nodes in our config unlike our previous posts.

Seed nodes are basically a full node that will keep track of any new nodes they come in contact with and share their address book with them. This can save a lot of nodes the hassle of looking for peers but we should always keep a few trusted peers in our config just in case.

It should look something like this:

# Comma separated list of seed nodes to connect to
seeds = "d6aa4c9f3ccecb0cc52109a95962b4618d69dd3f@seed1.bitcanna.io:26656,23671067d0fd40aec523290585c7d8e91034a771@seed2.bitcanna.io:26656"

Update minimum-gas-prices in ~/.bcna/config/app.toml to prevent getting spammed by transactions with no gas.

sed -E -i 's/minimum-gas-prices = \".*\"/minimum-gas-prices = \"0.001ubcna\"/' $HOME/.bcna/config/app.toml

Setup Cosmovisor (optional but super recommended)

In order to do automatic on-chain upgrades we will be using cosmovisor. You can read more about it here: https://docs.cosmos.network/master/run-node/cosmovisor.html

# download the cosmovisor binary
go get github.com/cosmos/cosmos-sdk/cosmovisor/cmd/cosmovisor
# check the version (it should print DAEMON_NAME is not set)
cosmovisor version

Set up the environment variables

echo "# Setup Cosmovisor" >> ~/.profile
echo "export DAEMON_NAME=bcnad" >> ~/.profile
echo "export DAEMON_HOME=$HOME/.bcna" >> ~/.profile
source ~/.profile
# verify by running the following
echo $DAEMON_NAME

Copy the proper files

mkdir -p ~/.bcna/cosmovisor/upgrades
mkdir -p ~/.bcna/cosmovisor/genesis/bin/
cp $(which bcnad) ~/.bcna/cosmovisor/genesis/bin/
# verify by running the following (it should output the same version is running bcnad version):
cosmovisor version

Opening up proper ports

While opening any ports are optional, it is beneficial to the whole network if you open port 26656. This would allow new nodes to connect to you as a peer, making them sync faster and the connections more reliable.

For this reason, we will be opening port 26656 using ufw.

# running this should show it is inactive
sudo ufw status
# Turn on ssh if you need it
sudo ufw allow ssh
# Accept connections to port 26656 from any address
sudo ufw allow from any to any port 26656 proto tcp
# enable ufw
sudo ufw enable
# check ufw is running
sudo ufw status

Start the node (test run)

Before we can all fancy and setup a background service let’s take our node for a test drive.

cosmovisor start 

Don’t be surprise if it seems like the CLI is hanging there. As long as it doesn’t error out give it a few minutes.

If all is well, we can stop the node and setup a background service

Background service

This will allow the node to run in the background and restart automatically.

sudo tee /etc/systemd/system/bcnad.service > /dev/null <<EOF  
[Unit]
Description=BCNA Full Node
After=network-online.target

[Service]
User=$USER
ExecStart=$(which cosmovisor) start
Restart=always
RestartSec=3
LimitNOFILE=4096

Environment="DAEMON_HOME=$HOME/.bcna"
Environment="DAEMON_NAME=bcnad"

[Install]
WantedBy=multi-user.target
EOF

Update and start

sudo -S systemctl daemon-reload
sudo -S systemctl enable bcnad
sudo -S systemctl start bcnad

Check the status

sudo service bcnad status

Check the logs

sudo journalctl -u bcnad -f

Check that the node is syncing up

Some things you can check to make sure your node is syncing up correctly:

Check your sync status (if the output is false then you are all synced up)

bcnad status 2>&1 | jq "{catching_up: .SyncInfo.catching_up}"

Check that the latest block height is catching up

bcnad status 2>&1 | jq "{latest_block_height: .SyncInfo.latest_block_height}"

Check that you have peers

curl -sS "http://localhost:26657/net_info?" | jq -r '.result.n_peers'

Conclusion

Congrats! Once your status is no longer catching up you have a fully synced fullnode.

What you can do next is convert this fullnode into a validator node or keep it as a backup. Whatever you like ヾ(=`ω´=)ノ”

--

--

Cat Boss
Cat Boss

Written by Cat Boss

We’re dPoS validators and we like writing medium posts documenting our journey, sharing tips we learn along the way. Trust me, I am a Cat.

No responses yet