Skip to content

Install 0G Storage Node

This guide provides a step-by-step walkthrough for installing a 0G Storage Node. You will learn how to prepare your environment, build the node from source, configure the parameters for the Turbo Testnet, and verify your installation using the Storage CLI.

Before beginning the installation, ensure your system meets the following requirements:

  • Operating System: Ubuntu 22.04 LTS or higher.
  • CPU: 4 cores+
  • RAM: 16 GB+
  • Storage: 500 GB+ NVMe SSD recommended.

Update your local package index and install the necessary build tools and libraries required for compiling Rust and Go applications.

Terminal window
sudo apt-get update
sudo apt-get install clang cmake build-essential pkg-config libssl-dev jq -y

The Storage CLI and certain sub-modules require Go. This script installs version 1.22.0.

Terminal window
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

The core storage node is built using Rust. Use rustup to manage your toolchain.

Terminal window
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source $HOME/.cargo/env

Clone the official repository and check out the specific commit required for the current testnet phase.

Terminal window
cd $HOME
git clone https://github.com/0glabs/0g-storage-node.git
cd $HOME/0g-storage-node
git fetch --all --tags
git checkout 302aa88e2fde448c7f80e42ad8d8f1fce1cafc2c
git submodule update --init
cargo build --release

Copy the default testnet configuration and update the contract addresses to ensure the node communicates with the correct blockchain deployment.

Terminal window
cp $HOME/0g-storage-node/run/config-testnet-turbo.toml $HOME/0g-storage-node/run/config.toml

Open the config.toml file to verify or update the following parameters:

Terminal window
nano $HOME/0g-storage-node/run/config.toml

Ensure the following values are set:

ParameterValue
log_contract_address0xbD2C3F0E65eDF5582141C35969d66e34629cC768
mine_contract_address0x6815F41019255e00D6F34aAB8397a6Af5b6D806f
reward_contract_address0x51998C4d486F406a788B766d93510980ae1f9360
log_sync_start_block_number595059

Create a systemd service file to manage the node process in the background, ensuring it restarts automatically on failure.

Terminal window
sudo tee /etc/systemd/system/zgs.service > /dev/null <<EOF
[Unit]
Description=0G Storage Node
After=network.target
[Service]
User=$USER
WorkingDirectory=$HOME/0g-storage-node/run
ExecStart=$HOME/0g-storage-node/target/release/zgs_node --config $HOME/0g-storage-node/run/config.toml
Restart=on-failure
RestartSec=10
LimitNOFILE=65535
[Install]
WantedBy=multi-user.target
EOF
Terminal window
sudo systemctl daemon-reload
sudo systemctl enable zgs
sudo systemctl restart zgs

Use the following commands to monitor the health and synchronization status of your storage node.

Terminal window
# View full logs for the current day
tail -f ~/0g-storage-node/run/log/zgs.log.$(TZ=UTC date +%Y-%m-%d)
# Filter for transaction sequence updates
tail -f ~/0g-storage-node/run/log/zgs.log.$(TZ=UTC date +%Y-%m-%d) | grep tx_seq:

Run this loop to monitor your node’s logSyncHeight and peer count:

Terminal window
while true; do
response=$(curl -s -X POST http://localhost:5678 -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"zgs_getStatus","params":[],"id":1}')
logSyncHeight=$(echo $response | jq '.result.logSyncHeight')
connectedPeers=$(echo $response | jq '.result.connectedPeers')
echo -e "Sync Height: \033[32m$logSyncHeight\033[0m | Peers: \033[34m$connectedPeers\033[0m"
sleep 5
done

To verify the node can handle uploads, install the 0G Storage Client.

Terminal window
cd $HOME
git clone https://github.com/0glabs/0g-storage-client.git
cd 0g-storage-client
git checkout e283cdbfef2f3e5c94f97ef4c1815b464851f399
go build

Create a script to generate and upload dummy files to verify node functionality.

Terminal window
nano $HOME/upload_test.sh

Add the following logic (ensure you populate --url with your RPC provider and --key with your private key):

#!/bin/bash
while true; do
size=$(shuf -i 1024-5120 -n 1)
filename="test_$(date +%s).md"
$HOME/0g-storage-client/0g-storage-client gen --size $size --file $filename
$HOME/0g-storage-client/0g-storage-client upload \
--url <YOUR_RPC_ENDPOINT> \
--contract "0xbD2C3F0E65eDF5582141C35969d66e34629cC768" \
--key <YOUR_PRIVATE_KEY> \
--node http://127.0.0.1:5678 \
--file ./$filename
rm ./$filename
sleep 60
done