Skip to content

Commit 3e3f332

Browse files
authored
fix(trie): take earliest value in HashedStorage::from_reverts (#10475)
1 parent accd051 commit 3e3f332

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

crates/trie/db/src/storage.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::collections::hash_map;
2+
13
use crate::{DatabaseHashedCursorFactory, DatabaseTrieCursorFactory};
24
use reth_db::{cursor::DbCursorRO, models::BlockNumberAddress, tables, DatabaseError};
35
use reth_db_api::transaction::DbTx;
@@ -84,7 +86,9 @@ impl<TX: DbTx> DatabaseHashedStorage<TX> for HashedStorage {
8486
let (BlockNumberAddress((_, storage_address)), storage_change) = entry?;
8587
if storage_address == address {
8688
let hashed_slot = keccak256(storage_change.key);
87-
storage.storage.insert(hashed_slot, storage_change.value);
89+
if let hash_map::Entry::Vacant(entry) = storage.storage.entry(hashed_slot) {
90+
entry.insert(storage_change.value);
91+
}
8892
}
8993
}
9094
Ok(storage)

0 commit comments

Comments
 (0)