Running a Node is a Commitment, but If You Can't Afford It, There's No Need!

C4wv...2CQg
9 Jul 2024
20

Rewards Are Not Guaranteed ๐Ÿ’ฏ #DYOR
๐Ÿ“ข Let's Explore
Let's see๐Ÿ‘€
๐Ÿ’  Which VPS should I use? ๐Ÿ’  How do I install it?
๐Ÿ’  Which VPS should I use? ๐Ÿ“Œ I recommend purchasing the Contabo VPS-3 or VPS-4 as these are perfect for running this node.
๐ŸŒŸ VPS (Virtual Private Server) ๐ŸŒŸ You can buy it from: ๐Ÿ”ถ Contabo (Use the link below if you have a Credit or Debit Card) ๐Ÿ”ท Link: Contabo If not, use VPSDIME: ๐Ÿ”ถ VPSDIME (Pay with Crypto) ๐Ÿ”ท Link: VPSDIME
โšก Purchase the suitable VPS and then access your VPS using a MOBILE SSH App (if you're on iPhone/Android) or use Putty (PC).
๐Ÿ’  How do I install it?
๐ŸŒŸ Storage Node Deployment Guide ๐ŸŒŸ ๐Ÿ”ถ Install Rustup:

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

๐Ÿ”ถ Set variables:

INPUT YOUR OWN JSON-RPC ENDPOINT (http://yourvpsip:8545/) OR USE THIS ENDPOINT:
https://rpc-testnet.0g.ai/

read -p "Enter json-rpc: " BLOCKCHAIN_RPC_ENDPOINT && echo "Current json-rpc: $BLOCKCHAIN_RPC_ENDPOINT" &&
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="802"' >> ~/.bash_profile
echo 'export LOG_CONTRACT_ADDRESS="0x8873cc79c5b3b5666535C825205C9a128B1D75F1"' >> ~/.bash_profile
echo 'export MINE_CONTRACT="0x85F6722319538A805ED5733c5F4882d96F1C7384"' >> ~/.bash_profile
echo "export BLOCKCHAIN_RPC_ENDPOINT=\"$BLOCKCHAIN_RPC_ENDPOINT\"" >> ~/.bash_profile

source ~/.bash_profile

echo -e "\n\033[31mCHECK YOUR STORAGE NODE VARIABLES\033[0m\n\nLOG_CONTRACT_ADDRESS: $LOG_CONTRACT_ADDRESS\nMINE_CONTRACT: $MINE_CONTRACT\nZGS_LOG_SYNC_BLOCK: $ZGS_LOG_SYNC_BLOCK\nBLOCKCHAIN_RPC_ENDPOINT: $BLOCKCHAIN_RPC_ENDPOINT\n\n"

๐Ÿ“Œ Verify the JSON-RPC sync to ensure itโ€™s at the latest block:

curl -s -X POST $BLOCKCHAIN_RPC_ENDPOINT -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' | jq -r '.result' | xargs printf "%d\n"

๐Ÿ”ถ Download binary:

cd $HOME
git clone https://github.com/0glabs/0g-storage-node.git
cd $HOME/0g-storage-node
git fetch
git checkout tags/v0.3.3 --force
git submodule update --init
sudo apt install cargo
cargo build --release

๐Ÿ”ถ Export wallet private key:

0gchaind keys unsafe-export-eth-key $WALLET

๐Ÿ”ถ Save your private key in a variable:

read -sp "Enter your private key: " PRIVATE_KEY && echo

๐Ÿ”ถ Update node configuration:

sed -i '
s|^miner_key = ""|miner_key = "'"$PRIVATE_KEY"'"|
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*watch_loop_wait_time_ms\s*=.*|watch_loop_wait_time_ms = 1000|
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_listen_address_admin\s*=.*|rpc_listen_address_admin = "0.0.0.0:5679"|
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.167.69.68/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*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"'"|
' $HOME/0g-storage-node/run/config.toml

๐Ÿ”ถ Create service:

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 the Node:

sudo systemctl daemon-reload && \
sudo systemctl enable zgs && \
sudo systemctl start zgs && \
sudo systemctl status zgs

๐Ÿ”ถ Check full logs:

tail -f ~/0g-storage-node/run/log/zgs.log.$(TZ=UTC date +%Y-%m-%d)

๐Ÿ”ถ tx_seq-only logs:

tail -f ~/0g-storage-node/run/log/zgs.log.$(TZ=UTC date +%Y-%m-%d) | grep tx_seq:

๐Ÿ“Œ Wait until it syncs to the latest tx_seq number on the OG Storage Scan ๐Ÿ”ท Link: Storage Scan
Useful commands:
๐Ÿ”ถ Delete the Storage-node:

sudo systemctl stop zgs
sudo systemctl disable zgs
sudo rm /etc/systemd/system/zgs.service
rm -rf $HOME/0g-storage-node


Get fast shipping, movies & more with Amazon Prime

Start free trial

Enjoy this blog? Subscribe to eonoddo

1 Comment