Skip to content

Commit

Permalink
perf: do not take ownership of state_requests
Browse files Browse the repository at this point in the history
  • Loading branch information
xJonathanLEI committed Sep 11, 2024
1 parent 2850e25 commit 84e6431
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions crates/executor/client/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl ClientExecutorInput {
///
/// Note: This mutates the input and takes ownership of used storage proofs and block hashes
/// to avoid unnecessary cloning.
pub fn witness_db(&mut self) -> Result<WitnessDb> {
pub fn witness_db(&self) -> Result<WitnessDb> {
let state_root: B256 = self.parent_header().state_root;
if state_root != self.parent_state.state_root() {
eyre::bail!("parent state root mismatch");
Expand All @@ -51,8 +51,7 @@ impl ClientExecutorInput {

let mut accounts = HashMap::new();
let mut storage = HashMap::new();
let state_requests = std::mem::take(&mut self.state_requests);
for (address, slots) in state_requests {
for (&address, slots) in self.state_requests.iter() {
let hashed_address = keccak256(address);
let hashed_address = hashed_address.as_slice();

Expand Down Expand Up @@ -87,7 +86,7 @@ impl ClientExecutorInput {
.get(hashed_address)
.ok_or_else(|| eyre::eyre!("parent state does not contain storage trie"))?;

for slot in slots {
for &slot in slots {
let slot_value = storage_trie
.get_rlp::<U256>(keccak256(slot.to_be_bytes::<32>()).as_slice())?
.unwrap_or_default();
Expand Down

0 comments on commit 84e6431

Please sign in to comment.