Skip to content

Conversation

Sekhmet
Copy link
Member

@Sekhmet Sekhmet commented Mar 20, 2025

This function can be used to create getCheckpointsRange function for provider with out-of-the-box cache.

@Sekhmet Sekhmet requested a review from Copilot March 20, 2025 18:18
Copy link

@Copilot 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 new caching mechanism for checkpoint queries by adding the createGetCheckpointsRange function, which is integrated into both EVM and Starknet providers. Key changes include:

  • Implementation of createGetCheckpointsRange in a new file to cache checkpoint records across block ranges.
  • Integration of the new function into EVM and Starknet providers, replacing the previous manual implementations.
  • Addition of unit tests to validate the caching behavior and correctness of createGetCheckpointsRange.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
test/unit/providers/core/createGetCheckpointsRange.ts New tests validating query calls and caching scenarios.
src/providers/core/createGetCheckpointsRange.ts New function implementation that wraps checkpoint queries with caching.
src/providers/index.ts Exports the new createGetCheckpointsRange for external use.
src/providers/starknet/provider.ts Integrates the caching function, though contains a recursive querySourceFn call.
src/providers/evm/provider.ts Replaces prior getCheckpointsRange implementation with usage of createGetCheckpointsRange.
Comments suppressed due to low confidence (2)

src/providers/core/createGetCheckpointsRange.ts:66

  • [nitpick] The inner variable 'events' shadows the outer 'events' variable. Consider renaming it to 'queriedEvents' to avoid potential confusion.
const events = await options.querySourceFn(fromBlock, toBlock, source);

src/providers/starknet/provider.ts:47

  • This querySourceFn implementation calls getCheckpointsRangeForAddress recursively, which may lead to infinite recursion. Consider invoking a dedicated non-recursive function to fetch the events.
querySourceFn: async (fromBlock, toBlock, source) => this.getCheckpointsRangeForAddress(fromBlock, toBlock, source.contract, source.events.map(event => event.name))

This function can be used to create getCheckpointsRange function
for provider with out-of-the-box cache.
@Sekhmet Sekhmet force-pushed the sekhmet/checkpoints-query branch from 6428f1b to c83dcb3 Compare March 21, 2025 09:13
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