Image for post
Image for post

How to Setup a Terra (LUNA) Validator Node

Christian Lanz
May 7 · 12 min read

The following article is a walk-through on how to set-up a validator node on the Terra network.

Please note that the requirements below might change in the future as the network processes more transactions and the blockchain gets bigger, so your node may require higher specifications than those listed.

What are we going to do?

  1. Machine/Server Setup
  2. Sync Node
  3. Register & Run Validator
  4. Setup Oracle Price Feed

Machine/Server Setup

Launch Cloud Instance

You can either run a node on your own hardware or use a cloud provider. I would recommend choosing one of the big cloud providers, e.g. Amazon AWS.

Node Specifications

At least an m5.large General Purpose Instance with 2 CPU and 8GB of memory.

Use Ubuntu Server 18.04 LTS (64-bit) and ensure to allocate enough storage — the mainnet uses ~115GB of disk space at the moment. I would recommend going with at least 500GB of disk space for now.

Network Settings

Open up port 22 for SSH, as well as port 26656 for TCP traffic (so your node can communicate with others).

Setup Non-Root User

If there is already a non-root user available, you can skip this step.

# SSH into your machine
(local)$ ssh root@{VALIDATOR_IP_ADDRESS}
# Update the system
(validator)$ sudo apt-get update && sudo apt-get upgrade -y
# Create a non-root user
(validator)$ USER={USER}
(validator)$ sudo mkdir -p /home/$USER/.ssh
(validator)$ sudo touch /home/$USER/.ssh/authorized_keys
(validator)$ sudo useradd -d /home/$USER $USER
(validator)$ sudo usermod -aG sudo $USER
(validator)$ sudo chown -R $USER:$USER /home/$USER/
(validator)$ sudo chmod 700 /home/$USER/.ssh
(validator)$ sudo chmod 644 /home/$USER/.ssh/authorized_keys
  • Validator IP Address: The IP address of the remote machine/server
  • User: The name of the unix user you want to create

Make sure to paste your public SSH key into the authorized_keys file of the newly created user in order to be able to login via SSH.

# Enable sudo without password for the user
(validator)$ sudo vi /etc/sudoers

Add the following line to the end of the file:

{USER} ALL=NOPASSWD: ALL
  • User: The name of the unix user you just created
Image for post
Image for post
/etc/sudoers
# Install zsh
(validator)$ sudo apt-get install -y zsh
# Set zsh as the default shell for the user
(validator)$ sudo vi /etc/passwd

Go to the line with your username (most probably the last one, as you just created the user) and change the default shell at the end of the line from:

/bin/bash --> /bin/zsh
Image for post
Image for post
/etc/passwd

Now close the root SSH connection to the machine and login as your newly created user:

# Close the root SSH connection
(validator)$ exit
# Login as new user
(local)$ ssh {USER}@{VALIDATOR_IP_ADDRESS}
  • Validator IP Address: The IP address of the remote machine/server
  • User: The name of the unix user you created previously

Install zsh (optional)

Now let’s make the zsh shell a little bit prettier 🙂:

# Install oh-my-zsh
(validator)$ git clone https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
(validator)$ cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc

Exit the shell and login again for the changes be activated:

# Exit the shell
(validator)$ exit
# Re-Login
(local)$ ssh {USER}@{VALIDATOR_IP_ADDRESS}
  • Validator IP Address: The IP address of the remote machine/server
  • User: The name of the unix user you created previously

Install Required Tools

You are still logged in as the new user via SSH. Now we are going to install go and Terra Core.

First, install the required build tools:

# Install build-essential
(validator)$ sudo apt-get install -y build-essential

Install go

# Install go
(validator)$ wget https://dl.google.com/go/go1.13.3.linux-amd64.tar.gz
(validator)$ sudo tar -xvf go1.13.3.linux-amd64.tar.gz
(validator)$ sudo mv go /usr/local

Then open up your .zshrc file and export the required go paths:

# Export go paths
(validator)$ vi ~/.zshrc
# Append at the bottom of .zshrc
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH

Reload your .zshrc config:

# Reload .zshrc config
(validator)$ source ~/.zshrc

Validate go installation:

Image for post
Image for post
go

Install GolangCI-Lint

# Install go linter
(validator)$ curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.24.0

Validate golangci-lint installation:

Image for post
Image for post
golangci-lint

Install Terra Core

Go to https://github.com/terra-project/core/releases and see what’s the latest release, check it out and build it (at the moment it’s v0.3.5, but make sure you use the latest!):

# Install Terra Core
(validator)$ git clone https://github.com/terra-project/core/
(validator)$ cd core
(validator)$ git checkout v0.3.5
(validator)$ make install

