Skip to main content

Storage Node


Overview

In the 0G network, storage nodes play a vital role in maintaining the system's decentralized storage layer. They are responsible for storing and serving data, ensuring data availability and reliability across the network. By running a storage node, you actively contribute to the network and earn rewards for your participation. This guide details the process of running a storage node, including hardware specifications and interaction with on-chain contracts.

Hardware Requirements

ComponentStorage NodeStorage KV
Memory16 GB RAM4 GB RAM
CPU4 cores2 cores
Disk500GB / 1TB NVMe SSDSize matches the KV streams it maintains
Bandwidth500 Mbps (Download / Upload)-
note
  • For Storage Node: The NVMe SSD ensures fast read/write operations, critical for efficient blob storage and retrieval.
  • For Storage KV: The disk size requirement is flexible and should be adjusted based on the volume of KV streams you intend to maintain.

Next Steps

For detailed instructions on setting up and operating your Storage Node or Storage KV, please refer to our comprehensive setup guides below:

Overview

The 0G System comprises multiple components, each with specific functionalities. This guide provides detailed steps to deploy and run a storage node, a crucial part of the 0G network.

Prerequisites

Before setting up your storage node:

  • Understand that 0G Storage interacts with on-chain contracts for blob root confirmation and PoRA mining.
  • Check here for deployed contract addresses.

Deployment Steps Install Dependencies start by installing all the essential tools and libraries required to build the 0G storage node software.

sudo apt-get update
sudo apt-get install clang cmake build-essential pkg-config libssl-dev

Install rustup: (rustup) is the Rust toolchain installer, necessary as the 0G node software is written in Rust.

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Install Go

# Download the Go installer
wget https://go.dev/dl/go1.23.0.linux-amd64.tar.gz

# Extract the archive
sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.23.0.linux-amd64.tar.gz

# Add /usr/local/go/bin to the PATH environment variable
export PATH=$PATH:/usr/local/go/bin
  • Or download the Go installer from https://go.dev/dl.

  • Go is a programming language used for certain components of the 0G node.

Download the Source Code: clones the 0G storage node repository from GitHub, specifically the v0.4.6 branch.

git clone -b v0.4.6 https://github.com/0glabs/0g-storage-node.git
  1. Build the Source Code

    cd 0g-storage-node

    # Build in release mode
    cargo build --release
    • This compiles the Rust code into an executable binary. The --release flag optimizes the build for performance.
  2. Configure the Node

Navigate to the run directory and open config.toml for editing:

Configuration

  1. Edit the configuration file:
cd run
nano config.toml
  1. Update config.toml with your settings:
# ENR address: Your instance's public IP
network_enr_address = "YOUR_PUBLIC_IP"

# Peer nodes: Check 0g-storage/run/config-testnet.toml for official configurations
network_boot_nodes = []

# Contract addresses
log_contract_address = "CONTRACT_ADDRESS"
mine_contract_address = "CONTRACT_ADDRESS"

# Layer one blockchain RPC endpoint
blockchain_rpc_endpoint = "RPC_ENDPOINT"

# Start sync block number
log_sync_start_block_number = BLOCK_NUMBER

# Your private key (64 chars, no '0x' prefix, include leading zeros)
miner_key = "YOUR_PRIVATE_KEY"

# Max chunk entries in db (affects storage size)
db_max_num_chunks = MAX_CHUNKS
note
  • network_enr_address: Your node's public IP address, essential for other nodes to discover and connect to you.
    • network_boot_nodes: A list of peer nodes to help your node join the network. You can find official configurations in the 0g-storage/run/config-t file.
    • log_contract_address, mine_contract_address: The addresses of the smart contracts on the host blockchain that manage the log and mining processes, respectively.
    • blockchain_rpc_endpoint: The URL of an RPC endpoint to interact with the host blockchain.
    • log_sync_start_block_number: The block number from which your node should start synchronizing the log data.
    • miner_key: Your private key (without the 0x prefix) if you want to participate in PoRA mining and earn rewards.
    • db_max_num_chunks: The maximum number of chunk entries (each 256 bytes) to store in the database. This effectively limits the database size.

Running the Storage Node

  1. Check configuration options:
../target/release/zgs_node -h
  1. Run the storage service:
cd run
../target/release/zgs_node --config config-testnet.toml --miner-key <your_private_key>

For long-running sessions, use tmux or screen.

Additional Notes

  • Security: Keep your private key (miner_key) safe and secure. Anyone with access to it can control your node and potentially claim your mining rewards.

  • Network Connectivity: Ensure your node has a stable internet connection and that the necessary ports are open for communication with other nodes.

  • Monitoring: Monitor your node's logs and resource usage to ensure it's running smoothly.

  • Updates: Stay informed about updates to the 0G storage node software and follow the project's documentation for any changes in the setup process.

Remember: Running a storage node is a valuable contribution to the 0G network. You'll be helping to maintain its decentralization and robustness while earning rewards for your efforts.