filler accts: only add filler accts to slots in the current epoch (#21024)
This commit is contained in:
parent
7bb347faac
commit
e9ab214237
|
@ -52,7 +52,7 @@ use solana_measure::measure::Measure;
|
|||
use solana_rayon_threadlimit::get_thread_count;
|
||||
use solana_sdk::{
|
||||
account::{AccountSharedData, ReadableAccount},
|
||||
clock::{BankId, Epoch, Slot},
|
||||
clock::{BankId, Epoch, Slot, SlotCount},
|
||||
epoch_schedule::EpochSchedule,
|
||||
genesis_config::ClusterType,
|
||||
hash::{Hash, Hasher},
|
||||
|
@ -6761,6 +6761,14 @@ impl AccountsDb {
|
|||
Self::is_filler_account_helper(pubkey, self.filler_account_suffix.as_ref())
|
||||
}
|
||||
|
||||
/// retain slots in 'roots' that are > (max(roots) - slots_per_epoch)
|
||||
fn retain_roots_within_one_epoch_range(roots: &mut Vec<Slot>, slots_per_epoch: SlotCount) {
|
||||
if let Some(max) = roots.iter().max() {
|
||||
let min = max - slots_per_epoch;
|
||||
roots.retain(|slot| slot > &min);
|
||||
}
|
||||
}
|
||||
|
||||
/// filler accounts are space-holding accounts which are ignored by hash calculations and rent.
|
||||
/// They are designed to allow a validator to run against a network successfully while simulating having many more accounts present.
|
||||
/// All filler accounts share a common pubkey suffix. The suffix is randomly generated per validator on startup.
|
||||
|
@ -6775,7 +6783,8 @@ impl AccountsDb {
|
|||
info!("adding {} filler accounts", self.filler_account_count);
|
||||
// break this up to force the accounts out of memory after each pass
|
||||
let passes = 100;
|
||||
let roots = self.storage.all_slots();
|
||||
let mut roots = self.storage.all_slots();
|
||||
Self::retain_roots_within_one_epoch_range(&mut roots, epoch_schedule.slots_per_epoch);
|
||||
let root_count = roots.len();
|
||||
let per_pass = std::cmp::max(1, root_count / passes);
|
||||
let overall_index = AtomicUsize::new(0);
|
||||
|
@ -7374,6 +7383,14 @@ pub mod tests {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_retain_roots_within_one_epoch_range() {
|
||||
let mut roots = vec![0, 1, 2];
|
||||
let slots_per_epoch = 2;
|
||||
AccountsDb::retain_roots_within_one_epoch_range(&mut roots, slots_per_epoch);
|
||||
assert_eq!(&vec![1, 2], &roots);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic(
|
||||
expected = "bin_range.start < bins && bin_range.end <= bins &&\\n bin_range.start < bin_range.end"
|
||||
|
|
|
@ -4546,6 +4546,8 @@ impl Bank {
|
|||
Self::get_partitions(self.slot(), self.parent_slot(), slot_count_in_two_day)
|
||||
}
|
||||
|
||||
/// used only by filler accounts in debug path
|
||||
/// previous means slot - 1, not parent
|
||||
pub fn variable_cycle_partition_from_previous_slot(
|
||||
epoch_schedule: &EpochSchedule,
|
||||
slot: Slot,
|
||||
|
@ -4630,7 +4632,7 @@ impl Bank {
|
|||
)
|
||||
}
|
||||
|
||||
pub fn get_partition_from_slot_indexes(
|
||||
fn get_partition_from_slot_indexes(
|
||||
cycle_params: RentCollectionCycleParams,
|
||||
start_slot_index: SlotIndex,
|
||||
end_slot_index: SlotIndex,
|
||||
|
@ -4705,7 +4707,7 @@ impl Bank {
|
|||
self.do_partition_from_slot_indexes(start_slot_index, end_slot_index, epoch, true)
|
||||
}
|
||||
|
||||
pub fn rent_single_epoch_collection_cycle_params(
|
||||
fn rent_single_epoch_collection_cycle_params(
|
||||
epoch: Epoch,
|
||||
slot_count_per_epoch: SlotCount,
|
||||
) -> RentCollectionCycleParams {
|
||||
|
|
Loading…
Reference in New Issue