Full node build

Install Go

Feel free to skip this step if you already have Go and Cosmovisor.

Install Go

We will use Go v1.20.4 as example here. The code below also cleanly removes any previous Go installation.

sudo rm -rvf /usr/local/go/
wget https://golang.org/dl/go1.20.4.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.20.4.linux-amd64.tar.gz
rm go1.20.4.linux-amd64.tar.gz

Configure Go

Unless you want to configure in a non-standard way, then set these in the ~/.profile file.

export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export GO111MODULE=on
export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin

Install Node Binary

To get the uniond image, you can visit our container on the GitHub Container Registry, or run the following command:

export UNIOND_VERSION='v0.19.0'
docker pull ghcr.io/unionlabs/uniond:$UNIOND_VERSION

Running uniond

Creating a Chain Config & State Folder

Before running this image, we need to create a folder to host the chain configuration and state.

You can create this wherever you would like, but we'll be doing so in our current user's home directory.

CAUTION

It's important that you will be able to edit this contents of this folder.

To create a directory for uniond in your user home directory, run:

mkdir ~/.union

Initializing the Chain Config & State Folder

Now, using the uniond image and the folder we just created, we can initialize the contents of this folder.

To do this, we'll be using Docker volumes.

docker run -u $(id -u):$(id -g) -v ~/.union:/.union -it ghcr.io/unionlabs/uniond:$UNIOND_VERSION init $MONIKER bn254 --home /.union

Where MONIKER is the preferred moniker you'd like to use on this node.

NOTE

Note the usage of the flags and arguments we pass to docker run run here:

  • -u $(id -u):(id -g) ensures that the container is being created and ran with the current user and their permissions

  • -v ~/.union:/.union mounts the folder we created to the /.union folder of the container

  • -it ensures we are running the container interactively

After the uniond init command is done running, you should have a .union folder with the following contents:

.union
├── config
│   ├── app.toml
│   ├── client.toml
│   ├── config.toml
│   ├── genesis.json
│   ├── node_key.json
│   └── priv_validator_key.json
└── data
    └── priv_validator_state.json

Issuing Sub-Commands to uniond

To run uniond sub-commands, it will be useful to alias the Docker command in your shell .*rc file.

For example, in zsh, you can add the following alias to your .zshrc:

export UNIOND_VERSION='v0.19.0'
alias uniond='docker run -v ~/.union:/.union --network host -it ghcr.io/unionlabs/uniond:$UNIOND_VERSION --home /.union'

Configure Node

To run a node using uniond, you'll also need to expose ports to the container. We'll use this as an opportunity to create a Docker Compose file four uniond.

A minimal Docker Compose file for uniond looks like this:

services:
  node:
    image: ghcr.io/unionlabs/uniond:${UNIOND_VERSION}
    volumes:
      - ~/.union:/.union
      - /tmp:/tmp
    network_mode: "host"
    restart: unless-stopped
    command: start --home /.union

NOTE

You only need to mount /tmp if you intend to use State Sync to join the network

This will mount our chain configuration and settings folder while also exposing ports 26657, 1317, and 9093.

After creating a compose.yml file with the contents above, you'll be able to start your Union node with docker compose.

Download Genesis

curl https://rpc.cryptware.io/genesis | jq '.result.genesis' > ~/.union/config/genesis.json

Configure Seeds and Peers

Update Node configs

We can use sed to update various node configuration values without having to manually edit each file - which can be a pain.

Replace the values below with your own. These commands will update the following:

  • minimum_gas_prices

  • pruning configs

  • snapshot configs

sed -i -e "s|^minimum-gas-prices *=.*|minimum-gas-prices = \"0umuno\"|" $HOME/.union/config/app.toml
sed -i -e "s|^pruning *=.*|pruning = \"custom\"|" $HOME/.union/config/app.toml
sed -i -e "s|^pruning-keep-recent *=.*|pruning-keep-recent = \"113\"|" $HOME/.union/config/app.toml
sed -i -e "s|^pruning-keep-every *=.*|pruning-keep-every = \"0\"|" $HOME/.union/config/app.toml
sed -i -e "s|^pruning-interval *=.*|pruning-interval = \"17\"|" $HOME/.union/config/app.toml
sed -i -e "s|^snapshot-interval *=.*|snapshot-interval = \"0\"|" $HOME/.union/config/app.toml
sed -i -e "s|^snapshot-keep-recent *=.*|snapshot-keep-recent = \"2\"|" $HOME/.union/config/app.toml

Updating node ports

