Repository navigation
fix(automation): retry and narrow the v4 rebalance Rebalanced log search - #3039
Merged
Merged
Conversation
ousdUsdeV4Rebalance failed 14/687 runs in 24h on currentTokenId's eth_getLogs (dRPC: temporary internal error, 10000-block range limit, lagging upstream). Move the backwards search into tasks/lib/logs.ts: chunks capped at 9999 blocks, the newest 5 blocks queried on their own, 3 attempts with backoff on transient errors, and a range-limit error halves the chunk. ousdSusdeV4Rebalance shares the same lookup. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
shahthepro
approved these changes
Oct 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
ousdUsdeV4Rebalance(every 2 min,--network mainnet --cap-bps 1) failed 14 of 687 runs in 24h (~2%), all incurrentTokenId():module.queryFilter(Rebalanced(poolId))over 50,000-block chunks, no retry. The RPC is the dRPC load balancer, which routes each call to one of several upstreams:Temporary internal error. Please retry(HTTP 500, JSON-RPC code 19)query block range exceeds server limit, narrow your filter: 10000(-32602)block range extends beyond current head block(lagging upstream)A failed run sends nothing and the next one succeeds, but each failure fires a Talos alert.
What changed
New
tasks/lib/logs.ts→findLatestLog()(no retry / chunked-getLogs helper existed intasks/lib/), used by bothousdUsdeV4RebalanceandousdSusdeV4Rebalance(same lookup):to - from + 1 <= 10000).--log-chunkdefault is now9999and any larger value is capped.Rebalancedthere is our own run from 2 min ago, and missing it would read the burned position (the run would then fail onownerOf).SERVER_ERROR, "Temporary internal error", "beyond current head", timeouts). Non-transient errors (e.g. revert) throw immediately.toinstead of failing.warn;docs/ACTIONS.mddocuments--lookback-blocks/--log-chunkfor both actions.Tests
tasks/test/logs.js(8 cases): the three dRPC errors are classified; every query ≤ 10,000 blocks and contiguous down to the floor; event in the head range is found; retry then success (backoff 100/200); range-limit halves 9999 → 4999 → 2499 → 1249; throws after retries are exhausted; no retry on a non-transient error.pnpm test:tasks: 157 passingpnpm prettier:ts,eslinton touched files: cleanMainnet dry run
ousdSusdeV4Rebalance --dryrunalso finds its event ~39.5k blocks back (several 9,999-block chunks):Latest Rebalanced at block 26200340: minted 463219. (Its simulation then reportsContract with a Signer cannot override fromwith a non-operator throwaway signer — untouched by this PR.)🤖 Generated with Claude Code