Skip to main content

Validator Node


Running a validator node in the 0G ecosystem means actively participating in the network's security and consensus through the Proof-of-Stake (PoS) mechanism. As a validator, you'll validate transactions, propose new blocks, and earn rewards for your contribution to the network's integrity and decentralization.

Starting Your Node

1. Clone the Validator Node Repo:

git clone https://github.com/0glabs/0g-chain.git

2. Build and Start the Docker Node:

cd 0g-chain
docker build -f Dockerfile-node -t 0g-chain-validator .
docker run -d --name 0g-chain-validator -p 26656:26656 -p 26657:26657 -e GOGC=900 -e GOMEMLIMIT=40GiB 0g-chain-validator

Recommended on Garbage Collection for Pruning Nodes: To maximize sync speed for validators and other network providers that are running pruning nodes, the above settings are recommended. GOGC=900 instructs golang to start garbage collection when heap has grown to 9x, and GOMELIMIT=40GB ensures garbage collection runs whenever memory usage reaches 40GB.

Registering Your Validator

3. Create or Import an Account:

# Create a wallet and export the private key
docker exec -it <container_name> /bin/bash
0gchaind keys add <key_name> --eth
0gchaind keys unsafe-export-eth-key <key_name>
# Import an existing key by entering the mnemonic
docker exec -it <container_name> /bin/bash
0gchaind keys add <key_name> --recover --eth

4. Acquire Testnet Tokens: Obtain testnet tokens from the 0G faucet by entering your public key on our website or by requesting on Discord. These tokens are necessary for staking and becoming a validator.

5. Become a Validator: Register your node as a validator on the 0G network, specifying your stake amount, commission rates, and other important parameters.

0gchaind tx staking create-validator \
--amount=<staking_amount>ua0gi \
--pubkey=$(0gchaind tendermint show-validator) \
--moniker="<your_validator_name>" \
--chain-id=zgtendermint_16600-2 \
--commission-rate="0.10" \
--commission-max-rate="0.20" \
--commission-max-change-rate="0.01" \
--min-self-delegation="1" \
--from=<key_name> \
--gas=auto \
--gas-adjustment=1.4

Note: Only the top 125 staked validators will be active.

Check the Status on Your Validator

6. Check Validator Consensus Status: You can check the status of your validator, by executing the command below and you can confirm if your validator is active and participating in consensus.

0gchaind q staking validators -o json --limit=1000 | jq '.validators[] | select(.status=="BOND_STATUS_BONDED")' | jq -r '.tokens + " - " + .description.moniker' | sort -gr | nl

7. Check Validator Sync Status:

0gchaind status | jq '{ latest_block_height: .sync_info.latest_block_height, catching_up: .sync_info.catching_up }'

11. Unjail Your Validator (If Needed): If your validator gets "jailed" due to downtime or other issues, you can unjail using the following command and resume participation in the network.

0gchaind tx slashing unjail --from <key_name> --gas=500000 --gas-prices=99999neuron -y

Note: Only the top 125 staked validators will be active.

Remember

  • Stay updated with the latest testnet information and announcements on our socials and blog posts.
  • Reach out to us on Discord or to the community for support if you encounter any issues.

Troubleshooting

If you encounter any issues during the setup or operation of your validator node, please consult our FAQ section or reach out to our community support channels.

Next Steps

After successfully setting up your validator node, consider exploring the following:

Thank you for contributing to the security and decentralization of the 0g network!