Manual Installation (Cosmovisor)

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

Official Documentation: https://docs.0g.ai/run-a-node/validator-node

Install dependencies, if required

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, if required

cd $HOME
ver="1.22.3"
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

Download 0g & 0g-Geth binary

cd $HOME
wget https://github.com/0glabs/0gchain-NG/releases/download/v1.1.1/galileo-v1.1.1.tar.gz
tar -xzf galileo-v1.1.1.tar.gz
rm galileo-v1.1.1.tar.gz
cd galileo
sudo chmod +x $HOME/galileo/bin/geth
sudo chmod +x $HOME/galileo/bin/0gchaind

Initialize Node

echo 'export PATH=$PATH:$HOME/galileo/bin' >> $HOME/.bash_profile
source $HOME/.bash_profile
./bin/geth init --datadir $HOME/galileo/0g-home/geth-home ./genesis.json
./bin/0gchaind init "<moniker_name>" --home $HOME/galileo/tmp

Copy Node Files

cp $HOME/galileo/tmp/data/priv_validator_state.json $HOME/galileo/0g-home/0gchaind-home/data/
cp $HOME/galileo/tmp/config/node_key.json $HOME/galileo/0g-home/0gchaind-home/config/
cp $HOME/galileo/tmp/config/priv_validator_key.json $HOME/galileo/0g-home/0gchaind-home/config/

Install Cosmovisor v1.7.0

go install cosmossdk.io/tools/cosmovisor/cmd/[email protected]

Initialize Cosmovisor

mkdir -p $HOME/.0gchaind/0g-home/0gchaind-home/cosmovisor/upgrades
mkdir -p $HOME/.0gchaind/0g-home/0gchaind-home/cosmovisor/backup

# Set temporary environment variables
export DAEMON_NAME=0gchaind
export DAEMON_HOME=$HOME/.0gchaind/0g-home/0gchaind-home
export DAEMON_DATA_BACKUP_DIR=$HOME/.0gchaind/0g-home/0gchaind-home/data
export PATH=$PATH:$HOME/go/bin:/usr/local/go/bin
cosmovisor init $HOME/galileo/bin/0gchaind

Configure Node

mkdir -p $HOME/.0gchaind
mv $HOME/galileo/0g-home $HOME/.0gchaind/

[ ! -f "$HOME/galileo/jwt-secret.hex" ] && openssl rand -hex 32 > $HOME/galileo/jwt-secret.hex
[ ! -f "$HOME/galileo/kzg-trusted-setup.json" ] && curl -L -o $HOME/galileo/kzg-trusted-setup.json https://danksharding.io/trusted-setup/kzg-trusted-setup.json

Set Moniker

sed -i -e "s/^moniker *=.*/moniker = \"<moniker_name>\"/" $HOME/.0gchaind/galileo/0g-home/0gchaind-home/config/config.toml

Create 0g Service File

sudo tee /etc/systemd/system/0gchaind.service > /dev/null <<EOF
[Unit]
Description=0GChainD Service
After=network.target

[Service]
User=root
Environment="DAEMON_NAME=0gchaind"
Environment="DAEMON_HOME=/root/.0gchaind/0g-home/0gchaind-home"
Environment="DAEMON_ALLOW_DOWNLOAD_BINARIES=false"
Environment="DAEMON_RESTART_AFTER_UPGRADE=true"
Environment="DAEMON_DATA_BACKUP_DIR=/root/.0gchaind/0g-home/0gchaind-home/data"
WorkingDirectory=/root/galileo
ExecStart=/root/go/bin/cosmovisor run start \
    --rpc.laddr tcp://127.0.0.1:27657 \
    --chaincfg.chain-spec devnet \
    --chaincfg.kzg.trusted-setup-path=/root/galileo/kzg-trusted-setup.json \
    --chaincfg.engine.jwt-secret-path=/root/galileo/jwt-secret.hex \
    --chaincfg.kzg.implementation=crate-crypto/go-kzg-4844 \
    --chaincfg.block-store-service.enabled \
    --chaincfg.node-api.enabled \
    --chaincfg.node-api.logging \
    --chaincfg.node-api.address 0.0.0.0:27500 \
    --chaincfg.engine.rpc-dial-url=http://localhost:27551 \
    --pruning=nothing \
    --home /root/.0gchaind/0g-home/0gchaind-home \
    --p2p.seeds [email protected]:26656 \
    --p2p.external_address <your_IP>:27656
Restart=always
RestartSec=5
LimitNOFILE=4096

[Install]
WantedBy=multi-user.target
EOF

Create 0g-Geth Service File

sudo tee /etc/systemd/system/0g-geth.service > /dev/null <<EOF
[Unit]
Description=Geth Service for 0GChainD
After=network.target

[Service]
User=root
WorkingDirectory=$HOME/galileo
ExecStart=/root/galileo/bin/geth --config /root/galileo/geth-config.toml \
    --nat extip:<your_IP> \
    --bootnodes enode://de7b86d8ac452b1413983049c20eafa2ea0851a3219c2cc12649b971c1677bd83fe24c5331e078471e52a94d95e8cde84cb9d866574fec957124e57ac6056699@8.218.88.60:30303 \
    --datadir /root/.0gchaind/0g-home/geth-home \
    --networkid 16601
Restart=always
RestartSec=5
LimitNOFILE=4096

[Install]
WantedBy=multi-user.target
EOF

Start 0g & 0g-Geth

sudo systemctl daemon-reload
sudo systemctl enable 0g-geth
sudo systemctl enable 0gchaind
sudo systemctl start 0g-geth
sudo systemctl start 0gchaind

Check logs

sudo journalctl -u 0gchaind -f
sudo journalctl -u 0g-geth -f

Last updated