diff --git a/src/eth/storage/rocks/rocks_state.rs b/src/eth/storage/rocks/rocks_state.rs index 4c5cb05c9..1d1816137 100644 --- a/src/eth/storage/rocks/rocks_state.rs +++ b/src/eth/storage/rocks/rocks_state.rs @@ -352,22 +352,19 @@ impl RocksStorageState { /// Updates the in-memory state with changes from transaction execution pub fn update_state_with_execution_changes(&self, changes: &[ExecutionAccountChanges], block_number: BlockNumber, batch: &mut WriteBatch) { - // Directly capture the fields needed by each future from `self` let accounts = self.accounts.clone(); let accounts_history = self.accounts_history.clone(); let account_slots = self.account_slots.clone(); let account_slots_history = self.account_slots_history.clone(); - let changes_clone_for_accounts = changes.to_vec(); // Clone changes for accounts future - let changes_clone_for_slots = changes.to_vec(); // Clone changes for slots future - let mut account_changes = Vec::new(); let mut account_history_changes = Vec::new(); - for change in changes_clone_for_accounts { + for change in changes { if change.is_changed() { let address: AddressRocksdb = change.address.into(); let mut account_info_entry = accounts.entry_or_insert_with(address, AccountRocksdb::default); + if let Some(nonce) = change.nonce.clone().take_modified() { account_info_entry.nonce = nonce.into(); } @@ -389,10 +386,11 @@ impl RocksStorageState { let mut slot_changes = Vec::new(); let mut slot_history_changes = Vec::new(); - for change in changes_clone_for_slots { - let address: AddressRocksdb = change.address.into(); - for (slot_index, slot_change) in change.slots.clone() { - if let Some(slot) = slot_change.take_modified() { + for change in changes { + for (slot_index, slot_change) in &change.slots { + if let Some(slot) = slot_change.take_modified_ref() { + let address: AddressRocksdb = change.address.into(); + let slot_index = *slot_index; slot_changes.push(((address, slot_index.into()), slot.value.into())); slot_history_changes.push(((address, slot_index.into(), block_number.into()), slot.value.into())); }