ledger tool verify can store debug info on hash calc (#26837)

This commit is contained in:
Jeff Washington (jwash) 2022-07-29 15:54:56 -05:00 committed by GitHub
parent 38cd29810f
commit c7462b7a52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 23 additions and 1 deletions

View File

@ -1160,6 +1160,10 @@ fn main() {
.long("accounts-db-ancient-append-vecs") .long("accounts-db-ancient-append-vecs")
.help("AppendVecs that are older than an epoch are squashed together.") .help("AppendVecs that are older than an epoch are squashed together.")
.hidden(true); .hidden(true);
let halt_at_slot_store_hash_raw_data = Arg::with_name("halt_at_slot_store_hash_raw_data")
.long("halt-at-slot-store-hash-raw-data")
.help("After halting at slot, run an accounts hash calculation and store the raw hash data for debugging.")
.hidden(true);
let verify_index_arg = Arg::with_name("verify_accounts_index") let verify_index_arg = Arg::with_name("verify_accounts_index")
.long("verify-accounts-index") .long("verify-accounts-index")
.takes_value(false) .takes_value(false)
@ -1512,6 +1516,7 @@ fn main() {
.arg(&skip_rewrites_arg) .arg(&skip_rewrites_arg)
.arg(&accounts_db_skip_initial_hash_calc_arg) .arg(&accounts_db_skip_initial_hash_calc_arg)
.arg(&ancient_append_vecs) .arg(&ancient_append_vecs)
.arg(&halt_at_slot_store_hash_raw_data)
.arg(&hard_forks_arg) .arg(&hard_forks_arg)
.arg(&no_accounts_db_caching_arg) .arg(&no_accounts_db_caching_arg)
.arg(&accounts_db_test_hash_calculation_arg) .arg(&accounts_db_test_hash_calculation_arg)
@ -2442,6 +2447,8 @@ fn main() {
let process_options = ProcessOptions { let process_options = ProcessOptions {
new_hard_forks: hardforks_of(arg_matches, "hard_forks"), new_hard_forks: hardforks_of(arg_matches, "hard_forks"),
poh_verify: !arg_matches.is_present("skip_poh_verify"), poh_verify: !arg_matches.is_present("skip_poh_verify"),
on_halt_store_hash_raw_data_for_debug: arg_matches
.is_present("halt_at_slot_store_hash_raw_data"),
halt_at_slot: value_t!(arg_matches, "halt_at_slot", Slot).ok(), halt_at_slot: value_t!(arg_matches, "halt_at_slot", Slot).ok(),
debug_keys, debug_keys,
accounts_db_caching_enabled: !arg_matches.is_present("no_accounts_db_caching"), accounts_db_caching_enabled: !arg_matches.is_present("no_accounts_db_caching"),

View File

@ -708,6 +708,7 @@ pub struct ProcessOptions {
pub verify_index: bool, pub verify_index: bool,
pub shrink_ratio: AccountShrinkThreshold, pub shrink_ratio: AccountShrinkThreshold,
pub runtime_config: RuntimeConfig, pub runtime_config: RuntimeConfig,
pub on_halt_store_hash_raw_data_for_debug: bool,
} }
pub fn test_process_blockstore( pub fn test_process_blockstore(
@ -1399,6 +1400,7 @@ fn load_frozen_forks(
)?; )?;
let halt_at_slot = opts.halt_at_slot.unwrap_or(std::u64::MAX); let halt_at_slot = opts.halt_at_slot.unwrap_or(std::u64::MAX);
let on_halt_store_hash_raw_data_for_debug = opts.on_halt_store_hash_raw_data_for_debug;
if bank_forks.read().unwrap().root() != halt_at_slot { if bank_forks.read().unwrap().root() != halt_at_slot {
while !pending_slots.is_empty() { while !pending_slots.is_empty() {
timing.details.per_program_timings.clear(); timing.details.per_program_timings.clear();
@ -1540,6 +1542,7 @@ fn load_frozen_forks(
ignore_mismatch: true, ignore_mismatch: true,
require_rooted_bank: false, require_rooted_bank: false,
run_in_background: false, run_in_background: false,
store_hash_raw_data_for_debug: on_halt_store_hash_raw_data_for_debug,
}); });
break; break;
} }

View File

@ -126,6 +126,7 @@ fn test_accounts_hash_bank_hash(bencher: &mut Bencher) {
&RentCollector::default(), &RentCollector::default(),
false, false,
false, false,
false,
)) ))
}); });
} }

View File

