-
Notifications
You must be signed in to change notification settings - Fork 59
BandChain Laozi Mainnet: How to Join as a Validator
This document describes methods on how to join as a validator in Laozi Mainnet.
This step provides procedures to install Bandchain's executable and sync blocks with other peers.
Assuming to run on Ubuntu 20.04 LTS allowing connection on port 26656
for P2P connection.
Before beginning instructions, following variables should be set to be used in further instructions. Please make sure that these variables is set everytime when using the new shell session.
# Chain ID of Laozi Mainnet
export CHAIN_ID=laozi-mainnet
# Wallet name to be used as validator's account, please change this into your name (no whitespace).
export WALLET_NAME=<YOUR_WALLET_NAME>
# Name of your validator node, please change this into your name.
export MONIKER=<YOUR_MONIKER>
# URL of genesis file for Laozi Mainnet
export GENESIS_FILE_URL=https://raw.githubusercontent.com/bandprotocol/launch/master/laozi-mainnet/genesis.json
# Data sources/oracle scripts files
export BIN_FILES_URL=https://raw.githubusercontent.com/bandprotocol/launch/master/laozi-mainnet/files.tar.gz
The following application is required for Building and running Bandchain node.
- make, gcc, g++ (can be obtained from
build-essential
package on linux) - wget, curl for downloading files
# install required tools
sudo apt-get update && \
sudo apt-get upgrade -y && \
sudo apt-get install -y build-essential curl wget
- Go 1.16
# Install Go 1.16.7
wget https://dl.google.com/go/go1.16.7.linux-amd64.tar.gz
tar xf go1.16.7.linux-amd64.tar.gz
sudo mv go /usr/local/go
# Set Go path to $PATH variable
echo "export PATH=$PATH:/usr/local/go/bin:~/go/bin" >> $HOME/.profile
source ~/.profile
Go binary should be at /usr/local/go/bin
and any executable compiled by go install
command should be at ~/go/bin
# Clone Bandchain Laozi version v2.3.0
git clone https://github.com/bandprotocol/chain
cd chain
git checkout v2.3.0
# Install binaries to $GOPATH/bin
make install
cd $HOME
# Initialize configuration and genesis state
bandd init --chain-id $CHAIN_ID "$MONIKER"
# Replace genesis file with our genesis file
wget $GENESIS_FILE_URL -O $HOME/.band/config/genesis.json
# Download data sources / oracle scripts files, and store in $HOME/.band/files
wget -qO- $BIN_FILES_URL | tar xvz -C $HOME/.band/
# Create new account
bandd keys add $WALLET_NAME
This can be done by editing seeds
or persistent_peers
property in $HOME/.band/config/config.toml
.
Please see here for the list of seeds and peers.
We do recommend to run bandchain node as a daemon, which can be setup using systemctl
. Run the following command to create a new daemon for bandd
(This script work on non-root user).
# Write bandd service file to /etc/systemd/system/bandd.service
export USERNAME=$(whoami)
sudo -E bash -c 'cat << EOF > /etc/systemd/system/bandd.service
[Unit]
Description=BandChain Node Daemon
After=network-online.target
[Service]
User=$USERNAME
ExecStart=/home/$USERNAME/go/bin/bandd start
Restart=always
RestartSec=3
LimitNOFILE=4096
[Install]
WantedBy=multi-user.target
EOF'
Based on design, validator need to send a transaction to submit reports based on certain oracle requests. The validator should send transactions to submit reports within specified timeframe. However, the method is quite tedious. Therefore, we have develop an application called Yoda
, which is a bot application that help validator automatically listen new oracle requests on Bandchain, execute data sources, and submit report to Bandchain, so validators don't have to send the transactions manually.
Before setting up Yoda, Lambda function executor need to be setup to execute data sources. If this step has not been done yet, please follow the instructions on following pages (select either one of these methods):
Then, check Yoda version that we have compiled. It should be v2.3.0
.
yoda version
# v2.3.0
Firstly, configure Yoda's basic configurations
rm -rf ~/.yoda # clear old config if exist
yoda config chain-id $CHAIN_ID
yoda config node http://localhost:26657
yoda config broadcast-timeout "5m"
yoda config rpc-poll-interval "1s"
yoda config max-try 5
yoda config validator $(bandd keys show $WALLET_NAME -a --bech val)
Secondly, add multiple reporter accounts to allow Yoda submitting transactions concurrently.
yoda keys add REPORTER_1
yoda keys add REPORTER_2
yoda keys add REPORTER_3
yoda keys add REPORTER_4
yoda keys add REPORTER_5
Thirdly, config Lambda Executor endpoint
export EXECUTOR_URL=<YOUR_EXECUTOR_URL>
yoda config executor "rest:${EXECUTOR_URL}?timeout=10s"
We also do recommend to use systemctl
the same as bandd
.
# Write yoda service to /etc/systemd/system/yoda.service
export USERNAME=$(whoami)
sudo -E bash -c 'cat << EOF > /etc/systemd/system/yoda.service
[Unit]
Description=Yoda Daemon
After=network-online.target
[Service]
User=$USERNAME
ExecStart=/home/$USERNAME/go/bin/yoda run
Restart=always
RestartSec=3
LimitNOFILE=4096
[Install]
WantedBy=multi-user.target
EOF'
To register both bandd
and yoda
services, run the following commands.
# Register bandd daemon to systemctl
sudo systemctl enable bandd
# Register yoda to systemctl
sudo systemctl enable yoda
Then start bandd
service which also automatically initiates yoda
# Start bandd daemon
sudo systemctl start bandd
Once bandd
service has been started, logs can be queried by running journalctl -u bandd.service -f
command. You will see your node beginning to sync.
After yoda
service has been started, logs can be queried by running journalctl -u yoda.service -f
command. Log should be similar to the following log example below. Once verified, you can stop tailing the log by typing Control-C
.
... systemd[...]: Started Yoda Daemon.
... yoda[...]: I[...] ⭐ Creating HTTP client with node URI: tcp://localhost:26657
... yoda[...]: I[...] 🚀 Starting WebSocket subscriber
... yoda[...]: I[...] 👂 Subscribing to events with query: tm.event = 'Tx'...
This is an important step. We should wait for newly started Bandchain node to sync their blocks until the latest block is reached. The latest block can be checked on this Block Explorer.
This step provides procedures to register the node as a validator.
bandd keys show $WALLET_NAME
Then fund tokens into this account ready for staking.
bandd tx staking create-validator \
--amount 3000000uband \
--commission-max-change-rate 0.01 \
--commission-max-rate 0.2 \
--commission-rate 0.1 \
--from $WALLET_NAME \
--min-self-delegation 1 \
--moniker "$MONIKER" \
--pubkey $(bandd tendermint show-validator) \
--chain-id $CHAIN_ID
After became a validator, the validator node will be shown on Block Explorer here.
Now, Yoda have multiple reporters. In order to register the reporters to be owned by the validator, the following commands should be run.
Firstly, reporter accounts must be create on Bandchain by supplying some small amount of BAND tokens.
# Send 1uband from a wallet to each reporter.
bandd tx multi-send 1uband $(yoda keys list -a) \
--from $WALLET_NAME \
--chain-id $CHAIN_ID
Secondly, register reporters to the validator, so that oracle requests for validator can be assigned to the reporters.
bandd tx oracle add-reporters $(yoda keys list -a) \
--from $WALLET_NAME \
--chain-id $CHAIN_ID
Finally, activate the validator to become an oracle provider
bandd tx oracle activate \
--from $WALLET_NAME \
--chain-id $CHAIN_ID
If all procedures are successful, then oracle provider status for the validator should be active
.
bandd query oracle validator $(bandd keys show -a $WALLET_NAME --bech val)
# {
# "is_active": true,
# "since": ...
# }
And now you have become a validator on Bandchain Laozi mainnet.
Happy staking 📈, and may the HODL be with you.