Full Node Build

Install pre-requisites

# update the local package list and install any available upgrades
sudo apt-get update && sudo apt upgrade -y

# install toolchain and ensure accurate time synchronization
sudo apt-get install make build-essential gcc git jq chrony -y

Install Go

Follow the instructions here to install Go.

For an Ubuntu LTS, we can use:

# find location of existing GO (if any)
which go
go version

# remove old GO if existing
sudo rm -rf /usr/local/go

# install updated GO
wget https://golang.org/dl/go1.20.3.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.20.3.linux-amd64.tar.gz
rm -rf go1.20.3.linux-amd64.tar.gz

Unless you want to configure in a non standard way, then set these in the .zshrc in the user's home (i.e. ~/) folder.

nano ~/.zshrc

Add the "export Pathing" rules at the bottom, and then save the file:

# add export PATHS below
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOROOT/bin:$GOBIN

After updating your ~/.zshrc you will need to source it:

source ~/.zshrc

Build Daemon from source

git clone https://github.com/babylonchain/babylon
cd babylon
git checkout v0.7.2
make install

To confirm that the installation has succeeded, you can run:

babylond version --long

Configuration of Shell Variables

For this guide, we will be using shell variables. This will enable the use of the client commands verbatim. It is important to remember that shell commands are only valid for the current shell session, and if the shell session is closed, the shell variables will need to be re-defined.

If you want variables to persist for multiple sessions, then set them explicitly in your shell .profile, as you did for the Go environment variables.

To clear a variable binding, use unset $VARIABLE_NAME. Shell variables should be named with ALL CAPS.

CHAIN_ID="bbn-test-2"
MONIKER_NAME=<moniker-name>

Setting Up the Node

These instructions will direct you on how to initialize your node, synchronize to the network and upgrade your node to a validator.

Initialize the chain

Please replace YOUR_MONIKER with your own moniker.

babylond init YOUR_MONIKER --chain-id bbn-test-2

This will generate the following files in ~/.babylon/config/

  • genesis.json

  • node_key.json

  • priv_validator_key.json

Download the genesis file

wget https://github.com/babylonchain/networks/raw/main/bbn-test-2/genesis.tar.bz2
tar -xjf genesis.tar.bz2 && rm genesis.tar.bz2
mv genesis.json ~/.babylond/config/genesis.json

This will replace the genesis file created using babylond init command with the mainnet genesis.json.

Modify Configuration File

Edit the configuration file at ~/.babylond/config/config.toml and modify the seeds and persistent_peers attributes to contain appropriate seeds and peers of your choice. The full list of Babylon approved seeds and peers can be found under the bbn-test-2 network info page.

Edit the configuration file at ~/.babylond/config/app.toml and modify the btc-network attribute to contain the appropriate BTC network parameters as below.

[btc-config]
network = "mainnet"

Set Seeds

sed -i 's/seeds = ""/seeds = "seed0.testnet.babylonchain.io:26656"/' ~/.babylond/config/config.toml

Set minimum gas price

sed -i -e "s|^minimum-gas-prices *=.*|minimum-gas-prices = \"0.00001ubbn\"|" "${HOME}"/.babylond/config/app.toml

Create (or restore) a local key pair

Either create a new key pair or restore an existing wallet for your validator:

# Create new keypair
babylond keys add YOURKEY

# Restore existing juno wallet with mnemonic seed phrase.
# You will be prompted to enter mnemonic seed.
babylond keys add YOURKEY --recover

# Query the keystore for your public address
bbaylond keys show YOURKEY -a

After creating a new key, the key information and seed phrase will be shown. It is essential to write this seed phrase down and keep it in a safe place. The seed phrase is the only way to restore your keys.

Request Funds from the Babylon Testnet Faucet

This can be accomplished by going to the #faucet channel of the official Discord server to request funds by providing the address you created before. After joining the channel, users send a request starting with !faucet followed by the request address. For example, !faucet bbn1sajf5fd7tyjt0jjy6lqzahy09jl2nkcnx5qm06.

Setup cosmovisor

Follow the Setup Cosmovisor instructions to setup cosmovisor and start the node.

Create a BLS Key

Validators are expected to submit a BLS signature at the end of each epoch. To do that, a validator needs to have a BLS key pair to sign information with.

Using the address that you created on the previous step ($ADDR variable):

babylond create-bls-key $ADDR

This command will create a BLS key and add it to the ~/.babylond/config/priv_validator_key.json. This is the same file that stores the private key that the validator uses to sign blocks. Please ensure that this file is secured properly.

After creating a BLS key, you need to restart your node to load this key into memory. If you followed the setting up a node guide, you would have to

sudo systemctl stop babylond
sudo systemctl start babylond

Modify the Configuration

A Babylon validator needs to send BLS signature transactions at the end of each epoch. This process is done automatically through the Babylon codebase which identifies which key to use from the ~/.babylond/config/client.toml file. Edit this file and set the keyring backend that you're using. In this guide's case:

keyring-backend = "test"

Furthermore, you need to specify the name of the key that the validator will be using to submit BLS signature transactions under the ~/.babylond/config/app.toml file. Edit this file and set the key name to the one that holds funds on your keyring:

key-name = "val-key" # replace with your key name

Finally, it is strongly recommended to modify the timeout_commit value under ~/.babylond/config/config.toml. This value specifies how long a validator will wait before commiting a block before starting on a new height. More information can be found here. Given that Babylon aims to have a 10 second time between blocks, set this value to:

timeout_commit = "10s"

Upgrade to a validator

Do not attempt to upgrade your node to a validator until the node is fully in sync as per the previous step.

To upgrade the node to a validator, you will need to submit a create-validator transaction:

babylond tx staking create-validator \
  --amount 1000000ubbn \
  --commission-max-change-rate "0.1" \
  --commission-max-rate "0.20" \
  --commission-rate "0.1" \
  --min-self-delegation "1" \
  --details "Your details here" \
  --pubkey=$(babylond tendermint show-validator) \
  --moniker $MONIKER_NAME \
  --keyring-backend=test \
  --chain-id $CHAIN_ID \
  --fees 5000ubbn \
  --node http://<YOURIP>:<YOURPORT> \
  --from <KEYNAME>

The above transaction is just an example. There are many more flags that can be set to customize your validator, such as your validator website, or keybase.io id, etc. To see a full list:

babylond tx staking create-validator --help

Backup critical files

There are certain files that you need to back up to be able to restore your validator if, for some reason, it damaged or lost in some way. Please make a secure backup of the following files located in ~/.babylond/config/:

  • priv_validator_key.json

  • node_key.json

It is recommended that you encrypt and backup of these files.

Last updated

Logo

Made with ❤️ by WhisperNode // © 2024.