stop logging misleading bank hash mismatch (#25427)
This commit is contained in:
parent
3608801a54
commit
41f30a2383
|
@ -1346,7 +1346,7 @@ fn load_frozen_forks(
|
||||||
if slot >= halt_at_slot {
|
if slot >= halt_at_slot {
|
||||||
bank.force_flush_accounts_cache();
|
bank.force_flush_accounts_cache();
|
||||||
let can_cached_slot_be_unflushed = true;
|
let can_cached_slot_be_unflushed = true;
|
||||||
let _ = bank.verify_bank_hash(false, can_cached_slot_be_unflushed);
|
let _ = bank.verify_bank_hash(false, can_cached_slot_be_unflushed, true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,7 +124,8 @@ fn test_accounts_hash_bank_hash(bencher: &mut Bencher) {
|
||||||
test_hash_calculation,
|
test_hash_calculation,
|
||||||
&EpochSchedule::default(),
|
&EpochSchedule::default(),
|
||||||
&RentCollector::default(),
|
&RentCollector::default(),
|
||||||
false
|
false,
|
||||||
|
false,
|
||||||
))
|
))
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -796,6 +796,7 @@ impl Accounts {
|
||||||
epoch_schedule: &EpochSchedule,
|
epoch_schedule: &EpochSchedule,
|
||||||
rent_collector: &RentCollector,
|
rent_collector: &RentCollector,
|
||||||
can_cached_slot_be_unflushed: bool,
|
can_cached_slot_be_unflushed: bool,
|
||||||
|
ignore_mismatch: 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,
|
||||||
|
@ -805,6 +806,7 @@ impl Accounts {
|
||||||
epoch_schedule,
|
epoch_schedule,
|
||||||
rent_collector,
|
rent_collector,
|
||||||
can_cached_slot_be_unflushed,
|
can_cached_slot_be_unflushed,
|
||||||
|
ignore_mismatch,
|
||||||
) {
|
) {
|
||||||
warn!("verify_bank_hash failed: {:?}", err);
|
warn!("verify_bank_hash failed: {:?}", err);
|
||||||
false
|
false
|
||||||
|
|
|
@ -6372,6 +6372,7 @@ impl AccountsDb {
|
||||||
epoch_schedule,
|
epoch_schedule,
|
||||||
rent_collector,
|
rent_collector,
|
||||||
can_cached_slot_be_unflushed,
|
can_cached_slot_be_unflushed,
|
||||||
|
false,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6385,6 +6386,7 @@ impl AccountsDb {
|
||||||
epoch_schedule: &EpochSchedule,
|
epoch_schedule: &EpochSchedule,
|
||||||
rent_collector: &RentCollector,
|
rent_collector: &RentCollector,
|
||||||
can_cached_slot_be_unflushed: bool,
|
can_cached_slot_be_unflushed: bool,
|
||||||
|
ignore_mismatch: bool,
|
||||||
) -> Result<(), BankHashVerificationError> {
|
) -> Result<(), BankHashVerificationError> {
|
||||||
use BankHashVerificationError::*;
|
use BankHashVerificationError::*;
|
||||||
|
|
||||||
|
@ -6415,19 +6417,23 @@ impl AccountsDb {
|
||||||
return Err(MismatchedTotalLamports(calculated_lamports, total_lamports));
|
return Err(MismatchedTotalLamports(calculated_lamports, total_lamports));
|
||||||
}
|
}
|
||||||
|
|
||||||
let bank_hashes = self.bank_hashes.read().unwrap();
|
if ignore_mismatch {
|
||||||
if let Some(found_hash_info) = bank_hashes.get(&slot) {
|
Ok(())
|
||||||
if calculated_hash == found_hash_info.snapshot_hash {
|
|
||||||
Ok(())
|
|
||||||
} else {
|
|
||||||
warn!(
|
|
||||||
"mismatched bank hash for slot {}: {} (calculated) != {} (expected)",
|
|
||||||
slot, calculated_hash, found_hash_info.snapshot_hash
|
|
||||||
);
|
|
||||||
Err(MismatchedBankHash)
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Err(MissingBankHash)
|
let bank_hashes = self.bank_hashes.read().unwrap();
|
||||||
|
if let Some(found_hash_info) = bank_hashes.get(&slot) {
|
||||||
|
if calculated_hash == found_hash_info.snapshot_hash {
|
||||||
|
Ok(())
|
||||||
|
} else {
|
||||||
|
warn!(
|
||||||
|
"mismatched bank hash for slot {}: {} (calculated) != {} (expected)",
|
||||||
|
slot, calculated_hash, found_hash_info.snapshot_hash
|
||||||
|
);
|
||||||
|
Err(MismatchedBankHash)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Err(MissingBankHash)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6330,6 +6330,7 @@ impl Bank {
|
||||||
&self,
|
&self,
|
||||||
test_hash_calculation: bool,
|
test_hash_calculation: bool,
|
||||||
can_cached_slot_be_unflushed: bool,
|
can_cached_slot_be_unflushed: bool,
|
||||||
|
ignore_mismatch: bool,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
self.rc.accounts.verify_bank_hash_and_lamports(
|
self.rc.accounts.verify_bank_hash_and_lamports(
|
||||||
self.slot(),
|
self.slot(),
|
||||||
|
@ -6339,6 +6340,7 @@ impl Bank {
|
||||||
self.epoch_schedule(),
|
self.epoch_schedule(),
|
||||||
&self.rent_collector,
|
&self.rent_collector,
|
||||||
can_cached_slot_be_unflushed,
|
can_cached_slot_be_unflushed,
|
||||||
|
ignore_mismatch,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6540,7 +6542,7 @@ impl Bank {
|
||||||
let (mut verify, verify_time_us) = if !self.rc.accounts.accounts_db.skip_initial_hash_calc {
|
let (mut verify, verify_time_us) = if !self.rc.accounts.accounts_db.skip_initial_hash_calc {
|
||||||
info!("verify_bank_hash..");
|
info!("verify_bank_hash..");
|
||||||
let mut verify_time = Measure::start("verify_bank_hash");
|
let mut verify_time = Measure::start("verify_bank_hash");
|
||||||
let verify = self.verify_bank_hash(test_hash_calculation, false);
|
let verify = self.verify_bank_hash(test_hash_calculation, false, false);
|
||||||
verify_time.stop();
|
verify_time.stop();
|
||||||
(verify, verify_time.as_us())
|
(verify, verify_time.as_us())
|
||||||
} else {
|
} else {
|
||||||
|
@ -9641,17 +9643,17 @@ pub(crate) mod tests {
|
||||||
assert_eq!(bank0.get_account(&keypair.pubkey()).unwrap().lamports(), 10);
|
assert_eq!(bank0.get_account(&keypair.pubkey()).unwrap().lamports(), 10);
|
||||||
assert_eq!(bank1.get_account(&keypair.pubkey()), None);
|
assert_eq!(bank1.get_account(&keypair.pubkey()), None);
|
||||||
|
|
||||||
assert!(bank0.verify_bank_hash(true, false));
|
assert!(bank0.verify_bank_hash(true, false, false));
|
||||||
|
|
||||||
// Squash and then verify hash_internal value
|
// Squash and then verify hash_internal value
|
||||||
bank0.freeze();
|
bank0.freeze();
|
||||||
bank0.squash();
|
bank0.squash();
|
||||||
assert!(bank0.verify_bank_hash(true, false));
|
assert!(bank0.verify_bank_hash(true, false, false));
|
||||||
|
|
||||||
bank1.freeze();
|
bank1.freeze();
|
||||||
bank1.squash();
|
bank1.squash();
|
||||||
bank1.update_accounts_hash();
|
bank1.update_accounts_hash();
|
||||||
assert!(bank1.verify_bank_hash(true, false));
|
assert!(bank1.verify_bank_hash(true, false, false));
|
||||||
|
|
||||||
// keypair should have 0 tokens on both forks
|
// keypair should have 0 tokens on both forks
|
||||||
assert_eq!(bank0.get_account(&keypair.pubkey()), None);
|
assert_eq!(bank0.get_account(&keypair.pubkey()), None);
|
||||||
|
@ -9659,7 +9661,7 @@ pub(crate) mod tests {
|
||||||
bank1.force_flush_accounts_cache();
|
bank1.force_flush_accounts_cache();
|
||||||
bank1.clean_accounts(false, false, None);
|
bank1.clean_accounts(false, false, None);
|
||||||
|
|
||||||
assert!(bank1.verify_bank_hash(true, false));
|
assert!(bank1.verify_bank_hash(true, false, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -10721,7 +10723,7 @@ pub(crate) mod tests {
|
||||||
info!("transfer 2 {}", pubkey2);
|
info!("transfer 2 {}", pubkey2);
|
||||||
bank2.transfer(10, &mint_keypair, &pubkey2).unwrap();
|
bank2.transfer(10, &mint_keypair, &pubkey2).unwrap();
|
||||||
bank2.update_accounts_hash();
|
bank2.update_accounts_hash();
|
||||||
assert!(bank2.verify_bank_hash(true, false));
|
assert!(bank2.verify_bank_hash(true, false, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -10745,19 +10747,19 @@ pub(crate) mod tests {
|
||||||
// Checkpointing should never modify the checkpoint's state once frozen
|
// Checkpointing should never modify the checkpoint's state once frozen
|
||||||
let bank0_state = bank0.hash_internal_state();
|
let bank0_state = bank0.hash_internal_state();
|
||||||
bank2.update_accounts_hash();
|
bank2.update_accounts_hash();
|
||||||
assert!(bank2.verify_bank_hash(true, false));
|
assert!(bank2.verify_bank_hash(true, false, false));
|
||||||
let bank3 = Bank::new_from_parent(&bank0, &solana_sdk::pubkey::new_rand(), 2);
|
let bank3 = Bank::new_from_parent(&bank0, &solana_sdk::pubkey::new_rand(), 2);
|
||||||
assert_eq!(bank0_state, bank0.hash_internal_state());
|
assert_eq!(bank0_state, bank0.hash_internal_state());
|
||||||
assert!(bank2.verify_bank_hash(true, false));
|
assert!(bank2.verify_bank_hash(true, false, false));
|
||||||
bank3.update_accounts_hash();
|
bank3.update_accounts_hash();
|
||||||
assert!(bank3.verify_bank_hash(true, false));
|
assert!(bank3.verify_bank_hash(true, false, false));
|
||||||
|
|
||||||
let pubkey2 = solana_sdk::pubkey::new_rand();
|
let pubkey2 = solana_sdk::pubkey::new_rand();
|
||||||
info!("transfer 2 {}", pubkey2);
|
info!("transfer 2 {}", pubkey2);
|
||||||
bank2.transfer(10, &mint_keypair, &pubkey2).unwrap();
|
bank2.transfer(10, &mint_keypair, &pubkey2).unwrap();
|
||||||
bank2.update_accounts_hash();
|
bank2.update_accounts_hash();
|
||||||
assert!(bank2.verify_bank_hash(true, false));
|
assert!(bank2.verify_bank_hash(true, false, false));
|
||||||
assert!(bank3.verify_bank_hash(true, false));
|
assert!(bank3.verify_bank_hash(true, false, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Reference in New Issue