Skip to content

feat(ethexe): observer alloy chunked event#5392

Open
grishasobol wants to merge 5 commits intomasterfrom
feat/observer-alloy-chunked-event
Open

feat(ethexe): observer alloy chunked event#5392
grishasobol wants to merge 5 commits intomasterfrom
feat/observer-alloy-chunked-event

Conversation

@grishasobol
Copy link
Copy Markdown
Member

@grishasobol grishasobol commented Apr 29, 2026

Numbers (local Anvil, 5 runs each)

Range Old (custom chunked) New (alloy ChunkedEvent)
1500 blocks avg 131.0 ms avg 120.5 ms (~8% faster)
5000 blocks avg 445.1 ms avg 439.5 ms (~1% faster)

grishasobol and others added 3 commits April 29, 2026 11:37
Replace the hand-rolled 256-block chunking around `eth_getLogs` in
`EthereumBlockLoader::load_many` with `alloy::contract::ChunkedEvent`,
which adds an optimistic full-range query first and a per-block fallback
when an individual chunk fails. Block-header batching is kept and now
runs in parallel with the chunked log query.

Also adds an ignored `bench::bench_load_many` test that times
`load_many` against an in-process Anvil. Local numbers (1500 blocks):
old custom chunked ≈131 ms avg, new alloy ChunkedEvent ≈120 ms avg.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: Gregory Sobol <grishasobol@users.noreply.github.com>
@semanticdiff-com
Copy link
Copy Markdown

semanticdiff-com Bot commented Apr 29, 2026

Review changes with  SemanticDiff

Changed Files
File Status
  ethexe/observer/src/utils.rs  10% smaller
  ethexe/observer/Cargo.toml Unsupported file format

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request updates the observer's block loading logic to utilize alloy's ChunkedEvent utility. By decoupling the retrieval of block headers from log events, the implementation gains better resilience against RPC limitations and improved performance through concurrent log fetching. These changes ensure more reliable data synchronization in the observer component.

Highlights

  • Alloy ChunkedEvent Integration: Integrated alloy's ChunkedEvent to handle log fetching, improving robustness and efficiency when querying large block ranges.
  • Decoupled Block and Log Requests: Refactored EthereumBlockLoader to separate block header batch requests from log fetching, allowing for more granular control over concurrency and batch sizes.
  • Configurable Constants: Introduced new constants for log chunk size and concurrency limits to optimize performance during high-volume data retrieval.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@grishasobol grishasobol self-assigned this Apr 29, 2026
@grishasobol grishasobol added the A0-pleasereview PR is ready to be reviewed by the team label Apr 29, 2026
@StackOverflowExcept1on
Copy link
Copy Markdown
Member

I would like to see how it works with reth node where chunk size can be 100_000 and 5 parallel connections

/// Max number of blocks per `eth_getBlockByNumber` JSON-RPC batch.
const MAX_BLOCK_BATCH_SIZE: usize = 256;
/// Block-window size passed to alloy's [`alloy::contract::ChunkedEvent`] when fetching logs.
const LOGS_CHUNK_SIZE: u64 = 256;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

it can be up to 100k, mb make this configurable

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the Ethereum block and log loading logic in ethexe-observer. It introduces the use of alloy's ChunkedEvent helper for more robust and efficient log fetching, allowing for configurable chunk sizes and concurrency. The load_many function was updated to fetch block headers and logs in parallel, improving performance. Additionally, constants were renamed for clarity, and an empty range check was added. I have no feedback to provide.

@grishasobol
Copy link
Copy Markdown
Member Author

@claude fix review

@claude
Copy link
Copy Markdown

claude Bot commented Apr 30, 2026

Claude finished @grishasobol's task in 1m 53s —— View job


Fixed Review Feedback

  • Gather context and understand the request
  • Read ethexe/observer/src/utils.rs to understand current code
  • Make LOGS_CHUNK_SIZE and LOGS_MAX_CONCURRENCY configurable on EthereumBlockLoader via builder methods
  • Commit and push changes

Changes made (ethexe/observer/src/utils.rs):

Added two builder methods to EthereumBlockLoader so callers can override the defaults (e.g. for reth nodes that support chunks up to 100k):

EthereumBlockLoader::new(provider, router_address)
    .with_logs_chunk_size(100_000)
    .with_logs_max_concurrency(5)

The constants LOGS_CHUNK_SIZE (256) and LOGS_MAX_CONCURRENCY (8) remain as defaults — all existing call sites are unchanged. The request_logs method now reads from self.logs_chunk_size / self.logs_max_concurrency instead of the constants directly.
| Branch

…onfigurable

Add builder methods `with_logs_chunk_size` and `with_logs_max_concurrency` to
`EthereumBlockLoader` so callers (e.g. reth nodes) can override the defaults
for chunk size (up to 100k) and concurrency.

Co-authored-by: Gregory Sobol <grishasobol@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A0-pleasereview PR is ready to be reviewed by the team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants