Skip to main content

Storage Node


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
Memory32 GB RAM32 GB RAM
CPU8 cores8 cores
Disk500GB / 1TB NVMe SSDSize matches the KV streams it maintains
Bandwidth100 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:

Prerequisites

Before setting up your storage node:

  • Understand that 0G Storage interacts with on-chain contracts for blob root confirmation and PoRA mining.
  • Choose your network: Testnet or Mainnet
  • Check the respective network overview pages for deployed contract addresses and RPC endpoints.
  • For mainnet deployment: Ensure you have real OG tokens for transaction fees and mining rewards.

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 protobuf-compiler

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

Download the Source Code:

git clone -b <latest_tag> https://github.com/0gfoundation/0g-storage-node.git

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.

Setup and Configuration

Navigate to the run directory and configure your storage node for either testnet or mainnet.

Config File References

The official configuration files are available in the 0G Storage Node GitHub repository:

  • Testnet: config-testnet-turbo.toml
  • Mainnet: config-mainnet-turbo.toml

Always use the latest versions from the repository as they contain the most up-to-date network parameters.

Configuration

  1. Copy the testnet configuration:
cd run
cp config-testnet-turbo.toml config.toml
  1. Update the following fields in config.toml:
# Contract addresses for testnet
log_contract_address = "0x22E03a6A89B950F1c82ec5e74F8eCa321a105296" # Flow contract
mine_contract_address = "0x00A9E9604b0538e06b268Fb297Df333337f9593b" # Mine contract

# Testnet RPC endpoint
blockchain_rpc_endpoint = "https://evmrpc-testnet.0g.ai"

# Start sync block number for testnet
log_sync_start_block_number = 326165

# Your private key for mining (64 chars, no '0x' prefix)
miner_key = "YOUR_PRIVATE_KEY"
  1. Optional: Configure network settings if needed:
# Target number of connected peers (can be increased for better connectivity)
network_target_peers = 50

Running the Node

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

Snapshot

Make sure to only include flow_db and delete data_db under db folder when you use a snapshot from a 3rd party !

Using others' data_db will make the node mine for others!

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.