|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +set -e |
| 4 | + |
| 5 | +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| 6 | +PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" |
| 7 | + |
| 8 | +# Source common utilities if available, otherwise define locally |
| 9 | +if [ -f "$SCRIPT_DIR/util/common.sh" ]; then |
| 10 | + source "$SCRIPT_DIR/util/common.sh" |
| 11 | +else |
| 12 | + print_success() { echo "[SUCCESS] $1"; } |
| 13 | + print_error() { echo "[ERROR] $1"; } |
| 14 | + print_info() { echo "[INFO] $1"; } |
| 15 | +fi |
| 16 | + |
| 17 | +# Ensure we're in the project root |
| 18 | +cd "$PROJECT_ROOT" |
| 19 | + |
| 20 | +echo "Starting Devnet Provision Check (No Provers)" |
| 21 | +echo |
| 22 | + |
| 23 | +# Step 1: Clean up any existing deployment |
| 24 | +echo "Step 1: Cleanup existing deployment" |
| 25 | +print_info "Running surge-remover.sh --devnet-non-interactive" |
| 26 | +if ./surge-remover.sh --devnet-non-interactive; then |
| 27 | + print_success "Cleanup completed" |
| 28 | +else |
| 29 | + print_error "Cleanup failed" |
| 30 | + exit 1 |
| 31 | +fi |
| 32 | +echo |
| 33 | + |
| 34 | +# Step 2: Prepare environment |
| 35 | +echo "Step 2: Prepare environment" |
| 36 | +if [ ! -f .env ]; then |
| 37 | + print_info "Copying .env.devnet to .env" |
| 38 | + cp .env.devnet .env |
| 39 | + print_success ".env file created" |
| 40 | +else |
| 41 | + print_info ".env file already exists" |
| 42 | +fi |
| 43 | +echo |
| 44 | + |
| 45 | +# Step 3: Deploy protocol |
| 46 | +echo "Step 3: Deploy protocol (L1 contracts)" |
| 47 | +print_info "Running surge-protocol-deployer.sh --devnet-non-interactive" |
| 48 | +if ./surge-protocol-deployer.sh --devnet-non-interactive; then |
| 49 | + print_success "Protocol deployment completed" |
| 50 | +else |
| 51 | + print_error "Protocol deployment failed" |
| 52 | + exit 1 |
| 53 | +fi |
| 54 | +echo |
| 55 | + |
| 56 | +# Step 4: Verify protocol deployment artifacts |
| 57 | +echo "Step 4: Verify protocol deployment" |
| 58 | +if [ ! -f "deployment/deploy_l1.json" ]; then |
| 59 | + print_error "deploy_l1.json not found" |
| 60 | + exit 1 |
| 61 | +else |
| 62 | + print_success "deploy_l1.json found" |
| 63 | +fi |
| 64 | + |
| 65 | +if [ ! -f "deployment/proposer_wrappers.json" ]; then |
| 66 | + print_error "proposer_wrappers.json not found" |
| 67 | + exit 1 |
| 68 | +else |
| 69 | + print_success "proposer_wrappers.json found" |
| 70 | +fi |
| 71 | +echo |
| 72 | + |
| 73 | +# Step 5: Deploy stack |
| 74 | +echo "Step 5: Deploy L2 stack" |
| 75 | +print_info "Running surge-stack-deployer.sh --devnet-non-interactive" |
| 76 | +if ./surge-stack-deployer.sh --devnet-non-interactive; then |
| 77 | + print_success "Stack deployment completed" |
| 78 | +else |
| 79 | + print_error "Stack deployment failed" |
| 80 | + exit 1 |
| 81 | +fi |
| 82 | +echo |
| 83 | + |
| 84 | +# Step 6: Verify services are running |
| 85 | +echo "Step 6: Verify services" |
| 86 | +print_info "Checking running containers" |
| 87 | +docker compose ps |
| 88 | +echo |
| 89 | + |
| 90 | +print_info "Checking critical containers are healthy..." |
| 91 | +# Check L2 execution client container |
| 92 | +if docker compose ps | grep "l2-nethermind-execution-client" | grep -q "(healthy)"; then |
| 93 | + print_success "L2 execution client container is healthy" |
| 94 | +else |
| 95 | + print_error "L2 execution client container is not healthy" |
| 96 | + exit 1 |
| 97 | +fi |
| 98 | + |
| 99 | +# Check other critical containers are running |
| 100 | +CRITICAL_CONTAINERS=("l2-taiko-consensus-client" "l2-taiko-proposer-client" "relayer-l1-indexer" "relayer-l2-indexer") |
| 101 | +for container in "${CRITICAL_CONTAINERS[@]}"; do |
| 102 | + if docker compose ps | grep "$container" | grep -q "Up"; then |
| 103 | + print_success "$container is running" |
| 104 | + else |
| 105 | + print_error "$container is not running" |
| 106 | + exit 1 |
| 107 | + fi |
| 108 | +done |
| 109 | +echo |
| 110 | + |
| 111 | +# Step 7: Health check L2 RPC endpoints |
| 112 | +echo "Step 7: Health check L2 RPC endpoints" |
| 113 | +print_info "Waiting 30 seconds for services to stabilize..." |
| 114 | +sleep 30 |
| 115 | + |
| 116 | +print_info "Testing L2 RPC endpoint at http://localhost:8547" |
| 117 | +if curl -f http://localhost:8547 -X POST -H "Content-Type: application/json" \ |
| 118 | + --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' 2>/dev/null; then |
| 119 | + echo |
| 120 | + print_success "L2 execution client RPC is responding" |
| 121 | +else |
| 122 | + echo |
| 123 | + print_error "L2 execution client RPC health check failed" |
| 124 | + exit 1 |
| 125 | +fi |
| 126 | + |
| 127 | +print_info "Testing L2 WebSocket endpoint at ws://localhost:8548" |
| 128 | +if curl -f http://localhost:8548 -X POST -H "Content-Type: application/json" \ |
| 129 | + --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' 2>/dev/null; then |
| 130 | + echo |
| 131 | + print_success "L2 WebSocket endpoint is responding" |
| 132 | +else |
| 133 | + echo |
| 134 | + print_error "L2 WebSocket endpoint health check failed" |
| 135 | + exit 1 |
| 136 | +fi |
| 137 | +echo |
| 138 | + |
| 139 | +# Step 8: Check for errors in logs |
| 140 | +echo "Step 8: Check for errors in logs" |
| 141 | +print_info "Checking for errors in container logs (last 50 lines)" |
| 142 | +if docker compose logs --tail=50 | grep -i "error\|fatal\|panic" | grep -v "error_code" | head -20; then |
| 143 | + print_info "Found some errors in logs (review above)" |
| 144 | +else |
| 145 | + print_success "No critical errors found in recent logs" |
| 146 | +fi |
| 147 | +echo |
| 148 | + |
| 149 | +# Final summary |
| 150 | +echo "==========================================" |
| 151 | +echo "Provision Check Summary" |
| 152 | +echo "==========================================" |
| 153 | +print_success "All provision checks passed!" |
| 154 | +echo |
| 155 | +print_info "Services are running. You can now:" |
| 156 | +echo " - Access L2 RPC: http://localhost:8547" |
| 157 | +echo " - Access L2 Blockscout: http://localhost:3000" |
| 158 | +echo " - Access L1 RPC: http://localhost:32003" |
| 159 | +echo " - View logs: docker compose logs -f" |
| 160 | +echo |
| 161 | +print_info "To clean up when done:" |
| 162 | +echo " ./surge-remover.sh --devnet-non-interactive" |
| 163 | +echo |
0 commit comments