removes feature gate code preserving rent_epoch for rent exempt accounts (#28507)

* removes feature gate code preserving rent_epoch for rent exempt accounts

* update test expected hashes

Co-authored-by: jeff washington <jeff.washington@solana.com>
This commit is contained in:
behzad nouri 2022-11-01 13:36:59 +00:00 committed by GitHub
parent 4267a15292
commit 17680fe837
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 78 deletions

View File

@ -33,7 +33,7 @@ use {
account::{Account, AccountSharedData, ReadableAccount, WritableAccount},
account_utils::StateMut,
bpf_loader_upgradeable::{self, UpgradeableLoaderState},
clock::{BankId, Slot, INITIAL_RENT_EPOCH},
clock::{BankId, Slot},
feature_set::{
self, remove_deprecated_request_unit_ix, use_default_units_in_fee_calculation,
FeatureSet,
@ -272,8 +272,6 @@ impl Accounts {
let mut accounts = Vec::with_capacity(account_keys.len());
let mut account_deps = Vec::with_capacity(account_keys.len());
let mut rent_debits = RentDebits::default();
let preserve_rent_epoch_for_rent_exempt_accounts = feature_set
.is_active(&feature_set::preserve_rent_epoch_for_rent_exempt_accounts::id());
for (i, key) in account_keys.iter().enumerate() {
let account = if !message.is_non_loader_key(i) {
// Fill in an empty account for the program slots.
@ -301,7 +299,6 @@ impl Accounts {
key,
&mut account,
self.accounts_db.filler_account_suffix.as_ref(),
preserve_rent_epoch_for_rent_exempt_accounts,
)
.rent_amount;
(account, rent_due)
@ -1210,7 +1207,6 @@ impl Accounts {
rent_collector: &RentCollector,
durable_nonce: &DurableNonce,
lamports_per_signature: u64,
preserve_rent_epoch_for_rent_exempt_accounts: bool,
include_slot_in_hash: IncludeSlotInHash,
) {
let (accounts_to_store, txn_signatures) = self.collect_accounts_to_store(
@ -1220,7 +1216,6 @@ impl Accounts {
rent_collector,
durable_nonce,
lamports_per_signature,
preserve_rent_epoch_for_rent_exempt_accounts,
);
self.accounts_db.store_cached(
(slot, &accounts_to_store[..], include_slot_in_hash),
@ -1246,10 +1241,9 @@ impl Accounts {
txs: &'a [SanitizedTransaction],
execution_results: &'a [TransactionExecutionResult],
load_results: &'a mut [TransactionLoadResult],
rent_collector: &RentCollector,
_rent_collector: &RentCollector,
durable_nonce: &DurableNonce,
lamports_per_signature: u64,
preserve_rent_epoch_for_rent_exempt_accounts: bool,
) -> (
Vec<(&'a Pubkey, &'a AccountSharedData)>,
Vec<Option<&'a Signature>>,
@ -1303,24 +1297,6 @@ impl Accounts {
);
if execution_status.is_ok() || is_nonce_account || is_fee_payer {
if !preserve_rent_epoch_for_rent_exempt_accounts
&& account.rent_epoch() == INITIAL_RENT_EPOCH
{
let rent = rent_collector
.collect_from_created_account(
address,
account,
preserve_rent_epoch_for_rent_exempt_accounts,
)
.rent_amount;
loaded_transaction.rent += rent;
loaded_transaction.rent_debits.insert(
address,
rent,
account.lamports(),
);
}
// Add to the accounts to store
accounts.push((&*address, &*account));
signatures.push(Some(tx.signature()));
@ -3052,7 +3028,6 @@ mod tests {
&rent_collector,
&DurableNonce::default(),
0,
true, // preserve_rent_epoch_for_rent_exempt_accounts
);
assert_eq!(collected_accounts.len(), 2);
assert!(collected_accounts
@ -3536,7 +3511,6 @@ mod tests {
&rent_collector,
&durable_nonce,
0,
true, // preserve_rent_epoch_for_rent_exempt_accounts
);
assert_eq!(collected_accounts.len(), 2);
assert_eq!(
@ -3651,7 +3625,6 @@ mod tests {
&rent_collector,
&durable_nonce,
0,
true, // preserve_rent_epoch_for_rent_exempt_accounts
);
assert_eq!(collected_accounts.len(), 1);
let collected_nonce_account = collected_accounts

View File

@ -4892,7 +4892,6 @@ impl Bank {
&self.rent_collector,
&durable_nonce,
lamports_per_signature,
self.preserve_rent_epoch_for_rent_exempt_accounts(),
self.include_slot_in_hash(),
);
let rent_debits = self.collect_rent(&execution_results, loaded_txs);
@ -5321,15 +5320,12 @@ impl Bank {
let mut time_hashing_skipped_rewrites_us = 0;
let mut time_storing_accounts_us = 0;
let can_skip_rewrites = self.rc.accounts.accounts_db.skip_rewrites || just_rewrites;
let preserve_rent_epoch_for_rent_exempt_accounts =
self.preserve_rent_epoch_for_rent_exempt_accounts();
for (pubkey, account, _loaded_slot) in accounts.iter_mut() {
let (rent_collected_info, measure) =
measure!(self.rent_collector.collect_from_existing_account(
pubkey,
account,
self.rc.accounts.accounts_db.filler_account_suffix.as_ref(),
preserve_rent_epoch_for_rent_exempt_accounts,
));
time_collecting_rent_us += measure.as_us();
@ -7411,11 +7407,6 @@ impl Bank {
.is_active(&feature_set::send_to_tpu_vote_port::id())
}
fn preserve_rent_epoch_for_rent_exempt_accounts(&self) -> bool {
self.feature_set
.is_active(&feature_set::preserve_rent_epoch_for_rent_exempt_accounts::id())
}
pub fn read_cost_tracker(&self) -> LockResult<RwLockReadGuard<CostTracker>> {
self.cost_tracker.read()
}
@ -8415,7 +8406,6 @@ pub(crate) mod tests {
&keypairs[4].pubkey(),
&mut account_copy,
None,
true, // preserve_rent_epoch_for_rent_exempt_accounts
);
assert_eq!(expected_rent.rent_amount, too_few_lamports);
assert_eq!(account_copy.lamports(), 0);
@ -14508,13 +14498,13 @@ pub(crate) mod tests {
if bank.slot == 64 {
assert_eq!(
bank.hash().to_string(),
"4u8bxZRLYdQBkWRBwmpcwcQVMCJoEpzY7hCuAzxr3kCe"
"Ddk6ouAvSSA1U3Cw6BoKdM5v5LdRc9ShruGDzci9fKbY"
);
}
if bank.slot == 128 {
assert_eq!(
bank.hash().to_string(),
"4c5F8UbcDD8FM7qXcfv6BPPo6nHNYJQmN5gHiCMTdEzX"
"ANodC5vnedLWqeAyhcoErzR3ptNansb5YX6UTQ9cfP7S"
);
break;
}
@ -19864,7 +19854,6 @@ pub(crate) mod tests {
&keypair.pubkey(),
&mut account,
None,
true, // preserve_rent_epoch_for_rent_exempt_accounts
);
assert_eq!(info.account_data_len_reclaimed, data_size as u64);
}

View File

@ -125,14 +125,8 @@ impl RentCollector {
address: &Pubkey,
account: &mut AccountSharedData,
filler_account_suffix: Option<&Pubkey>,
preserve_rent_epoch_for_rent_exempt_accounts: bool,
) -> CollectedInfo {
match self.calculate_rent_result(
address,
account,
filler_account_suffix,
preserve_rent_epoch_for_rent_exempt_accounts,
) {
match self.calculate_rent_result(address, account, filler_account_suffix) {
RentResult::LeaveAloneNoRent => CollectedInfo::default(),
RentResult::CollectRent {
new_rent_epoch,
@ -164,7 +158,6 @@ impl RentCollector {
address: &Pubkey,
account: &impl ReadableAccount,
filler_account_suffix: Option<&Pubkey>,
preserve_rent_epoch_for_rent_exempt_accounts: bool,
) -> RentResult {
if self.can_skip_rent_collection(address, account, filler_account_suffix) {
return RentResult::LeaveAloneNoRent;
@ -172,16 +165,7 @@ impl RentCollector {
match self.get_rent_due(account) {
// Rent isn't collected for the next epoch.
// Make sure to check exempt status again later in current epoch.
RentDue::Exempt => {
if preserve_rent_epoch_for_rent_exempt_accounts {
RentResult::LeaveAloneNoRent
} else {
RentResult::CollectRent {
new_rent_epoch: self.epoch,
rent_due: 0,
}
}
}
RentDue::Exempt => RentResult::LeaveAloneNoRent,
// Maybe collect rent later, leave account alone.
RentDue::Paying(0) => RentResult::LeaveAloneNoRent,
// Rent is collected for next epoch.
@ -193,20 +177,15 @@ impl RentCollector {
}
#[must_use = "add to Bank::collected_rent"]
pub(crate) fn collect_from_created_account(
#[cfg(test)]
fn collect_from_created_account(
&self,
address: &Pubkey,
account: &mut AccountSharedData,
preserve_rent_epoch_for_rent_exempt_accounts: bool,
) -> CollectedInfo {
// initialize rent_epoch as created at this epoch
account.set_rent_epoch(self.epoch);
self.collect_from_existing_account(
address,
account,
None, // filler_account_suffix
preserve_rent_epoch_for_rent_exempt_accounts,
)
self.collect_from_existing_account(address, account, /*filler_account_suffix:*/ None)
}
/// Performs easy checks to see if rent collection can be skipped
@ -281,11 +260,8 @@ mod tests {
let rent_collector = default_rent_collector_clone_with_epoch(new_epoch);
// collect rent on a newly-created account
let collected = rent_collector.collect_from_created_account(
&solana_sdk::pubkey::new_rand(),
&mut created_account,
true, // preserve_rent_epoch_for_rent_exempt_accounts
);
let collected = rent_collector
.collect_from_created_account(&solana_sdk::pubkey::new_rand(), &mut created_account);
assert!(created_account.lamports() < old_lamports);
assert_eq!(
created_account.lamports() + collected.rent_amount,
@ -299,7 +275,6 @@ mod tests {
&solana_sdk::pubkey::new_rand(),
&mut existing_account,
None, // filler_account_suffix
true, // preserve_rent_epoch_for_rent_exempt_accounts
);
assert!(existing_account.lamports() < old_lamports);
assert_eq!(
@ -333,7 +308,6 @@ mod tests {
&pubkey,
&mut account,
None, // filler_account_suffix
true, // preserve_rent_epoch_for_rent_exempt_accounts
);
assert_eq!(account.lamports(), huge_lamports);
assert_eq!(collected, CollectedInfo::default());
@ -346,7 +320,6 @@ mod tests {
&pubkey,
&mut account,
None, // filler_account_suffix
true, // preserve_rent_epoch_for_rent_exempt_accounts
);
assert_eq!(account.lamports(), tiny_lamports - collected.rent_amount);
assert_ne!(collected, CollectedInfo::default());
@ -370,7 +343,6 @@ mod tests {
&pubkey,
&mut account,
None, // filler_account_suffix
true, // preserve_rent_epoch_for_rent_exempt_accounts
);
assert_eq!(account.lamports(), 0);
assert_eq!(collected.rent_amount, 1);
@ -395,7 +367,6 @@ mod tests {
&Pubkey::new_unique(),
&mut account,
None, // filler_account_suffix
true, // preserve_rent_epoch_for_rent_exempt_accounts
);
assert_eq!(collected.rent_amount, account_lamports);