remove redundant EpochSchedule (#24444)

This commit is contained in:
Jeff Washington (jwash) 2022-04-18 13:04:48 -05:00 committed by GitHub
parent 9052e41b32
commit bcc5b96bda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 25 deletions

View File

@ -274,7 +274,6 @@ impl ExpectedRentCollection {
account: &mut AccountSharedData,
storage_slot: &SlotInfoInEpoch,
bank_slot: &SlotInfoInEpoch,
epoch_schedule: &EpochSchedule,
rent_collector: &RentCollector,
pubkey: &Pubkey,
rewrites_skipped_this_slot: &Rewrites,
@ -283,7 +282,6 @@ impl ExpectedRentCollection {
account,
storage_slot,
bank_slot,
epoch_schedule,
rent_collector,
pubkey,
rewrites_skipped_this_slot,
@ -301,7 +299,6 @@ impl ExpectedRentCollection {
account: &AccountSharedData,
storage_slot: &SlotInfoInEpoch,
bank_slot: &SlotInfoInEpoch,
epoch_schedule: &EpochSchedule,
rent_collector: &RentCollector,
pubkey: &Pubkey,
rewrites_skipped_this_slot: &Rewrites,
@ -315,10 +312,10 @@ impl ExpectedRentCollection {
}
// grab epoch infno for bank slot and storage slot
let bank_info = bank_slot.get_epoch_info(epoch_schedule);
let bank_info = bank_slot.get_epoch_info(&rent_collector.epoch_schedule);
let (current_epoch, partition_from_current_slot) =
(bank_info.epoch, bank_info.partition_index);
let storage_info = storage_slot.get_epoch_info(epoch_schedule);
let storage_info = storage_slot.get_epoch_info(&rent_collector.epoch_schedule);
let (storage_epoch, storage_slot_partition) =
(storage_info.epoch, storage_info.partition_index);
let partition_from_pubkey =
@ -393,7 +390,6 @@ impl ExpectedRentCollection {
loaded_hash: &Hash,
pubkey: &Pubkey,
storage_slot: Slot,
epoch_schedule: &EpochSchedule,
rent_collector: &RentCollector,
stats: &HashStats,
max_slot_in_storages_exclusive: Slot,
@ -404,7 +400,6 @@ impl ExpectedRentCollection {
pubkey,
loaded_account,
storage_slot,
epoch_schedule,
rent_collector,
max_slot_in_storages_exclusive,
find_unskipped_slot,
@ -443,21 +438,23 @@ impl ExpectedRentCollection {
pubkey: &Pubkey,
loaded_account: &impl ReadableAccount,
storage_slot: Slot,
epoch_schedule: &EpochSchedule,
rent_collector: &RentCollector,
max_slot_in_storages_exclusive: Slot,
find_unskipped_slot: impl Fn(Slot) -> Option<Slot>,
filler_account_suffix: Option<&Pubkey>,
) -> Option<Self> {
let slots_per_epoch = epoch_schedule.get_slots_in_epoch(rent_collector.epoch);
let slots_per_epoch = rent_collector
.epoch_schedule
.get_slots_in_epoch(rent_collector.epoch);
assert!(max_slot_in_storages_exclusive > 0);
let max_slot_in_storages = max_slot_in_storages_exclusive.saturating_sub(1);
let partition_from_pubkey =
crate::bank::Bank::partition_from_pubkey(pubkey, slots_per_epoch);
let (epoch_of_max_storage_slot, partition_index_from_max_slot) =
epoch_schedule.get_epoch_and_slot_index(max_slot_in_storages);
let (epoch_of_max_storage_slot, partition_index_from_max_slot) = rent_collector
.epoch_schedule
.get_epoch_and_slot_index(max_slot_in_storages);
// now, we have to find the root that is >= the slot where this pubkey's rent would have been collected
let first_slot_in_max_epoch = max_slot_in_storages - partition_index_from_max_slot;
@ -580,7 +577,6 @@ pub mod tests {
&pubkey,
&account,
storage_slot,
&epoch_schedule,
&rent_collector,
max_slot_in_storages_exclusive,
find_unskipped_slot,
@ -610,7 +606,6 @@ pub mod tests {
&pubkey,
&account,
storage_slot,
&epoch_schedule,
&rent_collector,
max_slot_in_storages_exclusive,
find_unskipped_slot,
@ -635,7 +630,6 @@ pub mod tests {
&pubkey,
&account,
expected_rent_collection_slot_max_epoch,
&epoch_schedule,
&rent_collector,
max_slot_in_storages_exclusive,
find_unskipped_slot,
@ -663,7 +657,6 @@ pub mod tests {
&pubkey,
&account,
expected_rent_collection_slot_max_epoch + if greater { 1 } else { 0 },
&epoch_schedule,
&rent_collector,
max_slot_in_storages_exclusive,
find_unskipped_slot,
@ -689,7 +682,6 @@ pub mod tests {
&pubkey,
&account,
expected_rent_collection_slot_max_epoch,
&epoch_schedule,
&rent_collector,
max_slot_in_storages_exclusive + if previous_epoch { slots_per_epoch } else { 0 },
find_unskipped_slot,
@ -723,7 +715,6 @@ pub mod tests {
&pubkey,
&account,
expected_rent_collection_slot_max_epoch,
&epoch_schedule,
&rent_collector,
max_slot_in_storages_exclusive,
find_unskipped_slot,
@ -763,7 +754,6 @@ pub mod tests {
pubkey,
&account,
storage_slot,
&epoch_schedule,
&rent_collector,
max_slot_in_storages_exclusive,
find_unskipped_slot,
@ -813,7 +803,6 @@ pub mod tests {
&pubkey,
&account,
storage_slot,
&epoch_schedule,
&rent_collector,
max_slot_in_storages_exclusive,
find_unskipped_slot,
@ -856,7 +845,6 @@ pub mod tests {
&pubkey,
&account,
storage_slot,
&epoch_schedule,
&rent_collector,
max_slot_in_storages_exclusive,
find_unskipped_slot,
@ -889,7 +877,6 @@ pub mod tests {
&pubkey,
&account,
storage_slot,
&epoch_schedule,
&rent_collector,
max_slot_in_storages_exclusive,
find_unskipped_slot,
@ -1018,7 +1005,6 @@ pub mod tests {
&pubkey,
&account,
storage_slot,
&epoch_schedule,
&rent_collector,
max_slot_in_storages_exclusive,
find_unskipped_slot,
@ -1052,7 +1038,6 @@ pub mod tests {
&pubkey,
&account,
storage_slot,
&epoch_schedule,
&rent_collector,
max_slot_in_storages_exclusive,
find_unskipped_slot,
@ -1083,7 +1068,6 @@ pub mod tests {
&hash,
&pubkey,
storage_slot,
&epoch_schedule,
&rent_collector,
&HashStats::default(),
max_slot_in_storages_exclusive,
@ -1241,7 +1225,6 @@ pub mod tests {
&account,
&get_slot_info(storage_slot),
&get_slot_info(bank_slot),
&epoch_schedule,
&rent_collector,
&pubkey,
&rewrites,