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.
Prerequisites
Section titled “Prerequisites”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.
System Preparation and Dependencies
Section titled “System Preparation and Dependencies”Update your local package index and install the necessary build tools and libraries required for compiling Rust and Go applications.
sudo apt-get updatesudo apt-get install clang cmake build-essential pkg-config libssl-dev jq -yInstall Go
Section titled “Install Go”The Storage CLI and certain sub-modules require Go. This script installs version 1.22.0.
cd $HOMEver="1.22.0"wget "https://golang.org/dl/go$ver.linux-amd64.tar.gz"sudo rm -rf /usr/local/gosudo 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_profilesource ~/.bash_profileInstall Rust
Section titled “Install Rust”The core storage node is built using Rust. Use rustup to manage your toolchain.
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -ysource $HOME/.cargo/envBuild 0G Storage Node from Source
Section titled “Build 0G Storage Node from Source”Clone the official repository and check out the specific commit required for the current testnet phase.
cd $HOMEgit clone https://github.com/0glabs/0g-storage-node.gitcd $HOME/0g-storage-nodegit fetch --all --tagsgit checkout 302aa88e2fde448c7f80e42ad8d8f1fce1cafc2cgit submodule update --initcargo build --releaseConfiguration
Section titled “Configuration”Copy the default testnet configuration and update the contract addresses to ensure the node communicates with the correct blockchain deployment.
cp $HOME/0g-storage-node/run/config-testnet-turbo.toml $HOME/0g-storage-node/run/config.tomlEdit Configuration File
Section titled “Edit Configuration File”Open the config.toml file to verify or update the following parameters:
nano $HOME/0g-storage-node/run/config.tomlEnsure the following values are set:
| Parameter | Value |
|---|---|
log_contract_address | 0xbD2C3F0E65eDF5582141C35969d66e34629cC768 |
mine_contract_address | 0x6815F41019255e00D6F34aAB8397a6Af5b6D806f |
reward_contract_address | 0x51998C4d486F406a788B766d93510980ae1f9360 |
log_sync_start_block_number | 595059 |
Systemd Service Setup
Section titled “Systemd Service Setup”Create a systemd service file to manage the node process in the background, ensuring it restarts automatically on failure.
sudo tee /etc/systemd/system/zgs.service > /dev/null <<EOF[Unit]Description=0G Storage NodeAfter=network.target
[Service]User=$USERWorkingDirectory=$HOME/0g-storage-node/runExecStart=$HOME/0g-storage-node/target/release/zgs_node --config $HOME/0g-storage-node/run/config.tomlRestart=on-failureRestartSec=10LimitNOFILE=65535
[Install]WantedBy=multi-user.targetEOFStart the Service
Section titled “Start the Service”sudo systemctl daemon-reloadsudo systemctl enable zgssudo systemctl restart zgsMonitoring and Logs
Section titled “Monitoring and Logs”Use the following commands to monitor the health and synchronization status of your storage node.
Check Node Logs
Section titled “Check Node Logs”# View full logs for the current daytail -f ~/0g-storage-node/run/log/zgs.log.$(TZ=UTC date +%Y-%m-%d)
# Filter for transaction sequence updatestail -f ~/0g-storage-node/run/log/zgs.log.$(TZ=UTC date +%Y-%m-%d) | grep tx_seq:Check Sync Status via RPC
Section titled “Check Sync Status via RPC”Run this loop to monitor your node’s logSyncHeight and peer count:
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 5doneTesting with Storage CLI
Section titled “Testing with Storage CLI”To verify the node can handle uploads, install the 0G Storage Client.
Build Storage Client
Section titled “Build Storage Client”cd $HOMEgit clone https://github.com/0glabs/0g-storage-client.gitcd 0g-storage-clientgit checkout e283cdbfef2f3e5c94f97ef4c1815b464851f399go buildAutomated Upload Test
Section titled “Automated Upload Test”Create a script to generate and upload dummy files to verify node functionality.
nano $HOME/upload_test.shAdd the following logic (ensure you populate --url with your RPC provider and --key with your private key):
#!/bin/bashwhile 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 60done