-
Notifications
You must be signed in to change notification settings - Fork 194
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
feat(katana): getStorageProof
endpoint
#2809
Merged
Merged
+2,130
−781
Conversation
This file contains 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
27f3193
to
03c3cfa
Compare
kariy
added a commit
that referenced
this pull request
Dec 25, 2024
This was referenced Dec 25, 2024
kariy
added a commit
that referenced
this pull request
Dec 31, 2024
Merged
kariy
added a commit
that referenced
this pull request
Dec 31, 2024
This was referenced Jan 2, 2025
This was referenced Jan 10, 2025
This was referenced Jan 18, 2025
Merged
This was referenced Jan 27, 2025
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 PR introduces a new endpoint,
starknet_getStorageProof
for querying state proofs, including for historical states.We are already computing all the state tries (ie classes, contracts, and storages) in #2609, but we don't store the historical trie nodes. Therefore, it's only possible to get the latest state proofs. To support historical tries requires, there are at least two approaches I have could thought of; (1) storing the entire trie including historical trie nodes, or (2) recomputing the trie at runtime.
Approach (2) may possibly be the simplest considering we already have historical states and fetching them is pretty easy with the provider abstractions. We also don't need to create new tables for storing the historical nodes. But computing the trie is a very expensive operation, and depending on the block for which we want to recompute the trie, if the state update is very large, it might consume a lot of resources (iterating over db entries to fetch all historical states, and then computing the trie itself).
We also have to take into account the primary consumer for this new endpoint, which is
saya
. It'll be primarily used to fetch the state proofs required to runSNOS
for generating the proof of a block for settlement. It is understood very well thatsaya
's proof generations will inevitably lag behindkatana
in block productions. So,saya
could be askingkatana
for the state proofs of block 5 whilekatana
is already producing block 10. To prevent overloadingkatana
runtime performance (possibly impacting its perceived performance when executing transactions), we have opted for approach (1).We introduced 6 new tables;
ClassesTrieHistory
,ContractsTrieHistory
,StoragesTrieHistory
, for storing the trie node at a particular block, andClassesTrieChangeSet
,ContractsTrieChangeSet
,StoragesTrieChangeSet
for indexing the list of blocks where a trie node has changed. These tables serve similar purposes to the already existing tables that are also suffixed by*History
and*ChangeSet
. This mean for each node that exist in a trie, we require 2 more entries stored in the aforementioned tables respectively.We don't yet implement any pruning mechanism. This shall be implemented in the future.
The
getStorageProof
endpoint is also part of the RPC 0.8.0 spec. But we don't bump the RPC version as this PR doesn't include the other changes as defined in the new specification.