Skip to content

Conversation

@goran-ethernal
Copy link
Contributor

🔄 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

Copy link
Contributor

Copilot AI left a 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 ParseMaxRangeFromError function to detect and parse "block range too large" errors
  • Implemented a generic ChunkedRangeQuery function that handles automatic request chunking
  • Integrated chunking logic into l2gersync and bridgesync packages 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

Copy link
Contributor

@Stefan-Ethernal Stefan-Ethernal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯 Nice

@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 10, 2025

@goran-ethernal goran-ethernal merged commit 2e941bc into release/0.8 Dec 10, 2025
36 of 37 checks passed
@goran-ethernal goran-ethernal deleted the fix/block-range-too-large branch December 10, 2025 13:38
goran-ethernal added a commit that referenced this pull request Dec 10, 2025
## 🔄 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>
joanestebanr added a commit that referenced this pull request Dec 17, 2025
## 🔄 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>
joanestebanr added a commit that referenced this pull request Dec 17, 2025
## 🔄 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>
joanestebanr added a commit that referenced this pull request Dec 18, 2025
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants