Skip to content
This repository was archived by the owner on Jan 16, 2026. It is now read-only.
Merged
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
2 changes: 2 additions & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions crates/mpt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ alloy-transport-http = { version = "0.1" }
reqwest = "0.12.4"
tracing-subscriber = "0.3.18"
futures = { version = "0.3.30", default-features = false }
proptest = "1.4"
rand = "0.8.5"
26 changes: 14 additions & 12 deletions crates/mpt/src/db/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use alloy_rlp::{Decodable, Encodable};
use alloy_trie::Nibbles;
use anyhow::{anyhow, Result};
use revm::{
db::BundleState,
db::{states::StorageSlot, BundleState},
primitives::{AccountInfo, Bytecode, HashMap, BLOCK_HASH_HISTORY},
Database,
};
Expand Down Expand Up @@ -222,6 +222,10 @@ where
/// - `Err(_)` if the accounts could not be updated.
fn update_accounts(&mut self, bundle: &BundleState) -> Result<()> {
for (address, bundle_account) in bundle.state() {
if bundle_account.status.is_not_modified() {
continue;
}

// Compute the path to the account in the trie.
let account_path = Nibbles::unpack(keccak256(address.as_slice()));

Expand All @@ -247,13 +251,7 @@ where
.entry(*address)
.or_insert_with(|| TrieNode::new_blinded(EMPTY_ROOT_HASH));
bundle_account.storage.iter().try_for_each(|(index, value)| {
Self::change_storage(
acc_storage_root,
*index,
value.present_value,
&self.fetcher,
&self.hinter,
)
Self::change_storage(acc_storage_root, *index, value, &self.fetcher, &self.hinter)
})?;

// Recompute the account storage root.
Expand Down Expand Up @@ -288,17 +286,21 @@ where
fn change_storage(
storage_root: &mut TrieNode,
index: U256,
value: U256,
value: &StorageSlot,
fetcher: &F,
hinter: &H,
) -> Result<()> {
if !value.is_changed() {
return Ok(());
}

// RLP encode the storage slot value.
let mut rlp_buf = Vec::with_capacity(value.length());
value.encode(&mut rlp_buf);
let mut rlp_buf = Vec::with_capacity(value.present_value.length());
value.present_value.encode(&mut rlp_buf);

// Insert or update the storage slot in the trie.
let hashed_slot_key = Nibbles::unpack(keccak256(index.to_be_bytes::<32>().as_slice()));
if value.is_zero() {
if value.present_value.is_zero() {
// If the storage slot is being set to zero, prune it from the trie.
storage_root.delete(&hashed_slot_key, fetcher, hinter)?;
} else {
Expand Down
Loading