Skip to content

Commit

Permalink
remove dead code (#176)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffwashington authored and willhickey committed Mar 16, 2024
1 parent f5e13a1 commit ad42beb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 54 deletions.
30 changes: 0 additions & 30 deletions accounts-db/src/accounts_partition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,36 +98,6 @@ pub fn get_partition_from_slot_indexes(
(start_partition_index, end_partition_index, partition_count)
}

/// used only by filler accounts in debug path
/// previous means slot - 1, not parent
// These functions/fields are only usable from a dev context (i.e. tests and benches)
#[cfg(feature = "dev-context-only-utils")]
pub fn variable_cycle_partition_from_previous_slot(
epoch_schedule: &EpochSchedule,
slot: Slot,
) -> Partition {
// similar code to Bank::variable_cycle_partitions
let (current_epoch, current_slot_index) = epoch_schedule.get_epoch_and_slot_index(slot);
let (parent_epoch, mut parent_slot_index) =
epoch_schedule.get_epoch_and_slot_index(slot.saturating_sub(1));
let cycle_params = rent_single_epoch_collection_cycle_params(
current_epoch,
epoch_schedule.get_slots_in_epoch(current_epoch),
);

if parent_epoch < current_epoch {
parent_slot_index = 0;
}

let generated_for_gapped_epochs = false;
get_partition_from_slot_indexes(
cycle_params,
parent_slot_index,
current_slot_index,
generated_for_gapped_epochs,
)
}

/// return all end partition indexes for the given partition
/// partition could be (0, 1, N). In this case we only return [1]
/// the single 'end_index' that covers this partition.
Expand Down
28 changes: 4 additions & 24 deletions runtime/src/bank/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1279,26 +1279,6 @@ fn test_rent_complex() {
assert_eq!(bank.collected_rent.load(Relaxed), rent_collected);
}

fn test_rent_collection_partitions(bank: &Bank) -> Vec<Partition> {
let partitions = bank.rent_collection_partitions();
let slot = bank.slot();
if slot.saturating_sub(1) == bank.parent_slot() {
let partition = accounts_partition::variable_cycle_partition_from_previous_slot(
bank.epoch_schedule(),
bank.slot(),
);
assert_eq!(
partitions.last().unwrap(),
&partition,
"slot: {}, slots per epoch: {}, partitions: {:?}",
bank.slot(),
bank.epoch_schedule().slots_per_epoch,
partitions
);
}
partitions
}

#[test]
fn test_rent_eager_across_epoch_without_gap() {
let mut bank = create_simple_test_arc_bank(1).0;
Expand All @@ -1321,16 +1301,16 @@ fn test_rent_eager_across_epoch_without_gap_mnb() {
genesis_config.cluster_type = ClusterType::MainnetBeta;

let mut bank = Arc::new(Bank::new_for_tests(&genesis_config));
assert_eq!(test_rent_collection_partitions(&bank), vec![(0, 0, 32)]);
assert_eq!(bank.rent_collection_partitions(), vec![(0, 0, 32)]);

bank = Arc::new(new_from_parent(bank));
assert_eq!(test_rent_collection_partitions(&bank), vec![(0, 1, 32)]);
assert_eq!(bank.rent_collection_partitions(), vec![(0, 1, 32)]);
for _ in 2..32 {
bank = Arc::new(new_from_parent(bank));
}
assert_eq!(test_rent_collection_partitions(&bank), vec![(30, 31, 32)]);
assert_eq!(bank.rent_collection_partitions(), vec![(30, 31, 32)]);
bank = Arc::new(new_from_parent(bank));
assert_eq!(test_rent_collection_partitions(&bank), vec![(0, 0, 64)]);
assert_eq!(bank.rent_collection_partitions(), vec![(0, 0, 64)]);
}

#[test]
Expand Down

0 comments on commit ad42beb

Please sign in to comment.