Validate your Terra Core installation:

Image for post
Image for post
terrad and terracli

Sync Node

First initialize your node so all the necessary terra files and directories get created

(validator)$ terrad init {MONIKER}
  • Moniker: The name of your validator (e.g. “block42”)

Then download the genesis file of the columbus-3 network:

(validator)$ curl https://columbus-genesis.s3-ap-northeast-1.amazonaws.com/genesis.json > $HOME/.terrad/config/genesis.json

To speed up the sync process head over to chainlayer.io and get the latest “normal” Terra snapshot for the columbus-3 network.

Image for post
Image for post
Terra snapshot by chainlayer.io

Download the latest snapshot to the .terrad directory onto your machine:

(validator)$ cd ~/.terrad
(validator)$ wget http://quicksync.chainlayer.io/terra/columbus-3.DATE.TIME.tar.lz4

⚠️ Make sure to download the latest snapshot available at the time when you are reading this setup guide!

→ This will take some time, so feel free to grab a coffee. ☕

Before unpacking the snapshot you need to install the necessary tool:

(validator)$ sudo apt-get install wget liblz4-tool -y

Then, unpack it:

(validator)$ cd ~/.terrad
(validator)$ lz4 -d columbus-X.DATE.TIME.tar.lz4 | tar xf -

→ This will also take while, so you probably go and grab some more coffee. ☕

When everything is done, the snapshot should have been unpacked into your ~/.terrad/data directory.

Don’t forget to delete the snapshot archive, you don’t need it any more and it requires a lot of disk space.

Specify Seed Nodes

Open up your ~/.terrad/config/config.toml file:

(validator)$ vi ~/.terrad/config/config.toml

and set the seeds config to the following value:

seeds = "20271e0591a7204d72280b87fdaa854f50c55e7e@106.10.59.48:26656,3b1c85b86528d10acc5475cb2c874714a69fde1e@110.234.23.153:26656,49333a4cb195d570ea244dab675a38abf97011d2@13.113.103.57:26656,7f19128de85ced9b62c3947fd2c2db2064462533@52.68.3.126:26656"

Get Address Book

Download the latest address book so your node is able to find other nodes:

(validator)$ wget https://gist.githubusercontent.com/rekt0x/b3155de2ff072ff7be2eaf4c8c2c038c/raw/1d503aedc4137daaf6ab43c6c5fdcdb8b13c3dfc/addrbook.json > ~/.terrad/config/addrbook.json

Now let’s start up your Terra node:

(validator)$ cd ~
(validator)$ terrad start
Image for post
Image for post
terrad start

Don’t worry about the red error logs (those are from failed connections to other nodes), you should soon start to see your node syncing blocks. Just wait for a minute or so for your node to start syncing.

The error logs should disappear after a while and your console output should look something like this (errors could still appear from time to time though):

Image for post
Image for post
terrad start, no more errors

Now stop the node before proceeding with the next step.

Run Terra Node via pm2 Process Manager

You can use whatever process manager you prefer, I usually go with pm2. Now let’s install all prerequisites and run the Terra node via pm2 in the background:

# Install nodejs, npm and pm2
(validator)$ sudo apt-get install nodejs npm -y
(validator)$ sudo npm i -g pm2

Create a bash script to run the Terra node:

(validator)$ cd ~
(validator)$ touch runNode.sh
(validator)$ chmod +x runNode.sh

Put in the following content:

#!/bin/sh
terrad start

Create another file:

(validator)$ touch terra-node.ecosystem.config.js

Put in the following content:

module.exports = { apps : [ { name: "terra-node", script: "/home/{USER}/runNode.sh", exec_mode: "fork", exec_interpreter: "bash"} ] }
  • User: The name of the unix user you created previously

Start the Terra node as a pm2 process:

pm2 start ./terra-node.ecosystem.config.js

Execute the following two commands, so your node is auto restarted upon failure and system restart:

(validator)$ pm2 save
(validator)$ pm2 startup

Check status or logs with those commands:

# Check status
(validator)$ pm2 status
# Check logs
(validator)$ pm2 logs

Now your Terra node should be running in the background as a pm2 process.

Image for post
Image for post
Terra node running as pm2 process

Leave your node running until it synced to the latest block height. You can check the latest height at e.g.: https://terra.stake.id

Image for post
Image for post
terra.stake.id

You can also check if your node is still syncing via:

(validator)$ curl -Ss localhost:26657/status | jq -er “.result.sync_info”

You might need to install jq beforehand:

(validator)$ sudo apt-get install jq -y

This will give you something like that:

Image for post
Image for post
Terra node status

