Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
add a feature to disable rent collection
Browse files Browse the repository at this point in the history
  • Loading branch information
HaoranYi committed Nov 7, 2023
1 parent b8115b4 commit 814fc47
Show file tree
Hide file tree
Showing 7 changed files with 305 additions and 26 deletions.
6 changes: 6 additions & 0 deletions accounts-db/src/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ impl Accounts {
reward_interval: RewardInterval,
program_accounts: &HashMap<Pubkey, (&Pubkey, u64)>,
loaded_programs: &LoadedProgramsForTxBatch,
disable_rent_collection: bool,
) -> Result<LoadedTransaction> {
let in_reward_interval = reward_interval == RewardInterval::InsideInterval;

Expand Down Expand Up @@ -391,6 +392,7 @@ impl Accounts {
&mut account,
self.accounts_db.filler_account_suffix.as_ref(),
set_exempt_rent_epoch_max,
disable_rent_collection,
)
.rent_amount;
(account.data().len(), account, rent_due)
Expand Down Expand Up @@ -706,6 +708,7 @@ impl Accounts {
in_reward_interval: RewardInterval,
program_accounts: &HashMap<Pubkey, (&Pubkey, u64)>,
loaded_programs: &LoadedProgramsForTxBatch,
disable_rent_collection: bool,
) -> Vec<TransactionLoadResult> {
txs.iter()
.zip(lock_results)
Expand Down Expand Up @@ -740,6 +743,7 @@ impl Accounts {
in_reward_interval,
program_accounts,
loaded_programs,
disable_rent_collection,
) {
Ok(loaded_transaction) => loaded_transaction,
Err(e) => return (Err(e), None),
Expand Down Expand Up @@ -1564,6 +1568,7 @@ mod tests {
RewardInterval::OutsideInterval,
&HashMap::new(),
&LoadedProgramsForTxBatch::default(),
false,
)
}

Expand Down Expand Up @@ -3377,6 +3382,7 @@ mod tests {
RewardInterval::OutsideInterval,
&HashMap::new(),
&LoadedProgramsForTxBatch::default(),
false,
)
}

Expand Down
2 changes: 1 addition & 1 deletion accounts-db/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9000,7 +9000,7 @@ impl AccountsDb {
return None;
}
(rent_collector.should_collect_rent(pubkey, account)
&& !rent_collector.get_rent_due(account).is_exempt())
&& !rent_collector.get_rent_due(account, false).is_exempt())
.then(|| {
let min_balance = rent_collector.rent.minimum_balance(account.data().len());
// return lamports required to top off this account to make it rent exempt
Expand Down
Loading

0 comments on commit 814fc47

Please sign in to comment.