ponder speedup (#59)
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
This commit is contained in:
parent
514be62cbb
commit
d6f0bf4f02
10 changed files with 88 additions and 31 deletions
|
|
@ -53,6 +53,8 @@ log() {
|
|||
echo "[bootstrap] $*"
|
||||
}
|
||||
|
||||
BOOTSTRAP_START=$(date +%s%3N)
|
||||
|
||||
wait_for_rpc() {
|
||||
for _ in {1..120}; do
|
||||
if cast chain-id --rpc-url "$ANVIL_RPC" >/dev/null 2>&1; then
|
||||
|
|
@ -175,10 +177,20 @@ seed_application_state() {
|
|||
}
|
||||
|
||||
prime_chain() {
|
||||
log "Pre-mining blocks"
|
||||
for _ in {1..2000}; do
|
||||
cast rpc --rpc-url "$ANVIL_RPC" evm_mine >/dev/null 2>&1 || true
|
||||
done
|
||||
log "Pre-mining 200 blocks (2x ring buffer warmup)..."
|
||||
# Try batch mine first (0xc8 = 200 blocks = 2x MINIMUM_BLOCKS_FOR_RING_BUFFER, 0x1 = 1 second interval)
|
||||
if cast rpc --rpc-url "$ANVIL_RPC" anvil_mine "0xc8" "0x1" >/dev/null 2>&1; then
|
||||
log "Used batch mining"
|
||||
else
|
||||
log "Batch mining failed, using individual evm_mine calls"
|
||||
for i in {1..200}; do
|
||||
cast rpc --rpc-url "$ANVIL_RPC" evm_mine >/dev/null 2>&1 || true
|
||||
if ((i % 50 == 0)); then
|
||||
log "Mined $i blocks..."
|
||||
fi
|
||||
done
|
||||
fi
|
||||
log "Pre-mining complete"
|
||||
}
|
||||
|
||||
write_ponder_env() {
|
||||
|
|
@ -235,13 +247,15 @@ main() {
|
|||
fund_txn_bot_wallet
|
||||
prime_chain &
|
||||
local prime_pid=$!
|
||||
log "Bootstrap complete (mining blocks in background)"
|
||||
wait "$prime_pid"
|
||||
BOOTSTRAP_END=$(date +%s%3N)
|
||||
elapsed_ms=$((BOOTSTRAP_END - BOOTSTRAP_START))
|
||||
elapsed_sec=$(awk -v ms="$elapsed_ms" 'BEGIN { printf "%.3f", ms/1000 }')
|
||||
log "Bootstrap complete in ${elapsed_sec}s"
|
||||
log "Kraiken: $KRAIKEN"
|
||||
log "Stake: $STAKE"
|
||||
log "LiquidityManager: $LIQUIDITY_MANAGER"
|
||||
log "txnBot: $TXNBOT_ADDRESS"
|
||||
wait $prime_pid
|
||||
log "Block mining complete"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue