startup-optimizations (#48)
resolves #34 Co-authored-by: johba <johba@harb.eth> Reviewed-on: https://codeberg.org/johba/harb/pulls/48
This commit is contained in:
parent
3ab2d9454a
commit
3a7162462b
12 changed files with 941 additions and 20 deletions
|
|
@ -197,14 +197,17 @@ main() {
|
|||
grant_recenter_access
|
||||
call_recenter
|
||||
seed_application_state
|
||||
prime_chain
|
||||
write_ponder_env
|
||||
write_txn_bot_env
|
||||
fund_txn_bot_wallet
|
||||
log "Bootstrap complete"
|
||||
prime_chain &
|
||||
local prime_pid=$!
|
||||
log "Bootstrap complete (mining blocks in background)"
|
||||
log "Kraiken: $KRAIKEN"
|
||||
log "Stake: $STAKE"
|
||||
log "LiquidityManager: $LIQUIDITY_MANAGER"
|
||||
wait $prime_pid
|
||||
log "Block mining complete"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
|
|
|||
|
|
@ -12,6 +12,33 @@ done
|
|||
|
||||
cd "$PONDER_WORKDIR"
|
||||
|
||||
# Wait for .env.local to be created by bootstrap
|
||||
while [[ ! -f .env.local ]]; do
|
||||
echo "[ponder-entrypoint] waiting for .env.local"
|
||||
sleep 2
|
||||
done
|
||||
|
||||
# Load contract deployment info
|
||||
source "$CONTRACT_ENV"
|
||||
START_BLOCK=$(grep START_BLOCK .env.local 2>/dev/null | cut -d= -f2 || echo "")
|
||||
EXPECTED_SCHEMA="ponder_local_${START_BLOCK}"
|
||||
|
||||
# Check if schema changed (contract redeployment detected)
|
||||
if [[ -n "$START_BLOCK" ]]; then
|
||||
CURRENT_SCHEMA=$(grep DATABASE_SCHEMA .env.local 2>/dev/null | cut -d= -f2 || echo "")
|
||||
|
||||
if [[ -n "$CURRENT_SCHEMA" && "$CURRENT_SCHEMA" != "$EXPECTED_SCHEMA" ]]; then
|
||||
echo "[ponder-entrypoint] Contract redeployment detected (schema changed: $CURRENT_SCHEMA -> $EXPECTED_SCHEMA)"
|
||||
echo "[ponder-entrypoint] Resetting Ponder database..."
|
||||
|
||||
export PGPASSWORD=ponder_local
|
||||
psql -h postgres -U ponder -d ponder_local -c \
|
||||
"DROP SCHEMA IF EXISTS \"$CURRENT_SCHEMA\" CASCADE;" 2>/dev/null || true
|
||||
|
||||
echo "[ponder-entrypoint] Old schema dropped successfully"
|
||||
fi
|
||||
fi
|
||||
|
||||
REQUIRED_DIST="$ROOT_DIR/kraiken-lib/dist/index.js"
|
||||
if [[ ! -f "$REQUIRED_DIST" ]]; then
|
||||
echo "[ponder-entrypoint] ERROR: Run ./scripts/build-kraiken-lib.sh before starting containers" >&2
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue