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

Verifying snapshot bank must always specify the snapshot slot #27234

Merged
Show file tree
Hide file tree
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
10 changes: 5 additions & 5 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7124,19 +7124,19 @@ impl Bank {
&self,
test_hash_calculation: bool,
accounts_db_skip_shrink: bool,
last_full_snapshot_slot: Option<Slot>,
last_full_snapshot_slot: Slot,
) -> bool {
let mut clean_time = Measure::start("clean");
if !accounts_db_skip_shrink && self.slot() > 0 {
info!("cleaning..");
self.clean_accounts(true, true, last_full_snapshot_slot);
self.clean_accounts(true, true, Some(last_full_snapshot_slot));
}
clean_time.stop();

let mut shrink_all_slots_time = Measure::start("shrink_all_slots");
if !accounts_db_skip_shrink && self.slot() > 0 {
info!("shrinking..");
self.shrink_all_slots(true, last_full_snapshot_slot);
self.shrink_all_slots(true, Some(last_full_snapshot_slot));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the only call to Bank::shrink_all_slots. Maybe we should we convert the param type in that function as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that could work. I can look at that for a subsequent PR. Currently focusing on getting the Bank functions simpler. Since they're the ones called by more code, trying to remove unnecessary parameters to make this all safer.

}
shrink_all_slots_time.stop();

Expand Down Expand Up @@ -11631,11 +11631,11 @@ pub(crate) mod tests {
.unwrap();
bank.freeze();
bank.update_accounts_hash();
assert!(bank.verify_snapshot_bank(true, false, None));
assert!(bank.verify_snapshot_bank(true, false, bank.slot()));

// tamper the bank after freeze!
bank.increment_signature_count(1);
assert!(!bank.verify_snapshot_bank(true, false, None));
assert!(!bank.verify_snapshot_bank(true, false, bank.slot()));
}

// Test that two bank forks with the same accounts should not hash to the same value.
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/snapshot_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,7 @@ pub fn bank_from_snapshot_archives(
if !bank.verify_snapshot_bank(
test_hash_calculation,
accounts_db_skip_shrink || !full_snapshot_archive_info.is_remote(),
Some(full_snapshot_archive_info.slot()),
full_snapshot_archive_info.slot(),
) && limit_load_slot_count_from_snapshot.is_none()
{
panic!("Snapshot bank for slot {} failed to verify", bank.slot());
Expand Down