Files
proxmox/scripts/archive/consolidated/verify/verify-besu-node-consistency.sh
defiQUG fbda1b4beb
Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
docs: Ledger Live integration, contract deploy learnings, NEXT_STEPS updates
- ADD_CHAIN138_TO_LEDGER_LIVE: Ledger form done; public code review repo bis-innovations/LedgerLive; init/push commands
- CONTRACT_DEPLOYMENT_RUNBOOK: Chain 138 gas price 1 gwei, 36-addr check, TransactionMirror workaround
- CONTRACT_*: AddressMapper, MirrorManager deployed 2026-02-12; 36-address on-chain check
- NEXT_STEPS_FOR_YOU: Ledger done; steps completable now (no LAN); run-completable-tasks-from-anywhere
- MASTER_INDEX, OPERATOR_OPTIONAL, SMART_CONTRACTS_INVENTORY_SIMPLE: updates
- LEDGER_BLOCKCHAIN_INTEGRATION_COMPLETE: bis-innovations/LedgerLive reference

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 15:46:57 -08:00

226 lines
7.5 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# Verify Besu Node Consistency
# Checks enode addresses, IP addresses, static-nodes, and permissioned-nodes across all nodes
set -euo pipefail
# Load IP configuration
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
source "${PROJECT_ROOT}/config/ip-addresses.conf" 2>/dev/null || true
VALIDATORS_ML110="1003 1004"
VALIDATORS_R630="1000 1001 1002"
RPC_NODES="2500 2501 2502"
ML110_HOST="root@${PROXMOX_HOST_ML110}"
R630_HOST="root@${PROXMOX_HOST_R630_01}"
OUTPUT_DIR="/tmp/besu-node-verification"
mkdir -p "$OUTPUT_DIR"
echo "=== Besu Node Consistency Verification ==="
echo ""
# Function to get node info
get_node_info() {
local vmid=$1
local host=$2
local node_type=$3
echo "=== $node_type Node $vmid on $host ==="
# Get enode address
echo "Enode Address:"
ENODE=$(ssh -o StrictHostKeyChecking=no -o ConnectTimeout=5 "$host" \
"pct exec $vmid -- curl -s -X POST -H 'Content-Type: application/json' \
--data '{\"jsonrpc\":\"2.0\",\"method\":\"admin_nodeInfo\",\"params\":[],\"id\":1}' \
http://localhost:8545 2>/dev/null | grep -o '\"enode\":\"[^\"]*\"' | cut -d'\"' -f4" 2>/dev/null || echo "ERROR")
if [ "$ENODE" != "ERROR" ] && [ -n "$ENODE" ]; then
echo " $ENODE"
echo "$ENODE" > "$OUTPUT_DIR/enode_${vmid}.txt"
# Extract IP from enode
ENODE_IP=$(echo "$ENODE" | grep -oP '@\K[^:]+' || echo "N/A")
echo " IP from enode: $ENODE_IP"
else
echo " ⚠️ Could not retrieve enode (node may not be running or RPC not accessible)"
echo "ERROR" > "$OUTPUT_DIR/enode_${vmid}.txt"
fi
# Get actual IP address
echo "Actual IP Address:"
ACTUAL_IP=$(ssh -o StrictHostKeyChecking=no -o ConnectTimeout=5 "$host" \
"pct exec $vmid -- hostname -I | awk '{print \$1}'" 2>/dev/null || echo "ERROR")
if [ "$ACTUAL_IP" != "ERROR" ] && [ -n "$ACTUAL_IP" ]; then
echo " $ACTUAL_IP"
echo "$ACTUAL_IP" > "$OUTPUT_DIR/ip_${vmid}.txt"
else
echo " ⚠️ Could not retrieve IP"
echo "ERROR" > "$OUTPUT_DIR/ip_${vmid}.txt"
fi
# Check static-nodes.json
echo "static-nodes.json:"
STATIC_NODES=$(ssh -o StrictHostKeyChecking=no -o ConnectTimeout=5 "$host" \
"pct exec $vmid -- cat /etc/besu/static-nodes.json 2>/dev/null" 2>/dev/null || echo "NOT_FOUND")
if [ "$STATIC_NODES" != "NOT_FOUND" ] && [ -n "$STATIC_NODES" ]; then
echo "$STATIC_NODES" > "$OUTPUT_DIR/static-nodes_${vmid}.json"
echo " ✅ File exists"
echo " Content:"
echo "$STATIC_NODES" | jq '.' 2>/dev/null || echo "$STATIC_NODES" | head -20
echo ""
else
echo " ⚠️ File not found or empty"
echo "NOT_FOUND" > "$OUTPUT_DIR/static-nodes_${vmid}.json"
fi
# Check permissioned-nodes.json
echo "permissioned-nodes.json:"
PERM_NODES=$(ssh -o StrictHostKeyChecking=no -o ConnectTimeout=5 "$host" \
"pct exec $vmid -- cat /etc/besu/permissioned-nodes.json 2>/dev/null" 2>/dev/null || echo "NOT_FOUND")
if [ "$PERM_NODES" != "NOT_FOUND" ] && [ -n "$PERM_NODES" ]; then
echo "$PERM_NODES" > "$OUTPUT_DIR/permissioned-nodes_${vmid}.json"
echo " ✅ File exists"
echo " Content:"
echo "$PERM_NODES" | jq '.' 2>/dev/null || echo "$PERM_NODES" | head -20
echo ""
else
echo " File not found (may not be using permissioning)"
echo "NOT_FOUND" > "$OUTPUT_DIR/permissioned-nodes_${vmid}.json"
fi
echo ""
}
# Check all validators on ml110
echo "=== Validators on ml110 (${PROXMOX_HOST_ML110:-192.168.11.10}) ==="
for vmid in $VALIDATORS_ML110; do
get_node_info "$vmid" "$ML110_HOST" "Validator"
done
# Check all validators on r630-01
echo "=== Validators on r630-01 (${PROXMOX_HOST_R630_01:-192.168.11.11}) ==="
for vmid in $VALIDATORS_R630; do
get_node_info "$vmid" "$R630_HOST" "Validator"
done
# Check RPC nodes (assuming they're on ml110)
echo "=== RPC Nodes on ml110 (${PROXMOX_HOST_ML110:-192.168.11.10}) ==="
for vmid in $RPC_NODES; do
get_node_info "$vmid" "$ML110_HOST" "RPC"
done
echo ""
echo "=== Consistency Analysis ==="
echo ""
# Collect all enodes
echo "All Enode Addresses:"
for file in "$OUTPUT_DIR"/enode_*.txt; do
if [ -f "$file" ]; then
VMID=$(basename "$file" | sed 's/enode_\(.*\)\.txt/\1/')
ENODE=$(cat "$file")
if [ "$ENODE" != "ERROR" ]; then
echo " Node $VMID: $ENODE"
fi
fi
done
echo ""
echo "=== Checking static-nodes.json Consistency ==="
echo ""
# Compare static-nodes files
STATIC_FILES=("$OUTPUT_DIR"/static-nodes_*.json)
if [ -f "${STATIC_FILES[0]}" ]; then
FIRST_STATIC=$(cat "${STATIC_FILES[0]}")
ALL_MATCH=true
for file in "${STATIC_FILES[@]}"; do
VMID=$(basename "$file" | sed 's/static-nodes_\(.*\)\.json/\1/')
CURRENT=$(cat "$file")
if [ "$CURRENT" != "NOT_FOUND" ]; then
if [ "$CURRENT" != "$FIRST_STATIC" ]; then
echo " ⚠️ Node $VMID static-nodes.json differs from first node"
ALL_MATCH=false
fi
fi
done
if [ "$ALL_MATCH" = true ]; then
echo " ✅ All static-nodes.json files are consistent"
else
echo " ❌ static-nodes.json files are inconsistent"
fi
else
echo " ⚠️ No static-nodes.json files found"
fi
echo ""
echo "=== Checking permissioned-nodes.json Consistency ==="
echo ""
# Compare permissioned-nodes files
PERM_FILES=("$OUTPUT_DIR"/permissioned-nodes_*.json)
if [ -f "${PERM_FILES[0]}" ]; then
FIRST_PERM=$(cat "${PERM_FILES[0]}")
ALL_MATCH=true
for file in "${PERM_FILES[@]}"; do
VMID=$(basename "$file" | sed 's/permissioned-nodes_\(.*\)\.json/\1/')
CURRENT=$(cat "$file")
if [ "$CURRENT" != "NOT_FOUND" ] && [ -n "$CURRENT" ]; then
if [ "$CURRENT" != "$FIRST_PERM" ]; then
echo " ⚠️ Node $VMID permissioned-nodes.json differs from first node"
ALL_MATCH=false
fi
fi
done
if [ "$ALL_MATCH" = true ]; then
echo " ✅ All permissioned-nodes.json files are consistent"
else
echo " ❌ permissioned-nodes.json files are inconsistent"
fi
else
echo " No permissioned-nodes.json files found (permissioning may not be enabled)"
fi
echo ""
echo "=== Verifying Enode IP Addresses Match Actual IPs ==="
echo ""
# Check if enode IPs match actual IPs
for file in "$OUTPUT_DIR"/enode_*.txt; do
if [ -f "$file" ]; then
VMID=$(basename "$file" | sed 's/enode_\(.*\)\.txt/\1/')
ENODE=$(cat "$file")
IP_FILE="$OUTPUT_DIR/ip_${VMID}.txt"
if [ "$ENODE" != "ERROR" ] && [ -f "$IP_FILE" ]; then
ENODE_IP=$(echo "$ENODE" | grep -oP '@\K[^:]+' || echo "N/A")
ACTUAL_IP=$(cat "$IP_FILE")
if [ "$ENODE_IP" != "N/A" ] && [ "$ACTUAL_IP" != "ERROR" ]; then
if [ "$ENODE_IP" = "$ACTUAL_IP" ]; then
echo " ✅ Node $VMID: Enode IP ($ENODE_IP) matches actual IP ($ACTUAL_IP)"
else
echo " ⚠️ Node $VMID: Enode IP ($ENODE_IP) does NOT match actual IP ($ACTUAL_IP)"
fi
fi
fi
fi
done
echo ""
echo "=== Summary ==="
echo "All node information saved to: $OUTPUT_DIR"
echo ""
echo "Files created:"
ls -lh "$OUTPUT_DIR" 2>/dev/null | tail -n +2 || echo "No files created"