Skip to content

Commit 1390ec9

Browse files
v1.17: Adds more info to panic message in AccountsHashVerifier (backport of #35353) (#35358)
Adds more info to panic message in AccountsHashVerifier (#35353) (cherry picked from commit 6aaaf85) Co-authored-by: Brooks <brooks@solana.com>
1 parent ee1365a commit 1390ec9

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
lines changed

accounts-db/src/accounts_db.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7511,6 +7511,11 @@ impl AccountsDb {
75117511
self.accounts_hashes.lock().unwrap().get(&slot).cloned()
75127512
}
75137513

7514+
/// Get all accounts hashes
7515+
pub fn get_accounts_hashes(&self) -> HashMap<Slot, (AccountsHash, /*capitalization*/ u64)> {
7516+
self.accounts_hashes.lock().unwrap().clone()
7517+
}
7518+
75147519
/// Set the incremental accounts hash for `slot`
75157520
///
75167521
/// returns the previous incremental accounts hash for `slot`
@@ -7547,6 +7552,13 @@ impl AccountsDb {
75477552
.cloned()
75487553
}
75497554

7555+
/// Get all incremental accounts hashes
7556+
pub fn get_incremental_accounts_hashes(
7557+
&self,
7558+
) -> HashMap<Slot, (IncrementalAccountsHash, /*capitalization*/ u64)> {
7559+
self.incremental_accounts_hashes.lock().unwrap().clone()
7560+
}
7561+
75507562
/// Purge accounts hashes that are older than `last_full_snapshot_slot`
75517563
///
75527564
/// Should only be called by AccountsHashVerifier, since it consumes the accounts hashes and

core/src/accounts_hash_verifier.rs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -321,11 +321,26 @@ impl AccountsHashVerifier {
321321
else {
322322
panic!("Calculating incremental accounts hash requires a base slot");
323323
};
324-
let (base_accounts_hash, base_capitalization) = accounts_package
325-
.accounts
326-
.accounts_db
327-
.get_accounts_hash(base_slot)
328-
.expect("incremental snapshot requires accounts hash and capitalization from the full snapshot it is based on");
324+
let accounts_db = &accounts_package.accounts.accounts_db;
325+
let Some((base_accounts_hash, base_capitalization)) =
326+
accounts_db.get_accounts_hash(base_slot)
327+
else {
328+
panic!(
329+
"incremental snapshot requires accounts hash and capitalization \
330+
from the full snapshot it is based on \n\
331+
package: {accounts_package:?} \n\
332+
accounts hashes: {:?} \n\
333+
incremental accounts hashes: {:?} \n\
334+
full snapshot archives: {:?} \n\
335+
bank snapshots: {:?}",
336+
accounts_db.get_accounts_hashes(),
337+
accounts_db.get_incremental_accounts_hashes(),
338+
snapshot_utils::get_full_snapshot_archives(
339+
&snapshot_config.full_snapshot_archives_dir,
340+
),
341+
snapshot_utils::get_bank_snapshots(&snapshot_config.bank_snapshots_dir),
342+
);
343+
};
329344
let (incremental_accounts_hash, incremental_capitalization) =
330345
Self::_calculate_incremental_accounts_hash(accounts_package, base_slot);
331346
let bank_incremental_snapshot_persistence = BankIncrementalSnapshotPersistence {

0 commit comments

Comments
 (0)