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>
128 lines
4.2 KiB
Bash
Executable File
128 lines
4.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Deploy Contracts with Explicit Nonce Management
|
|
# Prevents "replacement transaction underpriced" errors
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
cd "$PROJECT_ROOT"
|
|
|
|
# Colors
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[0;34m'
|
|
CYAN='\033[0;36m'
|
|
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"; }
|
|
log_section() { echo -e "\n${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"; echo -e "${CYAN}$1${NC}"; echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}\n"; }
|
|
|
|
# Load environment
|
|
if [ -f "$PROJECT_ROOT/smom-dbis-138/.env" ]; then
|
|
set +e
|
|
source "$PROJECT_ROOT/smom-dbis-138/.env" 2>/dev/null || true
|
|
set -e
|
|
fi
|
|
|
|
PRIVATE_KEY="${PRIVATE_KEY:-}"
|
|
RPC_URL="${RPC_URL_138:-http://localhost:8545}"
|
|
|
|
if [ -z "$PRIVATE_KEY" ]; then
|
|
log_error "PRIVATE_KEY not set"
|
|
exit 1
|
|
fi
|
|
|
|
DEPLOYER=$(cast wallet address "$PRIVATE_KEY" 2>/dev/null || echo "")
|
|
if [ -z "$DEPLOYER" ]; then
|
|
log_error "Failed to derive deployer address"
|
|
exit 1
|
|
fi
|
|
|
|
log_section "Deployment with Nonce Management"
|
|
log_info "Deployer: $DEPLOYER"
|
|
log_info "RPC: $RPC_URL"
|
|
|
|
# Get current nonce
|
|
CURRENT_NONCE=$(cast nonce "$DEPLOYER" --rpc-url "$RPC_URL" 2>/dev/null || echo "0")
|
|
log_info "Current nonce: $CURRENT_NONCE"
|
|
|
|
# Clear broadcast cache
|
|
log_info "Clearing broadcast cache..."
|
|
cd "$PROJECT_ROOT/smom-dbis-138"
|
|
rm -rf broadcast/*/138/run-*.json 2>/dev/null || true
|
|
log_success "Cache cleared"
|
|
|
|
# Calculate gas prices
|
|
GAS_PRICE=$(bash "$PROJECT_ROOT/scripts/calculate-chain138-gas-price.sh" 2>/dev/null || echo "1100000000")
|
|
BASE_FEE_HEX=$(cast rpc eth_getBlockByNumber latest false --rpc-url "$RPC_URL" 2>/dev/null | grep -o '"baseFeePerGas":"[^"]*"' | cut -d'"' -f4 || echo "0x0")
|
|
BASE_FEE_DEC=$(cast --to-dec "$BASE_FEE_HEX" 2>/dev/null || echo "7")
|
|
|
|
USE_EIP1559=false
|
|
if [ -n "$BASE_FEE_HEX" ] && [ "$BASE_FEE_HEX" != "0x0" ] && [ "$BASE_FEE_HEX" != "null" ]; then
|
|
USE_EIP1559=true
|
|
MAX_FEE=$((GAS_PRICE * 2)) # Use 2x for safety
|
|
AVAILABLE=$((MAX_FEE - BASE_FEE_DEC))
|
|
PRIORITY=$((AVAILABLE / 10))
|
|
if [ "$PRIORITY" -lt "10000000" ]; then
|
|
PRIORITY="10000000"
|
|
fi
|
|
log_success "EIP-1559: Max=$MAX_FEE, Priority=$PRIORITY, Base=$BASE_FEE_DEC"
|
|
else
|
|
MAX_FEE=$((GAS_PRICE * 2))
|
|
log_info "Legacy: Gas Price=$MAX_FEE"
|
|
fi
|
|
|
|
# Deploy WETH9 Bridge
|
|
log_section "Deploy WETH9 Bridge"
|
|
|
|
if [ "$USE_EIP1559" = true ]; then
|
|
forge script script/DeployCCIPWETH9Bridge.s.sol:DeployCCIPWETH9Bridge \
|
|
--rpc-url "$RPC_URL" \
|
|
--broadcast \
|
|
--private-key "$PRIVATE_KEY" \
|
|
--with-gas-price "$MAX_FEE" \
|
|
--priority-gas-price "$PRIORITY" \
|
|
--slow \
|
|
-vvv 2>&1 | tee /tmp/weth9-deploy.log
|
|
else
|
|
forge script script/DeployCCIPWETH9Bridge.s.sol:DeployCCIPWETH9Bridge \
|
|
--rpc-url "$RPC_URL" \
|
|
--broadcast \
|
|
--private-key "$PRIVATE_KEY" \
|
|
--with-gas-price "$MAX_FEE" \
|
|
--legacy \
|
|
--slow \
|
|
-vvv 2>&1 | tee /tmp/weth9-deploy.log
|
|
fi
|
|
|
|
# Extract transaction hash
|
|
TXHASH=$(grep -oE "0x[a-fA-F0-9]{64}" /tmp/weth9-deploy.log | tail -1 || echo "")
|
|
if [ -n "$TXHASH" ]; then
|
|
log_info "Transaction hash: $TXHASH"
|
|
log_info "Waiting for confirmation..."
|
|
|
|
# Wait for transaction
|
|
if [ -f "$SCRIPT_DIR/check-transaction-status.sh" ]; then
|
|
bash "$SCRIPT_DIR/check-transaction-status.sh" "$TXHASH" "$RPC_URL" 600
|
|
else
|
|
log_warn "check-transaction-status.sh not found, manually verify transaction"
|
|
fi
|
|
fi
|
|
|
|
# Verify deployment
|
|
WETH9_ADDR="0x646e0026F8B5BCB94986377a25Da6f89BdCbBF6e"
|
|
CODE_SIZE=$(cast code "$WETH9_ADDR" --rpc-url "$RPC_URL" 2>/dev/null | wc -c || echo "0")
|
|
if [ "$CODE_SIZE" -gt 1000 ]; then
|
|
log_success "WETH9 Bridge deployed: $WETH9_ADDR ($CODE_SIZE bytes)"
|
|
else
|
|
log_error "WETH9 Bridge not deployed (code size: $CODE_SIZE bytes)"
|
|
exit 1
|
|
fi
|
|
|
|
log_success "Deployment complete!"
|