#!/usr/bin/env bash # Run ON a Proxmox host (no SSH). Fixes validator config (tx-pool layered + min-score=0) # and restarts besu-validator for given VMIDs. # # Usage on r630-01 (192.168.11.11): # bash fix-block-production-on-host.sh 1000 1001 1002 # Usage on ml110 (192.168.11.10): # bash fix-block-production-on-host.sh 1003 1004 # # Or from repo (pipe over SSH): # ssh root@192.168.11.11 'bash -s' 1000 1001 1002 < scripts/fix-block-production-on-host.sh # ssh root@192.168.11.10 'bash -s' 1003 1004 < scripts/fix-block-production-on-host.sh # # Requires: run as root on Proxmox host with pct available. set -euo pipefail RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' log_info() { echo -e "${BLUE}[INFO]${NC} $1"; } log_ok() { echo -e "${GREEN}[✓]${NC} $1"; } log_warn() { echo -e "${YELLOW}[⚠]${NC} $1"; } log_err() { echo -e "${RED}[✗]${NC} $1"; } VMIDS=("$@") if [ ${#VMIDS[@]} -eq 0 ]; then echo "Usage: $0 [vmid ...]" echo " e.g. on r630-01: $0 1000 1001 1002" echo " e.g. on ml110: $0 1003 1004" exit 1 fi fix_one() { local vmid="$1" local status status=$(pct status "$vmid" 2>/dev/null | awk '{print $2}' || echo "unknown") if [[ "$status" != "running" ]]; then log_warn "VMID $vmid not running (status: $status) — skip" return 0 fi log_info "VMID $vmid: updating config and restarting besu-validator" pct exec "$vmid" -- bash -c ' set -e CFG=/etc/besu/config-validator.toml [ -f /config/config-validator.toml ] && CFG=/config/config-validator.toml if [ ! -f "$CFG" ]; then echo "Config not found: $CFG"; exit 1; fi sed -i "/^tx-pool-max-size=/d" "$CFG" 2>/dev/null || true sed -i "/^tx-pool-limit-by-account-percentage=/d" "$CFG" 2>/dev/null || true sed -i "/^tx-pool-retention-hours=/d" "$CFG" 2>/dev/null || true if ! grep -q "tx-pool-max-future-by-sender" "$CFG"; then echo "" >> "$CFG" echo "# Layered Transaction Pool (Besu 23.10+)" >> "$CFG" echo "tx-pool-max-future-by-sender=200" >> "$CFG" echo "tx-pool-layer-max-capacity=12500000" >> "$CFG" echo "tx-pool-max-prioritized=2000" >> "$CFG" echo "tx-pool-price-bump=10" >> "$CFG" fi # Remove tx-pool-min-score if present (unsupported in some Besu builds) sed -i "/^tx-pool-min-score=/d" "$CFG" 2>/dev/null || true ' log_ok " Config updated" if ! pct exec "$vmid" -- systemctl restart besu-validator 2>/dev/null; then log_err " Restart failed (check: pct exec $vmid -- systemctl status besu-validator)" return 1 fi log_ok " besu-validator restarted" return 0 } FAILED=0 for vmid in "${VMIDS[@]}"; do if ! fix_one "$vmid"; then ((FAILED++)) || true fi echo "" done if [ "$FAILED" -eq 0 ]; then log_ok "Done. Wait 1–2 min then check: bash scripts/monitoring/monitor-blockchain-health.sh" exit 0 else log_err "$FAILED VMID(s) failed." exit 1 fi