Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skips merkle-based accounts verification when accounts lt hash is enabled #3208

Merged
merged 1 commit into from
Oct 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 33 additions & 23 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5663,8 +5663,10 @@ impl Bank {
.spawn(move || {
info!("Initial background accounts hash verification has started");
let start = Instant::now();
let mut accounts_lt_hash_time = None;
let mut lattice_verify_time = None;
let mut merkle_verify_time = None;
if is_accounts_lt_hash_enabled {
// accounts lt hash is *enabled* so use lattice-based verification
let accounts_db = &accounts_.accounts_db;
let (calculated_accounts_lt_hash, duration) =
meas_dur!(accounts_db.thread_pool_hash.install(|| {
Expand All @@ -5682,26 +5684,31 @@ impl Bank {
);
return false;
}
accounts_lt_hash_time = Some(duration);
lattice_verify_time = Some(duration);
} else {
// accounts lt hash is *disabled* so use merkle-based verification
let snapshot_storages_and_slots = (
snapshot_storages.0.as_slice(),
snapshot_storages.1.as_slice(),
);
let (result, duration) = meas_dur!(accounts_
.verify_accounts_hash_and_lamports(
snapshot_storages_and_slots,
slot,
capitalization,
base,
VerifyAccountsHashAndLamportsConfig {
ancestors: &ancestors,
epoch_schedule: &epoch_schedule,
rent_collector: &rent_collector,
..verify_config
},
));
if !result {
return false;
}
merkle_verify_time = Some(duration);
}

let snapshot_storages_and_slots = (
snapshot_storages.0.as_slice(),
snapshot_storages.1.as_slice(),
);
let (result, accounts_hash_time) = meas_dur!(accounts_
.verify_accounts_hash_and_lamports(
snapshot_storages_and_slots,
slot,
capitalization,
base,
VerifyAccountsHashAndLamportsConfig {
ancestors: &ancestors,
epoch_schedule: &epoch_schedule,
rent_collector: &rent_collector,
..verify_config
},
));
accounts_
.accounts_db
.verify_accounts_hash_in_bg
Expand All @@ -5712,13 +5719,16 @@ impl Bank {
("total_us", total_time.as_micros(), i64),
(
"verify_accounts_lt_hash_us",
accounts_lt_hash_time.as_ref().map(Duration::as_micros),
lattice_verify_time.as_ref().map(Duration::as_micros),
Option<i64>
),
("verify_accounts_hash_us",
merkle_verify_time.as_ref().map(Duration::as_micros),
Option<i64>
),
("verify_accounts_hash_us", accounts_hash_time.as_micros(), i64),
);
info!("Initial background accounts hash verification has stopped");
result
true
})
.unwrap()
});
Expand Down
Loading