Watch for the “catching_up” — this needs to be “false”. Then your node is fully synced. You can also take the latest block height from here and compare it with the one in the block explorer to see how far your node is still away.

⚠️ Syncing your node could take several hours or even days. Make sure to wait until it’s fully synced before continuing with the next step!

Register & Run Validator

After fully syncing your node, you are now ready to register as a validator and start your node in validator mode!

First you need to generate a new wallet which your validator will be using:

(validator)$ terracli keys add validator
Image for post
Image for post
Add validator wallet

⚠️ Make sure to save those 24 words in a secure place and DO NOT share them with anyone! You need them in case you want to restore your wallet. Also don’t forget to save the passwords you used to encrypt it!

Now you need to fund your newly generated validator wallet with some LUNA so you are able to pay the fees for the upcoming transactions. 💰

To register as a validator the following transaction needs to be sent:

(validator)$ terracli tx staking create-validator --pubkey {VALIDATOR_PUB_KEY} --amount "1000000uluna" --from {VALIDATOR_WALLET_NAME} --commission-rate="{COMMISSION_RATE}" --commission-max-rate="{COMMISSION_MAX_RATE}" --commission-max-change-rate="{COMMISSION_MAX_CHANGE_RATE}" --min-self-delegation "1" --moniker "{MONIKER}" --chain-id "columbus-3" --gas-auto --node tcp://127.0.0.1:26657 --gas-prices="1.5uluna" --gas-adjustment=1.4
  • Validator Pub Key: Execute the following command to get it:
(validator)$ terrad tendermint show-validator
  • Validator Wallet Name: Use the name you used before to create your validator wallet (e.g. “validator”)
  • Commission Rate: The %-fee you want to charge your delegators (from 0 to 1, e.g. 0.2 for 20%)
  • Commission Max Rate: The maximum %-fee you charge validators at any point in time — you can not change that afterwards, so set this carefully! (from 0 to 1, e.g. 1.00 for 100%)
  • Commission Max Change Rate: The maximum % by which you can change your fee rate within a certain period of time (from 0 to 1, e.g. 0.05 for 5%)
  • Moniker: The name of your validator (e.g. “block42”)

Verify that the transaction has succeeded, check it on: https://terra.stake.id

Image for post
Image for post
https://terra.stake.id/?#/tx/5D695063F887383D12C877770B689151078A94F58E0299079959EA5CD02C9957

After a few moments your validator node will be visible on Terra Station (marked as “new”):

Image for post
Image for post
https://station.terra.money/staking

If you want to add a nice logo to your node, check out how to edit your validator description: https://docs.terra.money/docs/validator-getting-started#edit-validator-description

I also suggest to head over to the Terra GitHub and create a validator profile so the Terra community knows who you are: https://github.com/terra-project/validator-profiles

Congrats, your validator is now up and running! 🥳

Setup Oracle Price Feed

It’s mandatory for validators on the Terra network to also provide a price feed.

You can find all available oracle implementations here: https://docs.terra.money/docs/validator-oracle

We decided to go with terra-oracle by Node A-Team: https://github.com/node-a-team/terra-oracle

Install & Setup

Clone the repository and install it:

(validator)$ git clone https://github.com/node-a-team/terra-oracle.git
(validator)$ cd terra-oracle
(validator)$ go install ./cmd/terra-oracle

Afterwards verify that the installation was completed successfully:

Image for post
Image for post
terra-oracle version

Set default config for terracli:

(validator)$ terracli config chain-id columbus-3
(validator)$ terracli config node tcp://localhost:26657

Add Oracle Wallet

As the next step you need to create an oracle wallet. This wallet will be used to send price feed transactions:

(validator)$ terracli keys add oracle
Image for post
Image for post
Add oracle wallet

⚠️ Make sure to save those 24 words in a secure place and DO NOT share them with anyone! You need them in case you want to restore your wallet. Also don’t forget to save the passwords you used to encrypt it!

Set Oracle Price Feeder

You need to tell the network which wallet will provide the price feed for your validator node.

(validator)$ terracli tx oracle set-feeder {ORACLE_WALLET_ADDRESS} --from={VALIDATOR_WALLET_NAME} --gas-prices="5.1uluna" --gas-adjustment=1.25
  • Oracle Wallet Address: The address of the oracle wallet you just created
  • Validator Wallet Name: The name of the validator wallet you created previously

Verify that the transaction has succeeded, check it on: https://terra.stake.id

Image for post
Image for post
https://terra.stake.id/?#/tx/D1393544EF3E1E51AEF8AF06A7600DFBF35E71492DE6DC9ECD43488A470CFBB8

