How to Setup a Terra (LUNA) Validator Node

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.

Updates

✅ 15.04.2021: Adapt the guide based on latest changes of the network

What are we going to do?

  1. Machine Setup
  2. Sync the Node
  3. Register as a Validator
  4. Setup the Oracle

Machine 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, Digital Ocean, etc.

Node Specifications

I suggest a machine with 4 CPUs, 32GB memory and ~1TB disk space.

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
/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
/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.16.3.linux-amd64.tar.gz
(validator)$ sudo tar -xvf go1.16.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:

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.39.0

Validate golangci-lint installation:

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.4.6, 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.4.6
(validator)$ make install

Validate your Terra Core installation:

terrad and terracli

Sync the 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 network you want to join. You can find the genesis file for the latest network here:

(validator)$ curl {GENESIS_URL} > $HOME/.terrad/config/genesis.json
  • Genesis URL: The URL of the genesis file you want to download (see above for both mainnet as well as testnet links)

Seed Nodes

You need an entry point to the network, that’s what the seed nodes are for. So head over to the Terra GitHub once more and find the seed nodes as well as the persistent peers for the network you want to join:

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

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

and set these values:

# Comma separated list of seed nodes to connect to
seeds = "..."
# Comma separated list of nodes to keep persistent connections to
persistent_peers = "..." // optional

To speed up the sync process head over to https://terra.quicksync.io and get the “default” Terra snapshot for the latest network (currently it’s columbus-4 for mainnet and tequila-4 for testnet, but this might already have changed by the time you read this guide, so make sure what’s the latest version of the network).

Terra snapshots

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

(validator)$ cd ~/.terrad
(validator)$ wget {SNAPSHOT_FILE_URL}
  • Snapshot File URL: The snapshot url from Quicksync above
Time for a coffee, this will take some time. ☕

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 {SNAPSHOT_FILE} | tar xf -
  • Snapshot File: The snapshot file you just downloaded

→ 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.

Address Books

Before starting the node we also need to download the latest address book, so the node can easily connect to the network. Therefore download the latest address book snapshot to your machine:

(validator)$ curl {ADDRESS_BOOK_URL} > $HOME/.terrad/config/addrbook.json
  • Address Book URL: The url for the address book

Now let’s start up your Terra node:

(validator)$ cd ~
(validator)$ terrad start
terrad

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.

Now stop the node again 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.

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

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:

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 (more likely hours if you used the provided snapshots). Make sure to wait until it’s fully synced before continuing with the next step!

Register as a 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
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, follow this guide from the official docs:

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

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

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

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 run an oracle and provide a price feed.

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
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!

Install & Setup

Follow the guide in the official GitHub repository:

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="0.5uluna" --chain-id {CHAIN_ID}
  • Oracle Wallet Address: The address of the oracle wallet you just created
  • Validator Wallet Name: The name of the validator wallet you created previously
  • Chain Id: The chain you want to connect to

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

https://terra.stake.id/?#/tx/D1393544EF3E1E51AEF8AF06A7600DFBF35E71492DE6DC9ECD43488A470CFBB8

Oracle price transactions are free for validators on Terra. You still need to have LUNA in your oracle wallet, otherwise it doesn’t work. So make sure to send 1 LUNA to your oracle wallet.

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 {CHAIN_ID} --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 1 LUNA = 1000000 uLUNA
  • Chain Id: The chain you want to connect to

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

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.:

--

--

--

Part-time dev, part-time degen.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Does Machine Translation support Kyiv?

FULL CIRCLE with Eclipse!

Basic SQL interview questions and answers

Exporting Static HTML From A Next.js 10 Site

Heading image

Fetch Cloud Firestore Data Stream in your Flutter App using StreamProvider &add data to Cloud…

Dynamic Programming Algorithm

No pod to pod communication on CentOS 8, Kubernetes with Calico

Diving into Kube-bench Policy Report Adapter-Summary of LFX Spring Mentorship for CNCF: Kubernetes

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
rekt0x

rekt0x

Part-time dev, part-time degen.

More from Medium

Battle Of The Stablecoins:

Defi Pulse Helps You Achieve Your Dreams

One-Block Irreversibility for Delegated Proof-Of-Stake (DPOS)

DFK — The future of GameFi