Page cover

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 πŸ”„

  1. Update the system: sudo apt update && sudo apt upgrade -y

  2. Install packages: sudo apt install curl git jq build-essential gcc unzip wget lz4 -y

Step 3: Install Go πŸš€

  1. Go to the home directory: cd $HOME

  2. Download and install Go: ver="1.22.4" && wget "https://golang.org/dl/go$ver.linux-amd64.tar.gz"

  3. 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"

  4. Add Go to the PATH and reload the profile: echo "export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin" >> ~/.bash_profile && source ~/.bash_profile

  5. Verify the installation: go version

Step 4: Install Rustup πŸ¦€

  1. Run the Rustup installation command: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

  2. When prompted, just press Enter to select the default option.

Step 5: Clone the Repository πŸ“‚

  1. Install Git (if not already installed): sudo apt install git

  2. Clone the repository: git clone -b v0.3.1 https://github.com/0glabs/0g-storage-node.git

Step 6: Build the Storage Node πŸ”¨

  1. Navigate to the project directory: cd $HOME/0g-storage-node

  2. Update submodules: git submodule update --init

  3. Install 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 βš™οΈ

  1. Open the app.toml file for editing: nano $HOME/.0gchain/config/app.toml

  2. Update JSON-RPC settings:

    • Change 127.0.0.1:8545 to 0.0.0.0:8545

    • Change api = "eth,net,web3" to api = "eth,txpool,personal,net,debug,web3"

  3. Save and exit the editor.

  4. 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 πŸ› οΈ

  1. Retrieve your VPS IP address: ENR_ADDRESS=$(wget -qO- eth0.me)

  2. 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 πŸ”‘

  1. 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 βš™οΈ

  1. Modify the config.toml file 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 πŸ“„

  1. 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 πŸš€

  1. Reload the daemon and enable the service: sudo systemctl daemon-reload && sudo systemctl enable zgs && sudo systemctl start zgs

Step 13: Check Logs πŸ“‹

  1. To view logs, use: tail -f ~/0g-storage-node/run/log/zgs.log.$(TZ=UTC date +%Y-%m-%d)

  2. 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