Files
proxmox/scripts/verify/check-rpc-2101-all-peers.sh
defiQUG bea1903ac9
Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
Sync all local changes: docs, config, scripts, submodule refs, verification evidence
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-21 15:46:06 -08:00

59 lines
2.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# Compare RPC 2101 connected peers vs all possible peers (permissions-nodes allowlist).
# Usage: ./scripts/verify/check-rpc-2101-all-peers.sh
# Requires: jq, curl, access to RPC and config/besu-node-lists/permissions-nodes.toml
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
RPC_URL="${RPC_URL_138:-http://192.168.11.211:8545}"
PERMS="${PROJECT_ROOT}/config/besu-node-lists/permissions-nodes.toml"
# Extract allowlist IPs (exclude self 192.168.11.211)
POSSIBLE=$(grep -oE '192\.168\.11\.[0-9]+' "$PERMS" 2>/dev/null | sort -u | grep -v '192.168.11.211' || true)
# Connected peers from admin_peers
CONNECTED=$(curl -s -m 10 -X POST -H "Content-Type: application/json" \
--data '{"jsonrpc":"2.0","method":"admin_peers","params":[],"id":1}' "$RPC_URL" 2>/dev/null \
| jq -r '.result[] | .network.remoteAddress // .remoteAddress // empty' 2>/dev/null \
| sed 's/:30303//' | sort -u || true)
echo ""
echo "=== RPC 2101: all possible peers vs connected ==="
echo " RPC: $RPC_URL"
echo " Allowlist: $PERMS"
echo ""
POSSIBLE_COUNT=$(echo "$POSSIBLE" | grep -c . 2>/dev/null || echo 0)
CONNECTED_COUNT=$(echo "$CONNECTED" | grep -c . 2>/dev/null || echo 0)
echo "Possible peers (allowlist, excluding self 211): $POSSIBLE_COUNT"
echo "Connected peers: $CONNECTED_COUNT"
echo ""
echo "--- Connected (${CONNECTED_COUNT}) ---"
echo "$CONNECTED" | while read -r ip; do [ -n "$ip" ] && echo " $ip"; done
echo ""
# Missing = in possible but not in connected
MISSING=""
while read -r ip; do
[ -z "$ip" ] && continue
if ! echo "$CONNECTED" | grep -qx "$ip" 2>/dev/null; then
MISSING="${MISSING}${ip}\n"
fi
done <<< "$POSSIBLE"
MISSING=$(echo -e "$MISSING" | grep -v '^$' || true)
MISSING_COUNT=$(echo "$MISSING" | grep -c . 2>/dev/null || echo 0)
echo "--- Not connected (in allowlist, ${MISSING_COUNT}) ---"
echo "$MISSING" | while read -r ip; do [ -n "$ip" ] && echo " $ip"; done
echo ""
# Summary
echo "Summary: $CONNECTED_COUNT/$POSSIBLE_COUNT possible peers connected."
if [ "$MISSING_COUNT" -gt 0 ]; then
echo "Not connected: node may be down, or RPC has not yet connected (max-peers=32 on 2101)."
fi
echo ""