Skip to content

OB-1885: Create install script for VPS Beam Validator Setup #248

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
158 changes: 158 additions & 0 deletions public/scripts/vps-installation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
# 🚀 Beam Subnet-EVM Node Setup

This guide walks you through setting up an AvalancheGo node and configuring it to track the **Beam L1 Subnet** using Beam's **Subnet-EVM**.

Tested on: **Ubuntu 22.04 / 24.04 LTS**

---

## 📁 Contents

- [1. Overview](#1-overview)
- [2. Prerequisites](#2-prerequisites)
- [3. Installation](#3-step-by-step-installation)
- [3.1 Configure the Node](#31-configure-the-node)
- [3.2 Apply Beam Network Upgrades](#32-apply-beam-network-upgrades)
- [3.3 Restart Node and Verify](#33-restart-node-and-verify)
- [4. Node Monitoring](#4-node-monitoring)
- [5. Notes](#5-notes)

---

## 1. Overview

This repo provides two automated Bash scripts to:

1. Install the [AvalancheGo](https://github.com/ava-labs/avalanchego) validator node.
2. Configure the node to track the [Beam Subnet](https://buildonbeam.com/) and apply its upgrade rules.

---

## 2. Prerequisites

- A clean Ubuntu 22.04 or 24.04 server (cloud or on-prem)
- Root or sudo access
- An open port (default `9651`) and optionally exposing it publicly

---

## 3. Installation

---

Run the following script to install AvalancheGo:

```bash
bash vps-setup-beam-validator.sh
```

This script will:

- Update system
- Install required packages: `wget`, `tar`, `jq`
- Prompt you to choose connection type, public IP, and RPC exposure
- Allow you to enable **State Sync** for faster sync times
- Install AvalancheGo as a systemd service
- Download and install Subnet-EVM v0.7.3
- Place it into the AvalancheGo plugin directory with the proper VMID
- Print success confirmation and paths
- Show your NodeID at the end

Example prompts:
- IP auto-detection and override
- Private vs. public RPC
- State sync: enabled or full archive

After install, the node will be running in the background.

---

## 3.1 Configure the Node

The script will also update your AvalancheGo config at:

```bash
~/.avalanchego/configs/node.json
```

It adds:

```json
{
"track-subnets": "eYwmVU67LmSfZb1RwqCMhBYkFyG8ftxn6jAwqzFmxC9STBWLC",
"partial-sync-primary-network": true
}
```

This ensures your node tracks only the Beam subnet and performs a partial sync to save resources.

---

## 3.2 Apply Beam Network Upgrades

The script will create the following chain config directory:

```bash
~/.avalanchego/configs/chains/2tmrrBo1Lgt1mzzvPSFt73kkQKFas5d1AP88tv9cicwoFp8BSn/
```

And download the Beam subnet upgrade file:

```bash
upgrade.json
```

This contains necessary configuration rules for proper syncing and upgrades.

---

## 3.3 Restart Node and Verify

The script will restart the AvalancheGo node and display its status:

```bash
sudo systemctl restart avalanchego
sudo systemctl status avalanchego
```

It will also extract your **NodeID** from the logs:

```bash
🔎 Your NodeID is: NodeID-XXXX...
```

This ID is essential for staking and network registration.

---

## 4. Node Monitoring

Follow logs in real time:

```bash
sudo journalctl -u avalanchego -f
```

Or just to check status:

```bash
sudo systemctl status avalanchego
```

---

## 5. Notes

- Always use the latest [Subnet-EVM release](https://github.com/ava-labs/subnet-evm/releases) compatible with Beam.
- VMID and BlockchainID are predefined and specific to Beam:
- **VMID**: `kLPs8zGsTVZ28DhP1VefPCFbCgS7o5bDNez8JUxPVw9E6Ubbz`
- **BlockchainID**: `2tmrrBo1Lgt1mzzvPSFt73kkQKFas5d1AP88tv9cicwoFp8BSn`
- If you modify the config path or structure, make sure to update the scripts accordingly.

---

## ✅ Done!

You're now ready to operate a Beam L1 node and contribute to its decentralized infrastructure.

Happy validating 🚀
192 changes: 192 additions & 0 deletions public/scripts/vps-installation/vps-setup-beam-validator.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
#!/bin/bash

# ---------------------------------------
# Beam Validator Node Installer Script
# Ubuntu 22.04 / 24.04 LTS
# ---------------------------------------
# Downloads and runs the official AvalancheGo installer
# Includes prompts for network, IP, RPC settings, state sync
# Ends with clear post-install steps and service info
# Installs Beam's Subnet-EVM binary for AvalancheGo
# Configures node to track the Beam subnet
# Applies upgrade rules and restarts AvalancheGo
# Displays the NodeID for staking and monitoring
# ---------------------------------------

set -e # Exit on any error

# Update system packages
echo "🔄 Updating system packages..."
sudo apt update -y && sudo apt upgrade -y

# Install prerequisites
echo "🔧 Installing required packages..."
sudo apt install -y wget tar jq

# Download AvalancheGo installer
echo "⬇️ Downloading AvalancheGo installer..."
wget -nd -m https://raw.githubusercontent.com/ava-labs/avalanche-docs/master/scripts/avalanchego-installer.sh

# Set execute permissions
echo "🔐 Setting executable permissions..."
chmod 755 avalanchego-installer.sh

# Display pre-install instructions
cat <<EOF

🚀 Starting AvalancheGo installation...

You will be prompted for the following inputs:

1️⃣ 🔌 Connection Type:
- [1] Residential (Dynamic IP)
- [2] Cloud (Static IP)

2️⃣ 🌐 Public IP:
- Confirms detected public IP or allows manual entry.

3️⃣ 🔓 RPC Port Exposure:
- [private]: Local access only (recommended for validators)
- [public]: Open to all interfaces (required for public API nodes)

⚠️ If choosing 'public', you must secure your RPC port via firewall rules
to restrict access to trusted IPs. Leaving it open is a serious risk.

4️⃣ ⚡ State Sync:
- [on]: Fast sync with current state (great for validators)
- [off]: Full archive node with history (needed for analytics or archival needs)

EOF

# Wait a moment before continuing
sleep 6

# Run the interactive installer
./avalanchego-installer.sh

# Post-installation
cat <<EOF

✅ AvalancheGo installation complete.
--------------------------------------

🔧 The node is now running in the background as a systemd service.

Proceeding to install Beam Network...

EOF

# Start the Beam Network installation

# Constants
PLUGIN_DIR="$HOME/.avalanchego/plugins"
SUBNET_EVM_VERSION="0.7.3"
SUBNET_EVM_URL="https://github.com/ava-labs/subnet-evm/releases/download/v${SUBNET_EVM_VERSION}/subnet-evm_${SUBNET_EVM_VERSION}_linux_amd64.tar.gz"
VM_ID="kLPs8zGsTVZ28DhP1VefPCFbCgS7o5bDNez8JUxPVw9E6Ubbz"
BLOCKCHAIN_ID="2tmrrBo1Lgt1mzzvPSFt73kkQKFas5d1AP88tv9cicwoFp8BSn"
UPGRADE_URL="https://raw.githubusercontent.com/BuildOnBeam/beam-subnet/main/subnets/beam-mainnet/upgrade.json"

# Step 1: Download and install Subnet-EVM
echo ""
echo "⬇️ Downloading Subnet-EVM v${SUBNET_EVM_VERSION}..."
mkdir -p subnetevm && cd subnetevm
wget -O subnet-evm.tar.gz "$SUBNET_EVM_URL"
tar -xvzf subnet-evm.tar.gz

echo "📁 Moving Subnet-EVM to plugins directory..."
mkdir -p "$PLUGIN_DIR"
cp subnet-evm "$PLUGIN_DIR/$VM_ID"

echo "✅ Subnet-EVM installed at: $PLUGIN_DIR/$VM_ID"
cd ..

# Step 2: Update AvalancheGo node config
echo ""
echo "🛠️ Configuring AvalancheGo to track the Beam subnet..."

NODE_CONFIG="$HOME/.avalanchego/configs/node.json"
mkdir -p "$(dirname "$NODE_CONFIG")"

if [[ -f "$NODE_CONFIG" ]]; then
jq '. + {
"track-subnets": "eYwmVU67LmSfZb1RwqCMhBYkFyG8ftxn6jAwqzFmxC9STBWLC",
"partial-sync-primary-network": true
}' "$NODE_CONFIG" > temp_node.json && mv temp_node.json "$NODE_CONFIG"
else
cat <<EOF > "$NODE_CONFIG"
{
"track-subnets": "eYwmVU67LmSfZb1RwqCMhBYkFyG8ftxn6jAwqzFmxC9STBWLC",
"partial-sync-primary-network": true
}
EOF
fi

echo "✅ Node config updated: $NODE_CONFIG"

# Step 3: Apply network upgrades
echo ""
echo "🔧 Applying Beam subnet upgrade rules..."

CHAIN_CONFIG_DIR="$HOME/.avalanchego/configs/chains/$BLOCKCHAIN_ID"
mkdir -p "$CHAIN_CONFIG_DIR"
cd "$CHAIN_CONFIG_DIR"

wget -O upgrade.json "$UPGRADE_URL"

if [[ -f "upgrade.json" ]]; then
echo "✅ upgrade.json downloaded successfully."
else
echo "❌ Failed to download upgrade.json"
exit 1
fi

cd ~

# Step 4: Restart AvalancheGo to apply all changes
echo ""
echo "🔄 Restarting AvalancheGo node service..."
sudo systemctl restart avalanchego
sleep 3
sudo systemctl status avalanchego --no-pager

# Step 5: Extract and display NodeID
echo ""
echo "🔎 Extracting NodeID from logs..."

NODE_ID=$(sudo journalctl -u avalanchego | grep -oP '"nodeID":\s*"(NodeID-[a-zA-Z0-9]+)"' | tail -n1 | grep -oP 'NodeID-[a-zA-Z0-9]+')

if [[ -n "$NODE_ID" ]]; then
echo ""
echo "✅ Your NodeID is:"
echo ""
echo " 🆔 $NODE_ID"
echo ""
echo "💡 Save this NodeID — it's required for staking and node monitoring."
else
echo "⚠️ Could not extract NodeID from logs. Try manually with:"
echo " sudo journalctl -u avalanchego | grep 'nodeID'"
fi

# Wrap-up message
cat <<EOF

✅ Beam Validator Node installation complete!
-----------------------------------------

🟢 To check the service status:
sudo systemctl status avalanchego
(Press 'q' to exit)

📄 Config paths:
- Node config: /home/ubuntu/.avalanchego/configs/node.json
- C-Chain config: /home/ubuntu/.avalanchego/configs/chains/C/config.json
- Plugins: /home/ubuntu/.avalanchego/plugins

🔌 Subnet-EVM plugin installed: $PLUGIN_DIR/$VM_ID
🧩 Node config file: $NODE_CONFIG
📈 Upgrade config path: $CHAIN_CONFIG_DIR/upgrade.json

📡 To monitor real-time logs:
sudo journalctl -u avalanchego -f

EOF