0G Labs Node deployment Nov 2024
Launch Your 0G Labs Node!
π Newton V2 Testnet is Live! 0G Labs has officially launched the Newton V2 testnet and is actively seeking validators. Now in the third round of selections, new validators are chosen every two weeks. Secure your spot and join the evolution of blockchain technology.
Step 1: Prepare Your VPS π₯οΈ
System Requirements:
CPU: 4 cores
Memory: 16GB
Storage: 500GB / 1TB NVMe SSD
Bandwidth: 500 Mbps download/upload
π‘ Tip: High bandwidth and fast read/write speeds are essential!
Step 2: Update & Install Required Packages π
Update the system:
sudo apt update && sudo apt upgrade -yInstall packages:
sudo apt install curl git jq build-essential gcc unzip wget lz4 -y
Step 3: Install Go π
Go to the home directory:
cd $HOMEDownload and install Go:
ver="1.22.4" && wget "https://golang.org/dl/go$ver.linux-amd64.tar.gz"Extract Go and set up the environment:
sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf "go$ver.linux-amd64.tar.gz"Add Go to the PATH and reload the profile:
echo "export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin" >> ~/.bash_profile && source ~/.bash_profileVerify the installation:
go version
Step 4: Install Rustup π¦
Run the Rustup installation command:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | shWhen prompted, just press Enter to select the default option.
Step 5: Clone the Repository π
Install Git (if not already installed):
sudo apt install gitClone the repository:
git clone -b v0.3.1 https://github.com/0glabs/0g-storage-node.git
Step 6: Build the Storage Node π¨
Navigate to the project directory:
cd $HOME/0g-storage-nodeUpdate submodules:
git submodule update --initInstall cargo and build:
sudo apt install cargo && cargo build --release
β οΈ Note: This may take 5β15 minutes depending on your VPS.
Step 7: Configure Your Own RPC βοΈ
Open the
app.tomlfile for editing:nano $HOME/.0gchain/config/app.tomlUpdate JSON-RPC settings:
Change
127.0.0.1:8545to0.0.0.0:8545Change
api = "eth,net,web3"toapi = "eth,txpool,personal,net,debug,web3"
Save and exit the editor.
Open port 8545:
sudo ufw allow 8545/tcp
β οΈ Note: Opening port 8545 can be a security risk, so avoid sharing your IP address publicly.
Step 8: Set Up Variables π οΈ
Retrieve your VPS IP address:
ENR_ADDRESS=$(wget -qO- eth0.me)Set up environment variables:
echo "export ENR_ADDRESS=${ENR_ADDRESS}" >> ~/.bash_profile echo 'export LOG_CONTRACT_ADDRESS="0xb8F03061969da6Ad38f0a4a9f8a86bE71dA3c8E7"' >> ~/.bash_profile echo 'export MINE_CONTRACT="0x96D90AAcb2D5Ab5C69c1c351B0a0F105aae490bE"' >> ~/.bash_profile echo 'export ZGS_LOG_SYNC_BLOCK="334797"' >> ~/.bash_profile echo 'export BLOCKCHAIN_RPC_ENDPOINT="http://x.x.x.x:8545"' >> ~/.bash_profile source ~/.bash_profile
Step 9: Private Key Extraction π
Extract your private key and add it to the config:
PRIVATE_KEY=$(0gchaind keys unsafe-export-eth-key $WALLET_NAME) sed -i 's|^miner_key = ""|miner_key = "'"$PRIVATE_KEY"'"|' $HOME/0g-storage-node/run/config.toml
Step 10: Update config.toml βοΈ
config.toml βοΈModify the
config.tomlfile as follows to set network and RPC settings:sed -i ' s|^\s*#?\snetwork_dir\s=.|network_dir = "network"| ...etc... ' $HOME/0g-storage-node/run/config.toml
Step 11: Create the Service File π
Create the service file:
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
Step 12: Start the Service π
Reload the daemon and enable the service:
sudo systemctl daemon-reload && sudo systemctl enable zgs && sudo systemctl start zgs
Step 13: Check Logs π
To view logs, use:
tail -f ~/0g-storage-node/run/log/zgs.log.$(TZ=UTC date +%Y-%m-%d)To stop the node:
sudo systemctl stop zgs
π Congratulations! You've successfully set up a 0G storage node. If you have questions, feel free to ask in our community.
Last updated
