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

Make VerifyAccountsHashConfig private #31235

Merged
merged 1 commit into from
Apr 18, 2023
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
28 changes: 7 additions & 21 deletions ledger/src/blockstore_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use {
accounts_update_notifier_interface::AccountsUpdateNotifier,
bank::{
Bank, TransactionBalancesSet, TransactionExecutionDetails, TransactionExecutionResult,
TransactionResults, VerifyAccountsHashConfig,
TransactionResults,
},
bank_forks::BankForks,
bank_utils,
Expand Down Expand Up @@ -1554,7 +1554,7 @@ fn load_frozen_forks(
.unwrap_or(false);
if done_processing {
if opts.run_final_accounts_hash_calc {
run_final_hash_calc(&bank, on_halt_store_hash_raw_data_for_debug);
bank.run_final_hash_calc(on_halt_store_hash_raw_data_for_debug);
}
break;
}
Expand All @@ -1569,30 +1569,16 @@ fn load_frozen_forks(
)?;
}
} else if on_halt_store_hash_raw_data_for_debug {
run_final_hash_calc(
&bank_forks.read().unwrap().root_bank(),
on_halt_store_hash_raw_data_for_debug,
);
bank_forks
.read()
.unwrap()
.root_bank()
.run_final_hash_calc(on_halt_store_hash_raw_data_for_debug);
}

Ok(total_slots_elapsed)
}

fn run_final_hash_calc(bank: &Bank, on_halt_store_hash_raw_data_for_debug: bool) {
bank.force_flush_accounts_cache();
// note that this slot may not be a root
let _ = bank.verify_accounts_hash(
None,
VerifyAccountsHashConfig {
test_hash_calculation: false,
ignore_mismatch: true,
require_rooted_bank: false,
run_in_background: false,
store_hash_raw_data_for_debug: on_halt_store_hash_raw_data_for_debug,
},
);
}

// `roots` is sorted largest to smallest by root slot
fn supermajority_root(roots: &[(Slot, u64)], total_epoch_stake: u64) -> Option<Slot> {
if roots.is_empty() {
Expand Down
29 changes: 22 additions & 7 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,12 @@ use {
};

/// params to `verify_accounts_hash`
pub struct VerifyAccountsHashConfig {
pub test_hash_calculation: bool,
pub ignore_mismatch: bool,
pub require_rooted_bank: bool,
pub run_in_background: bool,
pub store_hash_raw_data_for_debug: bool,
struct VerifyAccountsHashConfig {
test_hash_calculation: bool,
ignore_mismatch: bool,
require_rooted_bank: bool,
run_in_background: bool,
store_hash_raw_data_for_debug: bool,
}

mod address_lookup_table;
Expand Down Expand Up @@ -7013,12 +7013,27 @@ impl Bank {
epoch_accounts_hash
}

pub fn run_final_hash_calc(&self, on_halt_store_hash_raw_data_for_debug: bool) {
self.force_flush_accounts_cache();
// note that this slot may not be a root
_ = self.verify_accounts_hash(
None,
VerifyAccountsHashConfig {
test_hash_calculation: false,
ignore_mismatch: true,
require_rooted_bank: false,
run_in_background: false,
store_hash_raw_data_for_debug: on_halt_store_hash_raw_data_for_debug,
},
);
}

/// Recalculate the hash_internal_state from the account stores. Would be used to verify a
/// snapshot.
/// return true if all is good
/// Only called from startup or test code.
#[must_use]
pub fn verify_accounts_hash(
fn verify_accounts_hash(
&self,
base: Option<(Slot, /*capitalization*/ u64)>,
config: VerifyAccountsHashConfig,
Expand Down