type AccountSecondaryIndexes = HashSet (backport #17108) (#17149)

* type AccountSecondaryIndexes = HashSet (#17108)

(cherry picked from commit f39dda00e0)

# Conflicts:
#	runtime/benches/accounts.rs
#	runtime/src/accounts.rs
#	runtime/src/accounts_db.rs
#	runtime/src/accounts_index.rs

* resolve merge errors

Co-authored-by: Jeff Washington (jwash) <75863576+jeffwashington@users.noreply.github.com>
Co-authored-by: Jeff Washington (jwash) <wash678@gmail.com>
This commit is contained in:
mergify[bot]
2021-05-10 20:55:33 +00:00
committed by GitHub
parent 0cf83887c6
commit 733ef4b0b8
13 changed files with 220 additions and 134 deletions

View File

@ -6,10 +6,10 @@ use rayon::prelude::*;
use solana_measure::measure::Measure;
use solana_runtime::{
accounts::{create_test_accounts, update_accounts_bench, Accounts},
accounts_index::Ancestors,
accounts_index::{AccountSecondaryIndexes, Ancestors},
};
use solana_sdk::{genesis_config::ClusterType, pubkey::Pubkey};
use std::{collections::HashSet, env, fs, path::PathBuf};
use std::{env, fs, path::PathBuf};
fn main() {
solana_logger::setup();
@ -58,8 +58,12 @@ fn main() {
if fs::remove_dir_all(path.clone()).is_err() {
println!("Warning: Couldn't remove {:?}", path);
}
let accounts =
Accounts::new_with_config(vec![path], &ClusterType::Testnet, HashSet::new(), false);
let accounts = Accounts::new_with_config(
vec![path],
&ClusterType::Testnet,
AccountSecondaryIndexes::default(),
false,
);
println!("Creating {} accounts", num_accounts);
let mut create_time = Measure::start("create accounts");
let pubkeys: Vec<_> = (0..num_slots)

View File

@ -46,7 +46,7 @@ use solana_ledger::{
use solana_measure::measure::Measure;
use solana_metrics::datapoint_info;
use solana_runtime::{
accounts_index::AccountIndex,
accounts_index::AccountSecondaryIndexes,
bank::Bank,
bank_forks::{BankForks, SnapshotConfig},
commitment::BlockCommitmentCache,
@ -125,7 +125,7 @@ pub struct ValidatorConfig {
pub no_poh_speed_test: bool,
pub poh_pinned_cpu_core: usize,
pub poh_hashes_per_batch: u64,
pub account_indexes: HashSet<AccountIndex>,
pub account_indexes: AccountSecondaryIndexes,
pub accounts_db_caching_enabled: bool,
pub warp_slot: Option<Slot>,
pub accounts_db_test_hash_calculation: bool,
@ -181,7 +181,7 @@ impl Default for ValidatorConfig {
no_poh_speed_test: true,
poh_pinned_cpu_core: poh_service::DEFAULT_PINNED_CPU_CORE,
poh_hashes_per_batch: poh_service::DEFAULT_HASHES_PER_BATCH,
account_indexes: HashSet::new(),
account_indexes: AccountSecondaryIndexes::default(),
accounts_db_caching_enabled: false,
warp_slot: None,
accounts_db_test_hash_calculation: false,

View File

@ -47,6 +47,7 @@ mod tests {
use solana_runtime::{
accounts_background_service::{AbsRequestSender, SnapshotRequestHandler},
accounts_db,
accounts_index::AccountSecondaryIndexes,
bank::{Bank, BankSlotDelta},
bank_forks::{ArchiveFormat, BankForks, SnapshotConfig},
genesis_utils::{create_genesis_config, GenesisConfigInfo},
@ -106,7 +107,7 @@ mod tests {
&[],
None,
None,
HashSet::new(),
AccountSecondaryIndexes::default(),
false,
);
bank0.freeze();
@ -163,7 +164,7 @@ mod tests {
old_genesis_config,
None,
None,
HashSet::new(),
AccountSecondaryIndexes::default(),
false,
)
.unwrap();

View File

@ -16,7 +16,7 @@ use solana_measure::{measure::Measure, thread_mem_usage};
use solana_metrics::{datapoint_error, inc_new_counter_debug};
use solana_rayon_threadlimit::get_thread_count;
use solana_runtime::{
accounts_index::AccountIndex,
accounts_index::AccountSecondaryIndexes,
bank::{
Bank, ExecuteTimings, InnerInstructionsList, TransactionBalancesSet,
TransactionExecutionResult, TransactionLogMessages, TransactionResults,
@ -366,7 +366,7 @@ pub struct ProcessOptions {
pub new_hard_forks: Option<Vec<Slot>>,
pub frozen_accounts: Vec<Pubkey>,
pub debug_keys: Option<Arc<HashSet<Pubkey>>>,
pub account_indexes: HashSet<AccountIndex>,
pub account_indexes: AccountSecondaryIndexes,
pub accounts_db_caching_enabled: bool,
pub allow_dead_slots: bool,
}
@ -3042,7 +3042,7 @@ pub mod tests {
&[],
None,
None,
HashSet::new(),
AccountSecondaryIndexes::default(),
false,
);
*bank.epoch_schedule()

View File

@ -8,6 +8,7 @@ use rand::Rng;
use rayon::iter::{IntoParallelRefIterator, ParallelIterator};
use solana_runtime::{
accounts::{create_test_accounts, AccountAddressFilter, Accounts},
accounts_index::AccountSecondaryIndexes,
bank::*,
};
use solana_sdk::{
@ -53,7 +54,7 @@ fn test_accounts_create(bencher: &mut Bencher) {
&[],
None,
None,
HashSet::new(),
AccountSecondaryIndexes::default(),
false,
);
bencher.iter(|| {
@ -72,7 +73,7 @@ fn test_accounts_squash(bencher: &mut Bencher) {
&[],
None,
None,
HashSet::new(),
AccountSecondaryIndexes::default(),
false,
));
let mut pubkeys: Vec<Pubkey> = vec![];
@ -97,7 +98,7 @@ fn test_accounts_hash_bank_hash(bencher: &mut Bencher) {
let accounts = Accounts::new_with_config(
vec![PathBuf::from("bench_accounts_hash_internal")],
&ClusterType::Development,
HashSet::new(),
AccountSecondaryIndexes::default(),
false,
);
let mut pubkeys: Vec<Pubkey> = vec![];
@ -115,7 +116,7 @@ fn test_update_accounts_hash(bencher: &mut Bencher) {
let accounts = Accounts::new_with_config(
vec![PathBuf::from("update_accounts_hash")],
&ClusterType::Development,
HashSet::new(),
AccountSecondaryIndexes::default(),
false,
);
let mut pubkeys: Vec<Pubkey> = vec![];
@ -132,7 +133,7 @@ fn test_accounts_delta_hash(bencher: &mut Bencher) {
let accounts = Accounts::new_with_config(
vec![PathBuf::from("accounts_delta_hash")],
&ClusterType::Development,
HashSet::new(),
AccountSecondaryIndexes::default(),
false,
);
let mut pubkeys: Vec<Pubkey> = vec![];
@ -148,7 +149,7 @@ fn bench_delete_dependencies(bencher: &mut Bencher) {
let accounts = Accounts::new_with_config(
vec![PathBuf::from("accounts_delete_deps")],
&ClusterType::Development,
HashSet::new(),
AccountSecondaryIndexes::default(),
false,
);
let mut old_pubkey = Pubkey::default();
@ -181,7 +182,7 @@ fn store_accounts_with_possible_contention<F: 'static>(
.join(bench_name),
],
&ClusterType::Development,
HashSet::new(),
AccountSecondaryIndexes::default(),
false,
));
let num_keys = 1000;
@ -306,7 +307,7 @@ fn setup_bench_dashmap_iter() -> (Arc<Accounts>, DashMap<Pubkey, (AccountSharedD
.join("bench_dashmap_par_iter"),
],
&ClusterType::Development,
HashSet::new(),
AccountSecondaryIndexes::default(),
false,
));
@ -357,8 +358,12 @@ fn bench_dashmap_iter(bencher: &mut Bencher) {
#[bench]
fn bench_load_largest_accounts(b: &mut Bencher) {
let accounts =
Accounts::new_with_config(Vec::new(), &ClusterType::Development, HashSet::new(), false);
let accounts = Accounts::new_with_config(
Vec::new(),
&ClusterType::Development,
AccountSecondaryIndexes::default(),
false,
);
let mut rng = rand::thread_rng();
for _ in 0..10_000 {
let lamports = rng.gen();

View File

@ -3,9 +3,11 @@
extern crate test;
use rand::{thread_rng, Rng};
use solana_runtime::{accounts_db::AccountInfo, accounts_index::AccountsIndex};
use solana_runtime::{
accounts_db::AccountInfo,
accounts_index::{AccountSecondaryIndexes, AccountsIndex},
};
use solana_sdk::pubkey::{self, Pubkey};
use std::collections::HashSet;
use test::Bencher;
#[bench]
@ -24,7 +26,7 @@ fn bench_accounts_index(bencher: &mut Bencher) {
pubkey,
&Pubkey::default(),
&[],
&HashSet::new(),
&AccountSecondaryIndexes::default(),
AccountInfo::default(),
&mut reclaims,
);
@ -41,7 +43,7 @@ fn bench_accounts_index(bencher: &mut Bencher) {
&pubkeys[pubkey],
&Pubkey::default(),
&[],
&HashSet::new(),
&AccountSecondaryIndexes::default(),
AccountInfo::default(),
&mut reclaims,
);

View File

@ -1,6 +1,6 @@
use crate::{
accounts_db::{AccountsDb, BankHashInfo, ErrorCounters, LoadedAccount, ScanStorageResult},
accounts_index::{AccountIndex, Ancestors, IndexKey},
accounts_index::{AccountSecondaryIndexes, Ancestors, IndexKey},
bank::{
NonceRollbackFull, NonceRollbackInfo, TransactionCheckResult, TransactionExecutionResult,
},
@ -113,13 +113,18 @@ pub enum AccountAddressFilter {
impl Accounts {
pub fn new(paths: Vec<PathBuf>, cluster_type: &ClusterType) -> Self {
Self::new_with_config(paths, cluster_type, HashSet::new(), false)
Self::new_with_config(
paths,
cluster_type,
AccountSecondaryIndexes::default(),
false,
)
}
pub fn new_with_config(
paths: Vec<PathBuf>,
cluster_type: &ClusterType,
account_indexes: HashSet<AccountIndex>,
account_indexes: AccountSecondaryIndexes,
caching_enabled: bool,
) -> Self {
Self {
@ -1066,8 +1071,12 @@ mod tests {
) -> Vec<TransactionLoadResult> {
let mut hash_queue = BlockhashQueue::new(100);
hash_queue.register_hash(&tx.message().recent_blockhash, &fee_calculator);
let accounts =
Accounts::new_with_config(Vec::new(), &ClusterType::Development, HashSet::new(), false);
let accounts = Accounts::new_with_config(
Vec::new(),
&ClusterType::Development,
AccountSecondaryIndexes::default(),
false,
);
for ka in ka.iter() {
accounts.store_slow_uncached(0, &ka.0, &ka.1);
}
@ -1599,8 +1608,12 @@ mod tests {
#[test]
fn test_load_by_program_slot() {
let accounts =
Accounts::new_with_config(Vec::new(), &ClusterType::Development, HashSet::new(), false);
let accounts = Accounts::new_with_config(
Vec::new(),
&ClusterType::Development,
AccountSecondaryIndexes::default(),
false,
);
// Load accounts owned by various programs into AccountsDb
let pubkey0 = solana_sdk::pubkey::new_rand();
@ -1623,8 +1636,12 @@ mod tests {
#[test]
fn test_accounts_account_not_found() {
let accounts =
Accounts::new_with_config(Vec::new(), &ClusterType::Development, HashSet::new(), false);
let accounts = Accounts::new_with_config(
Vec::new(),
&ClusterType::Development,
AccountSecondaryIndexes::default(),
false,
);
let mut error_counters = ErrorCounters::default();
let ancestors = vec![(0, 0)].into_iter().collect();
@ -1642,8 +1659,12 @@ mod tests {
#[test]
#[should_panic]
fn test_accounts_empty_bank_hash() {
let accounts =
Accounts::new_with_config(Vec::new(), &ClusterType::Development, HashSet::new(), false);
let accounts = Accounts::new_with_config(
Vec::new(),
&ClusterType::Development,
AccountSecondaryIndexes::default(),
false,
);
accounts.bank_hash_at(1);
}
@ -1659,8 +1680,12 @@ mod tests {
let account2 = AccountSharedData::new(3, 0, &Pubkey::default());
let account3 = AccountSharedData::new(4, 0, &Pubkey::default());
let accounts =
Accounts::new_with_config(Vec::new(), &ClusterType::Development, HashSet::new(), false);
let accounts = Accounts::new_with_config(
Vec::new(),
&ClusterType::Development,
AccountSecondaryIndexes::default(),
false,
);
accounts.store_slow_uncached(0, &keypair0.pubkey(), &account0);
accounts.store_slow_uncached(0, &keypair1.pubkey(), &account1);
accounts.store_slow_uncached(0, &keypair2.pubkey(), &account2);
@ -1781,8 +1806,12 @@ mod tests {
let account1 = AccountSharedData::new(2, 0, &Pubkey::default());
let account2 = AccountSharedData::new(3, 0, &Pubkey::default());
let accounts =
Accounts::new_with_config(Vec::new(), &ClusterType::Development, HashSet::new(), false);
let accounts = Accounts::new_with_config(
Vec::new(),
&ClusterType::Development,
AccountSecondaryIndexes::default(),
false,
);
accounts.store_slow_uncached(0, &keypair0.pubkey(), &account0);
accounts.store_slow_uncached(0, &keypair1.pubkey(), &account1);
accounts.store_slow_uncached(0, &keypair2.pubkey(), &account2);
@ -1925,8 +1954,12 @@ mod tests {
let mut loaded = vec![loaded0, loaded1];
let accounts =
Accounts::new_with_config(Vec::new(), &ClusterType::Development, HashSet::new(), false);
let accounts = Accounts::new_with_config(
Vec::new(),
&ClusterType::Development,
AccountSecondaryIndexes::default(),
false,
);
{
accounts
.account_locks
@ -1973,8 +2006,12 @@ mod tests {
#[test]
fn huge_clean() {
solana_logger::setup();
let accounts =
Accounts::new_with_config(Vec::new(), &ClusterType::Development, HashSet::new(), false);
let accounts = Accounts::new_with_config(
Vec::new(),
&ClusterType::Development,
AccountSecondaryIndexes::default(),
false,
);
let mut old_pubkey = Pubkey::default();
let zero_account = AccountSharedData::new(0, 0, &AccountSharedData::default().owner);
info!("storing..");
@ -2016,8 +2053,12 @@ mod tests {
#[test]
fn test_instructions() {
solana_logger::setup();
let accounts =
Accounts::new_with_config(Vec::new(), &ClusterType::Development, HashSet::new(), false);
let accounts = Accounts::new_with_config(
Vec::new(),
&ClusterType::Development,
AccountSecondaryIndexes::default(),
false,
);
let instructions_key = solana_sdk::sysvar::instructions::id();
let keypair = Keypair::new();
@ -2296,8 +2337,12 @@ mod tests {
let mut loaded = vec![loaded];
let next_blockhash = Hash::new_unique();
let accounts =
Accounts::new_with_config(Vec::new(), &ClusterType::Development, HashSet::new(), false);
let accounts = Accounts::new_with_config(
Vec::new(),
&ClusterType::Development,
AccountSecondaryIndexes::default(),
false,
);
let collected_accounts = accounts.collect_accounts_to_store(
txs.iter(),
&loaders,
@ -2407,8 +2452,12 @@ mod tests {
let mut loaded = vec![loaded];
let next_blockhash = Hash::new_unique();
let accounts =
Accounts::new_with_config(Vec::new(), &ClusterType::Development, HashSet::new(), false);
let accounts = Accounts::new_with_config(
Vec::new(),
&ClusterType::Development,
AccountSecondaryIndexes::default(),
false,
);
let collected_accounts = accounts.collect_accounts_to_store(
txs.iter(),
&loaders,
@ -2434,8 +2483,12 @@ mod tests {
#[test]
fn test_load_largest_accounts() {
let accounts =
Accounts::new_with_config(Vec::new(), &ClusterType::Development, HashSet::new(), false);
let accounts = Accounts::new_with_config(
Vec::new(),
&ClusterType::Development,
AccountSecondaryIndexes::default(),
false,
);
let pubkey0 = Pubkey::new_unique();
let account0 = AccountSharedData::new(42, 0, &Pubkey::default());

View File

@ -22,8 +22,8 @@ use crate::{
accounts_cache::{AccountsCache, CachedAccount, SlotCache},
accounts_hash::{AccountsHash, CalculateHashIntermediate, HashStats},
accounts_index::{
AccountIndex, AccountsIndex, AccountsIndexRootsStats, Ancestors, IndexKey, IsCached,
SlotList, SlotSlice, ZeroLamport,
AccountSecondaryIndexes, AccountsIndex, AccountsIndexRootsStats, Ancestors, IndexKey,
IsCached, SlotList, SlotSlice, ZeroLamport,
},
append_vec::{AppendVec, StoredAccountMeta, StoredMeta},
contains::Contains,
@ -740,7 +740,7 @@ pub struct AccountsDb {
pub cluster_type: Option<ClusterType>,
pub account_indexes: HashSet<AccountIndex>,
pub account_indexes: AccountSecondaryIndexes,
pub caching_enabled: bool,
@ -1092,7 +1092,7 @@ impl Default for AccountsDb {
shrink_stats: ShrinkStats::default(),
stats: AccountsStats::default(),
cluster_type: None,
account_indexes: HashSet::new(),
account_indexes: AccountSecondaryIndexes::default(),
caching_enabled: false,
}
}
@ -1100,13 +1100,18 @@ impl Default for AccountsDb {
impl AccountsDb {
pub fn new(paths: Vec<PathBuf>, cluster_type: &ClusterType) -> Self {
AccountsDb::new_with_config(paths, cluster_type, HashSet::new(), false)
AccountsDb::new_with_config(
paths,
cluster_type,
AccountSecondaryIndexes::default(),
false,
)
}
pub fn new_with_config(
paths: Vec<PathBuf>,
cluster_type: &ClusterType,
account_indexes: HashSet<AccountIndex>,
account_indexes: AccountSecondaryIndexes,
caching_enabled: bool,
) -> Self {
let new = if !paths.is_empty() {
@ -7774,7 +7779,7 @@ pub mod tests {
&key0,
&Pubkey::default(),
&[],
&HashSet::new(),
&AccountSecondaryIndexes::default(),
info0,
&mut reclaims,
);
@ -7783,7 +7788,7 @@ pub mod tests {
&key0,
&Pubkey::default(),
&[],
&HashSet::new(),
&AccountSecondaryIndexes::default(),
info1.clone(),
&mut reclaims,
);
@ -7792,7 +7797,7 @@ pub mod tests {
&key1,
&Pubkey::default(),
&[],
&HashSet::new(),
&AccountSecondaryIndexes::default(),
info1,
&mut reclaims,
);
@ -7801,7 +7806,7 @@ pub mod tests {
&key1,
&Pubkey::default(),
&[],
&HashSet::new(),
&AccountSecondaryIndexes::default(),
info2.clone(),
&mut reclaims,
);
@ -7810,7 +7815,7 @@ pub mod tests {
&key2,
&Pubkey::default(),
&[],
&HashSet::new(),
&AccountSecondaryIndexes::default(),
info2,
&mut reclaims,
);
@ -7819,7 +7824,7 @@ pub mod tests {
&key2,
&Pubkey::default(),
&[],
&HashSet::new(),
&AccountSecondaryIndexes::default(),
info3,
&mut reclaims,
);
@ -8208,7 +8213,7 @@ pub mod tests {
let db = Arc::new(AccountsDb::new_with_config(
Vec::new(),
&ClusterType::Development,
HashSet::new(),
AccountSecondaryIndexes::default(),
caching_enabled,
));
@ -8244,7 +8249,7 @@ pub mod tests {
let db = Arc::new(AccountsDb::new_with_config(
Vec::new(),
&ClusterType::Development,
HashSet::new(),
AccountSecondaryIndexes::default(),
caching_enabled,
));
@ -8367,7 +8372,7 @@ pub mod tests {
let db = Arc::new(AccountsDb::new_with_config(
Vec::new(),
&ClusterType::Development,
HashSet::new(),
AccountSecondaryIndexes::default(),
caching_enabled,
));
let account_key = Pubkey::new_unique();
@ -8451,7 +8456,7 @@ pub mod tests {
let accounts_db = AccountsDb::new_with_config(
Vec::new(),
&ClusterType::Development,
HashSet::new(),
AccountSecondaryIndexes::default(),
caching_enabled,
);
let slot: Slot = 0;
@ -8505,7 +8510,7 @@ pub mod tests {
let accounts_db = Arc::new(AccountsDb::new_with_config(
Vec::new(),
&ClusterType::Development,
HashSet::new(),
AccountSecondaryIndexes::default(),
caching_enabled,
));
let slots: Vec<_> = (0..num_slots as Slot).into_iter().collect();
@ -8893,7 +8898,7 @@ pub mod tests {
let db = AccountsDb::new_with_config(
Vec::new(),
&ClusterType::Development,
HashSet::default(),
AccountSecondaryIndexes::default(),
caching_enabled,
);
let account_key1 = Pubkey::new_unique();

View File

@ -72,6 +72,8 @@ pub enum AccountIndex {
SplTokenOwner,
}
pub type AccountSecondaryIndexes = HashSet<AccountIndex>;
#[derive(Debug)]
pub struct AccountMapEntryInner<T> {
ref_count: AtomicU64,
@ -607,7 +609,11 @@ impl<T: 'static + Clone + IsCached + ZeroLamport> AccountsIndex<T> {
(w_account_entry.unwrap(), is_newly_inserted)
}
pub fn handle_dead_keys(&self, dead_keys: &[&Pubkey], account_indexes: &HashSet<AccountIndex>) {
pub fn handle_dead_keys(
&self,
dead_keys: &[&Pubkey],
account_indexes: &AccountSecondaryIndexes,
) {
if !dead_keys.is_empty() {
for key in dead_keys.iter() {
let mut w_index = self.account_maps.write().unwrap();
@ -709,7 +715,7 @@ impl<T: 'static + Clone + IsCached + ZeroLamport> AccountsIndex<T> {
pubkey: &Pubkey,
slots_to_purge: &'a C,
reclaims: &mut SlotList<T>,
account_indexes: &HashSet<AccountIndex>,
account_indexes: &AccountSecondaryIndexes,
) -> bool
where
C: Contains<'a, Slot>,
@ -818,7 +824,7 @@ impl<T: 'static + Clone + IsCached + ZeroLamport> AccountsIndex<T> {
slot: Slot,
account_owner: &Pubkey,
account_data: &[u8],
account_indexes: &HashSet<AccountIndex>,
account_indexes: &AccountSecondaryIndexes,
) {
if account_indexes.is_empty() {
return;
@ -870,7 +876,7 @@ impl<T: 'static + Clone + IsCached + ZeroLamport> AccountsIndex<T> {
pubkey: &Pubkey,
account_owner: &Pubkey,
account_data: &[u8],
account_indexes: &HashSet<AccountIndex>,
account_indexes: &AccountSecondaryIndexes,
account_info: T,
reclaims: &mut SlotList<T>,
) {
@ -893,7 +899,7 @@ impl<T: 'static + Clone + IsCached + ZeroLamport> AccountsIndex<T> {
pubkey: &Pubkey,
account_owner: &Pubkey,
account_data: &[u8],
account_indexes: &HashSet<AccountIndex>,
account_indexes: &AccountSecondaryIndexes,
account_info: T,
reclaims: &mut SlotList<T>,
) -> bool {
@ -947,7 +953,7 @@ impl<T: 'static + Clone + IsCached + ZeroLamport> AccountsIndex<T> {
&'a self,
inner_key: &Pubkey,
slots_to_remove: Option<&'a C>,
account_indexes: &HashSet<AccountIndex>,
account_indexes: &AccountSecondaryIndexes,
) where
C: Contains<'a, Slot>,
{
@ -973,7 +979,7 @@ impl<T: 'static + Clone + IsCached + ZeroLamport> AccountsIndex<T> {
list: &mut SlotList<T>,
reclaims: &mut SlotList<T>,
max_clean_root: Option<Slot>,
account_indexes: &HashSet<AccountIndex>,
account_indexes: &AccountSecondaryIndexes,
) {
let roots_tracker = &self.roots_tracker.read().unwrap();
let max_root = Self::get_max_root(&roots_tracker.roots, &list, max_clean_root);
@ -997,7 +1003,7 @@ impl<T: 'static + Clone + IsCached + ZeroLamport> AccountsIndex<T> {
pubkey: &Pubkey,
reclaims: &mut SlotList<T>,
max_clean_root: Option<Slot>,
account_indexes: &HashSet<AccountIndex>,
account_indexes: &AccountSecondaryIndexes,
) {
if let Some(mut locked_entry) = self.get_account_write_entry(pubkey) {
locked_entry.slot_list_mut(|slot_list| {
@ -1158,19 +1164,19 @@ pub mod tests {
DashMap(&'a SecondaryIndex<DashMapSecondaryIndexEntry>),
}
pub fn spl_token_mint_index_enabled() -> HashSet<AccountIndex> {
pub fn spl_token_mint_index_enabled() -> AccountSecondaryIndexes {
let mut account_indexes = HashSet::new();
account_indexes.insert(AccountIndex::SplTokenMint);
account_indexes
}
pub fn spl_token_owner_index_enabled() -> HashSet<AccountIndex> {
pub fn spl_token_owner_index_enabled() -> AccountSecondaryIndexes {
let mut account_indexes = HashSet::new();
account_indexes.insert(AccountIndex::SplTokenOwner);
account_indexes
}
fn create_dashmap_secondary_index_state() -> (usize, usize, HashSet<AccountIndex>) {
fn create_dashmap_secondary_index_state() -> (usize, usize, AccountSecondaryIndexes) {
{
// Check that we're actually testing the correct variant
let index = AccountsIndex::<bool>::default();
@ -1180,7 +1186,7 @@ pub mod tests {
(0, PUBKEY_BYTES, spl_token_mint_index_enabled())
}
fn create_rwlock_secondary_index_state() -> (usize, usize, HashSet<AccountIndex>) {
fn create_rwlock_secondary_index_state() -> (usize, usize, AccountSecondaryIndexes) {
{
// Check that we're actually testing the correct variant
let index = AccountsIndex::<bool>::default();
@ -1217,7 +1223,7 @@ pub mod tests {
&key.pubkey(),
&Pubkey::default(),
&[],
&HashSet::new(),
&AccountSecondaryIndexes::default(),
true,
&mut gc,
);
@ -1242,7 +1248,7 @@ pub mod tests {
&key.pubkey(),
&Pubkey::default(),
&[],
&HashSet::new(),
&AccountSecondaryIndexes::default(),
true,
&mut gc,
);
@ -1266,7 +1272,7 @@ pub mod tests {
&key.pubkey(),
&Pubkey::default(),
&[],
&HashSet::new(),
&AccountSecondaryIndexes::default(),
true,
&mut gc,
);
@ -1299,7 +1305,7 @@ pub mod tests {
&new_pubkey,
&Pubkey::default(),
&[],
&HashSet::new(),
&AccountSecondaryIndexes::default(),
true,
&mut vec![],
);
@ -1315,7 +1321,7 @@ pub mod tests {
&Pubkey::default(),
&Pubkey::default(),
&[],
&HashSet::new(),
&AccountSecondaryIndexes::default(),
true,
&mut vec![],
);
@ -1446,7 +1452,7 @@ pub mod tests {
&solana_sdk::pubkey::new_rand(),
&Pubkey::default(),
&[],
&HashSet::new(),
&AccountSecondaryIndexes::default(),
true,
&mut gc,
);
@ -1471,7 +1477,7 @@ pub mod tests {
&key.pubkey(),
&Pubkey::default(),
&[],
&HashSet::new(),
&AccountSecondaryIndexes::default(),
true,
&mut gc,
);
@ -1585,7 +1591,7 @@ pub mod tests {
&key.pubkey(),
&Pubkey::default(),
&[],
&HashSet::new(),
&AccountSecondaryIndexes::default(),
true,
&mut gc,
);
@ -1600,7 +1606,7 @@ pub mod tests {
&key.pubkey(),
&Pubkey::default(),
&[],
&HashSet::new(),
&AccountSecondaryIndexes::default(),
false,
&mut gc,
);
@ -1621,7 +1627,7 @@ pub mod tests {
&key.pubkey(),
&Pubkey::default(),
&[],
&HashSet::new(),
&AccountSecondaryIndexes::default(),
true,
&mut gc,
);
@ -1631,7 +1637,7 @@ pub mod tests {
&key.pubkey(),
&Pubkey::default(),
&[],
&HashSet::new(),
&AccountSecondaryIndexes::default(),
false,
&mut gc,
);
@ -1653,7 +1659,7 @@ pub mod tests {
&key.pubkey(),
&Pubkey::default(),
&[],
&HashSet::new(),
&AccountSecondaryIndexes::default(),
true,
&mut gc,
);
@ -1663,7 +1669,7 @@ pub mod tests {
&key.pubkey(),
&Pubkey::default(),
&[],
&HashSet::new(),
&AccountSecondaryIndexes::default(),
false,
&mut gc,
);
@ -1672,7 +1678,7 @@ pub mod tests {
&key.pubkey(),
&Pubkey::default(),
&[],
&HashSet::new(),
&AccountSecondaryIndexes::default(),
true,
&mut gc,
);
@ -1681,7 +1687,7 @@ pub mod tests {
&key.pubkey(),
&Pubkey::default(),
&[],
&HashSet::new(),
&AccountSecondaryIndexes::default(),
true,
&mut gc,
);
@ -1693,7 +1699,7 @@ pub mod tests {
&key.pubkey(),
&Pubkey::default(),
&[],
&HashSet::new(),
&AccountSecondaryIndexes::default(),
true,
&mut gc,
);
@ -1727,7 +1733,7 @@ pub mod tests {
&key.pubkey(),
&Pubkey::default(),
&[],
&HashSet::new(),
&AccountSecondaryIndexes::default(),
12,
&mut gc
));
@ -1737,7 +1743,7 @@ pub mod tests {
&key.pubkey(),
&Pubkey::default(),
&[],
&HashSet::new(),
&AccountSecondaryIndexes::default(),
10,
&mut gc
));
@ -1754,7 +1760,7 @@ pub mod tests {
&key.pubkey(),
&Pubkey::default(),
&[],
&HashSet::new(),
&AccountSecondaryIndexes::default(),
9,
&mut gc
));
@ -1810,7 +1816,7 @@ pub mod tests {
secondary_index: &SecondaryIndex<SecondaryIndexEntryType>,
key_start: usize,
key_end: usize,
account_index: &HashSet<AccountIndex>,
account_index: &AccountSecondaryIndexes,
) {
// No roots, should be no reclaims
let slots = vec![1, 2, 5, 9];
@ -1899,7 +1905,7 @@ pub mod tests {
&mut slot_list,
&mut reclaims,
None,
&HashSet::new(),
&AccountSecondaryIndexes::default(),
);
assert!(reclaims.is_empty());
assert_eq!(slot_list, vec![(1, true), (2, true), (5, true), (9, true)]);
@ -1915,7 +1921,7 @@ pub mod tests {
&mut slot_list,
&mut reclaims,
None,
&HashSet::new(),
&AccountSecondaryIndexes::default(),
);
assert_eq!(reclaims, vec![(1, true), (2, true)]);
assert_eq!(slot_list, vec![(5, true), (9, true)]);
@ -1929,7 +1935,7 @@ pub mod tests {
&mut slot_list,
&mut reclaims,
None,
&HashSet::new(),
&AccountSecondaryIndexes::default(),
);
assert_eq!(reclaims, vec![(1, true), (2, true)]);
assert_eq!(slot_list, vec![(5, true), (9, true)]);
@ -1943,7 +1949,7 @@ pub mod tests {
&mut slot_list,
&mut reclaims,
Some(6),
&HashSet::new(),
&AccountSecondaryIndexes::default(),
);
assert_eq!(reclaims, vec![(1, true), (2, true)]);
assert_eq!(slot_list, vec![(5, true), (9, true)]);
@ -1956,7 +1962,7 @@ pub mod tests {
&mut slot_list,
&mut reclaims,
Some(5),
&HashSet::new(),
&AccountSecondaryIndexes::default(),
);
assert_eq!(reclaims, vec![(1, true), (2, true)]);
assert_eq!(slot_list, vec![(5, true), (9, true)]);
@ -1970,7 +1976,7 @@ pub mod tests {
&mut slot_list,
&mut reclaims,
Some(2),
&HashSet::new(),
&AccountSecondaryIndexes::default(),
);
assert!(reclaims.is_empty());
assert_eq!(slot_list, vec![(1, true), (2, true), (5, true), (9, true)]);
@ -1984,7 +1990,7 @@ pub mod tests {
&mut slot_list,
&mut reclaims,
Some(1),
&HashSet::new(),
&AccountSecondaryIndexes::default(),
);
assert!(reclaims.is_empty());
assert_eq!(slot_list, vec![(1, true), (2, true), (5, true), (9, true)]);
@ -1998,7 +2004,7 @@ pub mod tests {
&mut slot_list,
&mut reclaims,
Some(7),
&HashSet::new(),
&AccountSecondaryIndexes::default(),
);
assert_eq!(reclaims, vec![(1, true), (2, true)]);
assert_eq!(slot_list, vec![(5, true), (9, true)]);
@ -2037,7 +2043,7 @@ pub mod tests {
secondary_index: &SecondaryIndex<SecondaryIndexEntryType>,
key_start: usize,
key_end: usize,
account_index: &HashSet<AccountIndex>,
account_index: &AccountSecondaryIndexes,
) {
let account_key = Pubkey::new_unique();
let index_key = Pubkey::new_unique();
@ -2127,7 +2133,7 @@ pub mod tests {
secondary_index: &SecondaryIndex<SecondaryIndexEntryType>,
index_key_start: usize,
index_key_end: usize,
account_index: &HashSet<AccountIndex>,
account_index: &AccountSecondaryIndexes,
) {
let account_key = Pubkey::new_unique();
let secondary_key1 = Pubkey::new_unique();

View File

@ -8,7 +8,7 @@ use crate::{
TransactionLoadResult, TransactionLoaders,
},
accounts_db::{ErrorCounters, SnapshotStorages},
accounts_index::{AccountIndex, Ancestors, IndexKey},
accounts_index::{AccountSecondaryIndexes, Ancestors, IndexKey},
blockhash_queue::BlockhashQueue,
builtins::{self, ActivationType},
epoch_stakes::{EpochStakes, NodeVoteAccounts},
@ -900,7 +900,7 @@ impl Bank {
&[],
None,
None,
HashSet::new(),
AccountSecondaryIndexes::default(),
false,
)
}
@ -912,7 +912,7 @@ impl Bank {
&[],
None,
None,
HashSet::new(),
AccountSecondaryIndexes::default(),
false,
);
@ -923,7 +923,7 @@ impl Bank {
#[cfg(test)]
pub(crate) fn new_with_config(
genesis_config: &GenesisConfig,
account_indexes: HashSet<AccountIndex>,
account_indexes: AccountSecondaryIndexes,
accounts_db_caching_enabled: bool,
) -> Self {
Self::new_with_paths(
@ -943,7 +943,7 @@ impl Bank {
frozen_account_pubkeys: &[Pubkey],
debug_keys: Option<Arc<HashSet<Pubkey>>>,
additional_builtins: Option<&Builtins>,
account_indexes: HashSet<AccountIndex>,
account_indexes: AccountSecondaryIndexes,
accounts_db_caching_enabled: bool,
) -> Self {
let mut bank = Self::default();
@ -5031,7 +5031,9 @@ pub(crate) mod tests {
use super::*;
use crate::{
accounts_db::SHRINK_RATIO,
accounts_index::{AccountMap, Ancestors, ITER_BATCH_SIZE},
accounts_index::{
AccountIndex, AccountMap, AccountSecondaryIndexes, Ancestors, ITER_BATCH_SIZE,
},
genesis_utils::{
activate_all_features, bootstrap_validator_stake_lamports,
create_genesis_config_with_leader, create_genesis_config_with_vote_accounts,
@ -8903,7 +8905,7 @@ pub(crate) mod tests {
#[test]
fn test_get_filtered_indexed_accounts() {
let (genesis_config, _mint_keypair) = create_genesis_config(500);
let mut account_indexes = HashSet::new();
let mut account_indexes = AccountSecondaryIndexes::default();
account_indexes.insert(AccountIndex::ProgramId);
let bank = Arc::new(Bank::new_with_config(
&genesis_config,
@ -10357,7 +10359,7 @@ pub(crate) mod tests {
// of the storage for this slot
let mut bank0 = Arc::new(Bank::new_with_config(
&genesis_config,
HashSet::new(),
AccountSecondaryIndexes::default(),
false,
));
bank0.restore_old_behavior_for_fragile_tests();
@ -10388,7 +10390,11 @@ pub(crate) mod tests {
let pubkey2 = solana_sdk::pubkey::new_rand();
// Set root for bank 0, with caching enabled
let mut bank0 = Arc::new(Bank::new_with_config(&genesis_config, HashSet::new(), true));
let mut bank0 = Arc::new(Bank::new_with_config(
&genesis_config,
AccountSecondaryIndexes::default(),
true,
));
bank0.restore_old_behavior_for_fragile_tests();
let pubkey0_size = get_shrink_account_size();
@ -11568,7 +11574,7 @@ pub(crate) mod tests {
genesis_config.rent = Rent::free();
let bank0 = Arc::new(Bank::new_with_config(
&genesis_config,
HashSet::new(),
AccountSecondaryIndexes::default(),
accounts_db_caching_enabled,
));

View File

@ -2,7 +2,7 @@ use {
crate::{
accounts::Accounts,
accounts_db::{AccountStorageEntry, AccountsDb, AppendVecId, BankHashInfo},
accounts_index::{AccountIndex, Ancestors},
accounts_index::{AccountSecondaryIndexes, Ancestors},
append_vec::AppendVec,
bank::{Bank, BankFieldsToDeserialize, BankRc, Builtins},
blockhash_queue::BlockhashQueue,
@ -127,7 +127,7 @@ pub(crate) fn bank_from_stream<R>(
frozen_account_pubkeys: &[Pubkey],
debug_keys: Option<Arc<HashSet<Pubkey>>>,
additional_builtins: Option<&Builtins>,
account_indexes: HashSet<AccountIndex>,
account_indexes: AccountSecondaryIndexes,
caching_enabled: bool,
) -> std::result::Result<Bank, Error>
where
@ -235,7 +235,7 @@ fn reconstruct_bank_from_fields<E>(
unpacked_append_vec_map: UnpackedAppendVecMap,
debug_keys: Option<Arc<HashSet<Pubkey>>>,
additional_builtins: Option<&Builtins>,
account_indexes: HashSet<AccountIndex>,
account_indexes: AccountSecondaryIndexes,
caching_enabled: bool,
) -> Result<Bank, Error>
where
@ -268,7 +268,7 @@ fn reconstruct_accountsdb_from_fields<E>(
account_paths: &[PathBuf],
unpacked_append_vec_map: UnpackedAppendVecMap,
cluster_type: &ClusterType,
account_indexes: HashSet<AccountIndex>,
account_indexes: AccountSecondaryIndexes,
caching_enabled: bool,
) -> Result<AccountsDb, Error>
where

View File

@ -71,7 +71,7 @@ where
account_paths,
unpacked_append_vec_map,
&ClusterType::Development,
HashSet::new(),
AccountSecondaryIndexes::default(),
false,
)
}
@ -123,8 +123,12 @@ where
fn test_accounts_serialize_style(serde_style: SerdeStyle) {
solana_logger::setup();
let (_accounts_dir, paths) = get_temp_accounts_paths(4).unwrap();
let accounts =
Accounts::new_with_config(paths, &ClusterType::Development, HashSet::new(), false);
let accounts = Accounts::new_with_config(
paths,
&ClusterType::Development,
AccountSecondaryIndexes::default(),
false,
);
let mut pubkeys: Vec<Pubkey> = vec![];
create_test_accounts(&accounts, &mut pubkeys, 100, 0);
@ -220,7 +224,7 @@ fn test_bank_serialize_style(serde_style: SerdeStyle) {
&[],
None,
None,
HashSet::new(),
AccountSecondaryIndexes::default(),
false,
)
.unwrap();

View File

@ -1,7 +1,7 @@
use {
crate::{
accounts_db::AccountsDb,
accounts_index::AccountIndex,
accounts_index::AccountSecondaryIndexes,
bank::{Bank, BankSlotDelta, Builtins},
bank_forks::ArchiveFormat,
hardened_unpack::{unpack_snapshot, UnpackError, UnpackedAppendVecMap},
@ -592,7 +592,7 @@ pub fn bank_from_archive<P: AsRef<Path>>(
genesis_config: &GenesisConfig,
debug_keys: Option<Arc<HashSet<Pubkey>>>,
additional_builtins: Option<&Builtins>,
account_indexes: HashSet<AccountIndex>,
account_indexes: AccountSecondaryIndexes,
accounts_db_caching_enabled: bool,
) -> Result<Bank> {
let unpack_dir = tempfile::Builder::new()
@ -771,7 +771,7 @@ fn rebuild_bank_from_snapshots(
genesis_config: &GenesisConfig,
debug_keys: Option<Arc<HashSet<Pubkey>>>,
additional_builtins: Option<&Builtins>,
account_indexes: HashSet<AccountIndex>,
account_indexes: AccountSecondaryIndexes,
accounts_db_caching_enabled: bool,
) -> Result<Bank> {
info!("snapshot version: {}", snapshot_version);