Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fork provider for non-state data #1466

Open
kariy opened this issue Jan 20, 2024 · 8 comments · May be fixed by #1700
Open

Add fork provider for non-state data #1466

kariy opened this issue Jan 20, 2024 · 8 comments · May be fixed by #1700
Assignees
Labels
enhancement New feature or request external-contributor help wanted Extra attention is needed katana This issue is related to Katana

Comments

@kariy
Copy link
Member

kariy commented Jan 20, 2024

Currently katana only provides forked data for state-related info (eg storage, nonce, class hash) thru the SharedStateProvider. We should extend the forking functionality to also allow fetching non-state data as well (eg block, events, tx) from the forked network.

We can extend the Backend to handle more request types.

Proposed solution

We can mimic ForkedStateDb where it uses SharedStateProvider as the underlying db for CacheStateDb by creating similar forked provider type specifically for the CacheDb instead, that handles non-state data (ie block, tx). Unlike SharedStateProvider, we don't have to implement the provider traits as most of the traits are mainly for abstracting over the db layout. We only need to fetch data that can only be fetched from the RPC. So, that means we only need to implement fork handlers for data that can only be obtain from the Katana RPC.

Regarding caching (ie storing the fetch forked data into local storage), ideally we can store the fetched data directly into the main storage, but how the storage is laid out at the moment isn't very friendly to unordered insertion like this case. Maybe we can have the forked provider type to include a storage to store the data fetched from the forked RPC.

@kariy kariy added enhancement New feature or request help wanted Extra attention is needed katana This issue is related to Katana labels Jan 20, 2024
@fishseabowl
Copy link
Contributor

@kariy can I take this? Thanks

@kariy
Copy link
Member Author

kariy commented Feb 8, 2024

Assigned! Let me know if you have any questions or require more context on the issue.

@kariy
Copy link
Member Author

kariy commented Feb 8, 2024

@fishseabowl I've updated the issue description for more context. Thanks for the contribution 🙂

@kariy
Copy link
Member Author

kariy commented Feb 18, 2024

Hey @fishseabowl. Any updates on this? Let me know if there's something blocking you.

@fishseabowl
Copy link
Contributor

@kariy Thank you. I'm currently handling this. If I have any questions, I'll message you.

@fishseabowl
Copy link
Contributor

@kariy Do you know where is a code example using the starknet-provider API, e.g. if I call API get_events, what are the parameters filter and chunk_size? Thanks

/// Returns all events matching the given filter
    async fn get_events(
        &self,
        filter: EventFilter,
        continuation_token: Option<String>,
        chunk_size: u64,
    ) -> Result<EventsPage, ProviderError>;

@kariy
Copy link
Member Author

kariy commented Feb 29, 2024

@fishseabowl I'm not sure about the example but you can refer to the RPC specs here to know what each of the params are used for.

@tarrencev tarrencev changed the title [Katana] Add fork provider for non-state data [Katana] Add fork provider for non-state data Mar 5, 2024
@glihm
Copy link
Collaborator

glihm commented Mar 7, 2024

@kariy Do you know where is a code example using the starknet-provider API, e.g. if I call API get_events, what are the parameters filter and chunk_size? Thanks

/// Returns all events matching the given filter
    async fn get_events(
        &self,
        filter: EventFilter,
        continuation_token: Option<String>,
        chunk_size: u64,
    ) -> Result<EventsPage, ProviderError>;

Some example of code from starknet-rs @fishseabowl: https://github.com/xJonathanLEI/starknet-rs/blob/400deb6f058447e8b67316a92ecd9ad3b6d4330c/starknet-providers/tests/jsonrpc.rs#L795.

The chunk size is expected to be None where no more data have to be fetched. You can see the fetching as paginated using this continuation token.

@glihm glihm changed the title [Katana] Add fork provider for non-state data Add fork provider for non-state data Jun 19, 2024
@glihm glihm modified the milestone: 1.0.0 Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request external-contributor help wanted Extra attention is needed katana This issue is related to Katana
Projects
Status: In Progress
Development

Successfully merging a pull request may close this issue.

4 participants