remove expected rent collection and rehashing completely (#28422)

This commit is contained in:
Jeff Washington (jwash) 2022-10-17 07:24:42 -07:00 committed by GitHub
parent fed0c12468
commit 28a89a1d99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 4 additions and 1438 deletions

View File

@ -125,7 +125,6 @@ fn main() {
&ancestors,
&EpochSchedule::default(),
&RentCollector::default(),
true,
);
time.stop();
let mut time_store = Measure::start("hash using store");
@ -137,7 +136,6 @@ fn main() {
None,
&EpochSchedule::default(),
&RentCollector::default(),
false,
true,
);
time_store.stop();

View File

@ -232,7 +232,6 @@ impl AccountsHashVerifier {
rent_collector: &accounts_package.rent_collector,
store_detailed_debug_info_on_failure: false,
full_snapshot: None,
enable_rehashing: accounts_package.enable_rehashing,
},
&sorted_storages,
timings,
@ -255,7 +254,6 @@ impl AccountsHashVerifier {
rent_collector: &accounts_package.rent_collector,
store_detailed_debug_info_on_failure: false,
full_snapshot: None,
enable_rehashing: accounts_package.enable_rehashing,
},
);
info!(
@ -275,7 +273,6 @@ impl AccountsHashVerifier {
// now that we've failed, store off the failing contents that produced a bad capitalization
store_detailed_debug_info_on_failure: true,
full_snapshot: None,
enable_rehashing: accounts_package.enable_rehashing,
},
&sorted_storages,
HashStats::default(),
@ -564,7 +561,6 @@ mod tests {
accounts: Arc::clone(&accounts),
epoch_schedule: EpochSchedule::default(),
rent_collector: RentCollector::default(),
enable_rehashing: true,
};
AccountsHashVerifier::process_accounts_package(

View File

@ -320,7 +320,6 @@ fn test_epoch_accounts_hash_basic(test_environment: TestEnvironment) {
rent_collector: bank.rent_collector(),
store_detailed_debug_info_on_failure: false,
full_snapshot: None,
enable_rehashing: true,
},
)
.unwrap();

View File

@ -99,7 +99,6 @@ fn test_accounts_hash_bank_hash(bencher: &mut Bencher) {
&ancestors,
&EpochSchedule::default(),
&RentCollector::default(),
true,
);
let test_hash_calculation = false;
bencher.iter(|| {
@ -112,7 +111,6 @@ fn test_accounts_hash_bank_hash(bencher: &mut Bencher) {
&RentCollector::default(),
false,
false,
true,
false,
))
});
@ -137,7 +135,6 @@ fn test_update_accounts_hash(bencher: &mut Bencher) {
&ancestors,
&EpochSchedule::default(),
&RentCollector::default(),
true,
);
});
}

View File

