Setting Up a 0G Node & Becoming a Validator: Updated Guide

Node Scribe
5 min readMay 27, 2024

--

0G Labs has announced a shift from the Evmos network to Kava and has opened a registration form for becoming Node Operators and Validators. This guide will help you set up a 0G node according to the latest updates from the project and register to become a Node Operator or Validator.

Overview of 0G Labs

0G Labs is behind the innovative ZeroGravity (0G), a decentralized data (DA) service that prioritizes security, scalability, and decentralization. The project secured $35 million in pre-seed funding, marking one of the largest initial investments in the Web3 and AI sectors.

0G Labs node

This substantial support came from over 40 institutions, including Hack VC, OKX Ventures, GSR, Animoca Brands, Arca, NGC Ventures, DWF Labs, Foresight Ventures, gumi Cryptos Capital, and Dispersion Capital.

Step 1: VPS Configuration Requirements

To launch the 0G Validator node, here are the new recommended configuration specs from the project:

  • Memory: 64 GB RAM
  • CPU: 8 cores
  • Disk: 1 TB NVME SSD
  • Bandwidth: 100 Mbps for Download/Upload
  • Operating System: Linux amd64 arm64 (tested on Ubuntu 20.04 LTS)

The block synchronization process for the 0G node requires a high-performance VPS/Server. If your VPS has low performance, you will miss many blocks, leading to disqualification from the Validator application.

Recommendation: Vultr is a renowned cloud server provider known for high performance and stability. They currently offer a $300 free trial which you can take advantage of to test their services:

==> Try Vultr with $300 free credit.

Please note! This code will be available for a limited time!

Step 2: Install required packages

sudo apt update && \
sudo apt install curl git jq build-essential gcc unzip wget lz4 -y

Step 3: Install Go

cd $HOME && \
ver="1.22.0" && \
wget "https://golang.org/dl/go$ver.linux-amd64.tar.gz" && \
sudo rm -rf /usr/local/go && \
sudo tar -C /usr/local -xzf "go$ver.linux-amd64.tar.gz" && \
rm "go$ver.linux-amd64.tar.gz" && \
echo "export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin" >> ~/.bash_profile && \
source ~/.bash_profile && \
go version

Step 4: Build 0gchaind binary

git clone -b v0.1.0 https://github.com/0glabs/0g-chain.git
cd 0g-chain
make install
0gchaind version

Step 5: Set up variables

# Customize your MONIKER name
echo 'export MONIKER="My_Node"' >> ~/.bash_profile
echo 'export CHAIN_ID="zgtendermint_16600-1"' >> ~/.bash_profile
echo 'export WALLET_NAME="wallet"' >> ~/.bash_profile
echo 'export RPC_PORT="26657"' >> ~/.bash_profile
source $HOME/.bash_profile

Step 6: Initialize the node

cd $HOME
0gchaind init $MONIKER --chain-id $CHAIN_ID
0gchaind config chain-id $CHAIN_ID
0gchaind config node tcp://localhost:$RPC_PORT
0gchaind config keyring-backend os # You can set it to "test" so you will not be asked for a password

Step 7: Download genesis.json

wget https://github.com/0glabs/0g-chain/releases/download/v0.1.0/genesis.json -O $HOME/.0gchain/config/genesis.json

Step 8: Add seeds and peers to the config.toml

SEEDS="c4d619f6088cb0b24b4ab43a0510bf9251ab5d7f@54.241.167.190:26656,44d11d4ba92a01b520923f51632d2450984d5886@54.176.175.48:26656,f2693dd86766b5bf8fd6ab87e2e970d564d20aff@54.193.250.204:26656,f878d40c538c8c23653a5b70f615f8dccec6fb9f@54.215.187.94:26656" && \
sed -i.bak -e "s/^seeds *=.*/seeds = \"${SEEDS}\"/" $HOME/.0gchain/config/config.toml

Step 9: Change ports

# Customize if you need
EXTERNAL_IP=$(wget -qO- eth0.me) \
PROXY_APP_PORT=26658 \
P2P_PORT=26656 \
PPROF_PORT=6060 \
API_PORT=1317 \
GRPC_PORT=9090 \
GRPC_WEB_PORT=9091
sed -i \
-e "s/\(proxy_app = \"tcp:\/\/\)\([^:]*\):\([0-9]*\).*/\1\2:$PROXY_APP_PORT\"/" \
-e "s/\(laddr = \"tcp:\/\/\)\([^:]*\):\([0-9]*\).*/\1\2:$RPC_PORT\"/" \
-e "s/\(pprof_laddr = \"\)\([^:]*\):\([0-9]*\).*/\1localhost:$PPROF_PORT\"/" \
-e "/\[p2p\]/,/^\[/{s/\(laddr = \"tcp:\/\/\)\([^:]*\):\([0-9]*\).*/\1\2:$P2P_PORT\"/}" \
-e "/\[p2p\]/,/^\[/{s/\(external_address = \"\)\([^:]*\):\([0-9]*\).*/\1${EXTERNAL_IP}:$P2P_PORT\"/; t; s/\(external_address = \"\).*/\1${EXTERNAL_IP}:$P2P_PORT\"/}" \
$HOME/.0gchain/config/config.toml
sed -i \
-e "/\[api\]/,/^\[/{s/\(address = \"tcp:\/\/\)\([^:]*\):\([0-9]*\)\(\".*\)/\1\2:$API_PORT\4/}" \
-e "/\[grpc\]/,/^\[/{s/\(address = \"\)\([^:]*\):\([0-9]*\)\(\".*\)/\1\2:$GRPC_PORT\4/}" \
-e "/\[grpc-web\]/,/^\[/{s/\(address = \"\)\([^:]*\):\([0-9]*\)\(\".*\)/\1\2:$GRPC_WEB_PORT\4/}" \
$HOME/.0gchain/config/app.toml

