Shaurya Chopra
  • Introduction
  • Story Testnet (Odyssey)
    • Snapshot
    • Live Peers
    • Endpoints (Odyssey)
    • Auto Installation
    • Manual Installation (Cosmovisor)
    • Story Dashboard
    • Telegram Bot
  • Zero Gravity (0G)
    • Endpoints, Peer, Explorer
    • 0g Validator Snapshot
    • Storage Node Snapshot (Turbo)
    • 0g Validator Node Setup
    • 0g Storage Node Setup
    • 0g DA Node Setup
    • 0g Storage KV Setup
  • Pell
    • Endpoints, Peer, Explorer
    • Pell Snapshot
    • Pell Validator Node Setup
Powered by GitBook
On this page
  1. Zero Gravity (0G)

0g Validator Node Setup

Recommended Hardware: 8 Cores, 64GB RAM, 1TB of storage (NVME)

Installation

Install dependencies

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

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

Build 0gchaind binary from source

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

Setup your variable settings

echo 'export MONIKER="My_Node"' >> ~/.bash_profile
echo 'export CHAIN_ID="zgtendermint_16600-2"' >> ~/.bash_profile
echo 'export WALLET_NAME="wallet"' >> ~/.bash_profile
echo 'export OG_PORT="51"' >> ~/.bash_profile
source $HOME/.bash_profile

Initialize node & create home directory for .0gchain

cd $HOME
0gchaind init $MONIKER --chain-id $CHAIN_ID
0gchaind config chain-id $CHAIN_ID
0gchaind config node tcp://localhost:${OG_PORT}657
0gchaind config keyring-backend os

Download genesis file

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

Set seeds & peers

SEEDS="8f21742ea5487da6e0697ba7d7b36961d3599567@og-testnet-seed.itrocket.net:47656"
PEERS="80fa309afab4a35323018ac70a40a446d3ae9caf@og-testnet-peer.itrocket.net:11656,5c8426b14ff9cb62f10100de54f1d134a477105d@65.21.198.58:26656,4e7e6e9a3bc116612644d11b43c9b32b4003bb2c@37.27.128.102:26656,23e96ba46f8120735e6b5646a755f32a65bf381b@146.59.118.198:29156,f09ba2eb52ca96dfab9ef59bafcbe0a193111124@135.181.237.91:12656,88a20c8881c36c0d530ccb22e148f620941142e9@109.199.98.178:47656,219e0d480e699ba0d361049c0ce5a020f443d5f8@45.159.229.204:12656,feec86b33e5d46c83501e4c3ddb6471653f158db@194.163.181.101:47656,f5c0019956c9849895da36a0defb553cc9d50ca9@158.220.123.90:12656,38bb09933a8f2175af407887fbb37945750ebd93@109.199.127.5:12656,71e01e28fdf9c09dbd5229ecdf3d97c584c89385@149.50.96.112:26656,b0b1b3d699186309e707d19af80f8e5d6cc568d2@65.109.64.133:12656,713d85a83cfb587467053c0ea94b5850674a89ad@158.220.123.69:12656,4109414b09167ad2dde0a0265827497187d906a3@89.117.58.218:12656,9c665db23dbbe8a667910fb5e1482908a27ed69e@45.159.229.205:12656,c0dab875b2e19d74a830b4a13393b004d8bf9504@84.21.171.218:12656,922e74b2a646b0549979596bdfbeda426c3adeac@158.220.99.241:12656,e53bfcc6b4b5383be85a96d787ac23b4e18a91b1@144.91.123.30:12656,88df2f5dbe9fa7833e6019942cef07aaba7a5153@75.119.157.128:12656,13e74dd26858a94f9f87b1e2aeafcc6a5dbc3457@156.67.81.82:12656,421dfab26d994798575ecadbe1157271e3627652@45.8.148.206:12656"
sed -i -e "/^\[p2p\]/,/^\[/{s/^[[:space:]]*seeds *=.*/seeds = \"$SEEDS\"/}" \
       -e "/^\[p2p\]/,/^\[/{s/^[[:space:]]*persistent_peers *=.*/persistent_peers = \"$PEERS\"/}" $HOME/.0gchain/config/config.toml

Set required variable in config.toml & app.toml

sed -i.bak -e "s%:1317%:${OG_PORT}317%g;
s%:8080%:${OG_PORT}080%g;
s%:9090%:${OG_PORT}090%g;
s%:9091%:${OG_PORT}091%g;
s%:8545%:${OG_PORT}545%g;
s%:8546%:${OG_PORT}546%g;
s%:6065%:${OG_PORT}065%g" $HOME/.0gchain/config/app.toml
sed -i.bak -e "s%:26658%:${OG_PORT}658%g;
s%:26657%:${OG_PORT}657%g;
s%:6060%:${OG_PORT}060%g;
s%:26656%:${OG_PORT}656%g;
s%^external_address = \"\"%external_address = \"$(wget -qO- eth0.me):${OG_PORT}656\"%;
s%:26660%:${OG_PORT}660%g" $HOME/.0gchain/config/config.toml

Pruning (Optional to save storage space)

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"

Set min gas price

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

Disable indexer

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

Create 0gd service for your node to run in the background

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

Download snapshot

sudo cp $HOME/.0gchain/data/priv_validator_state.json $HOME/.0gchain/priv_validator_state.json.backup
sudo rm -rf $HOME/.0gchain/data
cd $HOME
sudo rm snapshot_0g.lz4
wget -O snapshot_0g.lz4 https://snapshot_0g.shachopra.com:8443/downloads/snapshot_0g.lz4
lz4 -c -d snapshot_0g.lz4 | pv | sudo tar -xv -C $HOME/.0gchain/
sudo cp $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 start 0gd && \
sudo journalctl -u 0gd -f -o cat

Check logs

tail -f ~/.0gchain/log/chain.log

Create wallet

0gchaind keys add $WALLET_NAME --eth

# 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

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: "10000000"
  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="" \
--website="" \
--min-self-delegation="1" \
--from="$WALLET_NAME" \
--gas=auto \
--gas-adjustment=1.6 \
-y

Run curl test to check for your RPC port if it's works properly

# set IP variable
IP=$(wget -qO- eth0.me)

# query for current block height (json-rpc)
curl -X POST http://$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://$IP:8545 -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"net_version","params":[],"id":1}'
PreviousStorage Node Snapshot (Turbo)Next0g Storage Node Setup

Last updated 3 months ago

- use your 0x address to request

Once your validator is created, check your validator .

Faucet
here