-
Notifications
You must be signed in to change notification settings - Fork 19
fix: handle block range too large rpc error, and do chunk calls #1387
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces a robust generic solution for handling "block range too large" RPC errors that occur when querying blockchain events over large block ranges. The implementation automatically detects such errors, extracts the maximum allowed range from the error message, and transparently chunks the request into smaller queries.
Key Changes:
- Added
ParseMaxRangeFromErrorfunction to detect and parse "block range too large" errors - Implemented a generic
ChunkedRangeQueryfunction that handles automatic request chunking - Integrated chunking logic into
l2gersyncandbridgesyncpackages for GER and bridge event queries
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| common/errors.go | New error parsing utility to extract max range from RPC errors |
| common/errors_test.go | Comprehensive tests for error parsing including edge cases and wrapped errors |
| common/block_range.go | Generic chunking implementation using Go generics to support different return types |
| common/block_range_test.go | Tests for chunking logic covering various scenarios (empty ranges, errors, single blocks) |
| l2gersync/l2_evm_ger_reader.go | Integration of chunking for injected and removed GER queries with new fetch helper methods |
| l2gersync/l2_evm_ger_reader_test.go | Tests verifying chunking behavior for GER queries with proper mock expectations |
| bridgesync/agglayer_bridge_l2_reader.go | Integration of chunking for unset claims queries with new fetch helper method |
| bridgesync/agglayer_bridge_l2_reader_test.go | Tests verifying chunking behavior for bridge queries including error scenarios |
Stefan-Ethernal
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯 Nice
|
## 🔄 Changes Summary This PR addresses the issue that happened on one of the testnets, which reported `block range too large` error when reading a contract for specific logs in a block range. The PR adds a generic way to recognize the given error when reading contracts and does a chunk calls to get all the data to avoid the error. ##⚠️ Breaking Changes NA ## 📋 Config Updates NA ## ✅ Testing - 🤖 **Automatic**: `aggkit` CI ## 🐞 Issues - Closes #1386 --------- Co-authored-by: Stefan Negovanović <stefan@ethernal.tech>
## 🔄 Changes Summary - Update parsing function `ParseMaxRangeFromError` to admit a new error: `exceeded maximum block range:` that appears using as RPC *immutable geth* ## ✅ Testing - 🤖 **Automatic**: unittest ## 🐞 Issues - Closes #1412 ## 🔗 Related PRs - #1387 --------- Co-authored-by: Thiago Nobayashi <tnobayashi@polygon.technology>
## 🔄 Changes Summary - Update parsing function `ParseMaxRangeFromError` to admit a new error: `exceeded maximum block range:` that appears using as RPC *immutable geth* ## ✅ Testing - 🤖 **Automatic**: unittest ## 🐞 Issues - Closes #1412 ## 🔗 Related PRs - #1387 --------- Co-authored-by: Thiago Nobayashi <tnobayashi@polygon.technology>
…ock range:) (#1413) (#1414) cherry-pick from `develop`: #1413, #1393 ## 🔄 Changes Summary - Update parsing function `ParseMaxRangeFromError` to admit a new error: `exceeded maximum block range:` that appears using as RPC *immutable geth* ## ✅ Testing - 🤖 **Automatic**: unittest ## 🐞 Issues - Closes #1412 ## 🔗 Related PRs - #1387 --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Thiago Nobayashi <tnobayashi@polygon.technology> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Rachit Sonthalia <54906134+rachit77@users.noreply.github.com>

🔄 Changes Summary
This PR addresses the issue that happened on one of the testnets, which reported
block range too largeerror when reading a contract for specific logs in a block range.The PR adds a generic way to recognize the given error when reading contracts and does a chunk calls to get all the data to avoid the error.
NA
📋 Config Updates
NA
✅ Testing
aggkitCI🐞 Issues