Validator Node Setup Guide
Guide on Validator Node setup & Storage Node for ZeroGravity (0G) by NodeCattel 🐈 💻
Run a 0G Full Node
# Current version used in doc
Binary: 0gchaind
Chain-id: zgtendermint_16600-2
Version: 0.2.3
Service Name : 0gd.service
Chain Explorer : https://testnet.0g.explorers.guru/
📢 Validator node upgrade read here 📢 | zgtendermint_16600-2
⚙️ Hardware Requirement
- Memory: 64 GB
- CPU: 8 cores
- Disk: 1 TB NVME SSD
- Bandwidth: 100 MBps for Download / Upload
System updates, installation of required dependencies
sudo apt update
sudo apt install curl git jq build-essential gcc unzip wget lz4 -y
Install GO
# install the latest GO
cd $HOME && \
ver="1.22.4" && \
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" >> $HOME/.bash_profile && \
source $HOME/.bash_profile && \
go version
Build 0gchaind binary from source
git clone -b v0.2.3 https://github.com/0glabs/0g-chain.git
cd 0g-chain
make install
echo 'export PATH=$PATH:$(go env GOPATH)/bin' >> ~/.profile
source ~/.profile
0gchaind version
Setup your variable settings
*Please set to your own Moniker (validator node's name) and RPC_PORT if you're running more than one node on the same machine*
echo 'export MONIKER="your_node_name_here"' >> ~/.bash_profile
echo 'export CHAIN_ID="zgtendermint_16600-2"' >> ~/.bash_profile
echo 'export WALLET_NAME="wallet"' >> ~/.bash_profile
echo 'export RPC_PORT="26657"' >> ~/.bash_profile
source $HOME/.bash_profile
💻 Initialize node & create home directory for .0gchain
cd $HOME
0gchaind config chain-id $CHAIN_ID
0gchaind config node tcp://localhost:$RPC_PORT
0gchaind config keyring-backend file
0gchaind init $MONIKER --chain-id $CHAIN_ID
Download genesis file
# Download and replace genesis file
rm ~/.0gchain/config/genesis.json
wget -P ~/.0gchain/config https://github.com/0glabs/0g-chain/releases/download/v0.2.3/genesis.json
Set 0G chain seeds
SEEDS="[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656"
sed -i -e "s/^seeds *=.*/seeds = \"$SEEDS\"/" $HOME/.0gchain/config/config.toml
Set NodeCattel's Peers for faster peers discovery
PEERS="[email protected]:36656"
sed -i "s/^persistent_peers *=.*/persistent_peers = \"$PEERS\"/" "$HOME/.0gchain/config/config.toml"
Confirm your ports - These can be changed if you are running more than one cosmos based chains
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
Set all variables in config.toml & app.toml
Please execute the script block by block and make sure you are reading what you are doing before proceed.
# Set PROXY_APP, RPC, PPROF, P2P ports to config.toml
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
# Set TCP, GRPC, GRPC Web ports to app.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
# Optional pruning setting - set it if you want to save storage space
sed -i.bak -e "s/^pruning *=.*/pruning = \"custom\"/" $HOME/.0gchain/config/app.toml
sed -i.bak -e "s/^pruning-keep-recent *=.*/pruning-keep-recent = \"100\"/" $HOME/.0gchain/config/app.toml
sed -i.bak -e "s/^pruning-interval *=.*/pruning-interval = \"10\"/" $HOME/.0gchain/config/app.toml
# Set gas price to app.toml
sed -i "s/^minimum-gas-prices *=.*/minimum-gas-prices = \"0ua0gi\"/" $HOME/.0gchain/config/app.toml
# Set indexer to config.toml
sed -i "s/^indexer *=.*/indexer = \"kv\"/" $HOME/.0gchain/config/config.toml
# Set json-rpc to app.toml
sed -i \
-e 's/address = "127.0.0.1:8545"/address = "0.0.0.0:8545"/' \
-e 's|^api = ".*"|api = "eth,txpool,personal,net,debug,web3"|' \
$HOME/.0gchain/config/app.toml
Create 0gd service for your node to run in the background
sudo tee /etc/systemd/system/0gd.service > /dev/null <<EOF
[Unit]
Description=OG Node
After=network.target
[Service]
User=$USER
Type=simple
ExecStart=$(which 0gchaind) start --json-rpc.api eth,txpool,personal,net,debug,web3 --home $HOME/.0gchain
Restart=on-failure
RestartSec=10
LimitNOFILE=65535
Environment="G0GC=900"
Environment="G0MELIMIT=40GB"
[Install]
WantedBy=multi-user.target
EOF
Download snapshot for quick sync - powered by NodeCattel
# download snapshot
sudo systemctl stop 0gd
cp $HOME/.0gchain/data/priv_validator_state.json $HOME/.0gchain/priv_validator_state.json.backup
0gchaind tendermint unsafe-reset-all --home $HOME/.0gchain --keep-addr-book
curl -L https://snapshot.nodecattel.xyz/0gchain/zgtendermint_16600-2_latest.tar.lz4 | sudo lz4 -dc - | sudo tar -xf - -C $HOME/.0gchain
mv $HOME/.0gchain/priv_validator_state.json.backup $HOME/.0gchain/data/priv_validator_state.json
💻 Start node
sudo systemctl daemon-reload && \
sudo systemctl enable 0gd && \
sudo systemctl restart 0gd && \
sudo journalctl -u 0gd -f -o cat
You can exit the node's log by using ctrl + c
Stop Validator node - (if you wish to stop the service)
sudo systemctl stop 0gd
View Validator node's log
sudo journalctl -u 0gd -f -o cat
Check for your syncing progress
0gchaind status | jq '{ latest_block_height: .sync_info.latest_block_height, catching_up: .sync_info.catching_up }'
The result should be "catching_up": false
when your node is fully synced
Result example
{
"latest_block_height": "419865",
"catching_up": false
}
NodeGuru's explorer for checking latest block height here
🤑 Create new wallet for your validator
0gchaind keys add $WALLET_NAME --eth
# DO NOT FORGET TO SAVE THE SEED PHRASE & YOUR PASSPHRASE YOU SET FOR THIS WALLET
# You can add --recover flag to restore existing key instead of creating
Extract the 0x address and use it for receiving testnet token
echo "0x$(0gchaind debug addr $(0gchaind keys show $WALLET_NAME -a) | grep hex | awk '{print $3}')"
👏 Request for Testnet token
| Faucet | - use your 0x address to request
Check your wallet balance (node must be synced in order to see the current balance)
0gchaind q bank balances $(0gchaind keys show $WALLET_NAME -a)
Result example - 1 A0GI = 1,000,000 ua0gi
balances:
- amount: "41694146"
denom: ua0gi
pagination:
next_key: null
total: "0"
👽 Create validator
0gchaind tx staking create-validator \
--amount=1000000ua0gi \
--pubkey=$(0gchaind tendermint show-validator) \
--moniker="$MONIKER" \
--chain-id=zgtendermint_16600-2 \
--commission-rate="0.10" \
--commission-max-rate="0.20" \
--commission-max-change-rate="0.01" \
--details="NodeCattel's army is meowifying ur blocks..." \
--website="https://docs.nodecattel.xyz" \
--min-self-delegation="1" \
--from="$WALLET_NAME" \
--gas=auto \
--gas-adjustment=1.4 \
-y
Once your validator is created you can look up your validator here. Most likely it will be in inactive
set as you will need enough stake to reach top 125 TVL validator. This is normal ~~~
(Optional) Delegate token to your own validator
The command below is to delegate 1 A0GI to your validator node, you may change the amount as you wish
0gchaind tx staking delegate $(0gchaind keys show $WALLET_NAME --bech val -a) 1000000ua0gi \
--from $WALLET_NAME \
--chain-id zgtendermint_16600-2 \
--gas-adjustment 1.4 \
--gas auto \
--gas-prices 0.0025ua0gi \
-y
Create backup for Node’s important files
In the case of hardfork or you would like to migrate your validator to another server. We must make sure that we have all essential files ready.
# download script from gist.github and run 0g-backup.sh
curl -o $HOME/.0gchain/0g-backup.sh https://gist.githubusercontent.com/nodecattel/5d2682e7fce4179e10521f00d9699fa5/raw/bcfcd4492af1d3e59809fd38ed0ffb9be7b3b10a/0g-backup.sh
chmod +x $HOME/.0gchain/0g-backup.sh
# Execute the script
$HOME/.0gchain/0g-backup.sh
Your backup files will be available at $HOME/0g-chain-backup
Upgrade 0g validator node hardfork from v0.1.0
# stop the validator node
sudo systemctl stop 0gd
# remove the previous cloned repo
rm -rf $HOME/0g-chain
# clone new source code and compile new version
cd $HOME
git clone -b v0.2.3 https://github.com/0glabs/0g-chain
cd 0g-chain
git checkout tags/v0.2.3
make install
0gchaind version
Once it fully update the 0gchaind
binary should be version 0.2.3
- Set new CHAIN-ID
0gchaind config chain-id zgtendermint_16600-2
- Set 0G chain v2 newton testnet SEEDS
SEEDS="[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656"
sed -i -e "s/^seeds *=.*/seeds = \"$SEEDS\"/" $HOME/.0gchain/config/config.toml
- Add NodeCattel's peer for faster discovery
PEERS="[email protected]:36656"
sed -i "s/^persistent_peers *=.*/persistent_peers = \"$PEERS\"/" "$HOME/.0gchain/config/config.toml"
- Alternatively, fetch the live peers from our node
In the case our node already have max peer connection, please fetch live peers instead of using our node’s peer
# download script from gist.github and run 0gpeers.sh
curl -o $HOME/.0gchain/0gpeers.sh https://gist.githubusercontent.com/nodecattel/8d28377a323a23d874d8bc64006ab2fc/raw/9a44bead876e6539efe0fd1b80050b837572d6d9/0gpeers.sh
chmod +x $HOME/.0gchain/0gpeers.sh
# Execute the script
$HOME/.0gchain/0gpeers.sh
- Becareful at these following steps will RESET all your data
You must make sure that you have all the important files backup in case there is something wrong.
Go to this backup step if you haven't already
Prepare new genesis file
# remove the outdated files
rm $HOME/.0gchain/config/addrbook.json $HOME/.0gchain/config/genesis.json
# download new genesis file
wget -P ~/.0gchain/config https://github.com/0glabs/0g-chain/releases/download/v0.2.3/genesis.json
0gchaind validate-genesis
Update the 0gd.service with additional environment setting
*** Reset Node's data ***
# reset all node's data to pristine state
0gchaind tendermint unsafe-reset-all --home $HOME/.0gchain
- Start Node and Monitoring
sudo systemctl daemon-reload && \
sudo systemctl enable 0gd && \
sudo systemctl restart 0gd && \
sudo journalctl -u 0gd -f -o cat
Once your node is fully synced do get token from the faucet and create-new-validator again.
Hardfork upgrade is completed ✅
Check bonding status
0gchaind q staking validator $(0gchaind keys show $WALLET_NAME --bech val -a)
Run curl test to check for your RPC port if it's works properly
# set EXTERNAL_IP variable
EXTERNAL_IP=$(wget -qO- eth0.me)
# query for current block height (json-rpc)
curl -X POST http://$EXTERNAL_IP:8545 -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'
# query for Net version (json-rpc)
curl -X POST http://$EXTERNAL_IP:8545 -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"net_version","params":[],"id":1}'
Result example
Current block height
{"jsonrpc":"2.0","id":1,"result":"0x66972"}
Net version (evm chain-id)
{"jsonrpc":"2.0","id":1,"result":"16600"}
Congratulation!! 😻
Now you have completed your node for 0gchain and we will move on to creating your storage node next.

Last updated