Files
proxmox/scripts/optimize-besu-logging.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

231 lines
8.7 KiB
Bash
Executable File

#!/usr/bin/env bash
# Optimize Besu Logging Configuration
# Sets minimal logging (WARN) for validators and RPC nodes
# Maintains INFO logging for sentry nodes (full archive nodes)
set -euo pipefail
# 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)"
# Dry-run mode flag
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"; }
# Function to backup a file
backup_file() {
local file="$1"
if [ -f "$file" ]; then
local backup="${file}.backup.$(date +%Y%m%d_%H%M%S)"
if [ "$DRY_RUN" != "--dry-run" ]; then
cp "$file" "$backup"
echo "$backup"
else
echo "${file}.backup.TIMESTAMP"
fi
fi
}
# Function to update logging in a file
update_logging() {
local file="$1"
local target_level="$2"
local node_type="$3"
if [ ! -f "$file" ]; then
log_warn "File not found: $file (skipping)"
return 1
fi
# Check current logging level
local current_level=$(grep -E '^logging\s*=\s*"' "$file" | head -1 | sed -E 's/.*logging\s*=\s*"([^"]+)".*/\1/' || echo "")
if [ -z "$current_level" ]; then
log_warn "No logging setting found in: $file (skipping)"
return 1
fi
if [ "$current_level" == "$target_level" ]; then
log_info "$file: Already set to $target_level (no change needed)"
return 0
fi
log_info "$file: Updating logging from $current_level to $target_level ($node_type)"
if [ "$DRY_RUN" != "--dry-run" ]; then
# Backup file
local backup=$(backup_file "$file")
log_info " Backup created: $backup"
# Update logging level (handle both spacing variations)
sed -i -E "s/^logging\s*=\s*\"${current_level}\"/logging=\"${target_level}\"/" "$file"
# Verify change
local new_level=$(grep -E '^logging\s*=\s*"' "$file" | head -1 | sed -E 's/.*logging\s*=\s*"([^"]+)".*/\1/' || echo "")
if [ "$new_level" == "$target_level" ]; then
log_success " Updated successfully: $current_level$target_level"
return 0
else
log_error " Failed to update (current: $new_level, expected: $target_level)"
return 1
fi
else
log_info " [DRY-RUN] Would update: $current_level$target_level"
return 0
fi
}
# Function to verify sentry config
verify_sentry_config() {
local file="$1"
if [ ! -f "$file" ]; then
log_warn "Sentry config not found: $file"
return 1
fi
log_info "Verifying sentry config: $file"
local logging_level=$(grep -E '^logging\s*=\s*"' "$file" | head -1 | sed -E 's/.*logging\s*=\s*"([^"]+)".*/\1/' || echo "")
local sync_mode=$(grep -E '^sync-mode\s*=\s*"' "$file" | head -1 | sed -E 's/.*sync-mode\s*=\s*"([^"]+)".*/\1/' || echo "")
local issues=0
if [ "$logging_level" != "INFO" ] && [ "$logging_level" != "DEBUG" ]; then
log_warn " Sentry logging is $logging_level (should be INFO or DEBUG for archive)"
issues=$((issues + 1))
else
log_success " Logging level: $logging_level (appropriate for archive)"
fi
if [ "$sync_mode" != "FULL" ]; then
log_warn " Sync mode is $sync_mode (should be FULL for archive)"
issues=$((issues + 1))
else
log_success " Sync mode: $sync_mode (appropriate for archive)"
fi
return $issues
}
# Main execution
echo -e "${BLUE}╔══════════════════════════════════════════════════════════════╗${NC}"
echo -e "${BLUE}║ BESU LOGGING CONFIGURATION OPTIMIZATION ║${NC}"
echo -e "${BLUE}╚══════════════════════════════════════════════════════════════╝${NC}"
echo ""
if [ "$DRY_RUN" == "--dry-run" ]; then
log_warn "DRY-RUN MODE: No files will be modified"
echo ""
fi
# Track statistics
UPDATED=0
SKIPPED=0
FAILED=0
# Validator configurations (change to WARN)
echo -e "${BLUE}═══════════════════════════════════════════════════════════════${NC}"
echo -e "${BLUE}Updating Validator Configurations${NC}"
echo -e "${BLUE}═══════════════════════════════════════════════════════════════${NC}"
echo ""
VALIDATOR_FILES=(
"$PROJECT_ROOT/smom-dbis-138/config/config-validator.toml"
"$PROJECT_ROOT/smom-dbis-138-proxmox/templates/besu-configs/config-validator.toml"
)
for file in "${VALIDATOR_FILES[@]}"; do
if update_logging "$file" "WARN" "validator"; then
UPDATED=$((UPDATED + 1))
else
SKIPPED=$((SKIPPED + 1))
fi
echo ""
done
# RPC node configurations (change to WARN)
echo -e "${BLUE}═══════════════════════════════════════════════════════════════${NC}"
echo -e "${BLUE}Updating RPC Node Configurations${NC}"
echo -e "${BLUE}═══════════════════════════════════════════════════════════════${NC}"
echo ""
RPC_FILES=(
"$PROJECT_ROOT/smom-dbis-138/config/config-rpc-core.toml"
"$PROJECT_ROOT/smom-dbis-138/config/config-rpc-public.toml"
"$PROJECT_ROOT/smom-dbis-138/config/config-rpc-perm.toml"
"$PROJECT_ROOT/smom-dbis-138/config/config-rpc-thirdweb.toml"
"$PROJECT_ROOT/smom-dbis-138/config/config-rpc-4.toml"
"$PROJECT_ROOT/smom-dbis-138/config/config-rpc-putu-1.toml"
"$PROJECT_ROOT/smom-dbis-138/config/config-rpc-putu-8a.toml"
"$PROJECT_ROOT/smom-dbis-138/config/config-rpc-luis-1.toml"
"$PROJECT_ROOT/smom-dbis-138/config/config-rpc-luis-8a.toml"
"$PROJECT_ROOT/smom-dbis-138/config/config-member.toml"
"$PROJECT_ROOT/smom-dbis-138-proxmox/templates/besu-configs/config-rpc-core.toml"
"$PROJECT_ROOT/smom-dbis-138-proxmox/templates/besu-configs/config-rpc.toml"
"$PROJECT_ROOT/smom-dbis-138-proxmox/templates/besu-configs/config-rpc-4.toml"
)
for file in "${RPC_FILES[@]}"; do
if update_logging "$file" "WARN" "RPC"; then
UPDATED=$((UPDATED + 1))
else
SKIPPED=$((SKIPPED + 1))
fi
echo ""
done
# Verify sentry configurations (keep INFO)
echo -e "${BLUE}═══════════════════════════════════════════════════════════════${NC}"
echo -e "${BLUE}Verifying Sentry Configurations (Archive Nodes)${NC}"
echo -e "${BLUE}═══════════════════════════════════════════════════════════════${NC}"
echo ""
SENTRY_FILES=(
"$PROJECT_ROOT/smom-dbis-138-proxmox/templates/besu-configs/config-sentry.toml"
)
for file in "${SENTRY_FILES[@]}"; do
if verify_sentry_config "$file"; then
log_success "Sentry config verified: $file"
else
log_warn "Sentry config has issues: $file"
FAILED=$((FAILED + 1))
fi
echo ""
done
# Summary
echo -e "${BLUE}═══════════════════════════════════════════════════════════════${NC}"
echo -e "${BLUE}Summary${NC}"
echo -e "${BLUE}═══════════════════════════════════════════════════════════════${NC}"
echo ""
echo "Files updated: $UPDATED"
echo "Files skipped: $SKIPPED"
echo "Files with issues: $FAILED"
echo ""
if [ "$DRY_RUN" == "--dry-run" ]; then
log_warn "This was a dry-run. No files were modified."
echo "Run without --dry-run to apply changes."
else
log_success "Configuration optimization complete!"
echo ""
echo "Next steps:"
echo " 1. Review the changes in the updated configuration files"
echo " 2. Deploy updated configurations to Besu nodes"
echo " 3. Restart Besu services to apply new logging levels"
fi