diff --git a/src/eth/primitives/execution_account_changes.rs b/src/eth/primitives/execution_account_changes.rs index 1551dbabc..936d902f8 100644 --- a/src/eth/primitives/execution_account_changes.rs +++ b/src/eth/primitives/execution_account_changes.rs @@ -113,4 +113,9 @@ impl ExecutionAccountChanges { pub fn is_account_update(&self) -> bool { not(self.new_account) } + + /// Checks if the Nonce, Balance or Bytecode are modified + pub fn is_account_change(&self) -> bool { + self.nonce.is_modified() || self.balance.is_modified() || self.bytecode.is_modified() + } } diff --git a/src/eth/storage/rocks/rocks_state.rs b/src/eth/storage/rocks/rocks_state.rs index 69e6179bf..a8041b832 100644 --- a/src/eth/storage/rocks/rocks_state.rs +++ b/src/eth/storage/rocks/rocks_state.rs @@ -398,20 +398,22 @@ impl RocksStorageState { let account_changes_future = tokio::task::spawn_blocking(move || { for change in changes_clone_for_accounts { - 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(); - } - if let Some(balance) = change.balance.clone().take_modified() { - account_info_entry.balance = balance.into(); - } - if let Some(bytecode) = change.bytecode.clone().take_modified() { - account_info_entry.bytecode = bytecode.map_into(); - } + if change.is_account_change() { + 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(); + } + if let Some(balance) = change.balance.clone().take_modified() { + account_info_entry.balance = balance.into(); + } + if let Some(bytecode) = change.bytecode.clone().take_modified() { + account_info_entry.bytecode = bytecode.map_into(); + } - account_changes.push((address, account_info_entry.clone())); - account_history_changes.push(((address, block_number.into()), account_info_entry)); + account_changes.push((address, account_info_entry.clone())); + account_history_changes.push(((address, block_number.into()), account_info_entry)); + } } accounts.insert_batch(account_changes, Some(block_number.into()));