Additional requirements
For using the prebuilt zgs
- you need to run Ubuntu
- 20.04
Network Bandwidth: 500 MBps for Download / Upload
Port 8545 is not occupied by another process
Have available or create a wallet from which you export the private key
⏱️ Installation time: ~20-60 minutes
The installation time depends on many factors, such as your skills, resources and characteristics of your server, the most important: disk speed, internet connection, server load CPU, RAM, so this value may differ from the one indicated by us.
⚡ Automatic installation
With the help of a one-line script, all the necessary commands will be executed automatically, you only need to specify the value of your Private Key
, which is unique for everyone and will identify you on the network.
Copy bash <( curl -s https://raw.githubusercontent.com/UnityNodes/scripts/main/0g-testnet/0g-storage-install.sh )
📝 Manual installation
Step-by-step copy and paste the commands on your server following the instructions and hints provided in the instructions.
📌 Step 1: Installation packeges and dependencies
Copy # Install dependencies for building from source
sudo apt update && sudo apt upgrade -y && sleep 1
sudo apt install curl tar wget clang pkg-config protobuf-compiler libssl-dev jq build-essential protobuf-compiler bsdmainutils git make ncdu gcc git jq chrony liblz4-tool cmake -y && sleep 1
sudo apt -qy upgrade -y
sudo apt install jq -y
Copy # Install Go
sudo rm -rf /usr/local/go
curl -L https://go.dev/dl/go1.21.6.linux-amd64.tar.gz | sudo tar -xzf - -C /usr/local
echo 'export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin' >> $HOME /.bash_profile
source .bash_profile
📌Step 2: Check go version
📌 Step 3: Install Rustup
When asked for Rust installation options, choose the default. Press 1
and Enter
to continue.
Copy curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME /.cargo/env
rustup default stable
rustup update
rustup update nightly
rustup target add wasm32-unknown-unknown --toolchain nightly
📌 Step 4: Install node
Copy # Clone project repository
rm -rf 0g-storage-node
git clone -b v0.5.1 https://github.com/0glabs/0g-storage-node.git
cd $HOME /0g-storage-node
git stash
git fetch --all --tags
git checkout 1434b94
git submodule update --init
cargo build --release
The installation process will take some time, so wait for the download to complete before continuing.
The screenshot above shows what you should see after the node is fully loaded, after that proceed further.
📌 Step 4.1 : Install Snapshot
Copy cd $HOME
wget --show-progress https://snapshots-testnet.unitynodes.com/0gchain-testnet/storage_0gchain_snapshot.lz4
rm -rf $HOME /0g-storage-node/run/{db,log,network}
lz4 -c -d storage_0gchain_snapshot.lz4 | pv | tar -x -C $HOME /0g-storage-node/run
📌 Step 5: Save RPC variables
If you want to use JSON-RPC Endpoint vlans, then find out the address with the following command:
Copy echo -e "\033[33mYour node Json-RPC endpoint:\033[0m $( sed -n 's/^laddr *= *//p' /root/.0gchain/config/app.toml )"
If you want to use our public JSON-RPC, use the command below.
This command uses our public RPC , if you have your own validator node RPC you can replace this value with yours, otherwise we recommend not to change anything.
Copy # Set bash
echo 'export NETWORK_LISTEN_ADDRESS="$(wget -qO- eth0.me)"' >> ~/.bash_profile
echo 'export BLOCKCHAIN_RPC_ENDPOINT="https://evm-rpc.0gchain-testnet.unitynodes.com"' >> ~/.bash_profile
source ~/.bash_profile
📌 Step 6: Set configuration
Copy ENR_ADDRESS = $( wget -qO- eth0.me )
echo "export ENR_ADDRESS=${ENR_ADDRESS}" >> ~/.bash_profile
echo 'export ZGS_LOG_DIR="$HOME/0g-storage-node/run/log"' >> ~/.bash_profile
echo 'export ZGS_LOG_SYNC_BLOCK="1033320"' >> ~/.bash_profile
echo 'export LOG_CONTRACT_ADDRESS="0xbD2C3F0E65eDF5582141C35969d66e34629cC768"' >> ~/.bash_profile
echo 'export MINE_CONTRACT="0x6815F41019255e00D6F34aAB8397a6Af5b6D806f"' >> ~/.bash_profile
echo 'export REWARD_CONTRACT="0x51998C4d486F406a788B766d93510980ae1f9360"' >> ~/.bash_profile
echo 'export BLOCKCHAIN_RPC_ENDPOINT="https://evm-rpc.0gchain-testnet.unitynodes.com"' >> ~/.bash_profile
source ~/.bash_profile
sed -i '
s|^\s*#\?\s*network_dir\s*=.*|network_dir = "network"|
s|^\s*#\?\s*network_enr_address\s*=.*|network_enr_address = "'"$ENR_ADDRESS"'"|
s|^\s*#\?\s*network_enr_tcp_port\s*=.*|network_enr_tcp_port = 1234|
s|^\s*#\?\s*network_enr_udp_port\s*=.*|network_enr_udp_port = 1234|
s|^\s*#\?\s*network_libp2p_port\s*=.*|network_libp2p_port = 1234|
s|^\s*#\?\s*network_discovery_port\s*=.*|network_discovery_port = 1234|
s|^\s*#\s*rpc_listen_address\s*=.*|rpc_listen_address = "0.0.0.0:5678"|
s|^\s*#\?\s*rpc_enabled\s*=.*|rpc_enabled = true|
s|^\s*#\?\s*db_dir\s*=.*|db_dir = "db"|
s|^\s*#\?\s*log_config_file\s*=.*|log_config_file = "log_config"|
s|^\s*#\?\s*log_directory\s*=.*|log_directory = "log"|
s|^\s*#\?\s*network_boot_nodes\s*=.*|network_boot_nodes = \["/ip4/54.219.26.22/udp/1234/p2p/16Uiu2HAmTVDGNhkHD98zDnJxQWu3i1FL1aFYeh9wiQTNu4pDCgps","/ip4/52.52.127.117/udp/1234/p2p/16Uiu2HAkzRjxK2gorngB1Xq84qDrT4hSVznYDHj6BkbaE4SGx9oS","/ip4/18.162.65.205/udp/1234/p2p/16Uiu2HAm2k6ua2mGgvZ8rTMV8GhpW71aVzkQWy7D37TTDuLCpgmX"]|
s|^\s*#\?\s*log_contract_address\s*=.*|log_contract_address = "'"$LOG_CONTRACT_ADDRESS"'"|
s|^\s*#\?\s*mine_contract_address\s*=.*|mine_contract_address = "'"$MINE_CONTRACT"'"|
s|^\s*#\?\s*reward_contract_address\s*=.*|reward_contract_address = "'"$REWARD_CONTRACT"'"|
s|^\s*#\?\s*log_sync_start_block_number\s*=.*|log_sync_start_block_number = '"$ZGS_LOG_SYNC_BLOCK"'|
s|^\s*#\?\s*blockchain_rpc_endpoint\s*=.*|blockchain_rpc_endpoint = "'"$BLOCKCHAIN_RPC_ENDPOINT"'"|
s|^# \[sync\]|\[sync\]|
s|^# auto_sync_enabled = false|auto_sync_enabled = true|
s|^# find_peer_timeout = .*|find_peer_timeout = "10s"|
' $HOME /0g-storage-node/run/config-testnet-turbo.toml && \
echo -e "\033[32mNode has been configured successfully.\033[0m"
📌 Step 7: Save the value of the private key in config.toml
Replace YOUR PRIVATE KEY with yours, if you don't have it, you need to create a wallet and import the private key from the wallet.
Copy read -p "Your Private KEY: " PRIVATE_KEY
sed -i '/^# miner_key = ""/c\miner_key = "'"$PRIVATE_KEY"'"' $HOME /0g-storage-node/run/config-testnet-turbo.toml
The private key is your wallet key that you created in the validator node and exported via the private key command line, here are some useful commands and tips that may come in handy.
Only if you haven't exported your private key before
1. Create a wallet on your validator node:
0gchaind keys add wallet --eth
2.
Export your private key
0gchaind keys unsafe-export-eth-key wallet
📌 Step 8: Create a service file
Copy 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-testnet-turbo.toml
Restart=on-failure
RestartSec=10
LimitNOFILE=65535
[Install]
WantedBy=multi-user.target
EOF
📌 Step 9: Start the node
Copy sudo systemctl daemon-reload
sudo systemctl enable zgs
sudo systemctl restart zgs
sudo systemctl status zgs
📌 Step 10: Check logs
Copy tail -f $HOME /0g-storage-node/run/log/zgs.log. $(TZ = UTC date +%Y-%m-%d )
An example of what your log should look like if you installed the node correctly.
💡 Usefull commands
Check Logs
Copy tail -f ~/0g-storage-node/run/log/zgs.log. $(TZ = UTC date +%Y-%m-%d )
Check SyncHeight
Copy 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 = $( jq -r '.result.logSyncHeight' <<< "$response" )
connectedPeers = $( jq -r '.result.connectedPeers' <<< "$response" )
echo -e "logSyncHeight: \033[32m$logSyncHeight\033[0m, connectedPeers: \033[34m$connectedPeers\033[0m"
sleep 5
done
Check node version
Copy $HOME/0g-storage-node/target/release/zgs_node --version
Check your private key in config.toml
Copy grep '^miner_key' $HOME /0g-storage-node/run/config.toml | sed 's/miner_key = "\(.*\)"/\1/'
Restart node
Copy sudo systemctl restart zgs
Check the status of the process
Copy sudo systemctl status zgs
How much SSD use Storage Node (currently)
Copy du -sh $HOME /.0g-storage-node/
How much RAM use 0G Labs (currently)
Copy ps -p $( pgrep zgs ) -o rss= | awk '{printf("The process uses memory:: %.2f MB\n", $1/1024)}'
How much CPU use 0G Labs (currently)
Copy ps -C zgs-o %cpu --no-headers | awk '{print $1"% CPU"}'
Delete storage node
Copy sudo systemctl stop zgs.service
sudo systemctl disable zgs.service
sudo rm -rf /etc/systemd/system/zgs.service
sudo rm -rf $HOME /0g-storage-node
sudo rm -rf /usr/local/bin/zgs_node