use correct epoch schedule (#24904)

This commit is contained in:
Jeff Washington (jwash) 2022-05-03 09:21:47 -05:00 committed by GitHub
parent 503d0baf6d
commit 755100dd7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 6 deletions

View File

@ -5210,6 +5210,7 @@ impl AccountsDb {
&loaded_hash,
pubkey,
*slot,
config.epoch_schedule,
config.rent_collector,
&stats,
max_slot,
@ -5758,6 +5759,7 @@ impl AccountsDb {
&loaded_hash,
pubkey,
slot,
config.epoch_schedule,
config.rent_collector,
stats,
storage.range().end.saturating_sub(1), // 'end' is exclusive, convert to inclusive

View File

@ -386,6 +386,7 @@ impl ExpectedRentCollection {
loaded_hash: &Hash,
pubkey: &Pubkey,
storage_slot: Slot,
epoch_schedule: &EpochSchedule,
rent_collector: &RentCollector,
stats: &HashStats,
max_slot_in_storages_inclusive: Slot,
@ -398,6 +399,7 @@ impl ExpectedRentCollection {
pubkey,
loaded_account,
storage_slot,
epoch_schedule,
rent_collector,
max_slot_in_storages_inclusive,
find_unskipped_slot,
@ -442,20 +444,18 @@ impl ExpectedRentCollection {
pubkey: &Pubkey,
loaded_account: &impl ReadableAccount,
storage_slot: Slot,
epoch_schedule: &EpochSchedule,
rent_collector: &RentCollector,
max_slot_in_storages_inclusive: Slot,
find_unskipped_slot: impl Fn(Slot) -> Option<Slot>,
filler_account_suffix: Option<&Pubkey>,
) -> Option<Self> {
let slots_per_epoch = rent_collector
.epoch_schedule
.get_slots_in_epoch(rent_collector.epoch);
let slots_per_epoch = epoch_schedule.get_slots_in_epoch(rent_collector.epoch);
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) = rent_collector
.epoch_schedule
.get_epoch_and_slot_index(max_slot_in_storages_inclusive);
let (epoch_of_max_storage_slot, partition_index_from_max_slot) =
epoch_schedule.get_epoch_and_slot_index(max_slot_in_storages_inclusive);
// 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 =
@ -579,6 +579,7 @@ pub mod tests {
&pubkey,
&account,
storage_slot,
&epoch_schedule,
&rent_collector,
max_slot_in_storages_inclusive,
find_unskipped_slot,
@ -606,6 +607,7 @@ pub mod tests {
&pubkey,
&account,
storage_slot,
&epoch_schedule,
&rent_collector,
max_slot_in_storages_inclusive,
find_unskipped_slot,
@ -630,6 +632,7 @@ pub mod tests {
&pubkey,
&account,
expected_rent_collection_slot_max_epoch,
&epoch_schedule,
&rent_collector,
max_slot_in_storages_inclusive,
find_unskipped_slot,
@ -657,6 +660,7 @@ pub mod tests {
&pubkey,
&account,
expected_rent_collection_slot_max_epoch + if greater { 1 } else { 0 },
&epoch_schedule,
&rent_collector,
max_slot_in_storages_inclusive,
find_unskipped_slot,
@ -682,6 +686,7 @@ pub mod tests {
&pubkey,
&account,
expected_rent_collection_slot_max_epoch,
&epoch_schedule,
&rent_collector,
max_slot_in_storages_inclusive + if previous_epoch { slots_per_epoch } else { 0 },
find_unskipped_slot,
@ -715,6 +720,7 @@ pub mod tests {
&pubkey,
&account,
expected_rent_collection_slot_max_epoch,
&epoch_schedule,
&rent_collector,
max_slot_in_storages_inclusive,
find_unskipped_slot,
@ -754,6 +760,7 @@ pub mod tests {
pubkey,
&account,
storage_slot,
&epoch_schedule,
&rent_collector,
max_slot_in_storages_inclusive,
find_unskipped_slot,
@ -803,6 +810,7 @@ pub mod tests {
&pubkey,
&account,
storage_slot,
&epoch_schedule,
&rent_collector,
max_slot_in_storages_inclusive,
find_unskipped_slot,
@ -845,6 +853,7 @@ pub mod tests {
&pubkey,
&account,
storage_slot,
&epoch_schedule,
&rent_collector,
max_slot_in_storages_inclusive,
find_unskipped_slot,
@ -877,6 +886,7 @@ pub mod tests {
&pubkey,
&account,
storage_slot,
&epoch_schedule,
&rent_collector,
max_slot_in_storages_inclusive,
find_unskipped_slot,
@ -1004,6 +1014,7 @@ pub mod tests {
&pubkey,
&account,
storage_slot,
&epoch_schedule,
&rent_collector,
max_slot_in_storages_inclusive,
find_unskipped_slot,
@ -1037,6 +1048,7 @@ pub mod tests {
&pubkey,
&account,
storage_slot,
&epoch_schedule,
&rent_collector,
max_slot_in_storages_inclusive,
find_unskipped_slot,
@ -1067,6 +1079,7 @@ pub mod tests {
&hash,
&pubkey,
storage_slot,
&epoch_schedule,
&rent_collector,
&HashStats::default(),
max_slot_in_storages_inclusive,