Skip to content

Speed up getting last event#669

Merged
evgeny-stakewise merged 1 commit intomasterfrom
speedup-lasst-event
Feb 25, 2026
Merged

Speed up getting last event#669
evgeny-stakewise merged 1 commit intomasterfrom
speedup-lasst-event

Conversation

@evgeny-stakewise
Copy link
Contributor

No description provided.

Copilot AI review requested due to automatic review settings February 25, 2026 18:41
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 optimizes the _get_last_event method in the ContractWrapper class by introducing concurrent batch processing of block ranges. The optimization changes from a sequential scan through block ranges to a concurrent batch-based approach that can fetch multiple chunks in parallel, significantly speeding up the operation when events are sparse or located in older blocks.

Changes:

  • Added itertools import to support batch processing
  • Refactored _get_last_event to build all chunk ranges upfront and process them in concurrent batches
  • Introduced a nested fetch_chunk async function to encapsulate the event fetching logic

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@evgeny-stakewise evgeny-stakewise merged commit 568c9c0 into master Feb 25, 2026
12 checks passed
@evgeny-stakewise evgeny-stakewise deleted the speedup-lasst-event branch February 25, 2026 19:29
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.

3 participants