AccountsIndexConfig -> AccountsDbConfig (#19687)
This commit is contained in:
committed by
GitHub
parent
590e113f16
commit
456bf15012
@ -1,12 +1,10 @@
|
||||
use crate::{
|
||||
accounts_db::{
|
||||
AccountShrinkThreshold, AccountsDb, BankHashInfo, ErrorCounters, LoadHint, LoadedAccount,
|
||||
ScanStorageResult,
|
||||
},
|
||||
accounts_index::{
|
||||
AccountSecondaryIndexes, AccountsIndexConfig, IndexKey, ScanResult,
|
||||
ACCOUNTS_INDEX_CONFIG_FOR_BENCHMARKS, ACCOUNTS_INDEX_CONFIG_FOR_TESTING,
|
||||
AccountShrinkThreshold, AccountsDb, AccountsDbConfig, BankHashInfo, ErrorCounters,
|
||||
LoadHint, LoadedAccount, ScanStorageResult, ACCOUNTS_DB_CONFIG_FOR_BENCHMARKS,
|
||||
ACCOUNTS_DB_CONFIG_FOR_TESTING,
|
||||
},
|
||||
accounts_index::{AccountSecondaryIndexes, IndexKey, ScanResult},
|
||||
ancestors::Ancestors,
|
||||
bank::{
|
||||
NonceRollbackFull, NonceRollbackInfo, RentDebits, TransactionCheckResult,
|
||||
@ -140,7 +138,7 @@ impl Accounts {
|
||||
account_indexes,
|
||||
caching_enabled,
|
||||
shrink_ratio,
|
||||
Some(ACCOUNTS_INDEX_CONFIG_FOR_TESTING),
|
||||
Some(ACCOUNTS_DB_CONFIG_FOR_TESTING),
|
||||
)
|
||||
}
|
||||
|
||||
@ -157,7 +155,7 @@ impl Accounts {
|
||||
account_indexes,
|
||||
caching_enabled,
|
||||
shrink_ratio,
|
||||
Some(ACCOUNTS_INDEX_CONFIG_FOR_BENCHMARKS),
|
||||
Some(ACCOUNTS_DB_CONFIG_FOR_BENCHMARKS),
|
||||
)
|
||||
}
|
||||
|
||||
@ -167,7 +165,7 @@ impl Accounts {
|
||||
account_indexes: AccountSecondaryIndexes,
|
||||
caching_enabled: bool,
|
||||
shrink_ratio: AccountShrinkThreshold,
|
||||
accounts_index_config: Option<AccountsIndexConfig>,
|
||||
accounts_db_config: Option<AccountsDbConfig>,
|
||||
) -> Self {
|
||||
Self {
|
||||
accounts_db: Arc::new(AccountsDb::new_with_config(
|
||||
@ -176,7 +174,7 @@ impl Accounts {
|
||||
account_indexes,
|
||||
caching_enabled,
|
||||
shrink_ratio,
|
||||
accounts_index_config,
|
||||
accounts_db_config,
|
||||
)),
|
||||
account_locks: Mutex::new(AccountLocks::default()),
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ use crate::{
|
||||
accounts_index::{
|
||||
AccountIndexGetResult, AccountSecondaryIndexes, AccountsIndex, AccountsIndexConfig,
|
||||
AccountsIndexRootsStats, IndexKey, IsCached, RefCount, ScanResult, SlotList, SlotSlice,
|
||||
ZeroLamport, ACCOUNTS_INDEX_CONFIG_FOR_TESTING,
|
||||
ZeroLamport, ACCOUNTS_INDEX_CONFIG_FOR_BENCHMARKS, ACCOUNTS_INDEX_CONFIG_FOR_TESTING,
|
||||
},
|
||||
ancestors::Ancestors,
|
||||
append_vec::{AppendVec, StoredAccountMeta, StoredMeta, StoredMetaWriteVersion},
|
||||
@ -118,6 +118,18 @@ const CACHE_VIRTUAL_WRITE_VERSION: StoredMetaWriteVersion = 0;
|
||||
const CACHE_VIRTUAL_OFFSET: usize = 0;
|
||||
const CACHE_VIRTUAL_STORED_SIZE: usize = 0;
|
||||
|
||||
pub const ACCOUNTS_DB_CONFIG_FOR_TESTING: AccountsDbConfig = AccountsDbConfig {
|
||||
index: Some(ACCOUNTS_INDEX_CONFIG_FOR_TESTING),
|
||||
};
|
||||
pub const ACCOUNTS_DB_CONFIG_FOR_BENCHMARKS: AccountsDbConfig = AccountsDbConfig {
|
||||
index: Some(ACCOUNTS_INDEX_CONFIG_FOR_BENCHMARKS),
|
||||
};
|
||||
|
||||
#[derive(Debug, Default, Clone)]
|
||||
pub struct AccountsDbConfig {
|
||||
pub index: Option<AccountsIndexConfig>,
|
||||
}
|
||||
|
||||
struct FoundStoredAccount<'a> {
|
||||
pub account: StoredAccountMeta<'a>,
|
||||
pub store_id: AppendVecId,
|
||||
@ -1458,7 +1470,7 @@ impl AccountsDb {
|
||||
AccountSecondaryIndexes::default(),
|
||||
false,
|
||||
AccountShrinkThreshold::default(),
|
||||
Some(ACCOUNTS_INDEX_CONFIG_FOR_TESTING),
|
||||
Some(ACCOUNTS_DB_CONFIG_FOR_TESTING),
|
||||
)
|
||||
}
|
||||
|
||||
@ -1468,9 +1480,9 @@ impl AccountsDb {
|
||||
account_indexes: AccountSecondaryIndexes,
|
||||
caching_enabled: bool,
|
||||
shrink_ratio: AccountShrinkThreshold,
|
||||
accounts_index_config: Option<AccountsIndexConfig>,
|
||||
accounts_db_config: Option<AccountsDbConfig>,
|
||||
) -> Self {
|
||||
let accounts_index = AccountsIndex::new(accounts_index_config);
|
||||
let accounts_index = AccountsIndex::new(accounts_db_config.and_then(|x| x.index));
|
||||
let mut new = if !paths.is_empty() {
|
||||
Self {
|
||||
paths,
|
||||
@ -6498,7 +6510,7 @@ impl AccountsDb {
|
||||
account_indexes,
|
||||
caching_enabled,
|
||||
shrink_ratio,
|
||||
Some(ACCOUNTS_INDEX_CONFIG_FOR_TESTING),
|
||||
Some(ACCOUNTS_DB_CONFIG_FOR_TESTING),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -38,11 +38,11 @@ use crate::{
|
||||
AccountAddressFilter, Accounts, TransactionAccounts, TransactionLoadResult,
|
||||
TransactionLoaders,
|
||||
},
|
||||
accounts_db::{AccountShrinkThreshold, ErrorCounters, SnapshotStorages},
|
||||
accounts_index::{
|
||||
AccountSecondaryIndexes, AccountsIndexConfig, IndexKey, ScanResult,
|
||||
ACCOUNTS_INDEX_CONFIG_FOR_BENCHMARKS, ACCOUNTS_INDEX_CONFIG_FOR_TESTING,
|
||||
accounts_db::{
|
||||
AccountShrinkThreshold, AccountsDbConfig, ErrorCounters, SnapshotStorages,
|
||||
ACCOUNTS_DB_CONFIG_FOR_BENCHMARKS, ACCOUNTS_DB_CONFIG_FOR_TESTING,
|
||||
},
|
||||
accounts_index::{AccountSecondaryIndexes, IndexKey, ScanResult},
|
||||
ancestors::{Ancestors, AncestorsForSerialization},
|
||||
blockhash_queue::BlockhashQueue,
|
||||
builtins::{self, ActivationType, Builtin, Builtins},
|
||||
@ -1140,7 +1140,7 @@ impl Bank {
|
||||
accounts_db_caching_enabled,
|
||||
shrink_ratio,
|
||||
debug_do_not_add_builtins,
|
||||
Some(ACCOUNTS_INDEX_CONFIG_FOR_TESTING),
|
||||
Some(ACCOUNTS_DB_CONFIG_FOR_TESTING),
|
||||
)
|
||||
}
|
||||
|
||||
@ -1165,7 +1165,7 @@ impl Bank {
|
||||
accounts_db_caching_enabled,
|
||||
shrink_ratio,
|
||||
debug_do_not_add_builtins,
|
||||
Some(ACCOUNTS_INDEX_CONFIG_FOR_BENCHMARKS),
|
||||
Some(ACCOUNTS_DB_CONFIG_FOR_BENCHMARKS),
|
||||
)
|
||||
}
|
||||
|
||||
@ -1180,7 +1180,7 @@ impl Bank {
|
||||
accounts_db_caching_enabled: bool,
|
||||
shrink_ratio: AccountShrinkThreshold,
|
||||
debug_do_not_add_builtins: bool,
|
||||
accounts_index_config: Option<AccountsIndexConfig>,
|
||||
accounts_db_config: Option<AccountsDbConfig>,
|
||||
) -> Self {
|
||||
let accounts = Accounts::new_with_config(
|
||||
paths,
|
||||
@ -1188,7 +1188,7 @@ impl Bank {
|
||||
account_indexes,
|
||||
accounts_db_caching_enabled,
|
||||
shrink_ratio,
|
||||
accounts_index_config,
|
||||
accounts_db_config,
|
||||
);
|
||||
let mut bank = Self::default_with_accounts(accounts);
|
||||
bank.ancestors = Ancestors::from(vec![bank.slot()]);
|
||||
|
@ -2,9 +2,10 @@ use {
|
||||
crate::{
|
||||
accounts::Accounts,
|
||||
accounts_db::{
|
||||
AccountShrinkThreshold, AccountStorageEntry, AccountsDb, AppendVecId, BankHashInfo,
|
||||
AccountShrinkThreshold, AccountStorageEntry, AccountsDb, AccountsDbConfig, AppendVecId,
|
||||
BankHashInfo,
|
||||
},
|
||||
accounts_index::{AccountSecondaryIndexes, AccountsIndexConfig},
|
||||
accounts_index::AccountSecondaryIndexes,
|
||||
ancestors::Ancestors,
|
||||
append_vec::{AppendVec, StoredMetaWriteVersion},
|
||||
bank::{Bank, BankFieldsToDeserialize, BankRc},
|
||||
@ -198,7 +199,7 @@ pub(crate) fn bank_from_streams<R>(
|
||||
limit_load_slot_count_from_snapshot: Option<usize>,
|
||||
shrink_ratio: AccountShrinkThreshold,
|
||||
verify_index: bool,
|
||||
accounts_index_config: Option<AccountsIndexConfig>,
|
||||
accounts_db_config: Option<AccountsDbConfig>,
|
||||
) -> std::result::Result<Bank, Error>
|
||||
where
|
||||
R: Read,
|
||||
@ -236,7 +237,7 @@ where
|
||||
limit_load_slot_count_from_snapshot,
|
||||
shrink_ratio,
|
||||
verify_index,
|
||||
accounts_index_config,
|
||||
accounts_db_config,
|
||||
)?;
|
||||
Ok(bank)
|
||||
}};
|
||||
@ -329,7 +330,7 @@ fn reconstruct_bank_from_fields<E>(
|
||||
limit_load_slot_count_from_snapshot: Option<usize>,
|
||||
shrink_ratio: AccountShrinkThreshold,
|
||||
verify_index: bool,
|
||||
accounts_index_config: Option<AccountsIndexConfig>,
|
||||
accounts_db_config: Option<AccountsDbConfig>,
|
||||
) -> Result<Bank, Error>
|
||||
where
|
||||
E: SerializableStorage + std::marker::Sync,
|
||||
@ -344,7 +345,7 @@ where
|
||||
limit_load_slot_count_from_snapshot,
|
||||
shrink_ratio,
|
||||
verify_index,
|
||||
accounts_index_config,
|
||||
accounts_db_config,
|
||||
)?;
|
||||
accounts_db.freeze_accounts(
|
||||
&Ancestors::from(&bank_fields.ancestors),
|
||||
@ -396,7 +397,7 @@ fn reconstruct_accountsdb_from_fields<E>(
|
||||
limit_load_slot_count_from_snapshot: Option<usize>,
|
||||
shrink_ratio: AccountShrinkThreshold,
|
||||
verify_index: bool,
|
||||
accounts_index_config: Option<AccountsIndexConfig>,
|
||||
accounts_db_config: Option<AccountsDbConfig>,
|
||||
) -> Result<AccountsDb, Error>
|
||||
where
|
||||
E: SerializableStorage + std::marker::Sync,
|
||||
@ -407,7 +408,7 @@ where
|
||||
account_secondary_indexes,
|
||||
caching_enabled,
|
||||
shrink_ratio,
|
||||
accounts_index_config,
|
||||
accounts_db_config,
|
||||
);
|
||||
|
||||
let AccountsDbFields(
|
||||
|
@ -83,7 +83,7 @@ where
|
||||
None,
|
||||
AccountShrinkThreshold::default(),
|
||||
false,
|
||||
Some(crate::accounts_index::ACCOUNTS_INDEX_CONFIG_FOR_TESTING),
|
||||
Some(crate::accounts_db::ACCOUNTS_DB_CONFIG_FOR_TESTING),
|
||||
)
|
||||
}
|
||||
|
||||
@ -245,7 +245,7 @@ fn test_bank_serialize_style(serde_style: SerdeStyle) {
|
||||
None,
|
||||
AccountShrinkThreshold::default(),
|
||||
false,
|
||||
Some(crate::accounts_index::ACCOUNTS_INDEX_CONFIG_FOR_TESTING),
|
||||
Some(crate::accounts_db::ACCOUNTS_DB_CONFIG_FOR_TESTING),
|
||||
)
|
||||
.unwrap();
|
||||
dbank.src = ref_sc;
|
||||
|
@ -1,7 +1,7 @@
|
||||
use {
|
||||
crate::{
|
||||
accounts_db::AccountShrinkThreshold,
|
||||
accounts_index::{AccountSecondaryIndexes, AccountsIndexConfig},
|
||||
accounts_db::{AccountShrinkThreshold, AccountsDbConfig},
|
||||
accounts_index::AccountSecondaryIndexes,
|
||||
bank::{Bank, BankSlotDelta},
|
||||
builtins::Builtins,
|
||||
hardened_unpack::{unpack_snapshot, ParallelSelector, UnpackError, UnpackedAppendVecMap},
|
||||
@ -732,7 +732,7 @@ pub fn bank_from_snapshot_archives(
|
||||
test_hash_calculation: bool,
|
||||
accounts_db_skip_shrink: bool,
|
||||
verify_index: bool,
|
||||
accounts_index_config: Option<AccountsIndexConfig>,
|
||||
accounts_db_config: Option<AccountsDbConfig>,
|
||||
) -> Result<(Bank, BankFromArchiveTimings)> {
|
||||
check_are_snapshots_compatible(
|
||||
full_snapshot_archive_info,
|
||||
@ -796,7 +796,7 @@ pub fn bank_from_snapshot_archives(
|
||||
limit_load_slot_count_from_snapshot,
|
||||
shrink_ratio,
|
||||
verify_index,
|
||||
accounts_index_config,
|
||||
accounts_db_config,
|
||||
)?;
|
||||
measure_rebuild.stop();
|
||||
info!("{}", measure_rebuild);
|
||||
@ -842,7 +842,7 @@ pub fn bank_from_latest_snapshot_archives(
|
||||
test_hash_calculation: bool,
|
||||
accounts_db_skip_shrink: bool,
|
||||
verify_index: bool,
|
||||
accounts_index_config: Option<AccountsIndexConfig>,
|
||||
accounts_db_config: Option<AccountsDbConfig>,
|
||||
) -> Result<(
|
||||
Bank,
|
||||
BankFromArchiveTimings,
|
||||
@ -885,7 +885,7 @@ pub fn bank_from_latest_snapshot_archives(
|
||||
test_hash_calculation,
|
||||
accounts_db_skip_shrink,
|
||||
verify_index,
|
||||
accounts_index_config,
|
||||
accounts_db_config,
|
||||
)?;
|
||||
|
||||
verify_bank_against_expected_slot_hash(
|
||||
@ -1421,7 +1421,7 @@ fn rebuild_bank_from_snapshots(
|
||||
limit_load_slot_count_from_snapshot: Option<usize>,
|
||||
shrink_ratio: AccountShrinkThreshold,
|
||||
verify_index: bool,
|
||||
accounts_index_config: Option<AccountsIndexConfig>,
|
||||
accounts_db_config: Option<AccountsDbConfig>,
|
||||
) -> Result<Bank> {
|
||||
let (full_snapshot_version, full_snapshot_root_paths) =
|
||||
verify_unpacked_snapshots_dir_and_version(
|
||||
@ -1469,7 +1469,7 @@ fn rebuild_bank_from_snapshots(
|
||||
limit_load_slot_count_from_snapshot,
|
||||
shrink_ratio,
|
||||
verify_index,
|
||||
accounts_index_config,
|
||||
accounts_db_config,
|
||||
),
|
||||
}?,
|
||||
)
|
||||
@ -1814,6 +1814,7 @@ pub fn should_take_incremental_snapshot(
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::accounts_db::ACCOUNTS_DB_CONFIG_FOR_TESTING;
|
||||
use assert_matches::assert_matches;
|
||||
use bincode::{deserialize_from, serialize_into};
|
||||
use solana_sdk::{
|
||||
@ -2606,7 +2607,7 @@ mod tests {
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
Some(crate::accounts_index::ACCOUNTS_INDEX_CONFIG_FOR_TESTING),
|
||||
Some(ACCOUNTS_DB_CONFIG_FOR_TESTING),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
@ -2697,7 +2698,7 @@ mod tests {
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
Some(crate::accounts_index::ACCOUNTS_INDEX_CONFIG_FOR_TESTING),
|
||||
Some(ACCOUNTS_DB_CONFIG_FOR_TESTING),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
@ -2807,7 +2808,7 @@ mod tests {
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
Some(crate::accounts_index::ACCOUNTS_INDEX_CONFIG_FOR_TESTING),
|
||||
Some(ACCOUNTS_DB_CONFIG_FOR_TESTING),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
@ -2906,7 +2907,7 @@ mod tests {
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
Some(crate::accounts_index::ACCOUNTS_INDEX_CONFIG_FOR_TESTING),
|
||||
Some(ACCOUNTS_DB_CONFIG_FOR_TESTING),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
@ -3047,7 +3048,7 @@ mod tests {
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
Some(crate::accounts_index::ACCOUNTS_INDEX_CONFIG_FOR_TESTING),
|
||||
Some(ACCOUNTS_DB_CONFIG_FOR_TESTING),
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
@ -3109,7 +3110,7 @@ mod tests {
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
Some(crate::accounts_index::ACCOUNTS_INDEX_CONFIG_FOR_TESTING),
|
||||
Some(ACCOUNTS_DB_CONFIG_FOR_TESTING),
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
|
Reference in New Issue
Block a user