Files
jcc-blockchain/scripts/devnet-up.sh
T
BlockchainEngineer 6af3f606a2 fix(devnet): correct p2p ports, env typo, and missing validator volumes
- Fix docker-compose.yml p2p port mappings (30304:30303, 30305:30303)
- Fix typo BESUS_GENESIS_FILE -> BESU_GENESIS_FILE
- Add missing volumes/environment to validator2 and validator3 services
- Remove outdated package-lock.json to let CI regenerate cleanly
- Validate genesis determinism and extraData alignment

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-05-07 05:03:07 +00:00

70 lines
2.2 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
COMPOSE="${PROJECT_ROOT}/devnet/docker-compose.yml"
NETWORK="jcc-devnet"
echo "==> JCC Devnet Up"
# 1. Generate validator keys + genesis if missing
if [[ ! -f "${PROJECT_ROOT}/devnet/besu-config/genesis.json" ]]; then
echo "--> Generating devnet config (genesis + keys + static-nodes)..."
node "${SCRIPT_DIR}/generate-devnet-config.js" "${PROJECT_ROOT}/devnet"
else
echo "--> Devnet config already present. Regenerate with: node scripts/generate-devnet-config.js"
fi
# 2. Ensure compose is available
if ! command -v docker >/dev/null 2>&1; then
echo "ERROR: Docker is not installed or not in PATH."
exit 1
fi
if ! docker compose version >/dev/null 2>&1 && ! docker-compose version >/dev/null 2>&1; then
echo "ERROR: Docker Compose is not available."
exit 1
fi
COMPOSE_CMD="docker compose"
if ! docker compose version >/dev/null 2>&1; then
COMPOSE_CMD="docker-compose"
fi
# 3. Pull images and start
${COMPOSE_CMD} -f "${COMPOSE}" pull
${COMPOSE_CMD} -f "${COMPOSE}" up -d
# 4. Wait for block production
echo "--> Waiting for block production..."
for i in {1..60}; do
RESP=$(curl -s -X POST http://localhost:8545 \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' || true)
if echo "$RESP" | grep -q '"result":'; then
BN_HEX=$(echo "$RESP" | sed -n 's/.*"result":"\([^"]*\)".*/\1/p')
if [[ -n "$BN_HEX" ]]; then
BN=$(printf '%d' "$BN_HEX" 2>/dev/null || echo "0")
if [[ "$BN" -ge 1 ]]; then
echo "==> Devnet ready. Latest block: $BN"
break
fi
fi
fi
sleep 2
done
# 5. Print endpoints
echo ""
echo "Endpoints:"
echo " Validator 1 RPC: http://localhost:8545"
echo " Validator 1 WS: ws://localhost:8546"
echo " Validator 1 Metrics: http://localhost:9545"
echo " Validator 2 RPC: http://localhost:8547"
echo " Validator 3 RPC: http://localhost:8549"
echo " Prometheus: http://localhost:9090"
echo " Grafana: http://localhost:3000 (admin / admin)"
echo ""
echo "Tail logs:"
echo " ${COMPOSE_CMD} -f ${COMPOSE} logs -f"