fix: add polling timeouts and safe fallback in recovery script (#644)
- Add max-iterations guard (60 polls × 5s = 5 min) to both cooldown polling loops with explicit error on timeout - Use LAST_RECENTER (already validated) as fallback instead of "0" for post-seed-buy lastRecenterTime read, preventing silent cooldown skip on transient RPC failure Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
8cfbf74e89
commit
20f5ac68cd
1 changed files with 17 additions and 3 deletions
|
|
@ -139,8 +139,15 @@ if [[ "$NOW" -lt "$COOLDOWN_END" ]]; then
|
||||||
if [[ "$DRY_RUN" == "true" ]]; then
|
if [[ "$DRY_RUN" == "true" ]]; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
info "Polling for recenter cooldown to elapse ..."
|
info "Polling for recenter cooldown to elapse (timeout: 5 min) ..."
|
||||||
|
POLL_ATTEMPTS=0
|
||||||
|
MAX_POLL_ATTEMPTS=60 # 60 × 5s = 5 min
|
||||||
while true; do
|
while true; do
|
||||||
|
POLL_ATTEMPTS=$(( POLL_ATTEMPTS + 1 ))
|
||||||
|
if [[ "$POLL_ATTEMPTS" -gt "$MAX_POLL_ATTEMPTS" ]]; then
|
||||||
|
error "Timed out waiting for recenter cooldown (${MAX_POLL_ATTEMPTS} polls). RPC may be degraded."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
NOW="$(cast block latest --rpc-url "$RPC_URL" --field timestamp 2>/dev/null || echo "0")"
|
NOW="$(cast block latest --rpc-url "$RPC_URL" --field timestamp 2>/dev/null || echo "0")"
|
||||||
if [[ "$NOW" -ge "$COOLDOWN_END" ]]; then
|
if [[ "$NOW" -ge "$COOLDOWN_END" ]]; then
|
||||||
info "Recenter cooldown elapsed."
|
info "Recenter cooldown elapsed."
|
||||||
|
|
@ -183,10 +190,17 @@ if [[ -n "$SEED_ETH" && -n "$KRAIKEN" ]]; then
|
||||||
info "Seed buy complete."
|
info "Seed buy complete."
|
||||||
|
|
||||||
# Poll until recenter cooldown elapses
|
# Poll until recenter cooldown elapses
|
||||||
info "Polling for recenter cooldown to elapse ..."
|
info "Polling for recenter cooldown to elapse (timeout: 5 min) ..."
|
||||||
LAST_RECENTER_AFTER="$(cast call --rpc-url "$RPC_URL" "$LM_ADDRESS" "lastRecenterTime()(uint256)" 2>/dev/null || echo "0")"
|
LAST_RECENTER_AFTER="$(cast call --rpc-url "$RPC_URL" "$LM_ADDRESS" "lastRecenterTime()(uint256)" 2>/dev/null || echo "$LAST_RECENTER")"
|
||||||
COOLDOWN_TARGET=$(( LAST_RECENTER_AFTER + 60 ))
|
COOLDOWN_TARGET=$(( LAST_RECENTER_AFTER + 60 ))
|
||||||
|
POLL_ATTEMPTS=0
|
||||||
|
MAX_POLL_ATTEMPTS=60 # 60 × 5s = 5 min
|
||||||
while true; do
|
while true; do
|
||||||
|
POLL_ATTEMPTS=$(( POLL_ATTEMPTS + 1 ))
|
||||||
|
if [[ "$POLL_ATTEMPTS" -gt "$MAX_POLL_ATTEMPTS" ]]; then
|
||||||
|
error "Timed out waiting for recenter cooldown (${MAX_POLL_ATTEMPTS} polls). RPC may be degraded."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
NOW="$(cast block latest --rpc-url "$RPC_URL" --field timestamp 2>/dev/null || echo "0")"
|
NOW="$(cast block latest --rpc-url "$RPC_URL" --field timestamp 2>/dev/null || echo "0")"
|
||||||
if [[ "$NOW" -ge "$COOLDOWN_TARGET" ]]; then
|
if [[ "$NOW" -ge "$COOLDOWN_TARGET" ]]; then
|
||||||
info "Recenter cooldown elapsed."
|
info "Recenter cooldown elapsed."
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue