Skip to content

Commit

Permalink
sanitized_epoch in scheduler controller
Browse files Browse the repository at this point in the history
  • Loading branch information
apfitzge committed Nov 5, 2024
1 parent 53a98e0 commit c86020c
Showing 1 changed file with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -512,9 +512,7 @@ impl<T: LikeClusterInfo> SchedulerController<T> {
(root_bank, working_bank)
};
let alt_resolved_slot = root_bank.slot();
let last_slot_in_epoch = root_bank
.epoch_schedule()
.get_last_slot_in_epoch(root_bank.epoch());
let sanitized_epoch = root_bank.epoch();
let transaction_account_lock_limit = working_bank.get_transaction_account_lock_limit();
let vote_only = working_bank.vote_only_bank();

Expand Down Expand Up @@ -559,7 +557,7 @@ impl<T: LikeClusterInfo> SchedulerController<T> {
arc_packets.push(packet);
transactions.push(tx);
max_ages.push(calculate_max_age(
last_slot_in_epoch,
sanitized_epoch,
deactivation_slot,
alt_resolved_slot,
));
Expand Down Expand Up @@ -701,10 +699,14 @@ impl<T: LikeClusterInfo> SchedulerController<T> {
/// slots, the value used here is the lower-bound on the deactivation
/// period, i.e. the transaction's address lookups are valid until
/// AT LEAST this slot.
fn calculate_max_age(resolved_epoch: Epoch, deactivation_slot: Slot, current_slot: Slot) -> MaxAge {
fn calculate_max_age(
sanitized_epoch: Epoch,
deactivation_slot: Slot,
current_slot: Slot,
) -> MaxAge {
let alt_min_expire_slot = estimate_last_valid_slot(deactivation_slot.min(current_slot));
MaxAge {
sanitized_epoch: resolved_epoch,
sanitized_epoch,
alt_invalidation_slot: alt_min_expire_slot,
}
}
Expand Down Expand Up @@ -1216,11 +1218,11 @@ mod tests {
#[test]
fn test_calculate_max_age() {
let current_slot = 100;
let resolved_epoch = 10;
let sanitized_epoch = 10;

// ALT deactivation slot is delayed
assert_eq!(
calculate_max_age(resolved_epoch, current_slot - 1, current_slot),
calculate_max_age(sanitized_epoch, current_slot - 1, current_slot),
MaxAge {
sanitized_epoch,
alt_invalidation_slot: current_slot - 1
Expand All @@ -1230,7 +1232,7 @@ mod tests {

// no deactivation slot
assert_eq!(
calculate_max_age(resolved_epoch, u64::MAX, current_slot),
calculate_max_age(sanitized_epoch, u64::MAX, current_slot),
MaxAge {
sanitized_epoch,
alt_invalidation_slot: current_slot + solana_sdk::slot_hashes::get_entries() as u64,
Expand Down

0 comments on commit c86020c

Please sign in to comment.