0g Storage Node Setup
Recommended Hardware: 4 Cores, 16GB RAM, 1TB of storage (NVME)
Install dependencies
sudo apt-get update
sudo apt-get install clang cmake build-essential pkg-config libssl-dev
sudo apt install cargo
Install go
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 && \
go version
Install rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env
Install binary
cd $HOME
rm -rf 0g-storage-node
git clone https://github.com/0glabs/0g-storage-node.git
cd 0g-storage-node
git checkout v0.7.3
git submodule update --init
cargo build --release
Copy config.toml
cp $HOME/0g-storage-node/run/config-testnet-turbo.toml $HOME/0g-storage-node/run/config.toml
Edit config.toml
nano $HOME/0g-storage-node/run/config.toml
blockchain_rpc_endpoint = https://evmrpc-testnet.0g.ai
log_contract_address : 0xbD2C3F0E65eDF5582141C35969d66e34629cC768
mine_contract_address : 0x6815F41019255e00D6F34aAB8397a6Af5b6D806f
reward_contract_address : 0x51998C4d486F406a788B766d93510980ae1f9360
miner_key = <your_evm_private_key>
Deployed Block Number: 595059
confirmation_block_count = 6
network_boot_nodes = ["/ip4/47.251.117.133/udp/1234/p2p/16Uiu2HAmTVDGNhkHD98zDnJxQWu3i1FL1aFYeh9wiQTNu4pDCgps","/ip4/47.76.61.226/udp/1234/p2p/16Uiu2HAm2k6ua2mGgvZ8rTMV8GhpW71aVzkQWy7D37TTDuLCpgmX"]
Create zgs service (storage node)
sudo tee /etc/systemd/system/zgs.service > /dev/null <<EOF
[Unit]
Description=ZGS 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
Start Storage node
sudo systemctl daemon-reload && \
sudo systemctl enable zgs && \
sudo systemctl start zgs
Check logs
full logs command
tail -f ~/0g-storage-node/run/log/zgs.log.$(TZ=UTC date +%Y-%m-%d)
tx_seq only logs command
tail -f ~/0g-storage-node/run/log/zgs.log.$(TZ=UTC date +%Y-%m-%d) | grep tx_seq:
minimized logs command
tail -f ~/0g-storage-node/run/log/zgs.log.$(TZ=UTC date +%Y-%m-%d) | grep -v "discv5\|network\|connect\|16U\|nounce"
check your storage node through rpc
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 "logSyncHeight: \033[32m$logSyncHeight\033[0m, connectedPeers: \033[34m$connectedPeers\033[0m"
sleep 5;
done
Last updated