dojoengine / dojo

Dojo is a toolchain for building provable games and autonomous worlds with Cairo
https://dojoengine.org
Apache License 2.0
388 stars 147 forks source link

Dedup fork requests #1465

Open kariy opened 5 months ago

kariy commented 5 months ago

When running katana in forking mode, there's a potential inefficiency that occurs when the forked backend processes identical requests simultaneously. This leads to unnecessary duplication in data fetching, as the same data is retrieved multiple times. To optimize this, we should implement a mechanism to deduplicate incoming requests, allowing the reuse of data from the first identical request.

Example scenario for context:

Consider a situation where a specific storage slot is not present in the local storage. katana then attempts to fetch it from the forked network. If, while this request is still processing, another request for the same storage slot is made, katana will again try to fetch from the forked provider. As a result, two identical requests are sent to the forked network, which is inefficient.

Proposed solution:

Implement a request deduplication process. When a request is made, katana should first check if an identical request is already in progress. If so, it should wait for the initial request to complete and then use that data, rather than initiating a new request to the forked network.

We can use the requests params (eg. contract address, storage key) as the request id, and perform the dedup process on an incoming request that has identical id.

rkdud007 commented 5 months ago

can i take this?

kariy commented 5 months ago

Assigned. Let me know if you have questions or need more context on this issue.

btirth commented 2 months ago

@rkdud007: If you haven't started working on this, can I take this one?

FYI: @kariy

rkdud007 commented 2 months ago

Hey, sure you can pick up this issue 😄

glihm commented 2 months ago

@rkdud007: If you haven't started working on this, can I take this one?

FYI: @kariy

@tirth1 if you're ok with tackling this and #1409 just assigned to you, let's do it! Let us know if we should also assign this one to you. 👍

cwkang1998 commented 2 months ago

Interested in taking this if it's not being worked on

kariy commented 2 months ago

@btirth im gonna be assigning this to @cwkang1998 considering you already have an issue assigned to you.