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>
302 lines
11 KiB
Bash
Executable File
302 lines
11 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Deploy Besu Configuration Files to Running Nodes
|
|
# Rolling deployment of cleaned configs to production Besu 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
|
|
|
|
|
|
# Colors
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m'
|
|
|
|
# Script directory
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
|
|
# Configuration
|
|
PROXMOX_HOST="${PROXMOX_HOST:-192.168.11.10}"
|
|
SSH_KEY="${SSH_KEY:-~/.ssh/id_ed25519_proxmox}"
|
|
DRY_RUN="${1:-}"
|
|
|
|
log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
|
|
log_success() { echo -e "${GREEN}[✓]${NC} $1"; }
|
|
log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
|
|
log_error() { echo -e "${RED}[ERROR]${NC} $1"; }
|
|
|
|
# Node definitions
|
|
VALIDATORS=(1000 1001 1002 1003 1004)
|
|
SENTRIES=(1500 1501 1502 1503)
|
|
RPC_NODES=(2101 2500 2501 2502 2503 2505 2506 2507 2508)
|
|
|
|
# Config file mappings
|
|
declare -A CONFIG_MAP=(
|
|
# Validators
|
|
[1000]="config-validator.toml"
|
|
[1001]="config-validator.toml"
|
|
[1002]="config-validator.toml"
|
|
[1003]="config-validator.toml"
|
|
[1004]="config-validator.toml"
|
|
# Sentries
|
|
[1500]="config-sentry.toml"
|
|
[1501]="config-sentry.toml"
|
|
[1502]="config-sentry.toml"
|
|
[1503]="config-sentry.toml"
|
|
# RPC Nodes (Note: 2101 is migrated from 2500)
|
|
[2101]="config-rpc-core.toml" # besu-rpc-core-1 (migrated from 2500)
|
|
[2500]="config-rpc-core.toml"
|
|
[2501]="config-rpc-perm.toml"
|
|
[2502]="config-rpc-public.toml"
|
|
[2503]="config-rpc-4.toml"
|
|
[2505]="config-rpc-luis-8a.toml"
|
|
[2506]="config-rpc-luis-1.toml"
|
|
[2507]="config-rpc-putu-8a.toml"
|
|
[2508]="config-rpc-putu-1.toml"
|
|
)
|
|
|
|
# Service name mappings
|
|
declare -A SERVICE_MAP=(
|
|
[1000]="besu-validator"
|
|
[1001]="besu-validator"
|
|
[1002]="besu-validator"
|
|
[1003]="besu-validator"
|
|
[1004]="besu-validator"
|
|
[1500]="besu-sentry"
|
|
[1501]="besu-sentry"
|
|
[1502]="besu-sentry"
|
|
[1503]="besu-sentry"
|
|
[2101]="besu-rpc" # besu-rpc-core-1 (migrated from 2500)
|
|
[2500]="besu-rpc"
|
|
[2501]="besu-rpc"
|
|
[2502]="besu-rpc"
|
|
[2503]="besu-rpc"
|
|
[2505]="besu-rpc"
|
|
[2506]="besu-rpc"
|
|
[2507]="besu-rpc"
|
|
[2508]="besu-rpc"
|
|
)
|
|
|
|
# Function to get source config file
|
|
get_source_config() {
|
|
local vmid=$1
|
|
local config_name="${CONFIG_MAP[$vmid]}"
|
|
|
|
# Check templates first
|
|
local template="$PROJECT_ROOT/smom-dbis-138-proxmox/templates/besu-configs/$config_name"
|
|
if [ -f "$template" ]; then
|
|
echo "$template"
|
|
return 0
|
|
fi
|
|
|
|
# Check source configs
|
|
local source="$PROJECT_ROOT/smom-dbis-138/config/$config_name"
|
|
if [ -f "$source" ]; then
|
|
echo "$source"
|
|
return 0
|
|
fi
|
|
|
|
log_error "Config file not found: $config_name for VMID $vmid"
|
|
return 1
|
|
}
|
|
|
|
# Function to get target config path on node
|
|
get_target_config() {
|
|
local vmid=$1
|
|
local config_name="${CONFIG_MAP[$vmid]}"
|
|
|
|
# Standard path: /etc/besu/{config-name}
|
|
echo "/etc/besu/$config_name"
|
|
}
|
|
|
|
# Function to validate config before deployment
|
|
validate_config() {
|
|
local config_file="$1"
|
|
|
|
if [ ! -f "$config_file" ]; then
|
|
log_error "Config file not found: $config_file"
|
|
return 1
|
|
fi
|
|
|
|
# Use validation script
|
|
if "$PROJECT_ROOT/scripts/validate-besu-config.sh" human >/dev/null 2>&1; then
|
|
# Quick check: ensure no deprecated options
|
|
if grep -qE '^(log-destination|fast-sync-min-peers|database-path|trie-logs-enabled|accounts-enabled|max-remote-initiated-connections|rpc-http-host-allowlist|rpc-tx-feecap="0x0"|tx-pool-max-size|tx-pool-price-bump|tx-pool-retention-hours)' "$config_file" 2>/dev/null; then
|
|
log_warn "Config may contain deprecated options: $config_file"
|
|
return 1
|
|
fi
|
|
return 0
|
|
fi
|
|
|
|
return 0
|
|
}
|
|
|
|
# Function to deploy config to a node
|
|
deploy_config() {
|
|
local vmid=$1
|
|
local node_type="$2"
|
|
|
|
log_info "Deploying config to VMID $vmid ($node_type)..."
|
|
|
|
# Get source and target paths
|
|
local source_config=$(get_source_config "$vmid")
|
|
if [ $? -ne 0 ] || [ -z "$source_config" ]; then
|
|
log_error "Failed to get source config for VMID $vmid"
|
|
return 1
|
|
fi
|
|
|
|
local target_config=$(get_target_config "$vmid")
|
|
local service_name="${SERVICE_MAP[$vmid]}"
|
|
|
|
# Validate config
|
|
if ! validate_config "$source_config"; then
|
|
log_error "Config validation failed for VMID $vmid"
|
|
return 1
|
|
fi
|
|
|
|
if [ "$DRY_RUN" == "--dry-run" ]; then
|
|
log_info " [DRY-RUN] Would deploy: $source_config → $target_config"
|
|
log_info " [DRY-RUN] Would restart: $service_name"
|
|
return 0
|
|
fi
|
|
|
|
# Check if container is running
|
|
local status=$(ssh -o StrictHostKeyChecking=accept-new -i "$SSH_KEY" "root@${PROXMOX_HOST}" \
|
|
"pct status $vmid 2>/dev/null" | awk '{print $2}' || echo "unknown")
|
|
|
|
if [ "$status" != "running" ]; then
|
|
log_warn "Container $vmid is not running (status: $status), skipping..."
|
|
return 1
|
|
fi
|
|
|
|
# Backup existing config
|
|
log_info " Backing up existing configuration..."
|
|
ssh -o StrictHostKeyChecking=accept-new -i "$SSH_KEY" "root@${PROXMOX_HOST}" \
|
|
"pct exec $vmid -- cp $target_config ${target_config}.backup.$(date +%Y%m%d_%H%M%S) 2>/dev/null || true"
|
|
|
|
# Copy config to container
|
|
log_info " Copying configuration file..."
|
|
cat "$source_config" | ssh -o StrictHostKeyChecking=accept-new -i "$SSH_KEY" "root@${PROXMOX_HOST}" \
|
|
"pct exec $vmid -- bash -c 'cat > $target_config'"
|
|
|
|
# Validate config on target (if Besu available)
|
|
log_info " Validating config on target node..."
|
|
# Note: Actual Besu validation would require Besu binary on node
|
|
|
|
# Restart service
|
|
log_info " Restarting service: $service_name..."
|
|
ssh -o StrictHostKeyChecking=accept-new -i "$SSH_KEY" "root@${PROXMOX_HOST}" \
|
|
"pct exec $vmid -- bash -c 'systemctl daemon-reload && systemctl restart ${service_name}.service'"
|
|
|
|
# Wait for service to start
|
|
sleep 5
|
|
|
|
# Check service status
|
|
local service_status=$(ssh -o StrictHostKeyChecking=accept-new -i "$SSH_KEY" "root@${PROXMOX_HOST}" \
|
|
"pct exec $vmid -- systemctl is-active ${service_name}.service 2>/dev/null" || echo "unknown")
|
|
|
|
if [ "$service_status" == "active" ]; then
|
|
log_success " Service restarted successfully"
|
|
return 0
|
|
else
|
|
log_warn " Service status: $service_status (may still be starting)"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
# Main execution
|
|
echo -e "${BLUE}╔══════════════════════════════════════════════════════════════╗${NC}"
|
|
echo -e "${BLUE}║ BESU CONFIGURATION DEPLOYMENT ║${NC}"
|
|
echo -e "${BLUE}╚══════════════════════════════════════════════════════════════╝${NC}"
|
|
echo ""
|
|
|
|
if [ "$DRY_RUN" == "--dry-run" ]; then
|
|
log_warn "DRY-RUN MODE: No files will be deployed"
|
|
echo ""
|
|
fi
|
|
|
|
# Track statistics
|
|
DEPLOYED=0
|
|
FAILED=0
|
|
SKIPPED=0
|
|
|
|
# Deployment order: Validators → Sentries → RPC
|
|
echo -e "${BLUE}═══════════════════════════════════════════════════════════════${NC}"
|
|
echo -e "${BLUE}Phase 1: Deploying to Validator Nodes${NC}"
|
|
echo -e "${BLUE}═══════════════════════════════════════════════════════════════${NC}"
|
|
echo ""
|
|
|
|
for vmid in "${VALIDATORS[@]}"; do
|
|
if deploy_config "$vmid" "validator"; then
|
|
DEPLOYED=$((DEPLOYED + 1))
|
|
else
|
|
FAILED=$((FAILED + 1))
|
|
fi
|
|
echo ""
|
|
sleep 2 # Stagger deployments
|
|
done
|
|
|
|
echo -e "${BLUE}═══════════════════════════════════════════════════════════════${NC}"
|
|
echo -e "${BLUE}Phase 2: Deploying to Sentry Nodes${NC}"
|
|
echo -e "${BLUE}═══════════════════════════════════════════════════════════════${NC}"
|
|
echo ""
|
|
|
|
for vmid in "${SENTRIES[@]}"; do
|
|
if deploy_config "$vmid" "sentry"; then
|
|
DEPLOYED=$((DEPLOYED + 1))
|
|
else
|
|
FAILED=$((FAILED + 1))
|
|
fi
|
|
echo ""
|
|
sleep 2 # Stagger deployments
|
|
done
|
|
|
|
echo -e "${BLUE}═══════════════════════════════════════════════════════════════${NC}"
|
|
echo -e "${BLUE}Phase 3: Deploying to RPC Nodes${NC}"
|
|
echo -e "${BLUE}═══════════════════════════════════════════════════════════════${NC}"
|
|
echo ""
|
|
|
|
for vmid in "${RPC_NODES[@]}"; do
|
|
if deploy_config "$vmid" "rpc"; then
|
|
DEPLOYED=$((DEPLOYED + 1))
|
|
else
|
|
FAILED=$((FAILED + 1))
|
|
fi
|
|
echo ""
|
|
sleep 2 # Stagger deployments
|
|
done
|
|
|
|
# Summary
|
|
echo -e "${BLUE}═══════════════════════════════════════════════════════════════${NC}"
|
|
echo -e "${BLUE}Deployment Summary${NC}"
|
|
echo -e "${BLUE}═══════════════════════════════════════════════════════════════${NC}"
|
|
echo ""
|
|
echo "Deployed: $DEPLOYED"
|
|
echo "Failed: $FAILED"
|
|
echo "Skipped: $SKIPPED"
|
|
echo ""
|
|
|
|
if [ "$DRY_RUN" == "--dry-run" ]; then
|
|
log_warn "This was a dry-run. No files were deployed."
|
|
echo "Run without --dry-run to deploy configurations."
|
|
else
|
|
if [ $FAILED -eq 0 ]; then
|
|
log_success "All configurations deployed successfully!"
|
|
echo ""
|
|
echo "Next steps:"
|
|
echo " 1. Monitor service logs for configuration errors"
|
|
echo " 2. Verify services are running correctly"
|
|
echo " 3. Check logging levels are applied (WARN for validators/RPC, INFO for sentries)"
|
|
echo " 4. Monitor for 24-48 hours post-deployment"
|
|
else
|
|
log_warn "Some deployments failed. Review logs above."
|
|
exit 1
|
|
fi
|
|
fi
|