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

Commit

Permalink
enforce rent_epoch to u64:max when rent collection is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
HaoranYi committed Nov 14, 2023
1 parent 52b84e5 commit 27bdf9d
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions accounts-db/src/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,16 +385,27 @@ impl Accounts {
self.accounts_db
.load_with_fixed_root(ancestors, key)
.map(|(mut account, _)| {
if should_collect_rent && message.is_writable(i) {
let rent_due = rent_collector
.collect_from_existing_account(
key,
&mut account,
self.accounts_db.filler_account_suffix.as_ref(),
set_exempt_rent_epoch_max,
)
.rent_amount;
(account.data().len(), account, rent_due)
if message.is_writable(i) {
if should_collect_rent {
let rent_due = rent_collector
.collect_from_existing_account(
key,
&mut account,
self.accounts_db.filler_account_suffix.as_ref(),
set_exempt_rent_epoch_max,
)
.rent_amount;

(account.data().len(), account, rent_due)
} else {
// All rent-exempt account will need to have its rent_epoch set to u64::max. This is done inside
// `collect_from_existing_account` when `should_collect_rent` is true. When rent collection is disabled,
// we should also enforce that the rent_epoch on these accounts is set to u64::MAX too.
if set_exempt_rent_epoch_max {
account.set_rent_epoch(u64::MAX);
}
(account.data().len(), account, 0)
}
} else {
(account.data().len(), account, 0)
}
Expand Down

0 comments on commit 27bdf9d

Please sign in to comment.