Fund your oracle wallet with LUNA, so it’s able to pay price feed transaction fees. 10 LUNA should be enough to pay all the fees in the near future. 💰

You can e.g. use funds from your validator wallet to fund your oracle wallet:

(validator)$ terracli tx send {VALIDATOR_WALLET_ADDRESS} {ORACLE_WALLET_ADDRESS} {LUNA_AMOUNT}uluna --chain-id="columbus-3" --gas-prices="0.5uluna"
  • Validator Wallet Address: The address of your validator wallet you created before
  • Oracle Wallet Address: The address of your oracle wallet you created before
  • LUNA Amount: The amount of LUNA you want to send in uLUNA format, so 10 LUNA = 10000000 uLUNA

The terra-oracle pays price feed transaction fees in KRW, not LUNA, so we need to swap the LUNA we just sent to KRW using the network’s swap feature:

(validator)$ terracli tx market swap {LUNA_AMOUNT}uluna ukrw --from={ORACLE_WALLET_NAME} --gas-prices="0.5uluna"
  • LUNA Amount: The amount of LUNA you want to send in uLUNA format, so 5 LUNA = 5000000 uLUNA
  • Oracle Wallet Name: The name of your oracle wallet you created before

After swapping LUNA to KRW we need to configure the oracle service by editing the following file:

(validator)$ vi ~/terra-oracle/config.toml

Put in the correct operator address into the Validator section:

[Validator]
operatorAddr = "{OPERATOR_ADDRESS}"
  • Operator Address: To find your operator address execute the following command
(validator)$ terracli keys show -a --bech val {VALIDATOR_WALLET_NAME}

Put in your oracle wallet password in the Feeder section:

[Feeder]
password = "{PASSWORD}"
  • Password: Your oracle wallet password, so your oracle service is able to send transactions

Put in your CurrencyLayer API key into the APIs.mnt section:

[APIs.mnt]
# API key is required
# https://currencylayer.com/product
currencylayer = "http://www.apilayer.net/api/live?access_key={API_KEY}"

Run Terra Oracle via pm2 Process Manager

You can use whatever process manager you prefer, I usually go with pm2. Now let’s install all prerequisites and run the Terra oracle via pm2 in the background:

Create a bash script to run the Terra oracle:

(validator)$ cd ~
(validator)$ touch runOracle.sh
(validator)$ chmod +x runOracle.sh

Put in the following content:

#!/bin/sh
terra-oracle service --from=oracle --fees=3000ukrw --gas=150000 --broadcast-mode=block --config=/home/{USER}/terra-oracle
  • User: The name of the unix user you created previously

Create another file:

(validator)$ touch terra-oracle.ecosystem.config.js

Put in the following content:

module.exports = { apps : [ { name: "terra-oracle", script: "/home/{USER}/runOracle.sh", exec_mode: "fork", exec_interpreter: "bash"} ] }
  • User: The name of the unix user you created previously

Start the Terra node as a pm2 process:

pm2 start ./terra-oracle.ecosystem.config.js

Execute the following command, so your oracle is auto restarted upon failure and system restart:

(validator)$ pm2 save

Now both your Terra node and oracle should be running in the background as pm2 processes.

Image for post
Image for post
pm2 status

Congrats on finishing your Terra node + oracle price feed setup! 🥳

As a final step make sure you set minimum gas prices for your node, so it can not be misused to spam the network.

Open up the following file:

(validator)$ vi /home/{USER}/.terrad/config/app.toml
  • User: The current user on your machine you are logged in with

and change the minimum-gas-prices to the following:

minimum-gas-prices = "0.015uluna,0.015usdr,0.015uusd,0.015ukrw,0.015umnt"

Basically you can put in whatever you want, just make sure it’s a non zero value and not insanely high. In this case we also specify various currencies, so our node accepts transaction fee payments in all of those currencies.

Cheers on you setting up a validator! Excited to see that more and more people are joining the Terra ecosystem. 👊

Image for post
Image for post
Photo by Wil Stewart on Unsplash

ℹ️ Keep in mind that this is a quick start guide, so there is more to do in order to provide a stable validator infrastructure with maximum security (key management, sentry nodes across data centers, … etc.) which will go way beyond this article.

Support

I hope this guide helped you setting up your Terra validator node. Feel free to get in contact with me/us if you have any questions, etc.:

About block42
At block42 we invest into the most promising crypto ecosystems and help them secure their networks. We provide consulting and development services on top of those protocols to bring adoption and to co-create a decentralised future.

Image for post
Image for post

Website | Medium | Twitter | Github | Staking

block42

We envision a world of shared prosperity.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store