Skip to content

Commit

Permalink
Remove SVM dependency on Bank::should_collect_rent() (solana-labs#35011)
Browse files Browse the repository at this point in the history
  • Loading branch information
pgarg66 authored Jan 30, 2024
1 parent d5ab2fa commit c6c2340
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
1 change: 0 additions & 1 deletion runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5370,7 +5370,6 @@ impl Bank {
self.get_reward_interval(),
&program_accounts_map,
&programs_loaded_for_tx_batch.borrow(),
self.should_collect_rent(),
);
load_time.stop();

Expand Down
1 change: 0 additions & 1 deletion runtime/src/bank/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10998,7 +10998,6 @@ fn test_rent_state_list_len() {
RewardInterval::OutsideInterval,
&HashMap::new(),
&LoadedProgramsForTxBatch::default(),
true,
);

let compute_budget = bank.runtime_config.compute_budget.unwrap_or_else(|| {
Expand Down
22 changes: 10 additions & 12 deletions runtime/src/svm/account_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use {
create_executable_meta, is_builtin, is_executable, Account, AccountSharedData,
ReadableAccount, WritableAccount,
},
feature_set::{include_loaded_accounts_data_size_in_fee_calculation, FeatureSet},
feature_set::{self, include_loaded_accounts_data_size_in_fee_calculation, FeatureSet},
fee::FeeStructure,
message::SanitizedMessage,
native_loader,
Expand Down Expand Up @@ -52,7 +52,6 @@ pub(crate) fn load_accounts(
in_reward_interval: RewardInterval,
program_accounts: &HashMap<Pubkey, (&Pubkey, u64)>,
loaded_programs: &LoadedProgramsForTxBatch,
should_collect_rent: bool,
) -> Vec<TransactionLoadResult> {
txs.iter()
.zip(lock_results)
Expand Down Expand Up @@ -87,7 +86,6 @@ pub(crate) fn load_accounts(
in_reward_interval,
program_accounts,
loaded_programs,
should_collect_rent,
) {
Ok(loaded_transaction) => loaded_transaction,
Err(e) => return (Err(e), None),
Expand Down Expand Up @@ -128,7 +126,6 @@ fn load_transaction_accounts(
reward_interval: RewardInterval,
program_accounts: &HashMap<Pubkey, (&Pubkey, u64)>,
loaded_programs: &LoadedProgramsForTxBatch,
should_collect_rent: bool,
) -> Result<LoadedTransaction> {
let in_reward_interval = reward_interval == RewardInterval::InsideInterval;

Expand Down Expand Up @@ -190,7 +187,9 @@ fn load_transaction_accounts(
.load_with_fixed_root(ancestors, key)
.map(|(mut account, _)| {
if message.is_writable(i) {
if should_collect_rent {
if !feature_set
.is_active(&feature_set::disable_rent_fees_collection::id())
{
let rent_due = rent_collector
.collect_from_existing_account(
key,
Expand Down Expand Up @@ -514,7 +513,7 @@ mod tests {
lamports_per_signature: u64,
rent_collector: &RentCollector,
error_counters: &mut TransactionErrorMetrics,
feature_set: &FeatureSet,
feature_set: &mut FeatureSet,
fee_structure: &FeeStructure,
) -> Vec<TransactionLoadResult> {
let accounts_db = AccountsDb::new_single_for_tests();
Expand All @@ -524,6 +523,7 @@ mod tests {
}

let ancestors = vec![(0, 0)].into_iter().collect();
feature_set.deactivate(&feature_set::disable_rent_fees_collection::id());
let sanitized_tx = SanitizedTransaction::from_transaction_for_tests(tx);
load_accounts(
&accounts.accounts_db,
Expand All @@ -538,7 +538,6 @@ mod tests {
RewardInterval::OutsideInterval,
&HashMap::new(),
&LoadedProgramsForTxBatch::default(),
true,
)
}

Expand All @@ -565,7 +564,7 @@ mod tests {
lamports_per_signature,
&RentCollector::default(),
error_counters,
&all_features_except(exclude_features),
&mut all_features_except(exclude_features),
&FeeStructure {
lamports_per_signature,
..FeeStructure::default()
Expand Down Expand Up @@ -768,7 +767,7 @@ mod tests {
lamports_per_signature,
&rent_collector,
&mut error_counters,
&all_features_except(None),
&mut all_features_except(None),
&FeeStructure::default(),
);
assert_eq!(loaded_accounts.len(), 1);
Expand All @@ -784,7 +783,7 @@ mod tests {
lamports_per_signature,
&rent_collector,
&mut error_counters,
&FeatureSet::all_enabled(),
&mut FeatureSet::all_enabled(),
&FeeStructure::default(),
);
assert_eq!(loaded_accounts.len(), 1);
Expand All @@ -801,7 +800,7 @@ mod tests {
lamports_per_signature,
&rent_collector,
&mut error_counters,
&FeatureSet::all_enabled(),
&mut FeatureSet::all_enabled(),
&FeeStructure::default(),
);
assert_eq!(loaded_accounts.len(), 1);
Expand Down Expand Up @@ -1013,7 +1012,6 @@ mod tests {
RewardInterval::OutsideInterval,
&HashMap::new(),
&LoadedProgramsForTxBatch::default(),
true,
)
}

Expand Down

0 comments on commit c6c2340

Please sign in to comment.