Struct solana_runtime::accounts_db::AccountsDb
source · pub struct AccountsDb {Show 22 fields
pub accounts_index: AccountsIndex<AccountInfo>,
pub accounts_hash_complete_one_epoch_old: RwLock<Slot>,
pub skip_rewrites: bool,
pub ancient_append_vecs: bool,
pub skip_initial_hash_calc: bool,
pub storage: AccountStorage,
pub accounts_cache: AccountsCache,
pub next_id: AtomicAppendVecId,
pub shrink_candidate_slots: Mutex<HashMap<Slot, HashMap<AppendVecId, Arc<AccountStorageEntry>>>>,
pub shrink_candidate_slots_v1: Mutex<Vec<Slot>>,
pub shrink_paths: RwLock<Option<Vec<PathBuf>>>,
pub thread_pool: ThreadPool,
pub thread_pool_clean: ThreadPool,
pub bank_hashes: RwLock<HashMap<Slot, BankHashInfo>>,
pub stats: AccountsStats,
pub cluster_type: Option<ClusterType>,
pub account_indexes: AccountSecondaryIndexes,
pub caching_enabled: bool,
pub filler_account_suffix: Option<Pubkey>,
pub filler_accounts_per_slot: AtomicU64,
pub filler_account_slots_remaining: AtomicU64,
pub num_hash_scan_passes: Option<usize>,
/* private fields */
}
Fields§
§accounts_index: AccountsIndex<AccountInfo>
Keeps tracks of index into AppendVec on a per slot basis
accounts_hash_complete_one_epoch_old: RwLock<Slot>
slot that is one epoch older than the highest slot where accounts hash calculation has completed
skip_rewrites: bool
true iff rent exempt accounts are not rewritten in their normal rent collection slot
ancient_append_vecs: bool
true iff we want to squash old append vecs together into ‘ancient append vecs’
skip_initial_hash_calc: bool
true iff we want to skip the initial hash calculation on startup
storage: AccountStorage
§accounts_cache: AccountsCache
§next_id: AtomicAppendVecId
distribute the accounts across storage lists
shrink_candidate_slots: Mutex<HashMap<Slot, HashMap<AppendVecId, Arc<AccountStorageEntry>>>>
Set of shrinkable stores organized by map of slot to append_vec_id
shrink_candidate_slots_v1: Mutex<Vec<Slot>>
Legacy shrink slots to support non-cached code-path.
shrink_paths: RwLock<Option<Vec<PathBuf>>>
§thread_pool: ThreadPool
Thread pool used for par_iter
thread_pool_clean: ThreadPool
§bank_hashes: RwLock<HashMap<Slot, BankHashInfo>>
§stats: AccountsStats
§cluster_type: Option<ClusterType>
§account_indexes: AccountSecondaryIndexes
§caching_enabled: bool
§filler_account_suffix: Option<Pubkey>
§filler_accounts_per_slot: AtomicU64
number of filler accounts to add for each slot
filler_account_slots_remaining: AtomicU64
number of slots remaining where filler accounts should be added
num_hash_scan_passes: Option<usize>
Implementations§
source§impl AccountsDb
impl AccountsDb
sourcepub fn notify_account_restore_from_snapshot(&self)
pub fn notify_account_restore_from_snapshot(&self)
Notify the plugins of of account data when AccountsDb is restored from a snapshot. The data is streamed in the reverse order of the slots so that an account is only streamed once. At a slot, if the accounts is updated multiple times only the last write (with highest write_version) is notified.
pub fn notify_account_at_accounts_update( &self, slot: Slot, meta: &StoredMeta, account: &AccountSharedData, txn_signature: &Option<&Signature> )
source§impl AccountsDb
impl AccountsDb
pub fn default_for_tests() -> Self
pub fn new_for_tests(paths: Vec<PathBuf>, cluster_type: &ClusterType) -> Self
pub fn new_for_tests_with_caching( paths: Vec<PathBuf>, cluster_type: &ClusterType ) -> Self
pub fn new_with_config( paths: Vec<PathBuf>, cluster_type: &ClusterType, account_indexes: AccountSecondaryIndexes, caching_enabled: bool, shrink_ratio: AccountShrinkThreshold, accounts_db_config: Option<AccountsDbConfig>, accounts_update_notifier: Option<AccountsUpdateNotifier> ) -> Self
pub fn set_shrink_paths(&self, paths: Vec<PathBuf>)
pub fn file_size(&self) -> u64
pub fn new_single_for_tests() -> Self
pub fn new_single_for_tests_with_caching() -> Self
pub fn expected_cluster_type(&self) -> ClusterType
sourcepub fn notify_accounts_hash_calculated_complete(
&self,
completed_slot: Slot,
epoch_schedule: &EpochSchedule
)
pub fn notify_accounts_hash_calculated_complete( &self, completed_slot: Slot, epoch_schedule: &EpochSchedule )
hash calc is completed as of ‘slot’ so, any process that wants to take action on really old slots can now proceed up to ‘completed_slot’-slots per epoch
pub fn clean_accounts( &self, max_clean_root: Option<Slot>, is_startup: bool, last_full_snapshot_slot: Option<Slot> )
sourcepub fn should_move_to_ancient_append_vec(
&self,
all_storages: &SnapshotStorage,
current_ancient: &mut Option<(Slot, Arc<AccountStorageEntry>)>,
slot: Slot
) -> bool
pub fn should_move_to_ancient_append_vec( &self, all_storages: &SnapshotStorage, current_ancient: &mut Option<(Slot, Arc<AccountStorageEntry>)>, slot: Slot ) -> bool
return true if the accounts in this slot should be moved to an ancient append vec otherwise, return false and the caller can skip this slot side effect could be updating ‘current_ancient’
pub fn shrink_candidate_slots(&self) -> usize
pub fn shrink_all_slots( &self, is_startup: bool, last_full_snapshot_slot: Option<Slot> )
pub fn scan_accounts<F, A>( &self, ancestors: &Ancestors, bank_id: BankId, scan_func: F, config: &ScanConfig ) -> ScanResult<A>where F: Fn(&mut A, Option<(&Pubkey, AccountSharedData, Slot)>), A: Default,
pub fn unchecked_scan_accounts<F, A>( &self, metric_name: &'static str, ancestors: &Ancestors, scan_func: F, config: &ScanConfig ) -> Awhere F: Fn(&mut A, (&Pubkey, LoadedAccount<'_>, Slot)), A: Default,
sourcepub fn range_scan_accounts<F, A, R>(
&self,
metric_name: &'static str,
ancestors: &Ancestors,
range: R,
config: &ScanConfig,
scan_func: F
) -> Awhere
F: Fn(&mut A, Option<(&Pubkey, AccountSharedData, Slot)>),
A: Default,
R: RangeBounds<Pubkey> + Debug,
pub fn range_scan_accounts<F, A, R>( &self, metric_name: &'static str, ancestors: &Ancestors, range: R, config: &ScanConfig, scan_func: F ) -> Awhere F: Fn(&mut A, Option<(&Pubkey, AccountSharedData, Slot)>), A: Default, R: RangeBounds<Pubkey> + Debug,
Only guaranteed to be safe when called from rent collection
pub fn index_scan_accounts<F, A>( &self, ancestors: &Ancestors, bank_id: BankId, index_key: IndexKey, scan_func: F, config: &ScanConfig ) -> ScanResult<(A, bool)>where F: Fn(&mut A, Option<(&Pubkey, AccountSharedData, Slot)>), A: Default,
sourcepub fn scan_account_storage<R, B>(
&self,
slot: Slot,
cache_map_func: impl Fn(LoadedAccount<'_>) -> Option<R> + Sync,
storage_scan_func: impl Fn(&B, LoadedAccount<'_>) + Sync
) -> ScanStorageResult<R, B>where
R: Send,
B: Send + Default + Sync,
pub fn scan_account_storage<R, B>( &self, slot: Slot, cache_map_func: impl Fn(LoadedAccount<'_>) -> Option<R> + Sync, storage_scan_func: impl Fn(&B, LoadedAccount<'_>) + Sync ) -> ScanStorageResult<R, B>where R: Send, B: Send + Default + Sync,
Scan a specific slot through all the account storage in parallel
pub fn set_hash(&self, slot: Slot, parent_slot: Slot)
pub fn load( &self, ancestors: &Ancestors, pubkey: &Pubkey, load_hint: LoadHint ) -> Option<(AccountSharedData, Slot)>
pub fn load_account_into_read_cache(&self, ancestors: &Ancestors, pubkey: &Pubkey)
pub fn load_with_fixed_root( &self, ancestors: &Ancestors, pubkey: &Pubkey, load_zero_lamports: LoadZeroLamports ) -> Option<(AccountSharedData, Slot)>
pub fn load_without_fixed_root( &self, ancestors: &Ancestors, pubkey: &Pubkey ) -> Option<(AccountSharedData, Slot)>
pub fn load_account_hash( &self, ancestors: &Ancestors, pubkey: &Pubkey, max_root: Option<Slot>, load_hint: LoadHint ) -> Option<Hash>
pub fn create_drop_bank_callback( &self, pruned_banks_sender: DroppedSlotsSender ) -> SendDroppedBankCallback
sourcepub fn purge_slot(&self, slot: Slot, bank_id: BankId, is_serialized_with_abs: bool)
pub fn purge_slot(&self, slot: Slot, bank_id: BankId, is_serialized_with_abs: bool)
This should only be called after the Bank::drop()
runs in bank.rs, See BANK_DROP_SAFETY
comment below for more explanation.
is_serialized_with_abs
- indicates whehter this call runs sequentially with all other accounts_db relevant calls, such as shrinking, purging etc., in account background service.
pub fn remove_unrooted_slots(&self, remove_slots: &[(Slot, BankId)])
pub fn hash_account_with_rent_epoch<T: ReadableAccount>( slot: Slot, account: &T, pubkey: &Pubkey, rent_epoch: Epoch ) -> Hash
pub fn hash_account<T: ReadableAccount>( slot: Slot, account: &T, pubkey: &Pubkey ) -> Hash
pub fn mark_slot_frozen(&self, slot: Slot)
pub fn expire_old_recycle_stores(&self)
pub fn flush_accounts_cache_slot(&self, slot: Slot)
pub fn flush_accounts_cache( &self, force_flush: bool, requested_flush_root: Option<Slot> )
sourcepub fn find_unskipped_slot(
&self,
slot: Slot,
ancestors: Option<&Ancestors>
) -> Option<Slot>
pub fn find_unskipped_slot( &self, slot: Slot, ancestors: Option<&Ancestors> ) -> Option<Slot>
find slot >= ‘slot’ which is a root or in ‘ancestors’
pub fn checked_iterative_sum_for_capitalization( total_cap: u64, new_cap: u64 ) -> u64
pub fn checked_sum_for_capitalization<T: Iterator<Item = u64>>( balances: T ) -> u64
pub fn get_accounts_hash(&self, slot: Slot) -> Hash
pub fn update_accounts_hash( &self, slot: Slot, ancestors: &Ancestors, epoch_schedule: &EpochSchedule, rent_collector: &RentCollector ) -> (Hash, u64)
pub fn update_accounts_hash_with_index_option( &self, use_index: bool, debug_verify: bool, slot: Slot, ancestors: &Ancestors, expected_capitalization: Option<u64>, can_cached_slot_be_unflushed: bool, epoch_schedule: &EpochSchedule, rent_collector: &RentCollector, is_startup: bool ) -> (Hash, u64)
pub fn calculate_accounts_hash_without_index( &self, config: &CalcAccountsHashConfig<'_>, storages: &SortedStorages<'_>, stats: HashStats ) -> Result<(Hash, u64), BankHashVerificationError>
sourcepub fn verify_bank_hash_and_lamports(
&self,
slot: Slot,
ancestors: &Ancestors,
total_lamports: u64,
test_hash_calculation: bool,
epoch_schedule: &EpochSchedule,
rent_collector: &RentCollector,
can_cached_slot_be_unflushed: bool,
use_bg_thread_pool: bool
) -> Result<(), BankHashVerificationError>
pub fn verify_bank_hash_and_lamports( &self, slot: Slot, ancestors: &Ancestors, total_lamports: u64, test_hash_calculation: bool, epoch_schedule: &EpochSchedule, rent_collector: &RentCollector, can_cached_slot_be_unflushed: bool, use_bg_thread_pool: bool ) -> Result<(), BankHashVerificationError>
Only called from startup or test code.
sourcepub fn verify_bank_hash_and_lamports_new(
&self,
slot: Slot,
ancestors: &Ancestors,
total_lamports: u64,
test_hash_calculation: bool,
epoch_schedule: &EpochSchedule,
rent_collector: &RentCollector,
can_cached_slot_be_unflushed: bool,
ignore_mismatch: bool,
store_hash_raw_data_for_debug: bool,
use_bg_thread_pool: bool
) -> Result<(), BankHashVerificationError>
pub fn verify_bank_hash_and_lamports_new( &self, slot: Slot, ancestors: &Ancestors, total_lamports: u64, test_hash_calculation: bool, epoch_schedule: &EpochSchedule, rent_collector: &RentCollector, can_cached_slot_be_unflushed: bool, ignore_mismatch: bool, store_hash_raw_data_for_debug: bool, use_bg_thread_pool: bool ) -> Result<(), BankHashVerificationError>
Only called from startup or test code.
sourcepub fn scan_slot_and_insert_dirty_pubkeys_into_uncleaned_pubkeys(
&self,
slot: Slot
)
pub fn scan_slot_and_insert_dirty_pubkeys_into_uncleaned_pubkeys( &self, slot: Slot )
Scan a slot in the account storage for dirty pubkeys and insert them into the list of uncleaned pubkeys
This function is called in Bank::drop() when the bank is not frozen, so that its pubkeys are considered for cleanup.
pub fn get_accounts_delta_hash(&self, slot: Slot) -> Hash
pub fn get_accounts_delta_hash_with_rewrites( &self, slot: Slot, skipped_rewrites: &Rewrites ) -> Hash
pub fn store_cached<'a, T: ReadableAccount + Sync + ZeroLamport>( &self, accounts: impl StorableAccounts<'a, T>, txn_signatures: Option<&'a [Option<&'a Signature>]> )
sourcepub fn store_uncached(
&self,
slot: Slot,
accounts: &[(&Pubkey, &AccountSharedData)]
)
pub fn store_uncached( &self, slot: Slot, accounts: &[(&Pubkey, &AccountSharedData)] )
Store the account update. only called by tests
pub fn add_root(&self, slot: Slot) -> AccountsAddRootTiming
pub fn get_snapshot_storages( &self, snapshot_slot: Slot, snapshot_base_slot: Option<Slot>, ancestors: Option<&Ancestors> ) -> (SnapshotStorages, Vec<Slot>)
pub fn is_filler_account_helper( pubkey: &Pubkey, filler_account_suffix: Option<&Pubkey> ) -> bool
sourcepub fn is_filler_account(&self, pubkey: &Pubkey) -> bool
pub fn is_filler_account(&self, pubkey: &Pubkey) -> bool
true if ‘pubkey’ is a filler account
sourcepub fn filler_accounts_enabled(&self) -> bool
pub fn filler_accounts_enabled(&self) -> bool
true if it is possible that there are filler accounts present
sourcepub fn maybe_add_filler_accounts(
&self,
epoch_schedule: &EpochSchedule,
rent: &Rent,
slot: Slot
)
pub fn maybe_add_filler_accounts( &self, epoch_schedule: &EpochSchedule, rent: &Rent, slot: Slot )
filler accounts are space-holding accounts which are ignored by hash calculations and rent. They are designed to allow a validator to run against a network successfully while simulating having many more accounts present. All filler accounts share a common pubkey suffix. The suffix is randomly generated per validator on startup. The filler accounts are added to each slot in the snapshot after index generation. The accounts added in a slot are setup to have pubkeys such that rent will be collected from them before (or when?) their slot becomes an epoch old. Thus, the filler accounts are rewritten by rent and the old slot can be thrown away successfully.
pub fn generate_index( &self, limit_load_slot_count_from_snapshot: Option<usize>, verify: bool, genesis_config: &GenesisConfig ) -> IndexGenerationInfo
source§impl AccountsDb
impl AccountsDb
Legacy shrink functions to support non-cached path. Should be able to be deleted after cache path is the only path.