get_slot_stores -> get_slot_storage_entry (#29663)
This commit is contained in:
parent
e410d021ea
commit
9d1c0c5a3c
|
@ -5683,7 +5683,7 @@ impl AccountsDb {
|
||||||
pubkeys_removed_from_accounts_index: &PubkeysRemovedFromAccountsIndex,
|
pubkeys_removed_from_accounts_index: &PubkeysRemovedFromAccountsIndex,
|
||||||
) {
|
) {
|
||||||
// Slot purged from cache should not exist in the backing store
|
// Slot purged from cache should not exist in the backing store
|
||||||
assert!(self.storage.get_slot_stores(purged_slot).is_none());
|
assert!(self.storage.get_slot_storage_entry(purged_slot).is_none());
|
||||||
let num_purged_keys = pubkey_to_slot_set.len();
|
let num_purged_keys = pubkey_to_slot_set.len();
|
||||||
let (reclaims, _) = self.purge_keys_exact(pubkey_to_slot_set.iter());
|
let (reclaims, _) = self.purge_keys_exact(pubkey_to_slot_set.iter());
|
||||||
assert_eq!(reclaims.len(), num_purged_keys);
|
assert_eq!(reclaims.len(), num_purged_keys);
|
||||||
|
@ -9152,7 +9152,12 @@ pub mod test_utils {
|
||||||
slot: Slot,
|
slot: Slot,
|
||||||
) {
|
) {
|
||||||
let data_size = 0;
|
let data_size = 0;
|
||||||
if accounts.accounts_db.storage.get_slot_stores(slot).is_none() {
|
if accounts
|
||||||
|
.accounts_db
|
||||||
|
.storage
|
||||||
|
.get_slot_storage_entry(slot)
|
||||||
|
.is_none()
|
||||||
|
{
|
||||||
let bytes_required = num * aligned_stored_size(data_size);
|
let bytes_required = num * aligned_stored_size(data_size);
|
||||||
// allocate an append vec for this slot that can hold all the test accounts. This prevents us from creating more than 1 append vec for this slot.
|
// allocate an append vec for this slot that can hold all the test accounts. This prevents us from creating more than 1 append vec for this slot.
|
||||||
_ = accounts.accounts_db.create_and_insert_store(
|
_ = accounts.accounts_db.create_and_insert_store(
|
||||||
|
@ -10990,9 +10995,9 @@ pub mod tests {
|
||||||
//slot is gone
|
//slot is gone
|
||||||
accounts.print_accounts_stats("pre-clean");
|
accounts.print_accounts_stats("pre-clean");
|
||||||
accounts.add_root_and_flush_write_cache(1);
|
accounts.add_root_and_flush_write_cache(1);
|
||||||
assert!(accounts.storage.get_slot_stores(0).is_some());
|
assert!(accounts.storage.get_slot_storage_entry(0).is_some());
|
||||||
accounts.clean_accounts_for_tests();
|
accounts.clean_accounts_for_tests();
|
||||||
assert!(accounts.storage.get_slot_stores(0).is_none());
|
assert!(accounts.storage.get_slot_storage_entry(0).is_none());
|
||||||
|
|
||||||
//new value is there
|
//new value is there
|
||||||
let ancestors = vec![(1, 1)].into_iter().collect();
|
let ancestors = vec![(1, 1)].into_iter().collect();
|
||||||
|
@ -11082,8 +11087,8 @@ pub mod tests {
|
||||||
// Slot 1 should be removed, slot 0 cannot be removed because it still has
|
// Slot 1 should be removed, slot 0 cannot be removed because it still has
|
||||||
// the latest update for pubkey 2
|
// the latest update for pubkey 2
|
||||||
accounts.clean_accounts_for_tests();
|
accounts.clean_accounts_for_tests();
|
||||||
assert!(accounts.storage.get_slot_stores(0).is_some());
|
assert!(accounts.storage.get_slot_storage_entry(0).is_some());
|
||||||
assert!(accounts.storage.get_slot_stores(1).is_none());
|
assert!(accounts.storage.get_slot_storage_entry(1).is_none());
|
||||||
|
|
||||||
// Slot 1 should be cleaned because all it's accounts are
|
// Slot 1 should be cleaned because all it's accounts are
|
||||||
// zero lamports, and are not present in any other slot's
|
// zero lamports, and are not present in any other slot's
|
||||||
|
@ -11122,11 +11127,11 @@ pub mod tests {
|
||||||
accounts.clean_accounts_for_tests();
|
accounts.clean_accounts_for_tests();
|
||||||
// Slots 0 and 1 should each have been cleaned because all of their
|
// Slots 0 and 1 should each have been cleaned because all of their
|
||||||
// accounts are zero lamports
|
// accounts are zero lamports
|
||||||
assert!(accounts.storage.get_slot_stores(0).is_none());
|
assert!(accounts.storage.get_slot_storage_entry(0).is_none());
|
||||||
assert!(accounts.storage.get_slot_stores(1).is_none());
|
assert!(accounts.storage.get_slot_storage_entry(1).is_none());
|
||||||
// Slot 2 only has a zero lamport account as well. But, calc_delete_dependencies()
|
// Slot 2 only has a zero lamport account as well. But, calc_delete_dependencies()
|
||||||
// should exclude slot 2 from the clean due to changes in other slots
|
// should exclude slot 2 from the clean due to changes in other slots
|
||||||
assert!(accounts.storage.get_slot_stores(2).is_some());
|
assert!(accounts.storage.get_slot_storage_entry(2).is_some());
|
||||||
// Index ref counts should be consistent with the slot stores. Account 1 ref count
|
// Index ref counts should be consistent with the slot stores. Account 1 ref count
|
||||||
// should be 1 since slot 2 is the only alive slot; account 2 should have a ref
|
// should be 1 since slot 2 is the only alive slot; account 2 should have a ref
|
||||||
// count of 0 due to slot 0 being dead
|
// count of 0 due to slot 0 being dead
|
||||||
|
@ -11135,7 +11140,7 @@ pub mod tests {
|
||||||
|
|
||||||
accounts.clean_accounts_for_tests();
|
accounts.clean_accounts_for_tests();
|
||||||
// Slot 2 will now be cleaned, which will leave account 1 with a ref count of 0
|
// Slot 2 will now be cleaned, which will leave account 1 with a ref count of 0
|
||||||
assert!(accounts.storage.get_slot_stores(2).is_none());
|
assert!(accounts.storage.get_slot_storage_entry(2).is_none());
|
||||||
assert_eq!(accounts.accounts_index.ref_count_from_storage(&pubkey1), 0);
|
assert_eq!(accounts.accounts_index.ref_count_from_storage(&pubkey1), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11164,8 +11169,8 @@ pub mod tests {
|
||||||
// zero-lamport account should be cleaned
|
// zero-lamport account should be cleaned
|
||||||
accounts.clean_accounts_for_tests();
|
accounts.clean_accounts_for_tests();
|
||||||
|
|
||||||
assert!(accounts.storage.get_slot_stores(0).is_none());
|
assert!(accounts.storage.get_slot_storage_entry(0).is_none());
|
||||||
assert!(accounts.storage.get_slot_stores(1).is_none());
|
assert!(accounts.storage.get_slot_storage_entry(1).is_none());
|
||||||
|
|
||||||
// Slot 0 should be cleaned because all it's accounts have been
|
// Slot 0 should be cleaned because all it's accounts have been
|
||||||
// updated in the rooted slot 1
|
// updated in the rooted slot 1
|
||||||
|
@ -11605,13 +11610,8 @@ pub mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn assert_no_stores(accounts: &AccountsDb, slot: Slot) {
|
fn assert_no_stores(accounts: &AccountsDb, slot: Slot) {
|
||||||
let slot_stores = accounts.storage.get_slot_stores(slot);
|
let store = accounts.storage.get_slot_storage_entry(slot);
|
||||||
let r_slot_stores = slot_stores.as_ref().map(|slot_stores| {
|
assert!(store.is_none());
|
||||||
let r_slot_stores = slot_stores.read().unwrap();
|
|
||||||
info!("{:?}", *r_slot_stores);
|
|
||||||
r_slot_stores
|
|
||||||
});
|
|
||||||
assert!(r_slot_stores.is_none() || r_slot_stores.unwrap().is_empty());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -12567,12 +12567,7 @@ pub mod tests {
|
||||||
assert_eq!(1, db.get_snapshot_storages(..=after_slot, None).0.len());
|
assert_eq!(1, db.get_snapshot_storages(..=after_slot, None).0.len());
|
||||||
|
|
||||||
db.storage
|
db.storage
|
||||||
.get_slot_stores(0)
|
.get_slot_storage_entry(0)
|
||||||
.unwrap()
|
|
||||||
.read()
|
|
||||||
.unwrap()
|
|
||||||
.values()
|
|
||||||
.next()
|
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.remove_account(0, true);
|
.remove_account(0, true);
|
||||||
assert!(db.get_snapshot_storages(..=after_slot, None).0.is_empty());
|
assert!(db.get_snapshot_storages(..=after_slot, None).0.is_empty());
|
||||||
|
@ -12603,16 +12598,7 @@ pub mod tests {
|
||||||
let account = AccountSharedData::new(1, 0, AccountSharedData::default().owner());
|
let account = AccountSharedData::new(1, 0, AccountSharedData::default().owner());
|
||||||
accounts.store_for_tests(0, &[(&pubkey, &account)]);
|
accounts.store_for_tests(0, &[(&pubkey, &account)]);
|
||||||
accounts.add_root_and_flush_write_cache(0);
|
accounts.add_root_and_flush_write_cache(0);
|
||||||
let storage_entry = accounts
|
let storage_entry = accounts.storage.get_slot_storage_entry(0).unwrap();
|
||||||
.storage
|
|
||||||
.get_slot_stores(0)
|
|
||||||
.unwrap()
|
|
||||||
.read()
|
|
||||||
.unwrap()
|
|
||||||
.values()
|
|
||||||
.next()
|
|
||||||
.unwrap()
|
|
||||||
.clone();
|
|
||||||
storage_entry.remove_account(0, true);
|
storage_entry.remove_account(0, true);
|
||||||
storage_entry.remove_account(0, true);
|
storage_entry.remove_account(0, true);
|
||||||
}
|
}
|
||||||
|
@ -13495,11 +13481,8 @@ pub mod tests {
|
||||||
let pubkey = solana_sdk::pubkey::new_rand();
|
let pubkey = solana_sdk::pubkey::new_rand();
|
||||||
accounts.store_for_tests(0, &[(&pubkey, &account)]);
|
accounts.store_for_tests(0, &[(&pubkey, &account)]);
|
||||||
accounts.add_root_and_flush_write_cache(0);
|
accounts.add_root_and_flush_write_cache(0);
|
||||||
let slot_stores = accounts.storage.get_slot_stores(0).unwrap();
|
let store = accounts.storage.get_slot_storage_entry(0).unwrap();
|
||||||
let mut total_len = 0;
|
let total_len = store.accounts.len();
|
||||||
for (_id, store) in slot_stores.read().unwrap().iter() {
|
|
||||||
total_len += store.accounts.len();
|
|
||||||
}
|
|
||||||
info!("total: {}", total_len);
|
info!("total: {}", total_len);
|
||||||
assert_eq!(total_len, STORE_META_OVERHEAD);
|
assert_eq!(total_len, STORE_META_OVERHEAD);
|
||||||
}
|
}
|
||||||
|
@ -14232,10 +14215,7 @@ pub mod tests {
|
||||||
|
|
||||||
impl AccountsDb {
|
impl AccountsDb {
|
||||||
fn get_and_assert_single_storage(&self, slot: Slot) -> Arc<AccountStorageEntry> {
|
fn get_and_assert_single_storage(&self, slot: Slot) -> Arc<AccountStorageEntry> {
|
||||||
let mut storage_maps = self.get_storages_for_slot(slot).unwrap_or_default();
|
self.storage.get_slot_storage_entry(slot).unwrap()
|
||||||
|
|
||||||
assert_eq!(storage_maps.len(), 1);
|
|
||||||
storage_maps.pop().unwrap()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15292,7 +15272,7 @@ pub mod tests {
|
||||||
LoadHint::FixedMaxRoot
|
LoadHint::FixedMaxRoot
|
||||||
)
|
)
|
||||||
.is_some());
|
.is_some());
|
||||||
// Clear for next iteration so that `assert!(self.storage.get_slot_stores(purged_slot).is_none());`
|
// Clear for next iteration so that `assert!(self.storage.get_slot_storage_entry(purged_slot).is_none());`
|
||||||
// in `purge_slot_pubkeys()` doesn't trigger
|
// in `purge_slot_pubkeys()` doesn't trigger
|
||||||
db.remove_unrooted_slots(&[(*slot, *bank_id)]);
|
db.remove_unrooted_slots(&[(*slot, *bank_id)]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14894,7 +14894,7 @@ pub(crate) mod tests {
|
||||||
.accounts
|
.accounts
|
||||||
.accounts_db
|
.accounts_db
|
||||||
.storage
|
.storage
|
||||||
.get_slot_stores(1)
|
.get_slot_storage_entry(1)
|
||||||
.is_none());
|
.is_none());
|
||||||
|
|
||||||
bank3.print_accounts_stats();
|
bank3.print_accounts_stats();
|
||||||
|
|
Loading…
Reference in New Issue