Draft
Conversation
There was a problem hiding this comment.
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.
6428f1b to
c83dcb3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This function can be used to create getCheckpointsRange function for provider with out-of-the-box cache.