diff --git a/runtime/src/accounts_background_service.rs b/runtime/src/accounts_background_service.rs index 5edb88f3de..6d82b5643a 100644 --- a/runtime/src/accounts_background_service.rs +++ b/runtime/src/accounts_background_service.rs @@ -51,6 +51,10 @@ impl SnapshotRequestHandler { status_cache_slot_deltas, } = snapshot_request; + let mut hash_time = Measure::start("hash_time"); + snapshot_root_bank.update_accounts_hash(); + hash_time.stop(); + let mut shrink_time = Measure::start("shrink_time"); snapshot_root_bank.process_stale_slot_with_budget(0, SHRUNKEN_ACCOUNT_PER_INTERVAL); shrink_time.stop(); @@ -97,7 +101,8 @@ impl SnapshotRequestHandler { "purge_old_snapshots_time", purge_old_snapshots_time.as_us(), i64 - ) + ), + ("hash_time", hash_time.as_us(), i64), ); snapshot_root_bank.block_height() }) diff --git a/runtime/src/accounts_db.rs b/runtime/src/accounts_db.rs index 27a0eab813..79ae010c41 100644 --- a/runtime/src/accounts_db.rs +++ b/runtime/src/accounts_db.rs @@ -1953,6 +1953,7 @@ impl AccountsDB { fn calculate_accounts_hash( &self, + slot: Slot, ancestors: &Ancestors, check_hash: bool, ) -> Result<(Hash, u64), BankHashVerificationError> { @@ -1964,7 +1965,8 @@ impl AccountsDB { let hashes: Vec<_> = keys .par_iter() .filter_map(|pubkey| { - if let Some((list, index)) = accounts_index.get(pubkey, Some(ancestors), None) { + if let Some((list, index)) = accounts_index.get(pubkey, Some(ancestors), Some(slot)) + { let (slot, account_info) = &list[index]; if account_info.lamports != 0 { self.storage @@ -2032,7 +2034,9 @@ impl AccountsDB { } pub fn update_accounts_hash(&self, slot: Slot, ancestors: &Ancestors) -> (Hash, u64) { - let (hash, total_lamports) = self.calculate_accounts_hash(ancestors, false).unwrap(); + let (hash, total_lamports) = self + .calculate_accounts_hash(slot, ancestors, false) + .unwrap(); let mut bank_hashes = self.bank_hashes.write().unwrap(); let mut bank_hash_info = bank_hashes.get_mut(&slot).unwrap(); bank_hash_info.snapshot_hash = hash; @@ -2048,7 +2052,7 @@ impl AccountsDB { use BankHashVerificationError::*; let (calculated_hash, calculated_lamports) = - self.calculate_accounts_hash(ancestors, true)?; + self.calculate_accounts_hash(slot, ancestors, true)?; if calculated_lamports != total_lamports { warn!( diff --git a/runtime/src/bank_forks.rs b/runtime/src/bank_forks.rs index 290ee72d5f..277173b711 100644 --- a/runtime/src/bank_forks.rs +++ b/runtime/src/bank_forks.rs @@ -216,8 +216,6 @@ impl BankForks { bank.squash(); is_root_bank_squashed = bank_slot == root; - bank.update_accounts_hash(); - if self.snapshot_config.is_some() && snapshot_request_sender.is_some() { let snapshot_root_bank = self.root_bank().clone(); let root_slot = snapshot_root_bank.slot();