From 6aaaf858c98a59a7c266ee4b302eb932a929c638 Mon Sep 17 00:00:00 2001 From: Brooks Date: Wed, 28 Feb 2024 15:55:05 -0500 Subject: [PATCH] Adds more info to panic message in AccountsHashVerifier (#35353) --- accounts-db/src/accounts_db.rs | 12 ++++++++++++ core/src/accounts_hash_verifier.rs | 25 ++++++++++++++++++++----- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/accounts-db/src/accounts_db.rs b/accounts-db/src/accounts_db.rs index 167cbdbfa..f077f7a41 100644 --- a/accounts-db/src/accounts_db.rs +++ b/accounts-db/src/accounts_db.rs @@ -7430,6 +7430,11 @@ impl AccountsDb { self.accounts_hashes.lock().unwrap().get(&slot).cloned() } + /// Get all accounts hashes + pub fn get_accounts_hashes(&self) -> HashMap { + self.accounts_hashes.lock().unwrap().clone() + } + /// Set the incremental accounts hash for `slot` /// /// returns the previous incremental accounts hash for `slot` @@ -7466,6 +7471,13 @@ impl AccountsDb { .cloned() } + /// Get all incremental accounts hashes + pub fn get_incremental_accounts_hashes( + &self, + ) -> HashMap { + self.incremental_accounts_hashes.lock().unwrap().clone() + } + /// Purge accounts hashes that are older than `last_full_snapshot_slot` /// /// Should only be called by AccountsHashVerifier, since it consumes the accounts hashes and diff --git a/core/src/accounts_hash_verifier.rs b/core/src/accounts_hash_verifier.rs index 43a3911e4..0e427d067 100644 --- a/core/src/accounts_hash_verifier.rs +++ b/core/src/accounts_hash_verifier.rs @@ -297,11 +297,26 @@ impl AccountsHashVerifier { else { panic!("Calculating incremental accounts hash requires a base slot"); }; - let (base_accounts_hash, base_capitalization) = accounts_package - .accounts - .accounts_db - .get_accounts_hash(base_slot) - .expect("incremental snapshot requires accounts hash and capitalization from the full snapshot it is based on"); + let accounts_db = &accounts_package.accounts.accounts_db; + let Some((base_accounts_hash, base_capitalization)) = + accounts_db.get_accounts_hash(base_slot) + else { + panic!( + "incremental snapshot requires accounts hash and capitalization \ + from the full snapshot it is based on \n\ + package: {accounts_package:?} \n\ + accounts hashes: {:?} \n\ + incremental accounts hashes: {:?} \n\ + full snapshot archives: {:?} \n\ + bank snapshots: {:?}", + accounts_db.get_accounts_hashes(), + accounts_db.get_incremental_accounts_hashes(), + snapshot_utils::get_full_snapshot_archives( + &snapshot_config.full_snapshot_archives_dir, + ), + snapshot_utils::get_bank_snapshots(&snapshot_config.bank_snapshots_dir), + ); + }; let (incremental_accounts_hash, incremental_capitalization) = Self::_calculate_incremental_accounts_hash(accounts_package, base_slot); let bank_incremental_snapshot_persistence = BankIncrementalSnapshotPersistence {