From 158c4e05d5e60c5f5b3dc8e47f5f60a90beca6e1 Mon Sep 17 00:00:00 2001 From: "Jeff Washington (jwash)" Date: Mon, 11 Mar 2024 12:21:51 -0500 Subject: [PATCH] remove dead code (#176) --- accounts-db/src/accounts_partition.rs | 30 --------------------------- runtime/src/bank/tests.rs | 28 ++++--------------------- 2 files changed, 4 insertions(+), 54 deletions(-) diff --git a/accounts-db/src/accounts_partition.rs b/accounts-db/src/accounts_partition.rs index 05d3993adcfb70..01d6929c3e07e5 100644 --- a/accounts-db/src/accounts_partition.rs +++ b/accounts-db/src/accounts_partition.rs @@ -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. diff --git a/runtime/src/bank/tests.rs b/runtime/src/bank/tests.rs index f9b846d85b1512..29dbdc2e5aeacd 100644 --- a/runtime/src/bank/tests.rs +++ b/runtime/src/bank/tests.rs @@ -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 { - 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; @@ -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]