@ -814,6 +814,7 @@ impl Accounts {
/// Only called from startup or test code. /// Only called from startup or test code.
#[must_use] #[must_use]
#[allow(clippy::too_many_arguments)]
pub fn verify_bank_hash_and_lamports( pub fn verify_bank_hash_and_lamports(
&self, &self,
slot: Slot, slot: Slot,
@ -824,6 +825,7 @@ impl Accounts {
rent_collector: &RentCollector, rent_collector: &RentCollector,
can_cached_slot_be_unflushed: bool, can_cached_slot_be_unflushed: bool,
ignore_mismatch: bool, ignore_mismatch: bool,
store_detailed_debug_info: bool,
) -> bool { ) -> bool {
if let Err(err) = self.accounts_db.verify_bank_hash_and_lamports_new( if let Err(err) = self.accounts_db.verify_bank_hash_and_lamports_new(
slot, slot,
@ -834,6 +836,7 @@ impl Accounts {
rent_collector, rent_collector,
can_cached_slot_be_unflushed, can_cached_slot_be_unflushed,
ignore_mismatch, ignore_mismatch,
store_detailed_debug_info,
) { ) {
warn!("verify_bank_hash failed: {:?}, slot: {}", err, slot); warn!("verify_bank_hash failed: {:?}, slot: {}", err, slot);
false false

View File

@ -6990,10 +6990,12 @@ impl AccountsDb {
rent_collector, rent_collector,
can_cached_slot_be_unflushed, can_cached_slot_be_unflushed,
false, false,
false,
) )
} }
/// Only called from startup or test code. /// Only called from startup or test code.
#[allow(clippy::too_many_arguments)]
pub fn verify_bank_hash_and_lamports_new( pub fn verify_bank_hash_and_lamports_new(
&self, &self,
slot: Slot, slot: Slot,
@ -7004,6 +7006,7 @@ impl AccountsDb {
rent_collector: &RentCollector, rent_collector: &RentCollector,
can_cached_slot_be_unflushed: bool, can_cached_slot_be_unflushed: bool,
ignore_mismatch: bool, ignore_mismatch: bool,
store_hash_raw_data_for_debug: bool,
) -> Result<(), BankHashVerificationError> { ) -> Result<(), BankHashVerificationError> {
use BankHashVerificationError::*; use BankHashVerificationError::*;
@ -7023,7 +7026,7 @@ impl AccountsDb {
use_write_cache: can_cached_slot_be_unflushed, use_write_cache: can_cached_slot_be_unflushed,
epoch_schedule, epoch_schedule,
rent_collector, rent_collector,
store_detailed_debug_info_on_failure: false, store_detailed_debug_info_on_failure: store_hash_raw_data_for_debug,
full_snapshot: None, full_snapshot: None,
}, },
None, None,

View File

@ -178,6 +178,7 @@ pub struct VerifyBankHash {
pub ignore_mismatch: bool, pub ignore_mismatch: bool,
pub require_rooted_bank: bool, pub require_rooted_bank: bool,
pub run_in_background: bool, pub run_in_background: bool,
pub store_hash_raw_data_for_debug: bool,
} }
#[derive(Debug, Default)] #[derive(Debug, Default)]
@ -6903,6 +6904,7 @@ impl Bank {
&rent_collector, &rent_collector,
config.can_cached_slot_be_unflushed, config.can_cached_slot_be_unflushed,
config.ignore_mismatch, config.ignore_mismatch,
config.store_hash_raw_data_for_debug,
); );
accounts_ accounts_
.accounts_db .accounts_db
@ -6923,6 +6925,7 @@ impl Bank {
rent_collector, rent_collector,
config.can_cached_slot_be_unflushed, config.can_cached_slot_be_unflushed,
config.ignore_mismatch, config.ignore_mismatch,
config.store_hash_raw_data_for_debug,
); );
self.set_initial_accounts_hash_verification_completed(); self.set_initial_accounts_hash_verification_completed();
result result
@ -7162,6 +7165,7 @@ impl Bank {
ignore_mismatch: false, ignore_mismatch: false,
require_rooted_bank: false, require_rooted_bank: false,
run_in_background: true, run_in_background: true,
store_hash_raw_data_for_debug: false,
}); });
verify_time.stop(); verify_time.stop();
(verify, verify_time.as_us()) (verify, verify_time.as_us())
@ -10393,6 +10397,7 @@ pub(crate) mod tests {
ignore_mismatch: false, ignore_mismatch: false,
require_rooted_bank: false, require_rooted_bank: false,
run_in_background: false, run_in_background: false,
store_hash_raw_data_for_debug: false,
} }
} }
} }