Nodes Guide

Fullnode & Validator

Learn how to run your 0G-ZeroGravity Node or Validator with Cosmovisor support out of the box

Prerequisites

You have completed Getting Started with ZeroGravity

Set environment variables

This repository is for testnet at the moment. all keys are stored in the test keyring backend, keys stored on the other backends will be lost during container recreation

open .env file with your editor

nano .env

edit variables under 0G Node Config section. set your desired variables.

  • MONIKER A name for your node, will be public to others
  • WALLET_NAME can be any name, stored locally
  • SEEDS address of seed nodes
  • PERSISTENT_PEERS comma separated list of persistent peers
  • WALLET_NAME can be any name, stored locally
  • EXTERNAL_IP your server public IP address
  • P2P_PORT set a valid, non-busy port - default is 26656
  • RPC_PORT set a valid, non-busy port - default is 26657
  • EVM_JSON_RPC_PORT EVM RPC public port. set a valid, non-busy port - default is 8545
  • LCD_PORT API port. set a valid, non-busy port - default is 1317
you should restart your container everytime you change an environment variable
You don't have to open above ports on the firewall. just exposing them is enough to be accessible from outside world

Initialize network

both geth and node containers are required to run a fullnode or validator

Initialize node container

run and exec into an ephemeral container:

docker compose --profile node run --rm --entrypoint /bin/bash node

now we are inside the container, run the init script.
this will download genesis files and set required configs for this container to work

/init.sh

if you want to modify config files further edit the config manually

nano $HOME/.0gchain/config/config.toml

this will create a fresh $DAEMON_HOME/config/priv_validator_state.json , $DAEMON_HOME/config/node_key.json and $DAEMON_HOME/data/priv_validator_key.json. if you already have these files, you should import them by manually editing these files. otherwise, take a backup of them before proceeding.

MAKE A BACKUP OF ABOVE FILES!

to import your previous key files, for example the node_key.json or other files you can either :

  • use docker cp command in another terminal to copy your files
  • or manually edit files using nano and replace the content of your keys with your backups

Exit the container using Ctrl+D

Initialize geth container

docker compose --profile node run --rm --entrypoint /bin/bash geth

now we are inside the geth container, run the init script.

/init.sh

Exit the container using Ctrl+D

Run Node containers

you can now run node services in the background

docker compose --profile node up -d

then check logs

docker compose --profile node logs -f --tail 100 node
docker compose --profile node logs -f --tail 100 geth

Run commands inside the node container

to run any commands using 0gchaind, just exec into running node container

docker compose --profile node exec node bash

then run any commands you want normally, like 0gchaind status.
when you are done, exit the container using ctrl+D

if you don't have plan to run a Fullnode on 0G , but still want to have access to 0gchaind binary to run some commands, you can use ephemeral containers (they live as long as you are inside them, then will get removed)
docker compose --profile node run --rm --entrypoint /bin/bash node

Become Validator

in V3 creating a validator requires at least 32 tokens and it's not straightforward at all. fortunately, there is an amazing detailed guide by one of 0G community members. check it at AstroStake just note that, whenever you need to access the 0gchaind binary, you can use the ephemeral containers as explained above.