Storage Node And DA Services

0G System is composed of multiple components, each with its own functionalities. Detailed steps are provided as a guideline to deploy the whole and complete system.

Prerequisite

0G Storage and DA services interact with on-chain contracts for blob root confirmation and PoRA mining.

For official deployed contract addresses, visit this page.

Storage Node

Hardware Requirement

- Memory: 16 GB RAM
- CPU: 4 cores
- Disk: 500GB / 1T NVME SSD
- Bandwidth: 500 MBps for Download / Upload

Deployment Steps

First step is to deploy the storage node. As a distributed storage system, the system can have multiple instances.

  1. Install dependencies

  • For Linux

sudo apt-get update
sudo apt-get install clang cmake build-essential
  • For Mac

brew install llvm cmake
  1. Install rustup

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

  • For Linux

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

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

# Add /usr/local/go/bin to the PATH environment variable by adding the following line to your ~/.profile.
export PATH=$PATH:/usr/local/go/bin
  • For Mac

Download the Go installer from https://go.dev/dl/go1.22.0.darwin-amd64.pkg. Open the package file you downloaded and follow the prompts to install Go.

  1. Then download the source code

git clone -b v0.3.1 https://github.com/0glabs/0g-storage-node.git
  1. Build the source code

cd 0g-storage-node
git submodule update --init

# Build in release mode
cargo build --release
  1. Update the run/config.toml

# enr address, must fill your instance's public ip to support peer discovery
network_enr_address

# p2p port
network_libp2p_port

# rpc endpoint
rpc_listen_address

# peer nodes, we provided two nodes, you can also modify to your own ips
network_boot_nodes = ["/ip4/54.219.26.22/udp/1234/p2p/16Uiu2HAmTVDGNhkHD98zDnJxQWu3i1FL1aFYeh9wiQTNu4pDCgps","/ip4/52.52.127.117/udp/1234/p2p/16Uiu2HAkzRjxK2gorngB1Xq84qDrT4hSVznYDHj6BkbaE4SGx9oS"]

# flow contract address
log_contract_address

# mine contract address
mine_contract_address

# layer one blockchain rpc endpoint
blockchain_rpc_endpoint

# block number to start the sync
log_sync_start_block_number

# location for db, network logs
db_dir
network_dir

# your private key with 64 length
# do not include leading 0x
# do not omit leading 0
# must fill if you want to participate in the pora and get mining reward
miner_key
  1. Run the storage service

cd run

# consider using tmux in order to run in background
../target/release/zgs_node --config config.toml

Storage KV

Second step is to launch the kv service.

  1. Follow the same steps to install dependencies and rust in Stage 1

  2. Download the source code

git clone https://github.com/0glabs/0g-storage-kv.git
  1. Build the source code

cd 0g-storage-kv
git submodule update --init

# Build in release mode
cargo build --release
  1. Copy the config_example.toml to config.toml and update the parameters

# rpc endpoint
rpc_listen_address
# ips of storage service, separated by ","
zgs_node_urls = "http://ip1:port1,http://ip2:port2,..."

# layer one blockchain rpc endpoint
blockchain_rpc_endpoint

# flow contract address
log_contract_address

# block number to start the sync, better to align with the config in storage service
log_sync_start_block_number
  1. Run the kv service

cd run

# consider using tmux in order to run in background
../target/release/zgs_kv --config config.toml

Note: The recommended system configuration is the same as the storage node.

Storage Node CLI

We provided a client tool if you want to directly interact with the storage node.

  1. Download the source code

git clone https://github.com/0glabs/0g-storage-client.git
  1. Build the source code

cd 0g-storage-client
go build
  1. Run the file upload/download commands

# file upload
./0g-storage-client upload --url <blockchain_rpc_endpoint> --contract <0g-storage_contract_address> --key <private_key> --node <storage_node_rpc_endpoint> --file <file_path>
# file download
./0g-storage-client download --node <storage_node_rpc_endpoint> --root <file_root_hash> --file <output_file_path>

Check Contract Addresses to get the contract address.

For the storage node rpc endpoint, you could use the team deployed https://rpc-storage-testnet.0g.ai or you could deploy yourself by following the above instructions.

You are all set !

Last updated