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

[Katana] Reconstruction of historical block context (ie execution context) #1347

Closed
1 task done
kariy opened this issue Jan 2, 2024 · 0 comments
Closed
1 task done
Assignees
Labels
bug Something isn't working katana This issue is related to Katana

Comments

@kariy
Copy link
Member

kariy commented Jan 2, 2024

Issue

The block context in Katana is handled very naively atm. It doesn't allow for the recreation of historical block context, which is crucial for when you need to perform a contract execution against a historical block. This means some of the RPC apis that allow that (eg starknet_call) are being handled incorrectly.

Currently, this block context is shared across the whole system. Whenever an RPC api need to construct a block context for a tx execution, it would fetch it from there and every time a new block is created that block context is also updated. Thus every read for the block context will always result in the latest/current value. Because we don't store the historical block context, we are unable to reconstruct it. (technically you could reconstruct it from the historical block header)

Proposed solution

The env field should be removed entirely from the Backend struct. I already have defined a rough provider trait for fetching the block env for a desired block. As mentioned earlier, block env can be constructed from the block header. Which means there's no need to introduce a new field/db table in the provider impls to store these data as we are already storing the block header.

Whenever some functions require a block context of a historical block, it can retrieve it from the provider implementation that is used by Katana.

Tasks

@kariy kariy changed the title Reconstruction of historical block context [Katana] Reconstruction of historical block context (ie execution context) Jan 2, 2024
@kariy kariy added katana This issue is related to Katana bug Something isn't working labels Jan 2, 2024
@kariy kariy self-assigned this Jan 2, 2024
@kariy kariy closed this as completed in 3287ffa Jan 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working katana This issue is related to Katana
Projects
Status: Done
Development

No branches or pull requests

1 participant