Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds more info to panic message in AccountsHashVerifier #35353

Merged
merged 1 commit into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions accounts-db/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7443,6 +7443,11 @@ impl AccountsDb {
self.accounts_hashes.lock().unwrap().get(&slot).cloned()
}

/// Get all accounts hashes
pub fn get_accounts_hashes(&self) -> HashMap<Slot, (AccountsHash, /*capitalization*/ u64)> {
self.accounts_hashes.lock().unwrap().clone()
}

/// Set the incremental accounts hash for `slot`
///
/// returns the previous incremental accounts hash for `slot`
Expand Down Expand Up @@ -7479,6 +7484,13 @@ impl AccountsDb {
.cloned()
}

/// Get all incremental accounts hashes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure it requires any special "markup", but currently, we only plan to use this function (and the other new one) to get extra information before we panic, right? I guess it is a separate file AND crate, so these have to be pub

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, exactly.

pub fn get_incremental_accounts_hashes(
&self,
) -> HashMap<Slot, (IncrementalAccountsHash, /*capitalization*/ u64)> {
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
Expand Down
25 changes: 20 additions & 5 deletions core/src/accounts_hash_verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading