ZeroGravity: Storage node setup guide
Official ZeroGravity installation docs could be found here
This guide describes the installation method, slightly different from the official one. This creates a copy of the executable file and creates a separate directory for the configuration. The project repository and the running node are independent of each other. You can test builds of new versions without fear of breaking the working one.
network | chain_id | Stor node version | Stor node commit |
---|---|---|---|
testnet | zgtendermint_16600-2 | unknown | 1434b94495fe19b1eccc8162237dd64c25b2bec8 |
Hardware Requirements
- Memory: 16 GB RAM
- CPU: 4 cores
- Disk: 500GB / 1T NVME SSD
- Bandwidth: 500 MBps for Download / Upload
We use OS Ubuntu, version 22.04 and higher
Environment preparation
Package installation
sudo apt-get update
sudo apt-get install make gcc build-essential protobuf-compiler clang cmake jq -y
Rust installation
Installation script for current user, official page.
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Add Rust enviroments to .bash_profile
echo . '$HOME'/.cargo/env >> $HOME/.bash_profile
source $HOME/.bash_profile
Build binary from sources
Create directory for used binary add it to PATH
mkdir $HOME/bin
echo export PATH='$PATH':$HOME/bin >> $HOME/.bash_profile
source $HOME/.bash_profile
Clone OG repo and build
cd ~
git clone https://github.com/0glabs/0g-storage-node.git
cd 0g-storage-node
git fetch --all --tags
git checkout 1434b94
git submodule update --init
cargo build --release
Copy binary to ~/bin:
cp $HOME/0g-storage-node/target/release/zgs_node $HOME/bin
Node configuration
Create working directory for storage node, copy configuration file:
mkdir $HOME/.zgs_node
cp $HOME/0g-storage-node/run/* $HOME/.zgs_node
Generate new miner key ( miner_key )
This should be done on a consensus node. Its installation is described here
KEY_NAME=storage_miner_key
0gchaind keys add $KEY_NAME --eth
Enter keyring password (and keep it secure)
The public key address (bech32 format) and mnemonics will be returned. The mnemonics must be kept secure!
To see the key address in EVM format. This public key was used for EVM transactions, chain faucet take this address format
echo "0x$(0gchaind debug addr $(0gchaind keys show $KEY_NAME -a) | grep hex | awk '{print $3}')"
For export private key ( miner_key ), use command:
0gchaind keys unsafe-export-eth-key $KEY_NAME
Edit config file
Set the appropriate contract addresses. All actual contracts information in docs https://docs.0g.ai/0g-doc/docs/contract-addresses.
log_contract_address
mine_contract_address
reward_contract_address
log_sync_start_block_number
network_boot_nodes - peer list
Check current contracts configuration:
cat $HOME/.zgs_node/config.toml | grep -P 'log_contract_address|log_sync_start_block_number|mine_contract_address|reward_contract_address'
Check current peer configuration:
cat $HOME/.zgs_node/config.toml | grep -P 'network_boot_nodes'
You need to make some changes to $HOME/.zgs_node/config.toml file:
nano $HOME/.zgs_node/config.toml
Set configuration values for standard mode:
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"]
log_contract_address = "0xbD2C3F0E65eDF5582141C35969d66e34629cC768"
log_sync_start_block_number = 595059
mine_contract_address = "0x6815F41019255e00D6F34aAB8397a6Af5b6D806f"
reward_contract_address = "0x51998C4d486F406a788B766d93510980ae1f9360"
Firewall settings
Open storage node p2p port:
sudo ufw allow 1234
Run node
You can run node (for test purpose) in terminal with command:
EVM_RPC="http://127.0.0.1:8545"
MINER_KEY=<your-miner-private-key>
cd $HOME/.zgs_node
zgs_node --config $HOME/.zgs_node/config.toml --blockchain-rpc-endpoint ${EVM_RPC} --miner-key ${MINER_KEY}
Run node as service
Create service file:
EVM_RPC="http://127.0.0.1:8545"
MINER_KEY=<your-miner-private-key>
tee $HOME/zgsd.service > /dev/null <<EOF
[Unit]
Description=0G-Storage Node
After=network.target
[Service]
User=$USER
WorkingDirectory=$HOME/.zgs_node
ExecStart=$HOME/bin/zgs_node --config $HOME/.zgs_node/config.toml --blockchain-rpc-endpoint ${EVM_RPC} --miner-key ${MINER_KEY}
Restart=always
RestartSec=10
LimitNOFILE=65535
[Install]
WantedBy=multi-user.target
EOF
Init daemon with simlink:
sudo ln -s $HOME/zgsd.service /etc/systemd/system
sudo systemctl daemon-reload
sudo systemctl enable zgsd
Run node:
sudo systemctl start zgsd
Checking
Show node logs:
tail -f ~/.zgs_node/log/zgs.log.$(TZ=UTC date +%Y-%m-%d) -f
Best regards and Good luck with your installation!❤️👍
Pro-Nodes75 team📡🗻