Skip to content

Commit

Permalink
Make VerifyAccountsHashConfig private (#31235)
Browse files Browse the repository at this point in the history
  • Loading branch information
bw-solana authored Apr 18, 2023
1 parent 2b2eccf commit f5fe260
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 28 deletions.
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

0 comments on commit f5fe260

Please sign in to comment.