We'll use a powerful tool called sed for this process. sed is a stream editor that can perform operations, like substitutions, on a text file.

We will specifically focus on updating the ports to use a standardized prefix for your chain. This ensures consistency and improves overall system organization. It will also allow you to run multiple chains on a single server.

Let's start by understanding what we're updating:

  • proxy_app: This is the address used for inter-process communication between the ABCI application and the consensus engine.

  • laddr: This is the address that your node listens on for incoming connections.

  • pprof_laddr: This is the address for the profiling server to listen on.

  • prometheus_listen_addr: This is the address for the Prometheus metrics server to listen on.

  • address: These are various addresses that your node may use to listen for different types of connections.

Set Your Chain and Port Prefix

Your chain in this case is Union. For Union, we want to set the port prefix as 205. The port prefix will be used to replace the first 2 or 3 digits of the original ports.

# Set the prefix 
export PREFIX=246

Update config.toml

Next, we will update the config.toml file. For 5-digit ports, the first 3 digits will be replaced. Here is how to calculate the new port values and update the config.toml file:

PROXY_APP_PORT=$(echo 26658 | awk -v prefix=$PREFIX '{print prefix substr($0,4)}')
LADDR_PORT1=$(echo 26657 | awk -v prefix=$PREFIX '{print prefix substr($0,4)}')
LADDR_PORT2=$(echo 26656 | awk -v prefix=$PREFIX '{print prefix substr($0,4)}')
PPROF_LADDR_PORT=$(echo 26660 | awk -v prefix=$PREFIX '{print prefix substr($0,4)}')
PROMETHEUS_LISTEN_PORT=$(echo 26660 | awk -v prefix=$PREFIX '{print prefix substr($0,4)}')
sed -i.bak -e "\
s%^proxy_app = \"tcp://127.0.0.1:26658\"%proxy_app = \"tcp://127.0.0.1:$PROXY_APP_PORT\"%; \
s%^laddr = \"tcp://127.0.0.1:26657\"%laddr = \"tcp://0.0.0.0:$LADDR_PORT1\"%; \
s%^pprof_laddr = \"localhost:6060\"%pprof_laddr = \"localhost:$PPROF_LADDR_PORT\"%; \
s%^laddr = \"tcp://0.0.0.0:26656\"%laddr = \"tcp://0.0.0.0:$LADDR_PORT2\"%; \
s%^prometheus_listen_addr = \":26660\"%prometheus_listen_addr = \":$PROMETHEUS_LISTEN_PORT\"%" \
$HOME/.union/config/config.toml

Update app.toml

For 4-digit ports, the first 2 digits will be replaced. Here is how to calculate the new port values and update the app.toml file:

ADDRESS_PORT1=$(echo 1317 | awk -v prefix=$PREFIX '{print prefix substr($0,3)}')
ADDRESS_PORT2=$(echo 8080 | awk -v prefix=$PREFIX '{print prefix substr($0,3)}')
ADDRESS_PORT3=$(echo 9090 | awk -v prefix=$PREFIX '{print prefix substr($0,3)}')
ADDRESS_PORT4=$(echo 9091 | awk -v prefix=$PREFIX '{print prefix substr($0,3)}')
sed -i.bak -e "\
s%^address = \"tcp://0.0.0.0:1317\"%address = \"tcp://0.0.0.0:$ADDRESS_PORT1\"%; \
s%^address = \":8080\"%address = \":$ADDRESS_PORT2\"%; \
s%^address = \"0.0.0.0:9090\"%address = \"0.0.0.0:$ADDRESS_PORT3\"%; \
s%^address = \"0.0.0.0:9091\"%address = \"0.0.0.0:$ADDRESS_PORT4\"%" \
$HOME/.union/config/app.toml

Start the Node in Docker

docker compose up -f path/to/compose.yml -d

Create (or restore) a local key pair

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

# Create new keypair
uniond keys add YOURKEY

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

# Query the keystore for your public address
uniond 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.

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:

uniond tx staking create-validator \
  --amount 1000000muno \
  --pubkey $(uniond tendermint show-validator) \
  --moniker $MONIKER \
  --chain-id union-testnet-4 \
  --from $KEY_NAME \
  --commission-max-change-rate "0.1" \
  --commission-max-rate "0.20" \
  --commission-rate "0.1" \
  --min-self-delegation "1"

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

uniond tx staking create-validator --help

Backup critical files

There are certain files that you need to backup 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 ~/.dymension/config/:

  • priv_validator_key.json

  • node_key.json

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

Last updated

Logo

Made with ❤️ by WhisperNode // © 2024.