Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
- 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>
88 lines
3.0 KiB
Bash
Executable File
88 lines
3.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Block Production Monitor
|
|
# Continuously monitors block production and alerts on stalls
|
|
|
|
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
|
|
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
RPC_URL="${RPC_URL_138:-http://${RPC_CORE_1}:8545}"
|
|
CHECK_INTERVAL=30 # Check every 30 seconds
|
|
STALL_THRESHOLD=60 # Alert if no blocks for 60 seconds
|
|
ALERT_SCRIPT="${SCRIPT_DIR}/alert-block-stall.sh"
|
|
|
|
# Colors
|
|
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_success() { echo -e "${GREEN}[✓]${NC} $1"; }
|
|
log_warn() { echo -e "${YELLOW}[⚠]${NC} $1"; }
|
|
log_error() { echo -e "${RED}[✗]${NC} $1"; }
|
|
|
|
monitor_blocks() {
|
|
local last_block=0
|
|
local last_block_time=$(date +%s)
|
|
local stall_detected=false
|
|
|
|
log_info "Starting block production monitor..."
|
|
log_info "RPC URL: $RPC_URL"
|
|
log_info "Check interval: ${CHECK_INTERVAL}s"
|
|
log_info "Stall threshold: ${STALL_THRESHOLD}s"
|
|
echo ""
|
|
|
|
while true; do
|
|
local current_block=$(cast block-number --rpc-url "$RPC_URL" 2>/dev/null || echo "0")
|
|
local current_time=$(date +%s)
|
|
|
|
if [ "$current_block" != "0" ] && [ "$current_block" != "" ]; then
|
|
if [ "$current_block" != "$last_block" ]; then
|
|
# Block advanced
|
|
if [ "$stall_detected" = true ]; then
|
|
log_success "Block production RESUMED! Block: $current_block"
|
|
stall_detected=false
|
|
fi
|
|
|
|
local time_since_last=$((current_time - last_block_time))
|
|
log_success "Block: $current_block (advanced in ${time_since_last}s)"
|
|
|
|
last_block=$current_block
|
|
last_block_time=$current_time
|
|
else
|
|
# Block not advancing
|
|
local time_stalled=$((current_time - last_block_time))
|
|
|
|
if [ "$time_stalled" -ge "$STALL_THRESHOLD" ]; then
|
|
if [ "$stall_detected" = false ]; then
|
|
log_error "BLOCK PRODUCTION STALLED! Block: $current_block (stalled for ${time_stalled}s)"
|
|
stall_detected=true
|
|
|
|
# Trigger alert
|
|
if [ -f "$ALERT_SCRIPT" ]; then
|
|
bash "$ALERT_SCRIPT" "$current_block" "$time_stalled"
|
|
fi
|
|
else
|
|
log_error "Still stalled... (${time_stalled}s)"
|
|
fi
|
|
else
|
|
log_warn "Block not advancing (${time_stalled}s, threshold: ${STALL_THRESHOLD}s)"
|
|
fi
|
|
fi
|
|
else
|
|
log_error "Cannot get block number from RPC"
|
|
fi
|
|
|
|
sleep "$CHECK_INTERVAL"
|
|
done
|
|
}
|
|
|
|
monitor_blocks "$@"
|