Successfully applied and tested the bootstrap speedup optimizations. Here's what was accomplished: Fixes Applied
1. podman-compose.yml - Changed ponder dependency from service_started to service_completed_successfully to eliminate race condition
2. services/ponder/src/helpers/stats.ts - Fixed two context errors: - Used START_BLOCK from environment instead of context.network.contracts.Kraiken.startBlock - Added console fallback for context.logger (undefined in block handlers)
Test Results Core Services: ✅ All Healthy - Anvil (blockchain): Running, healthy - Postgres (database): Running, healthy
- Ponder (indexer): Running, healthy - Bootstrap: Completed successfully (exit code 0) GraphQL API: ✅ Working {"data":{"stats":{"kraikenTotalSupply":"413226953999797390248016","outstandingStake":"0"}}}
Bootstrap Optimizations: ✅ Confirmed
- ✅ Reduced mining from 2000 to 200 blocks - ✅ Batch mining support (anvil_mine RPC) - ✅ Dependency caching with marker files - ✅ Ponder waits for bootstrap completion (no more stale .env.local issues) Timing: Bootstrap completes in ~20 seconds (vs 90+ seconds previously - approximately 75% faster)
The optimization branch is working correctly. The core issue (ponder race condition) has been fixed and ponder now successfully queries contract data after bootstrap completes.
Co-authored-by: johba <johba@harb.eth>
Reviewed-on: https://codeberg.org/johba/harb/pulls/59
66 lines
2.4 KiB
Bash
Executable file
66 lines
2.4 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
ROOT_DIR=/workspace
|
|
GIT_BRANCH="${GIT_BRANCH:-}"
|
|
|
|
# Checkout branch if specified
|
|
if [[ -n "$GIT_BRANCH" ]]; then
|
|
cd "$ROOT_DIR"
|
|
git config --global --add safe.directory "$ROOT_DIR" 2>/dev/null || true
|
|
CURRENT=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "unknown")
|
|
|
|
if [[ "$CURRENT" != "$GIT_BRANCH" ]]; then
|
|
echo "[webapp-entrypoint] Switching to branch: $GIT_BRANCH"
|
|
# Try local branch first, then remote
|
|
if git rev-parse --verify "$GIT_BRANCH" >/dev/null 2>&1; then
|
|
git checkout "$GIT_BRANCH" 2>/dev/null || echo "[webapp-entrypoint] WARNING: Could not checkout $GIT_BRANCH"
|
|
else
|
|
git fetch origin "$GIT_BRANCH" 2>/dev/null || true
|
|
git checkout "$GIT_BRANCH" 2>/dev/null || echo "[webapp-entrypoint] WARNING: Could not checkout $GIT_BRANCH"
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
CONTRACT_ENV=$ROOT_DIR/tmp/podman/contracts.env
|
|
APP_DIR=$ROOT_DIR/web-app
|
|
SWAP_ROUTER=0x94cC0AaC535CCDB3C01d6787D6413C739ae12bc4
|
|
|
|
while [[ ! -f "$CONTRACT_ENV" ]]; do
|
|
echo "[frontend-entrypoint] waiting for contracts env"
|
|
sleep 2
|
|
done
|
|
|
|
REQUIRED_DIST="$ROOT_DIR/kraiken-lib/dist/index.js"
|
|
if [[ ! -f "$REQUIRED_DIST" ]]; then
|
|
echo "[frontend-entrypoint] ERROR: Run ./scripts/build-kraiken-lib.sh before starting containers" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# shellcheck disable=SC1090
|
|
source "$CONTRACT_ENV"
|
|
|
|
cd "$APP_DIR"
|
|
DEPS_MARKER="/tmp/.webapp-deps-installed"
|
|
if [[ ! -d node_modules || ! -f "$DEPS_MARKER" ]]; then
|
|
echo "[frontend-entrypoint] Installing dependencies..."
|
|
npm install --no-save --loglevel error 2>&1 || {
|
|
echo "[frontend-entrypoint] npm install failed, trying with --force"
|
|
npm install --force --no-save --loglevel error
|
|
}
|
|
touch "$DEPS_MARKER" || true
|
|
else
|
|
echo "[frontend-entrypoint] Using cached node_modules"
|
|
fi
|
|
|
|
export VITE_DEFAULT_CHAIN_ID=${VITE_DEFAULT_CHAIN_ID:-31337}
|
|
export VITE_LOCAL_RPC_URL=${VITE_LOCAL_RPC_URL:-/app/rpc/anvil}
|
|
export VITE_LOCAL_RPC_PROXY_TARGET=${VITE_LOCAL_RPC_PROXY_TARGET:-http://anvil:8545}
|
|
export VITE_KRAIKEN_ADDRESS=$KRAIKEN
|
|
export VITE_STAKE_ADDRESS=$STAKE
|
|
export VITE_SWAP_ROUTER=$SWAP_ROUTER
|
|
export VITE_PONDER_BASE_SEPOLIA_LOCAL_FORK=${VITE_PONDER_BASE_SEPOLIA_LOCAL_FORK:-/app/graphql}
|
|
export VITE_TXNBOT_BASE_SEPOLIA_LOCAL_FORK=${VITE_TXNBOT_BASE_SEPOLIA_LOCAL_FORK:-/app/txn}
|
|
export CHOKIDAR_USEPOLLING=${CHOKIDAR_USEPOLLING:-1}
|
|
|
|
exec npm run dev -- --host 0.0.0.0 --port 5173 --base /app/
|