Files
proxmox/scripts/configure-ethereum-mainnet-final.sh
defiQUG cb47cce074 Complete markdown files cleanup and organization
- Organized 252 files across project
- Root directory: 187 → 2 files (98.9% reduction)
- Moved configuration guides to docs/04-configuration/
- Moved troubleshooting guides to docs/09-troubleshooting/
- Moved quick start guides to docs/01-getting-started/
- Moved reports to reports/ directory
- Archived temporary files
- Generated comprehensive reports and documentation
- Created maintenance scripts and guides

All files organized according to established standards.
2026-01-06 01:46:25 -08:00

146 lines
5.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# Final script to configure Ethereum Mainnet - Run after Besu restart
# Usage: ./configure-ethereum-mainnet-final.sh
set -uo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SOURCE_PROJECT="/home/intlc/projects/smom-dbis-138"
# 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}[WARN]${NC} $1"; }
log_error() { echo -e "${RED}[ERROR]${NC} $1"; }
source "$SOURCE_PROJECT/.env"
RPC_URL="${RPC_URL_138:-http://192.168.11.250:8545}"
WETH9_BRIDGE="${CCIPWETH9_BRIDGE_CHAIN138:-0x89dd12025bfCD38A168455A44B400e913ED33BE2}"
WETH10_BRIDGE="${CCIPWETH10_BRIDGE_CHAIN138:-0xe0E93247376aa097dB308B92e6Ba36bA015535D0}"
ETHEREUM_MAINNET_SELECTOR="5009297550715157269"
WETH9_MAINNET_BRIDGE="0x8078a09637e47fa5ed34f626046ea2094a5cde5e"
WETH10_MAINNET_BRIDGE="0x105f8a15b819948a89153505762444ee9f324684"
DEPLOYER=$(cast wallet address --private-key "$PRIVATE_KEY" 2>/dev/null)
log_info "========================================="
log_info "Configure Ethereum Mainnet (Final)"
log_info "========================================="
log_info ""
# Get optimal gas price
CURRENT_GAS=$(cast gas-price --rpc-url "$RPC_URL" 2>/dev/null || echo "1000000000")
OPTIMAL_GAS=$(echo "$CURRENT_GAS * 2" | bc 2>/dev/null || echo "2000000000")
log_info "Current gas price: $CURRENT_GAS wei"
log_info "Using gas price: $OPTIMAL_GAS wei"
log_info ""
# Don't specify nonce - let cast send automatically determine the correct nonce
# This avoids issues with ghost nonces and pending transactions we can't see
CURRENT_NONCE=$(cast nonce "$DEPLOYER" --rpc-url "$RPC_URL" 2>/dev/null || echo "0")
log_info "Current on-chain nonce: $CURRENT_NONCE"
log_info "Using automatic nonce (cast will determine correct nonce)"
# Configure WETH9
log_info "Configuring WETH9 bridge..."
TX_OUTPUT=$(cast send "$WETH9_BRIDGE" \
"addDestination(uint64,address)" \
"$ETHEREUM_MAINNET_SELECTOR" \
"$WETH9_MAINNET_BRIDGE" \
--rpc-url "$RPC_URL" \
--private-key "$PRIVATE_KEY" \
--gas-price "$OPTIMAL_GAS" \
--gas-limit 200000 \
2>&1 || echo "FAILED")
if echo "$TX_OUTPUT" | grep -qE "transactionHash|Success"; then
HASH=$(echo "$TX_OUTPUT" | grep -oE "transactionHash[[:space:]]+0x[0-9a-fA-F]{64}" | awk '{print $2}' || echo "")
log_success "✓ WETH9 bridge configured: $HASH"
sleep 10
else
ERR=$(echo "$TX_OUTPUT" | grep -E "Error|reverted" | head -1 || echo "Unknown")
log_error "✗ WETH9 configuration failed: $ERR"
if echo "$ERR" | grep -q "underpriced"; then
log_warn "⚠ Mempool still blocking - Besu may need restart"
fi
fi
log_info ""
# Configure WETH10
log_info "Configuring WETH10 bridge..."
TX_OUTPUT=$(cast send "$WETH10_BRIDGE" \
"addDestination(uint64,address)" \
"$ETHEREUM_MAINNET_SELECTOR" \
"$WETH10_MAINNET_BRIDGE" \
--rpc-url "$RPC_URL" \
--private-key "$PRIVATE_KEY" \
--gas-price "$OPTIMAL_GAS" \
--gas-limit 200000 \
2>&1 || echo "FAILED")
if echo "$TX_OUTPUT" | grep -qE "transactionHash|Success"; then
HASH=$(echo "$TX_OUTPUT" | grep -oE "transactionHash[[:space:]]+0x[0-9a-fA-F]{64}" | awk '{print $2}' || echo "")
log_success "✓ WETH10 bridge configured: $HASH"
sleep 10
else
ERR=$(echo "$TX_OUTPUT" | grep -E "Error|reverted" | head -1 || echo "Unknown")
log_error "✗ WETH10 configuration failed: $ERR"
if echo "$ERR" | grep -q "underpriced"; then
log_warn "⚠ Mempool still blocking - Besu may need restart"
fi
fi
log_info ""
# Verify
log_info "Verifying configuration..."
sleep 5
WETH9_CHECK=$(cast call "$WETH9_BRIDGE" "destinations(uint64)" "$ETHEREUM_MAINNET_SELECTOR" --rpc-url "$RPC_URL" 2>/dev/null || echo "")
WETH10_CHECK=$(cast call "$WETH10_BRIDGE" "destinations(uint64)" "$ETHEREUM_MAINNET_SELECTOR" --rpc-url "$RPC_URL" 2>/dev/null || echo "")
log_info ""
log_success "========================================="
log_success "Verification Results"
log_success "========================================="
log_info ""
if [ -n "$WETH9_CHECK" ] && ! echo "$WETH9_CHECK" | grep -qE "^0x0+$" && ! echo "$WETH9_CHECK" | grep -qE "^0x0000000000000000000000000000000000000000$"; then
log_success "✓ WETH9 bridge: CONFIGURED"
else
log_error "✗ WETH9 bridge: NOT CONFIGURED"
fi
if [ -n "$WETH10_CHECK" ] && ! echo "$WETH10_CHECK" | grep -qE "^0x0+$" && ! echo "$WETH10_CHECK" | grep -qE "^0x0000000000000000000000000000000000000000$"; then
log_success "✓ WETH10 bridge: CONFIGURED"
else
log_error "✗ WETH10 bridge: NOT CONFIGURED"
fi
log_info ""
if [ -n "$WETH9_CHECK" ] && ! echo "$WETH9_CHECK" | grep -qE "^0x0+$" && [ -n "$WETH10_CHECK" ] && ! echo "$WETH10_CHECK" | grep -qE "^0x0+$"; then
log_success "✅ Ethereum Mainnet configuration complete!"
log_info ""
log_info "Run test to verify:"
log_info " ./scripts/test-bridge-all-7-networks.sh weth9"
else
log_warn "⚠ Configuration incomplete"
log_info ""
log_info "If still failing, restart Besu node:"
log_info " sudo systemctl restart besu-rpc # On 192.168.11.250"
log_info " Then run this script again"
fi
log_info ""