This is the Validator Node Guide for 0G Labs’ Modular AI Chain
Recommended specifications are below.
System Requirements
CPU : 8cores
Memory : 64GB
Storage : 1TB NVMe SSD
Bandwidth : 100mps for Download / Upload
NOTICE
- Basically, please paste the code line by line
- In the code box that says (at once), copy and paste the entire code by clicking the Copy button in the upper right as shown in the picture below
IMPORTANT!!
# 0. You should back-up your priv_validator_key.json file before move
If you can't bring up your wallet with mnemonic, you should back up your wallet data as well
# Stop your 0g service
sudo systemctl stop 0gchaind.service && sudo systemctl disable 0gchaind.service
# Backup your priv_validator_key.json file
sudo cp $HOME/.0gchain/config/priv_validator_key.json $HOME/
# Delete your 0g chain
sudo rm -rf $HOME/0g-chain/ $HOME/.0gchain
# 1. install dependency & install go & git clone 0g-chain & install Cosmovisor
sudo apt update && \
sudo apt install curl git jq build-essential gcc unzip wget lz4 openssl -y
sudo apt-get update -y
sudo apt-get install clang cmake build-essential -y
sudo apt install git -y
sudo apt install libssl-dev -y
sudo apt install pkg-config -y
sudo apt-get install protobuf-compiler -y
sudo apt-get install clang -y
sudo apt-get install llvm llvm-dev -y
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
sudo apt install git
git clone https://github.com/0glabs/0g-chain.git
cd 0g-chain
git checkout v0.3.1.alpha.1
make build
make install
cd $HOME
source ~/.bash_profile
0gchaind version
go install cosmossdk.io/tools/cosmovisor/cmd/cosmovisor@latest
# 2. Use 0G - all - in - one script from nodebrand
sudo wget -O $HOME/0G_all_in https://0g.service.nodebrand.xyz/0G/0G_all_in
chmod +x $HOME/0G_all_in
$HOME/0G_all_in
and you can see below commands
type 1 and set your Validator's variables
if you want to use default values just type enter till last one
and type below command
source ~/.bash_profile
# 3. node init
cd $HOME
0gchaind init $MONIKER --chain-id $CHAIN_ID --home $OG_HOME
0gchaind config chain-id $CHAIN_ID --home $OG_HOME
0gchaind config node tcp://localhost:$RPC_PORT --home $OG_HOME
0gchaind config keyring-backend file --home $OG_HOME
0gchaind config --home $OG_HOME
# 4. download genesis, Update addrbook, Peers(use 0G-all-in-one tool)
# download genesis
sudo wget https://github.com/0glabs/0g-chain/releases/download/v0.2.3/genesis.json -O $OG_HOME/config/genesis.json
# type 5 to update fresh peers
$HOME/0G_all_in
# type 6 to update addrbook
$HOME/0G_all_in
# 5. Update seed
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" && \
sed -i.bak -e "s/^seeds *=.*/seeds = \"${SEEDS}\"/" $HOME/.0gchain/config/config.toml
# 6. config setting
sudo mkdir -p $OG_HOME/cosmovisor/genesis/bin
sudo mkdir -p $OG_HOME/cosmovisor/upgrades
sudo mkdir -p $OG_HOME/cosmovisor/backup
cp $HOME/go/bin/0gchaind $OG_HOME/cosmovisor/genesis/bin
# type 2 to update your config.toml and app.toml files
$HOME/0G_all_in
# 8. Create service file
sudo tee /etc/systemd/system/0gchaind.service > /dev/null <<EOF
[Unit]
Description=0gchaind node service
After=network-online.target
[Service]
User=root
ExecStart=$HOME/go/bin/cosmovisor run start --home $OG_HOME
Restart=on-failure
RestartSec=5
LimitNOFILE=65535
Environment="DAEMON_NAME=0gchaind"
Environment="DAEMON_HOME=$OG_HOME"
Environment="DAEMON_ALLOW_DOWNLOAD_BINARIES=true"
Environment="DAEMON_RESTART_AFTER_UPGRADE=true"
Environment="DAEMON_DATA_BACKUP_DIR=$OG_HOME/cosmovisor/backup"
Environment="UNSAFE_SKIP_BACKUP=true"
[Install]
WantedBy=multi-user.target
EOF
# 9. service execution
sudo systemctl daemon-reload && \
sudo systemctl enable 0gchaind && \
sudo systemctl start 0gchaind
# 10. Download snapshot(if you want), wait till download success
sudo systemctl stop 0gchaind
sudo cp $OG_HOME/data/priv_validator_state.json $OG_HOME/priv_validator_state.json.backup
sudo rm -rf $OG_HOME/data
curl https://snapshot.validatorvn.com/0g/data.tar.lz4 | lz4 -dc - | tar -xf - -C $OG_HOME
sudo mv $OG_HOME/priv_validator_state.json.backup $OG_HOME/data/priv_validator_state.json
sudo systemctl restart 0gchaind && sudo tail -f -n 100 $OG_HOME/log/chain.log
If you see something like the below, you will have to wait a while until it syncs.
To determine how much block sync is left,
you can compare the block height in the Nodebrand 0g-chain dashboard with the block height that appears when you enter the command below
# 11. check Latest Block Height
you can see your node's latsest_block_height like below
# type 3 to check block height
$HOME/0G_all_in
IMPORTANT!!
IF SYNC DONE, BACKUP YOUR "priv_validator_key.json" file
BACKUP )) # ADD. BACKUP YOUR "priv_validator_key.json" and rerun your node
# Back up new key for just in case
cp $OG_HOME/config/priv_validator_key.json $HOME/new_priv_validator_key.json
# RELOAD your priv_validator_key.json file
cp $HOME/priv_validator_key.json $OG_HOME/config/priv_validator_key.json
# 12. Wallet config, check EVM address
- Create a wallet or recover (the last command is to extract the wallet’s private key)
# Create your wallet
0gchaind keys add $WALLET_NAME --eth --home $OG_HOME
# Recover your used wallet
0gchaind keys add $WALLET_NAME --recover --eth --home $OG_HOME
# Add private key to MetaMask
0gchaind keys unsafe-export-eth-key $WALLET_NAME --home $OG_HOME
- Now restart Node
sudo systemctl restart 0gchaind.service
- If you want to get your wallet’s evm address right away
0gchaind debug addr --home $OG_HOME $(0gchaind keys show $WALLET_NAME -a --home $OG_HOME) | grep 'Address (hex):' | awk -F ': ' '{print "0x" $2}'
Now you can create NEW validator with old validator key
visit 0G Faucet and apply for a Faucet.
If you successfully claimed the token from Faucet,
# 13. Check Balance & Create Validator & Check Validator
0gchaind q bank balances --home $OG_HOME $(0gchaind keys show $WALLET_NAME -a --home $OG_HOME)
After checking the balance,
0gchaind tx staking create-validator --home $OG_HOME \
--amount=1000000ua0gi \
--pubkey=$(0gchaind tendermint show-validator --home $OG_HOME) \
--moniker="$MONIKER" \
--chain-id="$CHAIN_ID" \
--commission-rate="0.10" \
--commission-max-rate="0.20" \
--commission-max-change-rate="0.01" \
--details="Node-0G-brand to the Moon!" \
--min-self-delegation="1" \
--from="$WALLET_NAME" \
--gas=auto \
--gas-adjustment=1.4 \
-y
Afterwards, press y and Enter to create the Validator.
After some time, you can check whether it has been properly registered in the terminal with the command below
0gchaind q staking validator --home $OG_HOME $(0gchaind keys show $WALLET_NAME --bech val -a --home $OG_HOME)
or you can check your tx hash in
0G tx dashboard
and also can check your operator address in
0G staking dashboard
Congratulation you are now 0G's validator
If you successfully create Validator
# 14. Claim Token from Faucet & Delegate yourself
Change <amount> to your token quantity.
0gchaind tx staking delegate --home $OG_HOME $(0gchaind keys show $WALLET_NAME --bech val -a --home $OG_HOME) <amount>ua0gi \
--from $WALLET_NAME \
-y
If you have any questions or would like to get faster node, airdrop, and project information,
Please enter the Telegram link below! (Click on the photo to connect.)
'0g_Labs' 카테고리의 다른 글
0G-Useful-Command (0) | 2024.07.05 |
---|---|
0G Labs Storage Node Guide(v.0.4.4) (0) | 2024.07.03 |
0G Config & Guide list (0) | 2024.07.03 |
How to check your STORAGE NODE via CLI (0) | 2024.06.08 |