Step 10: Configure pruning to save storage

sed -i \
-e "s/^pruning *=.*/pruning = \"custom\"/" \
-e "s/^pruning-keep-recent *=.*/pruning-keep-recent = \"100\"/" \
-e "s/^pruning-interval *=.*/pruning-interval = \"10\"/" \
"$HOME/.0gchain/config/app.toml"

Step 11: Set min gas price

sed -i "s/^minimum-gas-prices *=.*/minimum-gas-prices = \"0ua0gi\"/" $HOME/.0gchain/config/app.toml

Step 12: Enable indexer

sed -i "s/^indexer *=.*/indexer = \"kv\"/" $HOME/.0gchain/config/config.toml

Step 13: Create a service file

sudo tee /etc/systemd/system/0gd.service > /dev/null <<EOF
[Unit]
Description=0G Node
After=network.target

[Service]
User=$USER
Type=simple
ExecStart=$(which 0gchaind) start --home $HOME/.0gchain
Restart=on-failure
LimitNOFILE=65535

[Install]
WantedBy=multi-user.target
EOF

Step 14: Start the node

sudo systemctl daemon-reload && \
sudo systemctl enable 0gd && \
sudo systemctl restart 0gd && \
sudo journalctl -u 0gd -f -o cat

Step 15: Download latest snapshot

wget https://snapshot.validatorvn.com/og/data.tar.lz4

Step 16: Stop the node

sudo systemctl stop 0gd

Step 17: Backup priv_validator_state.json

cp $HOME/.0gchain/data/priv_validator_state.json $HOME/.0gchain/priv_validator_state.json.backup

Step 18: Reset DB

0gchaind tendermint unsafe-reset-all --home $HOME/.0gchain --keep-addr-book

Step 19: Extract files fromt the arvhive

lz4 -d -c ./data.tar.lz4 | tar -xf - -C $HOME/.0gchain

Step 20: Move priv_validator_state.json back

mv $HOME/.0gchain/priv_validator_state.json.backup $HOME/.0gchain/data/priv_validator_state.json

Step 21: Restart the node

sudo systemctl restart 0gd && sudo journalctl -u 0gd -f -o cat

Step 22: Check the synchronization status

0gchaind status | jq

Wait “catching_up”: false for make sure your node is fully synced.

Wait “catching_up”: false

Step 23: Create a wallet for your validator

0gchaind keys add $WALLET_NAME --eth

# SAVE THE SEED PHRASE

Step 24: Extract the HEX address & Faucet Token

echo "0x$(0gchaind debug addr $(0gchaind keys show $WALLET_NAME -a) | grep hex | awk '{print $3}')"

At this step, you will receive a wallet address starting with “0x….”. Use this address to faucet testnet tokens at the following link:

> FAUCET <-

Step 25: Check wallet balance

0gchaind q bank balances $(0gchaind keys show $WALLET_NAME -a) 

Step 26: Create a validator

0gchaind tx staking create-validator \
--amount=1000000ua0gi \
--pubkey=$(0gchaind tendermint show-validator) \
--moniker=$MONIKER \
--chain-id=$CHAIN_ID \
--commission-rate=0.05 \
--commission-max-rate=0.10 \
--commission-max-change-rate=0.01 \
--min-self-delegation=1 \
--from=$WALLET_NAME \
--identity="" \
--website="" \
--details="0G to the moon!" \
--gas=auto --gas-adjustment=1.4 -y

Do not forget to save priv_validator_key.json file located in $HOME/.0gchain/config/

Step 27: Finalize and Register Your Validator Node

Congratulations! You’ve successfully set up a 0G Labs validator node on the new chain. Now, complete the registration form to apply to become a Validator: Registration Form.

Join the project’s Discord channel to stay updated on the validator selection process. The project will replace low-performance nodes with better-performing ones every two weeks. Good luck!

Useful commands

Query your validator

0gchaind q staking validator $(0gchaind keys show $WALLET_NAME --bech val -a) 

Query missed blocks counter & jail details of your validator

0gchaind q slashing signing-info $(0gchaind tendermint show-validator)

Unjail your validator

0gchaind tx slashing unjail --from $WALLET_NAME --gas=500000 --gas-prices=99999ua0gi -y

Delegate tokens to your validator

0gchaind tx staking delegate $(0gchaind keys show $WALLET_NAME --bech val -a)  <AMOUNT>ua0gi --from $WALLET_NAME --gas=500000 --gas-prices=99999ua0gi -y

Check logs of the node

sudo journalctl -u 0gd -f -o cat

Restart the node

sudo systemctl restart 0gd

Stop the node

sudo systemctl stop 0gd

Upgrade the node

0G_VERSION=<version>

cd $HOME
rm -rf $HOME/0g-chain
git clone -b $0G_VERSION https://github.com/0glabs/0g-chain.git
./0g-chain/networks/testnet/install.sh
source .profile
0gchaind version
# Restart the node
sudo systemctl restart 0gd && sudo journalctl -u 0gd -f -o cat

Delete the node from the server

# !!! IF YOU HAVE CREATED A VALIDATOR, MAKE SURE TO BACKUP `priv_validator_key.json` file located in $HOME/.0gchain/config/ 
sudo systemctl stop 0gd
sudo systemctl disable 0gd
sudo rm /etc/systemd/system/0gd.service
rm -rf $HOME/.0gchain $HOME/0g-chain

Thank you for reading this guide.

Follow me: https://x.com/nodescribe89
Buy Me a Coffee: 0x90f123Bd9E762811bfDe9574353C11c1054CB6C6

Thank you very much:))

--

--