0G (Zero Gravity) - Validator Node

ChainID: zgtendermint_16600-2

Resources

Hardware requirements

8 cores

64 GB

1 TB NVME

100 mbps

Linux (Ubuntu 20.04 x64)

Installation 💾

Install dependencies

sudo apt update && sudo apt upgrade -y
sudo apt install curl git wget htop tmux build-essential jq make lz4 gcc unzip -y

Install GO 1.22.2

sudo rm -rf /usr/local/go && \
curl -L https://go.dev/dl/go1.22.2.linux-amd64.tar.gz | sudo tar -xzf - -C /usr/local && \
echo 'export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin' >> $HOME/.bash_profile && \
source .bash_profile && \
go version

Set vars (change <wallet-name> and <moniker>)

echo "export WALLET="<WALLET_NAME>"" >> $HOME/.bash_profile
echo "export MONIKER="<MONIKER>"" >> $HOME/.bash_profile
echo "export OG_CHAIN_ID="zgtendermint_16600-2"" >> $HOME/.bash_profile
source $HOME/.bash_profile

Get binary

cd $HOME
rm -rf 0g-chain
git clone https://github.com/0glabs/0g-chain.git
cd 0g-chain
git checkout v0.3.1
git submodule update --init
make install

0gchaind version

Set config and init

0gchaind config node tcp://localhost:26657
0gchaind config keyring-backend os
0gchaind config chain-id zgtendermint_16600-2
0gchaind init "<MONIKER>" --chain-id zgtendermint_16600-2

Get genesis

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

Add seeds and peers in config.toml

SEEDS="81987895a11f6689ada254c6b57932ab7ed909b6@54.241.167.190:26656,010fb4de28667725a4fef26cdc7f9452cc34b16d@54.176.175.48:26656,e9b4bc203197b62cc7e6a80a64742e752f4210d5@54.193.250.204:26656,68b9145889e7576b652ca68d985826abd46ad660@18.166.164.232:26656" && \
PEERS="6122859577a3465ba67065f3b63194cae67ef4c4@110.171.123.186:36656" && \
sed -i -e "s/^seeds *=.*/seeds = \"$SEEDS\"/; s/^persistent_peers *=.*/persistent_peers = \"$PEERS\"/" $HOME/.0gchain/config/config.toml

Set minimum gas price. (Optional) Enable prometheus and disable indexing

sed -i 's|minimum-gas-prices =.*|minimum-gas-prices = "0ua0gi"|g' $HOME/.0gchain/config/app.toml
sed -i -e "s/prometheus = false/prometheus = true/" $HOME/.0gchain/config/config.toml
sed -i -e "s/^indexer *=.*/indexer = \"null\"/" $HOME/.0gchain/config/config.toml

(Optional) Pruning data

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

Create a service

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
sudo systemctl daemon-reload

backup priv_validator_state.json

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

Download and extract snapshot for fast sync

curl https://server-5.itrocket.net/testnet/og/og_2024-08-09_588556_snap.tar.lz4 | lz4 -dc - | tar -xf - -C $HOME/.0gchain

move priv_validator_state.json back

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

Start the node and check logs

sudo systemctl enable 0gd && sudo systemctl restart 0gd && sudo journalctl -u 0gd -f

Create or recover wallet

Dont forget to save mnemonic

create wallet

0gchaind keys add $WALLET_NAME --eth

recover wallet

0gchaind keys add $WALLET_NAME --eth --recover

Set var wallet and validator addresses

WALLET_ADDRESS=$(0gchaind keys show $WALLET_NAME -a)
VALOPER_ADDRESS=$(0gchaind keys show $WALLET_NAME --bech val -a)
echo "export WALLET_ADDRESS="$WALLET_ADDRESS >> $HOME/.bash_profile
echo "export VALOPER_ADDRESS="$VALOPER_ADDRESS >> $HOME/.bash_profile
source $HOME/.bash_profile

Request tokens from the faucet 🆓

The faucet gives you 1 A0GI = 1,000,000 ua0gi

Extract the HEX address to request some tokens from the faucet

echo "0x$(0gchaind debug addr $(0gchaind keys show $WALLET_NAME -a) | grep hex | awk '{print $3}')"
https://faucet.0g.ai/

check balance

0gchaind query bank balances $WALLET_ADDRESS

Create a 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="" \
--website="" \
--min-self-delegation="1" \
--from="$WALLET_NAME" \
--gas=auto \
--gas-adjustment=1.4 \
-y

Useful commands ⚙️

Node status

0gchaind status 2>&1 | jq

Query your validator

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

Delegate tokens to your validator

0gchaind tx staking delegate $(0gchaind keys show $WALLET_NAME --bech val -a) 1000000ua0gi --from $WALLET_NAME --chain-id zgtendermint_16600-1 --gas=auto --gas-adjustment=1.6 -y

Delete node 🗑️

sudo systemctl stop 0gd
sudo systemctl disable 0gd
sudo rm -rf /etc/systemd/system/0gd.service
sudo rm $(which 0gchaind)
sudo rm -rf $HOME/.0gchain
sed -i "/OG_/d" $HOME/.bash_profile

Last updated