feature: don't do rewrites in rent collection (#26491)
* feature: don't do rewrites in rent collection * modify test to specifically test this feature
This commit is contained in:
parent
d41da2178c
commit
a703019caa
|
@ -7612,7 +7612,10 @@ impl AccountsDb {
|
||||||
/// 1. pubkey, hash pairs for the slot
|
/// 1. pubkey, hash pairs for the slot
|
||||||
/// 2. us spent scanning
|
/// 2. us spent scanning
|
||||||
/// 3. Measure started when we began accumulating
|
/// 3. Measure started when we began accumulating
|
||||||
fn get_pubkey_hash_for_slot(&self, slot: Slot) -> (Vec<(Pubkey, Hash)>, u64, Measure) {
|
pub(crate) fn get_pubkey_hash_for_slot(
|
||||||
|
&self,
|
||||||
|
slot: Slot,
|
||||||
|
) -> (Vec<(Pubkey, Hash)>, u64, Measure) {
|
||||||
let mut scan = Measure::start("scan");
|
let mut scan = Measure::start("scan");
|
||||||
|
|
||||||
let scan_result: ScanStorageResult<(Pubkey, Hash), DashMapVersionHash> = self
|
let scan_result: ScanStorageResult<(Pubkey, Hash), DashMapVersionHash> = self
|
||||||
|
|
|
@ -5342,6 +5342,15 @@ impl Bank {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// true if rent collection does NOT rewrite accounts whose pubkey indicates
|
||||||
|
/// it is time for rent collection, but the account is rent exempt.
|
||||||
|
/// false if rent collection DOES rewrite accounts if the account is rent exempt
|
||||||
|
/// This is the default behavior historically.
|
||||||
|
fn bank_hash_skips_rent_rewrites(&self) -> bool {
|
||||||
|
self.feature_set
|
||||||
|
.is_active(&feature_set::skip_rent_rewrites::id())
|
||||||
|
}
|
||||||
|
|
||||||
/// Collect rent from `accounts`
|
/// Collect rent from `accounts`
|
||||||
///
|
///
|
||||||
/// This fn is called inside a parallel loop from `collect_rent_in_partition()`. Avoid adding
|
/// This fn is called inside a parallel loop from `collect_rent_in_partition()`. Avoid adding
|
||||||
|
@ -5363,7 +5372,7 @@ impl Bank {
|
||||||
Vec::<(&Pubkey, &AccountSharedData)>::with_capacity(accounts.len());
|
Vec::<(&Pubkey, &AccountSharedData)>::with_capacity(accounts.len());
|
||||||
let mut time_collecting_rent_us = 0;
|
let mut time_collecting_rent_us = 0;
|
||||||
let mut time_storing_accounts_us = 0;
|
let mut time_storing_accounts_us = 0;
|
||||||
let can_skip_rewrites = false; // this will be goverened by a feature soon
|
let can_skip_rewrites = self.bank_hash_skips_rent_rewrites();
|
||||||
let set_exempt_rent_epoch_max: bool = self
|
let set_exempt_rent_epoch_max: bool = self
|
||||||
.feature_set
|
.feature_set
|
||||||
.is_active(&solana_sdk::feature_set::set_exempt_rent_epoch_max::id());
|
.is_active(&solana_sdk::feature_set::set_exempt_rent_epoch_max::id());
|
||||||
|
@ -10046,10 +10055,16 @@ pub(crate) mod tests {
|
||||||
fn test_collect_rent_from_accounts() {
|
fn test_collect_rent_from_accounts() {
|
||||||
solana_logger::setup();
|
solana_logger::setup();
|
||||||
|
|
||||||
|
for skip_rewrites in [false, true] {
|
||||||
let zero_lamport_pubkey = Pubkey::new(&[0; 32]);
|
let zero_lamport_pubkey = Pubkey::new(&[0; 32]);
|
||||||
|
|
||||||
let genesis_bank = create_simple_test_arc_bank(100000);
|
let genesis_bank = create_simple_test_arc_bank(100000);
|
||||||
let first_bank = Arc::new(new_from_parent(&genesis_bank));
|
let mut first_bank = new_from_parent(&genesis_bank);
|
||||||
|
if skip_rewrites {
|
||||||
|
first_bank.activate_feature(&feature_set::skip_rent_rewrites::id());
|
||||||
|
}
|
||||||
|
let first_bank = Arc::new(first_bank);
|
||||||
|
|
||||||
let first_slot = 1;
|
let first_slot = 1;
|
||||||
assert_eq!(first_slot, first_bank.slot());
|
assert_eq!(first_slot, first_bank.slot());
|
||||||
let epoch_delta = 4;
|
let epoch_delta = 4;
|
||||||
|
@ -10068,6 +10083,20 @@ pub(crate) mod tests {
|
||||||
None,
|
None,
|
||||||
PartitionIndex::default(),
|
PartitionIndex::default(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let deltas = later_bank
|
||||||
|
.rc
|
||||||
|
.accounts
|
||||||
|
.accounts_db
|
||||||
|
.get_pubkey_hash_for_slot(later_slot)
|
||||||
|
.0;
|
||||||
|
assert_eq!(
|
||||||
|
!deltas
|
||||||
|
.iter()
|
||||||
|
.any(|(pubkey, _)| pubkey == &zero_lamport_pubkey),
|
||||||
|
skip_rewrites
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -462,6 +462,10 @@ pub mod enable_early_verification_of_account_modifications {
|
||||||
solana_sdk::declare_id!("7Vced912WrRnfjaiKRiNBcbuFw7RrnLv3E3z95Y4GTNc");
|
solana_sdk::declare_id!("7Vced912WrRnfjaiKRiNBcbuFw7RrnLv3E3z95Y4GTNc");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub mod skip_rent_rewrites {
|
||||||
|
solana_sdk::declare_id!("CGB2jM8pwZkeeiXQ66kBMyBR6Np61mggL7XUsmLjVcrw");
|
||||||
|
}
|
||||||
|
|
||||||
pub mod prevent_crediting_accounts_that_end_rent_paying {
|
pub mod prevent_crediting_accounts_that_end_rent_paying {
|
||||||
solana_sdk::declare_id!("812kqX67odAp5NFwM8D2N24cku7WTm9CHUTFUXaDkWPn");
|
solana_sdk::declare_id!("812kqX67odAp5NFwM8D2N24cku7WTm9CHUTFUXaDkWPn");
|
||||||
}
|
}
|
||||||
|
@ -679,6 +683,7 @@ lazy_static! {
|
||||||
(stake_redelegate_instruction::id(), "enable the redelegate stake instruction #26294"),
|
(stake_redelegate_instruction::id(), "enable the redelegate stake instruction #26294"),
|
||||||
(preserve_rent_epoch_for_rent_exempt_accounts::id(), "preserve rent epoch for rent exempt accounts #26479"),
|
(preserve_rent_epoch_for_rent_exempt_accounts::id(), "preserve rent epoch for rent exempt accounts #26479"),
|
||||||
(enable_bpf_loader_extend_program_ix::id(), "enable bpf upgradeable loader ExtendProgram instruction #25234"),
|
(enable_bpf_loader_extend_program_ix::id(), "enable bpf upgradeable loader ExtendProgram instruction #25234"),
|
||||||
|
(skip_rent_rewrites::id(), "skip rewriting rent exempt accounts during rent collection #26491"),
|
||||||
(enable_early_verification_of_account_modifications::id(), "enable early verification of account modifications #25899"),
|
(enable_early_verification_of_account_modifications::id(), "enable early verification of account modifications #25899"),
|
||||||
(disable_rehash_for_rent_epoch::id(), "on accounts hash calculation, do not try to rehash accounts #28934"),
|
(disable_rehash_for_rent_epoch::id(), "on accounts hash calculation, do not try to rehash accounts #28934"),
|
||||||
(account_hash_ignore_slot::id(), "ignore slot when calculating an account hash #28420"),
|
(account_hash_ignore_slot::id(), "ignore slot when calculating an account hash #28420"),
|
||||||
|
|
Loading…
Reference in New Issue