Skip to content

Commit

Permalink
feat: disable partitioned rent
Browse files Browse the repository at this point in the history
  • Loading branch information
jstarry committed Jan 22, 2025
1 parent 018699f commit d7dd58f
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 2 deletions.
11 changes: 9 additions & 2 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ use {
solana_compute_budget_instruction::instructions_processor::process_compute_budget_instructions,
solana_cost_model::{block_cost_limits::simd_0207_block_limits, cost_tracker::CostTracker},
solana_feature_set::{
self as feature_set, remove_rounding_in_fee_calculation, reward_full_priority_fee,
FeatureSet,
self as feature_set, disable_partitioned_rent_collection,
remove_rounding_in_fee_calculation, reward_full_priority_fee, FeatureSet,
},
solana_lattice_hash::lt_hash::LtHash,
solana_measure::{meas_dur, measure::Measure, measure_time, measure_us},
Expand Down Expand Up @@ -3995,6 +3995,13 @@ impl Bank {
return;
}

if self
.feature_set
.is_active(&disable_partitioned_rent_collection::id())
{
return;
}

let mut measure = Measure::start("collect_rent_eagerly-ms");
let partitions = self.rent_collection_partitions();
let count = partitions.len();
Expand Down
42 changes: 42 additions & 0 deletions runtime/src/bank/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11852,6 +11852,48 @@ fn test_get_rent_paying_pubkeys() {
);
}

/// Ensure that accounts rent epoch is updated correctly by rent collection
#[test_case(true; "enable partitioned rent fees collection")]
#[test_case(false; "disable partitioned rent fees collection")]
fn test_partitioned_rent_collection(should_run_partitioned_rent_collection: bool) {
let GenesisConfigInfo {
mut genesis_config, ..
} = genesis_utils::create_genesis_config(100 * LAMPORTS_PER_SOL);
genesis_config.rent = Rent::default();
if should_run_partitioned_rent_collection {
genesis_config
.accounts
.remove(&solana_feature_set::disable_partitioned_rent_collection::id());
}

let bank = Arc::new(Bank::new_for_tests(&genesis_config));

let slot = bank.slot() + bank.slot_count_per_normal_epoch();
let bank = Arc::new(Bank::new_from_parent(bank, &Pubkey::default(), slot));

// make another bank so that any reclaimed accounts from the previous bank do not impact
// this test
let slot = bank.slot() + bank.slot_count_per_normal_epoch();
let bank: Arc<Bank> = Arc::new(Bank::new_from_parent(bank, &Pubkey::default(), slot));

// Store an account into the bank that is rent-exempt
let rent_exempt_balance = genesis_config.rent.minimum_balance(0);
let account_pubkey = Pubkey::new_unique();
let account = AccountSharedData::new(rent_exempt_balance, 0, &Pubkey::default());
bank.store_account(&account_pubkey, &account);

// Run partitioned rent collection. If enabled, partitioned rent collection
// will update the rent epoch for any rent exempt accounts whose rent epoch
// is not already set to RENT_EXEMPT_RENT_EPOCH.
bank.collect_rent_eagerly();
let updated_account = bank.get_account(&account_pubkey).unwrap();
if should_run_partitioned_rent_collection {
assert_eq!(updated_account.rent_epoch(), RENT_EXEMPT_RENT_EPOCH);
} else {
assert_eq!(updated_account.rent_epoch(), INITIAL_RENT_EPOCH);
}
}

/// Ensure that accounts data size is updated correctly by rent collection
#[test_case(true; "enable rent fees collection")]
#[test_case(false; "disable rent fees collection")]
Expand Down
5 changes: 5 additions & 0 deletions sdk/feature-set/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,10 @@ pub mod reserve_minimal_cus_for_builtin_instructions {
solana_pubkey::declare_id!("C9oAhLxDBm3ssWtJx1yBGzPY55r2rArHmN1pbQn6HogH");
}

pub mod disable_partitioned_rent_collection {
solana_pubkey::declare_id!("2B2SBNbUcr438LtGXNcJNBP2GBSxjx81F945SdSkUSfC");
}

pub mod raise_block_limits_to_50m {
solana_pubkey::declare_id!("5oMCU3JPaFLr8Zr4ct7yFA7jdk6Mw1RmB8K4u9ZbS42z");
}
Expand Down Expand Up @@ -1144,6 +1148,7 @@ lazy_static! {
(migrate_stake_program_to_core_bpf::id(), "Migrate Stake program to Core BPF SIMD-0196 #3655"),
(deplete_cu_meter_on_vm_failure::id(), "Deplete compute meter for vm errors SIMD-0182 #3993"),
(reserve_minimal_cus_for_builtin_instructions::id(), "Reserve minimal CUs for builtin instructions SIMD-170 #2562"),
(disable_partitioned_rent_collection::id(), "Disable partitioned rent collection SIMD-0175 #4562"),
(raise_block_limits_to_50m::id(), "Raise block limit to 50M SIMD-0207"),
/*************** ADD NEW FEATURES HERE ***************/
]
Expand Down

0 comments on commit d7dd58f

Please sign in to comment.