Skip to content

fix: halve chunk size when suggested get_logs range still exceeds max results#24

Merged
emmajam merged 1 commit intomainfrom
fix/get-logs-pagination-halving
Feb 17, 2026
Merged

fix: halve chunk size when suggested get_logs range still exceeds max results#24
emmajam merged 1 commit intomainfrom
fix/get-logs-pagination-halving

Conversation

@emmajam
Copy link
Member

@emmajam emmajam commented Feb 17, 2026

Problem

The get_logs_with_retry pagination logic fails when the server's suggested retry range itself exceeds the max results limit.

For example, with ~889 logs/block, the server suggests retrying with a 26-block range (~23k logs), but the 20k limit means that range also fails. On the recursive retry, the code detects that chunk_size >= original_len and gives up entirely, surfacing the error to the test runner.

This caused RPC test failures like:

get_logs: ❌ rpc1: ErrorResp(ErrorPayload { code: -32602, message: "query exceeds max results 20000, retry with the range 24476391-24476416", data: None })

Fix

Instead of giving up when the suggested chunk covers the entire (sub-)range, halve the chunk size and retry. This lets the pagination converge to a working chunk size regardless of how accurate the server's suggestion is.

Example

  • Original range: blocks 24476391..=24476422 (32 blocks)
  • Server suggests: retry with 24476391-24476416 (26 blocks) — still >20k logs
  • Before: gives up ❌
  • After: halves to 13 blocks (~11.5k logs), succeeds ✅

… results

When the server's suggested retry range itself exceeds the max results
limit (e.g., ~889 logs/block × 26 blocks > 20k limit), the pagination
logic would give up instead of splitting further. Now it halves the
chunk size and retries, allowing the pagination to converge.

Amp-Thread-ID: https://ampcode.com/threads/T-019c6c52-d0c7-7508-8a37-b5cacce32bde
Co-authored-by: Amp <[email protected]>
@emmajam emmajam merged commit 1814350 into main Feb 17, 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.

1 participant