diff --git a/ledger/src/blockstore_processor.rs b/ledger/src/blockstore_processor.rs index fbbe58b15324ed..8db00eda8b56b0 100644 --- a/ledger/src/blockstore_processor.rs +++ b/ledger/src/blockstore_processor.rs @@ -835,11 +835,7 @@ pub fn process_blockstore_from_root( // We might be promptly restarted after bad capitalization was detected while creating newer snapshot. // In that case, we're most likely restored from the last good snapshot and replayed up to this root. // So again check here for the bad capitalization to avoid to continue until the next snapshot creation. - bank.rc - .accounts - .accounts_db - .verify_accounts_hash_in_bg - .wait_for_complete(); + bank.wait_for_startup_verification_complete(); if !bank.calculate_and_verify_capitalization(opts.accounts_db_test_hash_calculation) { return Err( BlockstoreProcessorError::RootBankWithMismatchedCapitalization( diff --git a/runtime/src/accounts_db.rs b/runtime/src/accounts_db.rs index 5eee3f610c072d..fd57db023e59e6 100644 --- a/runtime/src/accounts_db.rs +++ b/runtime/src/accounts_db.rs @@ -1167,7 +1167,7 @@ pub struct AccountsDb { /// number of slots remaining where filler accounts should be added pub filler_account_slots_remaining: AtomicU64, - pub verify_accounts_hash_in_bg: VerifyAccountsHashInBackground, + pub(crate) verify_accounts_hash_in_bg: VerifyAccountsHashInBackground, // # of passes should be a function of the total # of accounts that are active. // higher passes = slower total time, lower dynamic memory usage diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 7a2797510f8c78..a05469d1404c22 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -3717,6 +3717,14 @@ impl Bank { .verification_complete() } + pub fn wait_for_startup_verification_complete(&self) { + self.rc + .accounts + .accounts_db + .verify_accounts_hash_in_bg + .wait_for_complete() + } + pub fn get_fee_for_message_with_lamports_per_signature( &self, message: &SanitizedMessage, diff --git a/runtime/src/verify_accounts_hash_in_background.rs b/runtime/src/verify_accounts_hash_in_background.rs index e8582a75497c09..90266e36a61a94 100644 --- a/runtime/src/verify_accounts_hash_in_background.rs +++ b/runtime/src/verify_accounts_hash_in_background.rs @@ -1,7 +1,6 @@ //! at startup, verify accounts hash in the background use { crate::waitable_condvar::WaitableCondvar, - log::*, std::{ sync::{ atomic::{AtomicBool, Ordering}, @@ -13,7 +12,7 @@ use { }; #[derive(Debug)] -pub struct VerifyAccountsHashInBackground { +pub(crate) struct VerifyAccountsHashInBackground { /// true when verification has completed or never had to run in background pub(crate) verified: Arc, /// enable waiting for verification to become complete @@ -41,7 +40,6 @@ impl Default for VerifyAccountsHashInBackground { impl VerifyAccountsHashInBackground { /// start the bg thread to do the verification pub(crate) fn start(&self, start: impl FnOnce() -> JoinHandle) { - warn!("BWLOG: starting bg thread for verification"); // note that we're not verified before self.verified.store(false, Ordering::Release); *self.thread.lock().unwrap() = Some(start()); @@ -57,24 +55,20 @@ impl VerifyAccountsHashInBackground { /// This can occur because it completed in the background /// or if the verification was run in the foreground. pub(crate) fn verification_complete(&self) { - warn!("BWLOG: verification complete"); self.verified.store(true, Ordering::Release); } /// block until bg process is complete pub fn wait_for_complete(&self) { // just now completing - warn!("BWLOG: entering wait_for_complete"); let mut lock = self.thread.lock().unwrap(); if lock.is_none() { - warn!("BWLOG: lock is none"); return; // nothing to do } let result = lock.take().unwrap().join().unwrap(); if !result { panic!("initial hash verification failed"); } - warn!("BWLOG: result is success"); // we never have to check again self.verification_complete(); } @@ -82,7 +76,7 @@ impl VerifyAccountsHashInBackground { /// return true if bg hash verification is complete /// return false if bg hash verification has not completed yet /// if hash verification failed, a panic will occur - pub fn check_complete(&self) -> bool { + pub(crate) fn check_complete(&self) -> bool { if self.verified.load(Ordering::Acquire) { // already completed return true;