From 1e3f9043b8b6291b79b029f2e1ca3eac062f1aa3 Mon Sep 17 00:00:00 2001 From: Brennan Watt Date: Mon, 17 Apr 2023 23:26:30 +0000 Subject: [PATCH] Make VerifyAccountsHashConfig private --- ledger/src/blockstore_processor.rs | 28 +++++++--------------------- runtime/src/bank.rs | 29 ++++++++++++++++++++++------- 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/ledger/src/blockstore_processor.rs b/ledger/src/blockstore_processor.rs index 733898e7664e29..f35bba57adfabe 100644 --- a/ledger/src/blockstore_processor.rs +++ b/ledger/src/blockstore_processor.rs @@ -25,7 +25,7 @@ use { accounts_update_notifier_interface::AccountsUpdateNotifier, bank::{ Bank, TransactionBalancesSet, TransactionExecutionDetails, TransactionExecutionResult, - TransactionResults, VerifyAccountsHashConfig, + TransactionResults, }, bank_forks::BankForks, bank_utils, @@ -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; } @@ -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 { if roots.is_empty() { diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index cf42b109fb0bc9..1b00b619d48a34 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -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; @@ -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,