Skip to content

[WIP] feat: migrate account state to trie#391

Closed
fmoletta wants to merge 17 commits into
mainfrom
integrate-trie
Closed

[WIP] feat: migrate account state to trie#391
fmoletta wants to merge 17 commits into
mainfrom
integrate-trie

Conversation

@fmoletta

@fmoletta fmoletta commented Sep 12, 2024

Copy link
Copy Markdown
Contributor

STATUS: Working with temporary DBs, working on creating tries from the engine using the DB trait in a separate PR (#399)
Motivation

Description

Closes #issue_number

assert_eq!(
test_state_root,
db.clone().world_state_root(),
db.clone().world_state_root().unwrap(),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we do the unwrap inside the world_state_root function?

github-merge-queue Bot pushed a commit that referenced this pull request Sep 16, 2024
**Motivation**

Being able to create a `Trie` struct 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-orgs

<!-- Why does this pull request exist? What are its goals? -->

**Description**
Added features:
* Add `world_state` method to `StoreEngine` api, which builds a `Trie`
from a block number and the engine's internal database (or value store)

Code refactors:
* Remove `DB` generic from `Trie` and instead store `Box<dyn TrieDB>`
(This is because the generic wouldn't allow us to return a single
generic `Trie<DB>` from different `StoreEngine` implementations)
* Store `Arc<Database>` instead of `&'a Database` in libmdbx impl of
`TrieDB` (This is so we can box it)
* Store `Arc<Database>` instead of `Database` in
`engine::libmdbx::Store` (Complies with above change)

Misc:

* Add `Trie::new_temp` test-feature gated method to simplify trie
creation in tests

<!-- A clear and concise general description of the changes this PR
introduces -->

<!-- Link to issues: Resolves #111, Resolves #222 -->

Closes None, but is needed for #391

---------

Co-authored-by: Tomás Arjovsky <t.arjovsky@gmail.com>
@fmoletta

Copy link
Copy Markdown
Contributor Author

Replaced by #407

@fmoletta fmoletta closed this Sep 17, 2024
@ilitteri ilitteri deleted the integrate-trie branch December 2, 2024 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants