Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions crates/blockchain/blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -602,12 +602,15 @@ impl Blockchain {
let (storage_trie, storage_updates_map) = storage_updates_map
.entry(hashed_address_h256)
.or_insert_with(|| {
(
storage.open_storage_trie(
let db = storage
.open_storage_trie(
hashed_address_h256,
account_state.storage_root,
*EMPTY_TRIE_HASH,
parent_header.state_root,
),
)
.map(|v| v.db);
(
db.and_then(|db| Trie::open_noroot(db).map_err(StoreError::Trie)),
Default::default(),
)
});
Expand Down
12 changes: 11 additions & 1 deletion crates/common/trie/trie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub type TrieNode = (Nibbles, NodeRLP);

/// Ethereum-compatible Merkle Patricia Trie
pub struct Trie {
db: Box<dyn TrieDB>,
pub db: Box<dyn TrieDB>,
pub root: NodeRef,
pending_removal: FxHashSet<Nibbles>,
dirty: FxHashSet<Nibbles>,
Expand Down Expand Up @@ -89,6 +89,16 @@ impl Trie {
}
}

pub fn open_noroot(db: Box<dyn TrieDB>) -> Result<Self, TrieError> {
let mut trie = Trie::open(db, *EMPTY_TRIE_HASH);
if let Some(root) = NodeRef::from(NodeHash::from(*EMPTY_TRIE_HASH))
.get_node(trie.db.as_ref(), Nibbles::default())?
{
trie.root = root.into();
}
Ok(trie)
}

/// Return a reference to the internal database.
///
/// Warning: All changes made to the db will bypass the trie and may cause the trie to suddenly
Expand Down
1 change: 1 addition & 0 deletions tooling/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.