Skip to content

fix(get_logs): paginate through full block range on max results exceeded#21

Merged
emmajam merged 2 commits intomainfrom
emma/fix-get-logs-pagination
Feb 11, 2026
Merged

fix(get_logs): paginate through full block range on max results exceeded#21
emmajam merged 2 commits intomainfrom
emma/fix-get-logs-pagination

Conversation

@gakonst
Copy link
Copy Markdown
Contributor

@gakonst gakonst commented Feb 11, 2026

Summary

Fixes the rpc-tester failing every nightly run due to get_logs exceeding the 20K result limit.

Motivation

The rpc-tester has been failing on every single nightly run — including when re-execute succeeds. The failure is always the same:

24432145..=24432176 ❌
    get_logs: ❌ rpc1: ErrorResp(ErrorPayload { code: -32602, message: "query exceeds max results 20000, retry with the range 24432145-24432171", data: None })

All per-block tests pass (32/32 ✅). The failure is only in test_block_range's unfiltered get_logs across 32 blocks, which produces >20K logs on mainnet.

The previous get_logs_with_retry had two bugs:

  1. It only retried once with the suggested narrower range — which could also exceed the limit
  2. In the comparison context (test_rpc_call), the retry only narrowed one provider's range while the other returned the full range, making comparison invalid

Changes

  • Replaced single-retry with recursive pagination in get_logs_with_retry (crates/rpc-tester/src/get_logs.rs)
  • Parses the RPC's suggested range to determine chunk size, splits the original range into chunks, and recursively fetches each chunk
  • Adds overflow protection, non-progress guards, and range validation
  • Both providers now independently paginate to return complete results for the full range

Testing

cargo clippy --workspace --all-targets -- -D warnings  # clean
cargo test -p rpc-tester                                # 5/5 pass

Thread: https://tempoxyz.slack.com/archives/C0A87C21805/p1770821518221609

gakonst and others added 2 commits February 11, 2026 15:48
Previously, get_logs_with_retry only retried once with the narrower range
suggested by the RPC error. This had two problems:

1. The retry range could still exceed the max results limit (no recursive retry)
2. In the comparison context, only one provider would use the narrowed range
   while the other returned the full range, making comparison meaningless

This caused every nightly rpc-tester run to fail on the unfiltered get_logs
call in test_block_range, even when all per-block tests passed.

The fix replaces the single retry with recursive pagination:
- Parse the suggested range to determine chunk size
- Split the original block range into chunks of that size
- Recursively fetch each chunk (handles nested max-results errors)
- Collect all results across the full range

Also adds overflow protection, non-progress guards, and range validation.

Amp-Thread-ID: https://ampcode.com/threads/T-019c4d30-13af-7466-a358-0c135dbebaf2
Co-authored-by: Amp <amp@ampcode.com>
@emmajam emmajam merged commit d79378b into main Feb 11, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants