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

Renames last_full_snapshot_slot to latest_full_snapshot_slot #2391

Merged
merged 1 commit into from
Aug 1, 2024
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
134 changes: 67 additions & 67 deletions accounts-db/src/accounts_db.rs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core/src/snapshot_packager_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl SnapshotPackagerService {

// Archiving the snapshot package is not allowed to fail.
// AccountsBackgroundService calls `clean_accounts()` with a value for
// last_full_snapshot_slot that requires this archive call to succeed.
// latest_full_snapshot_slot that requires this archive call to succeed.
let (archive_result, archive_time_us) = measure_us!(snapshot_utils::serialize_and_archive_snapshot_package(
snapshot_package,
&snapshot_config,
Expand Down
24 changes: 12 additions & 12 deletions core/tests/snapshots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ fn test_bank_forks_incremental_snapshot(
accounts_package_sender,
};

let mut last_full_snapshot_slot = None;
let mut latest_full_snapshot_slot = None;
for slot in 1..=LAST_SLOT {
// Make a new bank and perform some transactions
let bank = {
Expand Down Expand Up @@ -502,7 +502,7 @@ fn test_bank_forks_incremental_snapshot(
// at the right interval
if snapshot_utils::should_take_full_snapshot(slot, FULL_SNAPSHOT_ARCHIVE_INTERVAL_SLOTS) {
make_full_snapshot_archive(&bank, &snapshot_test_config.snapshot_config).unwrap();
last_full_snapshot_slot = Some(slot);
latest_full_snapshot_slot = Some(slot);
}
// Similarly, make an incremental snapshot archive at the right interval, but only if
// there's been at least one full snapshot first, and a full snapshot wasn't already
Expand All @@ -512,12 +512,12 @@ fn test_bank_forks_incremental_snapshot(
else if snapshot_utils::should_take_incremental_snapshot(
slot,
INCREMENTAL_SNAPSHOT_ARCHIVE_INTERVAL_SLOTS,
last_full_snapshot_slot,
) && slot != last_full_snapshot_slot.unwrap()
latest_full_snapshot_slot,
) && slot != latest_full_snapshot_slot.unwrap()
{
make_incremental_snapshot_archive(
&bank,
last_full_snapshot_slot.unwrap(),
latest_full_snapshot_slot.unwrap(),
&snapshot_test_config.snapshot_config,
)
.unwrap();
Expand Down Expand Up @@ -724,8 +724,8 @@ fn test_snapshots_with_background_services(
false,
);

let mut last_full_snapshot_slot = None;
let mut last_incremental_snapshot_slot = None;
let mut latest_full_snapshot_slot = None;
let mut latest_incremental_snapshot_slot = None;
let mint_keypair = &snapshot_test_config.genesis_config_info.mint_keypair;
for slot in 1..=LAST_SLOT {
// Make a new bank and process some transactions
Expand Down Expand Up @@ -778,16 +778,16 @@ fn test_snapshots_with_background_services(
);
std::thread::sleep(Duration::from_secs(1));
}
last_full_snapshot_slot = Some(slot);
latest_full_snapshot_slot = Some(slot);
} else if slot % INCREMENTAL_SNAPSHOT_ARCHIVE_INTERVAL_SLOTS == 0
&& last_full_snapshot_slot.is_some()
&& latest_full_snapshot_slot.is_some()
{
let timer = Instant::now();
while snapshot_utils::get_highest_incremental_snapshot_archive_slot(
&snapshot_test_config
.snapshot_config
.incremental_snapshot_archives_dir,
last_full_snapshot_slot.unwrap(),
latest_full_snapshot_slot.unwrap(),
) != Some(slot)
{
assert!(
Expand All @@ -796,7 +796,7 @@ fn test_snapshots_with_background_services(
);
std::thread::sleep(Duration::from_secs(1));
}
last_incremental_snapshot_slot = Some(slot);
latest_incremental_snapshot_slot = Some(slot);
}
}

Expand Down Expand Up @@ -831,7 +831,7 @@ fn test_snapshots_with_background_services(

assert_eq!(
deserialized_bank.slot(),
last_incremental_snapshot_slot.unwrap()
latest_incremental_snapshot_slot.unwrap()
);
assert_eq!(
&deserialized_bank,
Expand Down
4 changes: 2 additions & 2 deletions ledger/src/bank_forks_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,13 +336,13 @@ fn bank_forks_from_snapshot(
bank
};

// We must inform accounts-db of the last full snapshot slot, which is used by the background
// We must inform accounts-db of the latest full snapshot slot, which is used by the background
// processes to handle zero lamport accounts. Since we've now successfully loaded the bank
// from snapshots, this is a good time to do that update.
bank.rc
.accounts
.accounts_db
.set_last_full_snapshot_slot(full_snapshot_archive_info.slot());
.set_latest_full_snapshot_slot(full_snapshot_archive_info.slot());

let full_snapshot_hash = FullSnapshotHash((
full_snapshot_archive_info.slot(),
Expand Down
48 changes: 24 additions & 24 deletions runtime/src/accounts_background_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,14 +304,14 @@ impl SnapshotRequestHandler {
assert!(snapshot_root_bank.is_startup_verification_complete());

if accounts_package_kind == AccountsPackageKind::Snapshot(SnapshotKind::FullSnapshot) {
// The last full snapshot slot is what accounts-db uses to properly handle zero lamport
// The latest full snapshot slot is what accounts-db uses to properly handle zero lamport
// accounts. We are handling a full snapshot request here, and since taking a snapshot
// is not allowed to fail, we can update accounts-db now.
snapshot_root_bank
.rc
.accounts
.accounts_db
.set_last_full_snapshot_slot(snapshot_root_bank.slot());
.set_latest_full_snapshot_slot(snapshot_root_bank.slot());
}

let previous_accounts_hash = test_hash_calculation.then(|| {
Expand Down Expand Up @@ -734,12 +734,12 @@ fn new_accounts_package_kind(
snapshot_config: &SnapshotConfig,
) -> AccountsPackageKind {
let block_height = snapshot_request.snapshot_root_bank.block_height();
let last_full_snapshot_slot = snapshot_request
let latest_full_snapshot_slot = snapshot_request
.snapshot_root_bank
.rc
.accounts
.accounts_db
.last_full_snapshot_slot();
.latest_full_snapshot_slot();
match snapshot_request.request_kind {
SnapshotRequestKind::EpochAccountsHash => AccountsPackageKind::EpochAccountsHash,
SnapshotRequestKind::Snapshot => {
Expand All @@ -751,10 +751,10 @@ fn new_accounts_package_kind(
} else if snapshot_utils::should_take_incremental_snapshot(
block_height,
snapshot_config.incremental_snapshot_archive_interval_slots,
last_full_snapshot_slot,
latest_full_snapshot_slot,
) {
AccountsPackageKind::Snapshot(SnapshotKind::IncrementalSnapshot(
last_full_snapshot_slot.unwrap(),
latest_full_snapshot_slot.unwrap(),
))
} else {
AccountsPackageKind::AccountsHashVerifier
Expand Down Expand Up @@ -931,18 +931,18 @@ mod test {
.epoch_accounts_hash_manager
.set_valid(EpochAccountsHash::new(Hash::new_unique()), 0);

// We need to get and set accounts-db's last full snapshot slot to test
// We need to get and set accounts-db's latest full snapshot slot to test
// get_next_snapshot_request(). To workaround potential borrowing issues
// caused by make_banks() below, Arc::clone bank0 and add helper functions.
let bank0 = bank.clone();
fn last_full_snapshot_slot(bank: &Bank) -> Option<Slot> {
bank.rc.accounts.accounts_db.last_full_snapshot_slot()
fn latest_full_snapshot_slot(bank: &Bank) -> Option<Slot> {
bank.rc.accounts.accounts_db.latest_full_snapshot_slot()
}
fn set_last_full_snapshot_slot(bank: &Bank, slot: Slot) {
fn set_latest_full_snapshot_slot(bank: &Bank, slot: Slot) {
bank.rc
.accounts
.accounts_db
.set_last_full_snapshot_slot(slot);
.set_latest_full_snapshot_slot(slot);
}

// Create new banks and send snapshot requests so that the following requests will be in
Expand All @@ -965,7 +965,7 @@ mod test {
//
// (slots not called out will all be AHV)
// Also, incremental snapshots before slot 240 (the first full snapshot handled), will
// actually be AHV since the last full snapshot slot will be `None`. This is expected and
// actually be AHV since the latest full snapshot slot will be `None`. This is expected and
// fine; but maybe unexpected for a reader/debugger without this additional context.
let mut make_banks = |num_banks| {
for _ in 0..num_banks {
Expand All @@ -991,7 +991,7 @@ mod test {
make_banks(303);

// Ensure the EAH is handled 1st
assert_eq!(last_full_snapshot_slot(&bank0), None,);
assert_eq!(latest_full_snapshot_slot(&bank0), None,);
let (snapshot_request, accounts_package_kind, ..) = snapshot_request_handler
.get_next_snapshot_request()
.unwrap();
Expand All @@ -1003,7 +1003,7 @@ mod test {

// Ensure the full snapshot from slot 240 is handled 2nd
// (the older full snapshots are skipped and dropped)
assert_eq!(last_full_snapshot_slot(&bank0), None,);
assert_eq!(latest_full_snapshot_slot(&bank0), None,);
let (snapshot_request, accounts_package_kind, ..) = snapshot_request_handler
.get_next_snapshot_request()
.unwrap();
Expand All @@ -1012,11 +1012,11 @@ mod test {
AccountsPackageKind::Snapshot(SnapshotKind::FullSnapshot)
);
assert_eq!(snapshot_request.snapshot_root_bank.slot(), 240);
set_last_full_snapshot_slot(&bank0, 240);
set_latest_full_snapshot_slot(&bank0, 240);

// Ensure the incremental snapshot from slot 300 is handled 3rd
// (the older incremental snapshots are skipped and dropped)
assert_eq!(last_full_snapshot_slot(&bank0), Some(240),);
assert_eq!(latest_full_snapshot_slot(&bank0), Some(240),);
let (snapshot_request, accounts_package_kind, ..) = snapshot_request_handler
.get_next_snapshot_request()
.unwrap();
Expand All @@ -1028,7 +1028,7 @@ mod test {

// Ensure the accounts hash verifier from slot 303 is handled 4th
// (the older accounts hash verifiers are skipped and dropped)
assert_eq!(last_full_snapshot_slot(&bank0), Some(240),);
assert_eq!(latest_full_snapshot_slot(&bank0), Some(240),);
let (snapshot_request, accounts_package_kind, ..) = snapshot_request_handler
.get_next_snapshot_request()
.unwrap();
Expand All @@ -1039,7 +1039,7 @@ mod test {
assert_eq!(snapshot_request.snapshot_root_bank.slot(), 303);

// And now ensure the snapshot request channel is empty!
assert_eq!(last_full_snapshot_slot(&bank0), Some(240),);
assert_eq!(latest_full_snapshot_slot(&bank0), Some(240),);
assert!(snapshot_request_handler
.get_next_snapshot_request()
.is_none());
Expand All @@ -1060,7 +1060,7 @@ mod test {
make_banks(240);

// Ensure the full snapshot is handled 1st
assert_eq!(last_full_snapshot_slot(&bank0), Some(240),);
assert_eq!(latest_full_snapshot_slot(&bank0), Some(240),);
let (snapshot_request, accounts_package_kind, ..) = snapshot_request_handler
.get_next_snapshot_request()
.unwrap();
Expand All @@ -1069,10 +1069,10 @@ mod test {
AccountsPackageKind::Snapshot(SnapshotKind::FullSnapshot)
);
assert_eq!(snapshot_request.snapshot_root_bank.slot(), 480);
set_last_full_snapshot_slot(&bank0, 480);
set_latest_full_snapshot_slot(&bank0, 480);

// Ensure the EAH is handled 2nd
assert_eq!(last_full_snapshot_slot(&bank0), Some(480),);
assert_eq!(latest_full_snapshot_slot(&bank0), Some(480),);
let (snapshot_request, accounts_package_kind, ..) = snapshot_request_handler
.get_next_snapshot_request()
.unwrap();
Expand All @@ -1083,7 +1083,7 @@ mod test {
assert_eq!(snapshot_request.snapshot_root_bank.slot(), 500);

// Ensure the incremental snapshot is handled 3rd
assert_eq!(last_full_snapshot_slot(&bank0), Some(480),);
assert_eq!(latest_full_snapshot_slot(&bank0), Some(480),);
let (snapshot_request, accounts_package_kind, ..) = snapshot_request_handler
.get_next_snapshot_request()
.unwrap();
Expand All @@ -1094,7 +1094,7 @@ mod test {
assert_eq!(snapshot_request.snapshot_root_bank.slot(), 540);

// Ensure the accounts hash verifier is handled 4th
assert_eq!(last_full_snapshot_slot(&bank0), Some(480),);
assert_eq!(latest_full_snapshot_slot(&bank0), Some(480),);
let (snapshot_request, accounts_package_kind, ..) = snapshot_request_handler
.get_next_snapshot_request()
.unwrap();
Expand All @@ -1105,7 +1105,7 @@ mod test {
assert_eq!(snapshot_request.snapshot_root_bank.slot(), 543);

// And now ensure the snapshot request channel is empty!
assert_eq!(last_full_snapshot_slot(&bank0), Some(480),);
assert_eq!(latest_full_snapshot_slot(&bank0), Some(480),);
assert!(snapshot_request_handler
.get_next_snapshot_request()
.is_none());
Expand Down
4 changes: 2 additions & 2 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5847,7 +5847,7 @@ impl Bank {
test_hash_calculation: bool,
skip_shrink: bool,
force_clean: bool,
last_full_snapshot_slot: Slot,
latest_full_snapshot_slot: Slot,
base: Option<(Slot, /*capitalization*/ u64)>,
) -> bool {
let (_, clean_time_us) = measure_us!({
Expand All @@ -5859,7 +5859,7 @@ impl Bank {
// that slot, then accounts could be removed from older storages, which would
// change the accounts hash.
self.rc.accounts.accounts_db.clean_accounts(
Some(last_full_snapshot_slot),
Some(latest_full_snapshot_slot),
true,
self.epoch_schedule(),
);
Expand Down
8 changes: 4 additions & 4 deletions runtime/src/snapshot_bank_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -906,12 +906,12 @@ fn bank_to_full_snapshot_archive_with(
archive_format: ArchiveFormat,
) -> snapshot_utils::Result<FullSnapshotArchiveInfo> {
assert!(bank.is_complete());
// set accounts-db's last full snapshot slot here to ensure zero lamport
// set accounts-db's latest full snapshot slot here to ensure zero lamport
// accounts are handled properly.
bank.rc
.accounts
.accounts_db
.set_last_full_snapshot_slot(bank.slot());
.set_latest_full_snapshot_slot(bank.slot());
bank.squash(); // Bank may not be a root
bank.rehash(); // Bank accounts may have been manually modified by the caller
bank.force_flush_accounts_cache();
Expand Down Expand Up @@ -969,12 +969,12 @@ pub fn bank_to_incremental_snapshot_archive(

assert!(bank.is_complete());
assert!(bank.slot() > full_snapshot_slot);
// set accounts-db's last full snapshot slot here to ensure zero lamport
// set accounts-db's latest full snapshot slot here to ensure zero lamport
// accounts are handled properly.
bank.rc
.accounts
.accounts_db
.set_last_full_snapshot_slot(full_snapshot_slot);
.set_latest_full_snapshot_slot(full_snapshot_slot);
bank.squash(); // Bank may not be a root
bank.rehash(); // Bank accounts may have been manually modified by the caller
bank.force_flush_accounts_cache();
Expand Down
4 changes: 2 additions & 2 deletions runtime/src/snapshot_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2537,10 +2537,10 @@ pub fn should_take_full_snapshot(
pub fn should_take_incremental_snapshot(
block_height: Slot,
incremental_snapshot_archive_interval_slots: Slot,
last_full_snapshot_slot: Option<Slot>,
latest_full_snapshot_slot: Option<Slot>,
) -> bool {
block_height % incremental_snapshot_archive_interval_slots == 0
&& last_full_snapshot_slot.is_some()
&& latest_full_snapshot_slot.is_some()
}

/// Creates an "accounts path" directory for tests
Expand Down
2 changes: 1 addition & 1 deletion wen-restart/src/wen_restart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ pub(crate) fn generate_snapshot(
// slot new_root_slot is less than the the current highest full_snapshot_slot, that means the
// locally rooted full_snapshot_slot will be rolled back. this requires human inspection。
//
// In even rarer cases, the selected slot might be the last full snapshot slot. We could
// In even rarer cases, the selected slot might be the latest full snapshot slot. We could
// just re-generate a new snapshot to make sure the snapshot is up to date after hard fork,
// but for now we just return an error to keep the code simple.
check_slot_smaller_than_intended_snapshot_slot(full_snapshot_slot, new_root_slot, directory)?;
Expand Down