@ -787,7 +787,6 @@ impl Accounts {
debug_verify: bool,
epoch_schedule: &EpochSchedule,
rent_collector: &RentCollector,
enable_rehashing: bool,
) -> u64 {
let use_index = false;
let is_startup = true;
@ -804,7 +803,6 @@ impl Accounts {
epoch_schedule,
rent_collector,
is_startup,
enable_rehashing,
)
.1
}
@ -822,7 +820,6 @@ impl Accounts {
rent_collector: &RentCollector,
ignore_mismatch: bool,
store_detailed_debug_info: bool,
enable_rehashing: bool,
use_bg_thread_pool: bool,
) -> bool {
if let Err(err) = self.accounts_db.verify_bank_hash_and_lamports_new(
@ -834,7 +831,6 @@ impl Accounts {
rent_collector,
ignore_mismatch,
store_detailed_debug_info,
enable_rehashing,
use_bg_thread_pool,
) {
warn!("verify_bank_hash failed: {:?}, slot: {}", err, slot);

View File

@ -340,8 +340,6 @@ impl SnapshotRequestHandler {
rent_collector: snapshot_root_bank.rent_collector(),
store_detailed_debug_info_on_failure: false,
full_snapshot: None,
enable_rehashing: snapshot_root_bank
.bank_enable_rehashing_on_accounts_hash(),
},
)
.unwrap();

View File

@ -46,7 +46,6 @@ use {
cache_hash_data::CacheHashData,
contains::Contains,
epoch_accounts_hash::EpochAccountsHashManager,
expected_rent_collection::{ExpectedRentCollection, SlotInfoInEpoch},
pubkey_bins::PubkeyBinCalculator24,
read_only_accounts_cache::ReadOnlyAccountsCache,
rent_collector::RentCollector,
@ -1988,26 +1987,22 @@ trait AppendVecScan: Send + Sync + Clone {
/// These would have been captured in a fn from within the scan function.
/// Some of these are constant across all pubkeys, some are constant across a slot.
/// Some could be unique per pubkey.
struct ScanState<'a, T: Fn(Slot) -> Option<Slot> + Sync + Send + Clone> {
struct ScanState<'a> {
/// slot we're currently scanning
current_slot: Slot,
/// accumulated results
accum: BinnedHashData,
/// max slot (inclusive) that we're calculating accounts hash on
max_slot_info: SlotInfoInEpoch,
bin_calculator: &'a PubkeyBinCalculator24,
bin_range: &'a Range<usize>,
config: &'a CalcAccountsHashConfig<'a>,
mismatch_found: Arc<AtomicU64>,
stats: &'a crate::accounts_hash::HashStats,
find_unskipped_slot: &'a T,
filler_account_suffix: Option<&'a Pubkey>,
range: usize,
sort_time: Arc<AtomicU64>,
pubkey_to_bin_index: usize,
}
impl<'a, T: Fn(Slot) -> Option<Slot> + Sync + Send + Clone> AppendVecScan for ScanState<'a, T> {
impl<'a> AppendVecScan for ScanState<'a> {
fn set_slot(&mut self, slot: Slot) {
self.current_slot = slot;
}
@ -2029,26 +2024,6 @@ impl<'a, T: Fn(Slot) -> Option<Slot> + Sync + Send + Clone> AppendVecScan for Sc
let balance = loaded_account.lamports();
let loaded_hash = loaded_account.loaded_hash();
let new_hash = self
.config
.enable_rehashing
.then(|| {
ExpectedRentCollection::maybe_rehash_skipped_rewrite(
loaded_account,
&loaded_hash,
pubkey,
self.current_slot,
self.config.epoch_schedule,
self.config.rent_collector,
self.stats,
&self.max_slot_info,
self.find_unskipped_slot,
self.filler_account_suffix,
)
})
.flatten();
let loaded_hash = new_hash.unwrap_or(loaded_hash);
let source_item = CalculateHashIntermediate::new(loaded_hash, balance, *pubkey);
if self.config.check_hash
@ -6759,8 +6734,6 @@ impl AccountsDb {
let total_lamports = Mutex::<u64>::new(0);
let stats = HashStats::default();
let max_slot_info = SlotInfoInEpoch::new(max_slot, config.epoch_schedule);
let get_hashes = || {
keys.par_chunks(chunks)
.map(|pubkeys| {
@ -6793,24 +6766,7 @@ impl AccountsDb {
.get_loaded_account()
.and_then(
|loaded_account| {
let find_unskipped_slot = |slot: Slot| {
self.find_unskipped_slot(slot, config.ancestors)
};
let loaded_hash = loaded_account.loaded_hash();
let new_hash = config.enable_rehashing
.then(|| ExpectedRentCollection::maybe_rehash_skipped_rewrite(
&loaded_account,
&loaded_hash,
pubkey,
*slot,
config.epoch_schedule,
config.rent_collector,
&stats,
&max_slot_info,
find_unskipped_slot,
self.filler_account_suffix.as_ref(),
)).flatten();
let loaded_hash = new_hash.unwrap_or(loaded_hash);
let balance = loaded_account.lamports();
if config.check_hash && !self.is_filler_account(pubkey) { // this will not be supported anymore
let computed_hash =
@ -6895,7 +6851,6 @@ impl AccountsDb {
ancestors: &Ancestors,
epoch_schedule: &EpochSchedule,
rent_collector: &RentCollector,
enable_rehashing: bool,
) -> (Hash, u64) {
self.update_accounts_hash_with_index_option(
true,
@ -6906,7 +6861,6 @@ impl AccountsDb {
epoch_schedule,
rent_collector,
false,
enable_rehashing,
)
}
@ -6920,7 +6874,6 @@ impl AccountsDb {
None,
&EpochSchedule::default(),
&RentCollector::default(),
false,
true,
)
}
@ -7339,7 +7292,6 @@ impl AccountsDb {
epoch_schedule: &EpochSchedule,
rent_collector: &RentCollector,
is_startup: bool,
enable_rehashing: bool,
) -> (Hash, u64) {
let check_hash = false;
let (hash, total_lamports) = self
@ -7355,7 +7307,6 @@ impl AccountsDb {
rent_collector,
store_detailed_debug_info_on_failure: false,
full_snapshot: None,
enable_rehashing,
},
expected_capitalization,
)
@ -7391,22 +7342,15 @@ impl AccountsDb {
let range = bin_range.end - bin_range.start;
let sort_time = Arc::new(AtomicU64::new(0));
let find_unskipped_slot = |slot: Slot| self.find_unskipped_slot(slot, config.ancestors);
let max_slot_info =
SlotInfoInEpoch::new(storage.max_slot_inclusive(), config.epoch_schedule);
let scanner = ScanState {
current_slot: Slot::default(),
accum: BinnedHashData::default(),
bin_calculator: &bin_calculator,
config,
mismatch_found: mismatch_found.clone(),
max_slot_info,
find_unskipped_slot: &find_unskipped_slot,
filler_account_suffix,
range,
bin_range,
stats,
sort_time: sort_time.clone(),
pubkey_to_bin_index: 0,
};
@ -7603,7 +7547,6 @@ impl AccountsDb {
test_hash_calculation: bool,
epoch_schedule: &EpochSchedule,
rent_collector: &RentCollector,
enable_rehashing: bool,
use_bg_thread_pool: bool,
) -> Result<(), BankHashVerificationError> {
self.verify_bank_hash_and_lamports_new(
@ -7615,7 +7558,6 @@ impl AccountsDb {
rent_collector,
false,
false,
enable_rehashing,
use_bg_thread_pool,
)
}
@ -7632,7 +7574,6 @@ impl AccountsDb {
rent_collector: &RentCollector,
ignore_mismatch: bool,
store_hash_raw_data_for_debug: bool,
enable_rehashing: bool,
use_bg_thread_pool: bool,
) -> Result<(), BankHashVerificationError> {
use BankHashVerificationError::*;
@ -7652,7 +7593,6 @@ impl AccountsDb {
rent_collector,
store_detailed_debug_info_on_failure: store_hash_raw_data_for_debug,
full_snapshot: None,
enable_rehashing,
},
None,
)?;
@ -11646,14 +11586,12 @@ pub mod tests {
&ancestors,
&EpochSchedule::default(),
&RentCollector::default(),
true,
),
accounts.update_accounts_hash(
latest_slot,
&ancestors,
&EpochSchedule::default(),
&RentCollector::default(),
true,
)
);
}
@ -11937,7 +11875,6 @@ pub mod tests {
&Ancestors::default(),
&EpochSchedule::default(),
&RentCollector::default(),
true,
);
let accounts = f(accounts, current_slot);
@ -11957,7 +11894,6 @@ pub mod tests {
true,
&EpochSchedule::default(),
&RentCollector::default(),
true,
false,
)
.unwrap();
@ -12293,7 +12229,6 @@ pub mod tests {
rent_collector: &RENT_COLLECTOR,
store_detailed_debug_info_on_failure: false,
full_snapshot: None,
enable_rehashing: true,
}
}
}
@ -12362,7 +12297,6 @@ pub mod tests {
true,
&EpochSchedule::default(),
&RentCollector::default(),
true,
false,
),
Ok(_)
@ -12377,7 +12311,6 @@ pub mod tests {
true,
&EpochSchedule::default(),
&RentCollector::default(),
true,
false,
),
Err(MissingBankHash)
@ -12401,7 +12334,6 @@ pub mod tests {
true,
&EpochSchedule::default(),
&RentCollector::default(),
true,
false,
),
Err(MismatchedBankHash)
@ -12431,7 +12363,6 @@ pub mod tests {
true,
&EpochSchedule::default(),
&RentCollector::default(),
true,
false,
),
Ok(_)
@ -12454,14 +12385,13 @@ pub mod tests {
true,
&EpochSchedule::default(),
&RentCollector::default(),
true,
false,
),
Ok(_)
);
assert_matches!(
db.verify_bank_hash_and_lamports(some_slot, &ancestors, 10, true, &EpochSchedule::default(), &RentCollector::default(), true, false,),
db.verify_bank_hash_and_lamports(some_slot, &ancestors, 10, true, &EpochSchedule::default(), &RentCollector::default(), false,),
Err(MismatchedTotalLamports(expected, actual)) if expected == 2 && actual == 10
);
}
@ -12488,7 +12418,6 @@ pub mod tests {
true,
&EpochSchedule::default(),
&RentCollector::default(),
true,
false,
),
Ok(_)
@ -12533,7 +12462,6 @@ pub mod tests {
true,
&EpochSchedule::default(),
&RentCollector::default(),
true,
false,
),
Err(MismatchedBankHash)
@ -13144,7 +13072,6 @@ pub mod tests {
&no_ancestors,
&EpochSchedule::default(),
&RentCollector::default(),
true,
);
accounts
.verify_bank_hash_and_lamports(
@ -13154,7 +13081,6 @@ pub mod tests {
true,
&EpochSchedule::default(),
&RentCollector::default(),
true,
false,
)
.unwrap();
@ -13168,7 +13094,6 @@ pub mod tests {
true,
&EpochSchedule::default(),
&RentCollector::default(),
true,
false,
)
.unwrap();

View File

@ -56,8 +56,6 @@ pub struct CalcAccountsHashConfig<'a> {
pub rent_collector: &'a RentCollector,
/// used for tracking down hash mismatches after the fact
pub store_detailed_debug_info_on_failure: bool,
/// true if hash calculation can rehash based on skipped rewrites
pub enable_rehashing: bool,
/// `Some` if this is an incremental snapshot which only hashes slots since the base full snapshot
pub full_snapshot: Option<FullSnapshotAccountsHashInfo>,
}

View File

@ -55,7 +55,6 @@ use {
cost_tracker::CostTracker,
epoch_accounts_hash::{self, EpochAccountsHash},
epoch_stakes::{EpochStakes, NodeVoteAccounts},
expected_rent_collection::{ExpectedRentCollection, SlotInfoInEpoch},
inline_spl_associated_token_account, inline_spl_token,
message_processor::MessageProcessor,
rent_collector::{CollectedInfo, RentCollector},
@ -5204,13 +5203,6 @@ impl Bank {
}
}
/// If we are skipping rewrites for bank hash, then we don't want to
/// allow accounts hash calculation to rehash anything.
/// We should use whatever hash found for each account as-is.
pub fn bank_enable_rehashing_on_accounts_hash(&self) -> bool {
true // this will be governed by a feature later
}
/// Collect rent from `accounts`
///
/// This fn is called inside a parallel loop from `collect_rent_in_partition()`. Avoid adding
@ -6415,22 +6407,7 @@ impl Bank {
ancestors: &Ancestors,
pubkey: &Pubkey,
) -> Option<(AccountSharedData, Slot)> {
match self.rc.accounts.load_with_fixed_root(ancestors, pubkey) {
Some((mut account, storage_slot)) => {
ExpectedRentCollection::maybe_update_rent_epoch_on_load(
&mut account,
&SlotInfoInEpoch::new_small(storage_slot),
&SlotInfoInEpoch::new_small(self.slot()),
self.epoch_schedule(),
self.rent_collector(),
pubkey,
&self.rewrites_skipped_this_slot,
);
Some((account, storage_slot))
}
None => None,
}
self.rc.accounts.load_with_fixed_root(ancestors, pubkey)
}
pub fn get_program_accounts(
@ -6734,7 +6711,6 @@ impl Bank {
let cap = self.capitalization();
let epoch_schedule = self.epoch_schedule();
let rent_collector = self.rent_collector();
let enable_rehashing = self.bank_enable_rehashing_on_accounts_hash();
if config.run_in_background {
let ancestors = ancestors.clone();
let accounts = Arc::clone(accounts);
@ -6757,7 +6733,6 @@ impl Bank {
&rent_collector,
config.ignore_mismatch,
config.store_hash_raw_data_for_debug,
enable_rehashing,
// true to run using bg thread pool
true,
);
@ -6780,7 +6755,6 @@ impl Bank {
rent_collector,
config.ignore_mismatch,
config.store_hash_raw_data_for_debug,
enable_rehashing,
// fg is waiting for this to run, so we can use the fg thread pool
false,
);
@ -6883,7 +6857,6 @@ impl Bank {
debug_verify,
self.epoch_schedule(),
&self.rent_collector,
self.bank_enable_rehashing_on_accounts_hash(),
)
}
@ -6946,7 +6919,6 @@ impl Bank {
self.epoch_schedule(),
&self.rent_collector,
is_startup,
self.bank_enable_rehashing_on_accounts_hash(),
);
if total_lamports != self.capitalization() {
datapoint_info!(
@ -6972,7 +6944,6 @@ impl Bank {
self.epoch_schedule(),
&self.rent_collector,
is_startup,
self.bank_enable_rehashing_on_accounts_hash(),
);
}

File diff suppressed because it is too large Load Diff

View File

@ -37,7 +37,6 @@ pub mod cost_tracker;
pub mod epoch_accounts_hash;
pub mod epoch_stakes;
pub mod execute_cost_table;
mod expected_rent_collection;
pub mod genesis_utils;
pub mod hardened_unpack;
pub mod in_mem_accounts_index;

View File

@ -46,7 +46,6 @@ pub struct AccountsPackage {
pub accounts: Arc<Accounts>,
pub epoch_schedule: EpochSchedule,
pub rent_collector: RentCollector,
pub enable_rehashing: bool,
}
impl AccountsPackage {
@ -117,7 +116,6 @@ impl AccountsPackage {
accounts: bank.accounts(),
epoch_schedule: *bank.epoch_schedule(),
rent_collector: bank.rent_collector().clone(),
enable_rehashing: bank.bank_enable_rehashing_on_accounts_hash(),
})
}
@ -141,7 +139,6 @@ impl AccountsPackage {
accounts: Arc::new(Accounts::default_for_tests()),
epoch_schedule: EpochSchedule::default(),
rent_collector: RentCollector::default(),
enable_rehashing: bool::default(),
}
}
}