feat: create world state trie from engine DB#399
Merged
Conversation
…te_world_state_trie
mpaulucci
reviewed
Sep 16, 2024
| } | ||
| } | ||
|
|
||
| fn world_state(&self, block_number: BlockNumber) -> Result<Option<Trie>, StoreError> { |
Collaborator
There was a problem hiding this comment.
I would rename to state_trie. I haven't seen references to "world" in other client implementations, just state
Contributor
Author
There was a problem hiding this comment.
It is referred to as World State in the yellow paper, but I agree, we can just name it state trie
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.
Motivation
Being able to create a
Triestruct representing the world state based on the engine's internal value store (reading from a specific table in the case of libmdbx or map in the case of in_memory). The created trie would also use the given block's state root as its root in order to query historical data build new blocks based on the previous block's state, and easily process re-orgsDescription
Added features:
world_statemethod toStoreEngineapi, which builds aTriefrom a block number and the engine's internal database (or value store)Code refactors:
DBgeneric fromTrieand instead storeBox<dyn TrieDB>(This is because the generic wouldn't allow us to return a single genericTrie<DB>from differentStoreEngineimplementations)Arc<Database>instead of&'a Databasein libmdbx impl ofTrieDB(This is so we can box it)Arc<Database>instead ofDatabaseinengine::libmdbx::Store(Complies with above change)Misc:
Trie::new_temptest-feature gated method to simplify trie creation in testsCloses None, but is needed for #391