Removes unnecessary Accounts constructors (#34471)
This commit is contained in:
parent
aaccbdd0ae
commit
45eaa4c1a6
|
@ -9,7 +9,7 @@ use {
|
||||||
accounts::Accounts,
|
accounts::Accounts,
|
||||||
accounts_db::{
|
accounts_db::{
|
||||||
test_utils::{create_test_accounts, update_accounts_bench},
|
test_utils::{create_test_accounts, update_accounts_bench},
|
||||||
AccountShrinkThreshold, CalcAccountsHashDataSource,
|
AccountShrinkThreshold, AccountsDb, CalcAccountsHashDataSource,
|
||||||
},
|
},
|
||||||
accounts_index::AccountSecondaryIndexes,
|
accounts_index::AccountSecondaryIndexes,
|
||||||
ancestors::Ancestors,
|
ancestors::Ancestors,
|
||||||
|
@ -19,7 +19,7 @@ use {
|
||||||
solana_sdk::{
|
solana_sdk::{
|
||||||
genesis_config::ClusterType, pubkey::Pubkey, sysvar::epoch_schedule::EpochSchedule,
|
genesis_config::ClusterType, pubkey::Pubkey, sysvar::epoch_schedule::EpochSchedule,
|
||||||
},
|
},
|
||||||
std::{env, fs, path::PathBuf},
|
std::{env, fs, path::PathBuf, sync::Arc},
|
||||||
};
|
};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
@ -69,12 +69,13 @@ fn main() {
|
||||||
if fs::remove_dir_all(path.clone()).is_err() {
|
if fs::remove_dir_all(path.clone()).is_err() {
|
||||||
println!("Warning: Couldn't remove {path:?}");
|
println!("Warning: Couldn't remove {path:?}");
|
||||||
}
|
}
|
||||||
let accounts = Accounts::new_with_config_for_benches(
|
let accounts_db = AccountsDb::new_with_config_for_benches(
|
||||||
vec![path],
|
vec![path],
|
||||||
&ClusterType::Testnet,
|
&ClusterType::Testnet,
|
||||||
AccountSecondaryIndexes::default(),
|
AccountSecondaryIndexes::default(),
|
||||||
AccountShrinkThreshold::default(),
|
AccountShrinkThreshold::default(),
|
||||||
);
|
);
|
||||||
|
let accounts = Accounts::new(Arc::new(accounts_db));
|
||||||
println!("Creating {num_accounts} accounts");
|
println!("Creating {num_accounts} accounts");
|
||||||
let mut create_time = Measure::start("create accounts");
|
let mut create_time = Measure::start("create accounts");
|
||||||
let pubkeys: Vec<_> = (0..num_slots)
|
let pubkeys: Vec<_> = (0..num_slots)
|
||||||
|
|
|
@ -1,15 +1,10 @@
|
||||||
#[cfg(feature = "dev-context-only-utils")]
|
|
||||||
use crate::accounts_db::{ACCOUNTS_DB_CONFIG_FOR_BENCHMARKS, ACCOUNTS_DB_CONFIG_FOR_TESTING};
|
|
||||||
use {
|
use {
|
||||||
crate::{
|
crate::{
|
||||||
accounts_db::{
|
accounts_db::{
|
||||||
AccountShrinkThreshold, AccountsAddRootTiming, AccountsDb, AccountsDbConfig, LoadHint,
|
AccountsAddRootTiming, AccountsDb, LoadHint, LoadedAccount, ScanStorageResult,
|
||||||
LoadedAccount, ScanStorageResult, VerifyAccountsHashAndLamportsConfig,
|
VerifyAccountsHashAndLamportsConfig,
|
||||||
},
|
},
|
||||||
accounts_index::{
|
accounts_index::{IndexKey, ScanConfig, ScanError, ScanResult, ZeroLamport},
|
||||||
AccountSecondaryIndexes, IndexKey, ScanConfig, ScanError, ScanResult, ZeroLamport,
|
|
||||||
},
|
|
||||||
accounts_update_notifier_interface::AccountsUpdateNotifier,
|
|
||||||
ancestors::Ancestors,
|
ancestors::Ancestors,
|
||||||
nonce_info::{NonceFull, NonceInfo},
|
nonce_info::{NonceFull, NonceInfo},
|
||||||
rent_collector::RentCollector,
|
rent_collector::RentCollector,
|
||||||
|
@ -24,7 +19,6 @@ use {
|
||||||
account_utils::StateMut,
|
account_utils::StateMut,
|
||||||
address_lookup_table::{self, error::AddressLookupError, state::AddressLookupTable},
|
address_lookup_table::{self, error::AddressLookupError, state::AddressLookupTable},
|
||||||
clock::{BankId, Slot},
|
clock::{BankId, Slot},
|
||||||
genesis_config::ClusterType,
|
|
||||||
message::v0::{LoadedAddresses, MessageAddressTableLookup},
|
message::v0::{LoadedAddresses, MessageAddressTableLookup},
|
||||||
nonce::{
|
nonce::{
|
||||||
state::{DurableNonce, Versions as NonceVersions},
|
state::{DurableNonce, Versions as NonceVersions},
|
||||||
|
@ -42,9 +36,8 @@ use {
|
||||||
BinaryHeap, HashMap, HashSet,
|
BinaryHeap, HashMap, HashSet,
|
||||||
},
|
},
|
||||||
ops::RangeBounds,
|
ops::RangeBounds,
|
||||||
path::PathBuf,
|
|
||||||
sync::{
|
sync::{
|
||||||
atomic::{AtomicBool, AtomicUsize, Ordering},
|
atomic::{AtomicUsize, Ordering},
|
||||||
Arc, Mutex,
|
Arc, Mutex,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -125,30 +118,6 @@ pub enum AccountAddressFilter {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Accounts {
|
impl Accounts {
|
||||||
pub fn default_for_tests() -> Self {
|
|
||||||
Self::new(Arc::new(AccountsDb::default_for_tests()))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn new_with_config(
|
|
||||||
paths: Vec<PathBuf>,
|
|
||||||
cluster_type: &ClusterType,
|
|
||||||
account_indexes: AccountSecondaryIndexes,
|
|
||||||
shrink_ratio: AccountShrinkThreshold,
|
|
||||||
accounts_db_config: Option<AccountsDbConfig>,
|
|
||||||
accounts_update_notifier: Option<AccountsUpdateNotifier>,
|
|
||||||
exit: Arc<AtomicBool>,
|
|
||||||
) -> Self {
|
|
||||||
Self::new(Arc::new(AccountsDb::new_with_config(
|
|
||||||
paths,
|
|
||||||
cluster_type,
|
|
||||||
account_indexes,
|
|
||||||
shrink_ratio,
|
|
||||||
accounts_db_config,
|
|
||||||
accounts_update_notifier,
|
|
||||||
exit,
|
|
||||||
)))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn new(accounts_db: Arc<AccountsDb>) -> Self {
|
pub fn new(accounts_db: Arc<AccountsDb>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
accounts_db,
|
accounts_db,
|
||||||
|
@ -797,44 +766,6 @@ impl Accounts {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// These functions/fields are only usable from a dev context (i.e. tests and benches)
|
|
||||||
#[cfg(feature = "dev-context-only-utils")]
|
|
||||||
impl Accounts {
|
|
||||||
pub fn new_with_config_for_tests(
|
|
||||||
paths: Vec<PathBuf>,
|
|
||||||
cluster_type: &ClusterType,
|
|
||||||
account_indexes: AccountSecondaryIndexes,
|
|
||||||
shrink_ratio: AccountShrinkThreshold,
|
|
||||||
) -> Self {
|
|
||||||
Self::new_with_config(
|
|
||||||
paths,
|
|
||||||
cluster_type,
|
|
||||||
account_indexes,
|
|
||||||
shrink_ratio,
|
|
||||||
Some(ACCOUNTS_DB_CONFIG_FOR_TESTING),
|
|
||||||
None,
|
|
||||||
Arc::default(),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn new_with_config_for_benches(
|
|
||||||
paths: Vec<PathBuf>,
|
|
||||||
cluster_type: &ClusterType,
|
|
||||||
account_indexes: AccountSecondaryIndexes,
|
|
||||||
shrink_ratio: AccountShrinkThreshold,
|
|
||||||
) -> Self {
|
|
||||||
Self::new_with_config(
|
|
||||||
paths,
|
|
||||||
cluster_type,
|
|
||||||
account_indexes,
|
|
||||||
shrink_ratio,
|
|
||||||
Some(ACCOUNTS_DB_CONFIG_FOR_BENCHMARKS),
|
|
||||||
None,
|
|
||||||
Arc::default(),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn prepare_if_nonce_account(
|
fn prepare_if_nonce_account(
|
||||||
address: &Pubkey,
|
address: &Pubkey,
|
||||||
account: &mut AccountSharedData,
|
account: &mut AccountSharedData,
|
||||||
|
@ -893,6 +824,8 @@ mod tests {
|
||||||
use {
|
use {
|
||||||
super::*,
|
super::*,
|
||||||
crate::{
|
crate::{
|
||||||
|
accounts_db::AccountShrinkThreshold,
|
||||||
|
accounts_index::AccountSecondaryIndexes,
|
||||||
rent_collector::RentCollector,
|
rent_collector::RentCollector,
|
||||||
transaction_results::{DurableNonceFee, TransactionExecutionDetails},
|
transaction_results::{DurableNonceFee, TransactionExecutionDetails},
|
||||||
},
|
},
|
||||||
|
@ -949,7 +882,8 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_hold_range_in_memory() {
|
fn test_hold_range_in_memory() {
|
||||||
let accts = Accounts::default_for_tests();
|
let accounts_db = AccountsDb::default_for_tests();
|
||||||
|
let accts = Accounts::new(Arc::new(accounts_db));
|
||||||
let range = Pubkey::from([0; 32])..=Pubkey::from([0xff; 32]);
|
let range = Pubkey::from([0; 32])..=Pubkey::from([0xff; 32]);
|
||||||
accts.hold_range_in_memory(&range, true, &test_thread_pool());
|
accts.hold_range_in_memory(&range, true, &test_thread_pool());
|
||||||
accts.hold_range_in_memory(&range, false, &test_thread_pool());
|
accts.hold_range_in_memory(&range, false, &test_thread_pool());
|
||||||
|
@ -961,7 +895,8 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_hold_range_in_memory2() {
|
fn test_hold_range_in_memory2() {
|
||||||
let accts = Accounts::default_for_tests();
|
let accounts_db = AccountsDb::default_for_tests();
|
||||||
|
let accts = Accounts::new(Arc::new(accounts_db));
|
||||||
let range = Pubkey::from([0; 32])..=Pubkey::from([0xff; 32]);
|
let range = Pubkey::from([0; 32])..=Pubkey::from([0xff; 32]);
|
||||||
let idx = &accts.accounts_db.accounts_index;
|
let idx = &accts.accounts_db.accounts_index;
|
||||||
let bins = idx.account_maps.len();
|
let bins = idx.account_maps.len();
|
||||||
|
@ -1004,12 +939,13 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_load_lookup_table_addresses_account_not_found() {
|
fn test_load_lookup_table_addresses_account_not_found() {
|
||||||
let ancestors = vec![(0, 0)].into_iter().collect();
|
let ancestors = vec![(0, 0)].into_iter().collect();
|
||||||
let accounts = Accounts::new_with_config_for_tests(
|
let accounts_db = AccountsDb::new_with_config_for_tests(
|
||||||
Vec::new(),
|
Vec::new(),
|
||||||
&ClusterType::Development,
|
&ClusterType::Development,
|
||||||
AccountSecondaryIndexes::default(),
|
AccountSecondaryIndexes::default(),
|
||||||
AccountShrinkThreshold::default(),
|
AccountShrinkThreshold::default(),
|
||||||
);
|
);
|
||||||
|
let accounts = Accounts::new(Arc::new(accounts_db));
|
||||||
|
|
||||||
let invalid_table_key = Pubkey::new_unique();
|
let invalid_table_key = Pubkey::new_unique();
|
||||||
let address_table_lookup = MessageAddressTableLookup {
|
let address_table_lookup = MessageAddressTableLookup {
|
||||||
|
@ -1031,12 +967,13 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_load_lookup_table_addresses_invalid_account_owner() {
|
fn test_load_lookup_table_addresses_invalid_account_owner() {
|
||||||
let ancestors = vec![(0, 0)].into_iter().collect();
|
let ancestors = vec![(0, 0)].into_iter().collect();
|
||||||
let accounts = Accounts::new_with_config_for_tests(
|
let accounts_db = AccountsDb::new_with_config_for_tests(
|
||||||
Vec::new(),
|
Vec::new(),
|
||||||
&ClusterType::Development,
|
&ClusterType::Development,
|
||||||
AccountSecondaryIndexes::default(),
|
AccountSecondaryIndexes::default(),
|
||||||
AccountShrinkThreshold::default(),
|
AccountShrinkThreshold::default(),
|
||||||
);
|
);
|
||||||
|
let accounts = Accounts::new(Arc::new(accounts_db));
|
||||||
|
|
||||||
let invalid_table_key = Pubkey::new_unique();
|
let invalid_table_key = Pubkey::new_unique();
|
||||||
let mut invalid_table_account = AccountSharedData::default();
|
let mut invalid_table_account = AccountSharedData::default();
|
||||||
|
@ -1062,12 +999,13 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_load_lookup_table_addresses_invalid_account_data() {
|
fn test_load_lookup_table_addresses_invalid_account_data() {
|
||||||
let ancestors = vec![(0, 0)].into_iter().collect();
|
let ancestors = vec![(0, 0)].into_iter().collect();
|
||||||
let accounts = Accounts::new_with_config_for_tests(
|
let accounts_db = AccountsDb::new_with_config_for_tests(
|
||||||
Vec::new(),
|
Vec::new(),
|
||||||
&ClusterType::Development,
|
&ClusterType::Development,
|
||||||
AccountSecondaryIndexes::default(),
|
AccountSecondaryIndexes::default(),
|
||||||
AccountShrinkThreshold::default(),
|
AccountShrinkThreshold::default(),
|
||||||
);
|
);
|
||||||
|
let accounts = Accounts::new(Arc::new(accounts_db));
|
||||||
|
|
||||||
let invalid_table_key = Pubkey::new_unique();
|
let invalid_table_key = Pubkey::new_unique();
|
||||||
let invalid_table_account =
|
let invalid_table_account =
|
||||||
|
@ -1093,12 +1031,13 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_load_lookup_table_addresses() {
|
fn test_load_lookup_table_addresses() {
|
||||||
let ancestors = vec![(1, 1), (0, 0)].into_iter().collect();
|
let ancestors = vec![(1, 1), (0, 0)].into_iter().collect();
|
||||||
let accounts = Accounts::new_with_config_for_tests(
|
let accounts_db = AccountsDb::new_with_config_for_tests(
|
||||||
Vec::new(),
|
Vec::new(),
|
||||||
&ClusterType::Development,
|
&ClusterType::Development,
|
||||||
AccountSecondaryIndexes::default(),
|
AccountSecondaryIndexes::default(),
|
||||||
AccountShrinkThreshold::default(),
|
AccountShrinkThreshold::default(),
|
||||||
);
|
);
|
||||||
|
let accounts = Accounts::new(Arc::new(accounts_db));
|
||||||
|
|
||||||
let table_key = Pubkey::new_unique();
|
let table_key = Pubkey::new_unique();
|
||||||
let table_addresses = vec![Pubkey::new_unique(), Pubkey::new_unique()];
|
let table_addresses = vec![Pubkey::new_unique(), Pubkey::new_unique()];
|
||||||
|
@ -1138,12 +1077,13 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_load_by_program_slot() {
|
fn test_load_by_program_slot() {
|
||||||
let accounts = Accounts::new_with_config_for_tests(
|
let accounts_db = AccountsDb::new_with_config_for_tests(
|
||||||
Vec::new(),
|
Vec::new(),
|
||||||
&ClusterType::Development,
|
&ClusterType::Development,
|
||||||
AccountSecondaryIndexes::default(),
|
AccountSecondaryIndexes::default(),
|
||||||
AccountShrinkThreshold::default(),
|
AccountShrinkThreshold::default(),
|
||||||
);
|
);
|
||||||
|
let accounts = Accounts::new(Arc::new(accounts_db));
|
||||||
|
|
||||||
// Load accounts owned by various programs into AccountsDb
|
// Load accounts owned by various programs into AccountsDb
|
||||||
let pubkey0 = solana_sdk::pubkey::new_rand();
|
let pubkey0 = solana_sdk::pubkey::new_rand();
|
||||||
|
@ -1166,24 +1106,26 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_accounts_empty_bank_hash_stats() {
|
fn test_accounts_empty_bank_hash_stats() {
|
||||||
let accounts = Accounts::new_with_config_for_tests(
|
let accounts_db = AccountsDb::new_with_config_for_tests(
|
||||||
Vec::new(),
|
Vec::new(),
|
||||||
&ClusterType::Development,
|
&ClusterType::Development,
|
||||||
AccountSecondaryIndexes::default(),
|
AccountSecondaryIndexes::default(),
|
||||||
AccountShrinkThreshold::default(),
|
AccountShrinkThreshold::default(),
|
||||||
);
|
);
|
||||||
|
let accounts = Accounts::new(Arc::new(accounts_db));
|
||||||
assert!(accounts.accounts_db.get_bank_hash_stats(0).is_some());
|
assert!(accounts.accounts_db.get_bank_hash_stats(0).is_some());
|
||||||
assert!(accounts.accounts_db.get_bank_hash_stats(1).is_none());
|
assert!(accounts.accounts_db.get_bank_hash_stats(1).is_none());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_lock_accounts_with_duplicates() {
|
fn test_lock_accounts_with_duplicates() {
|
||||||
let accounts = Accounts::new_with_config_for_tests(
|
let accounts_db = AccountsDb::new_with_config_for_tests(
|
||||||
Vec::new(),
|
Vec::new(),
|
||||||
&ClusterType::Development,
|
&ClusterType::Development,
|
||||||
AccountSecondaryIndexes::default(),
|
AccountSecondaryIndexes::default(),
|
||||||
AccountShrinkThreshold::default(),
|
AccountShrinkThreshold::default(),
|
||||||
);
|
);
|
||||||
|
let accounts = Accounts::new(Arc::new(accounts_db));
|
||||||
|
|
||||||
let keypair = Keypair::new();
|
let keypair = Keypair::new();
|
||||||
let message = Message {
|
let message = Message {
|
||||||
|
@ -1202,12 +1144,13 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_lock_accounts_with_too_many_accounts() {
|
fn test_lock_accounts_with_too_many_accounts() {
|
||||||
let accounts = Accounts::new_with_config_for_tests(
|
let accounts_db = AccountsDb::new_with_config_for_tests(
|
||||||
Vec::new(),
|
Vec::new(),
|
||||||
&ClusterType::Development,
|
&ClusterType::Development,
|
||||||
AccountSecondaryIndexes::default(),
|
AccountSecondaryIndexes::default(),
|
||||||
AccountShrinkThreshold::default(),
|
AccountShrinkThreshold::default(),
|
||||||
);
|
);
|
||||||
|
let accounts = Accounts::new(Arc::new(accounts_db));
|
||||||
|
|
||||||
let keypair = Keypair::new();
|
let keypair = Keypair::new();
|
||||||
|
|
||||||
|
@ -1267,12 +1210,13 @@ mod tests {
|
||||||
let account2 = AccountSharedData::new(3, 0, &Pubkey::default());
|
let account2 = AccountSharedData::new(3, 0, &Pubkey::default());
|
||||||
let account3 = AccountSharedData::new(4, 0, &Pubkey::default());
|
let account3 = AccountSharedData::new(4, 0, &Pubkey::default());
|
||||||
|
|
||||||
let accounts = Accounts::new_with_config_for_tests(
|
let accounts_db = AccountsDb::new_with_config_for_tests(
|
||||||
Vec::new(),
|
Vec::new(),
|
||||||
&ClusterType::Development,
|
&ClusterType::Development,
|
||||||
AccountSecondaryIndexes::default(),
|
AccountSecondaryIndexes::default(),
|
||||||
AccountShrinkThreshold::default(),
|
AccountShrinkThreshold::default(),
|
||||||
);
|
);
|
||||||
|
let accounts = Accounts::new(Arc::new(accounts_db));
|
||||||
accounts.store_for_tests(0, &keypair0.pubkey(), &account0);
|
accounts.store_for_tests(0, &keypair0.pubkey(), &account0);
|
||||||
accounts.store_for_tests(0, &keypair1.pubkey(), &account1);
|
accounts.store_for_tests(0, &keypair1.pubkey(), &account1);
|
||||||
accounts.store_for_tests(0, &keypair2.pubkey(), &account2);
|
accounts.store_for_tests(0, &keypair2.pubkey(), &account2);
|
||||||
|
@ -1376,12 +1320,13 @@ mod tests {
|
||||||
let account1 = AccountSharedData::new(2, 0, &Pubkey::default());
|
let account1 = AccountSharedData::new(2, 0, &Pubkey::default());
|
||||||
let account2 = AccountSharedData::new(3, 0, &Pubkey::default());
|
let account2 = AccountSharedData::new(3, 0, &Pubkey::default());
|
||||||
|
|
||||||
let accounts = Accounts::new_with_config_for_tests(
|
let accounts_db = AccountsDb::new_with_config_for_tests(
|
||||||
Vec::new(),
|
Vec::new(),
|
||||||
&ClusterType::Development,
|
&ClusterType::Development,
|
||||||
AccountSecondaryIndexes::default(),
|
AccountSecondaryIndexes::default(),
|
||||||
AccountShrinkThreshold::default(),
|
AccountShrinkThreshold::default(),
|
||||||
);
|
);
|
||||||
|
let accounts = Accounts::new(Arc::new(accounts_db));
|
||||||
accounts.store_for_tests(0, &keypair0.pubkey(), &account0);
|
accounts.store_for_tests(0, &keypair0.pubkey(), &account0);
|
||||||
accounts.store_for_tests(0, &keypair1.pubkey(), &account1);
|
accounts.store_for_tests(0, &keypair1.pubkey(), &account1);
|
||||||
accounts.store_for_tests(0, &keypair2.pubkey(), &account2);
|
accounts.store_for_tests(0, &keypair2.pubkey(), &account2);
|
||||||
|
@ -1457,12 +1402,13 @@ mod tests {
|
||||||
let account2 = AccountSharedData::new(3, 0, &Pubkey::default());
|
let account2 = AccountSharedData::new(3, 0, &Pubkey::default());
|
||||||
let account3 = AccountSharedData::new(4, 0, &Pubkey::default());
|
let account3 = AccountSharedData::new(4, 0, &Pubkey::default());
|
||||||
|
|
||||||
let accounts = Accounts::new_with_config_for_tests(
|
let accounts_db = AccountsDb::new_with_config_for_tests(
|
||||||
Vec::new(),
|
Vec::new(),
|
||||||
&ClusterType::Development,
|
&ClusterType::Development,
|
||||||
AccountSecondaryIndexes::default(),
|
AccountSecondaryIndexes::default(),
|
||||||
AccountShrinkThreshold::default(),
|
AccountShrinkThreshold::default(),
|
||||||
);
|
);
|
||||||
|
let accounts = Accounts::new(Arc::new(accounts_db));
|
||||||
accounts.store_for_tests(0, &keypair0.pubkey(), &account0);
|
accounts.store_for_tests(0, &keypair0.pubkey(), &account0);
|
||||||
accounts.store_for_tests(0, &keypair1.pubkey(), &account1);
|
accounts.store_for_tests(0, &keypair1.pubkey(), &account1);
|
||||||
accounts.store_for_tests(0, &keypair2.pubkey(), &account2);
|
accounts.store_for_tests(0, &keypair2.pubkey(), &account2);
|
||||||
|
@ -1533,12 +1479,13 @@ mod tests {
|
||||||
let account2 = AccountSharedData::new(3, 0, &Pubkey::default());
|
let account2 = AccountSharedData::new(3, 0, &Pubkey::default());
|
||||||
let account3 = AccountSharedData::new(4, 0, &Pubkey::default());
|
let account3 = AccountSharedData::new(4, 0, &Pubkey::default());
|
||||||
|
|
||||||
let accounts = Accounts::new_with_config_for_tests(
|
let accounts_db = AccountsDb::new_with_config_for_tests(
|
||||||
Vec::new(),
|
Vec::new(),
|
||||||
&ClusterType::Development,
|
&ClusterType::Development,
|
||||||
AccountSecondaryIndexes::default(),
|
AccountSecondaryIndexes::default(),
|
||||||
AccountShrinkThreshold::default(),
|
AccountShrinkThreshold::default(),
|
||||||
);
|
);
|
||||||
|
let accounts = Accounts::new(Arc::new(accounts_db));
|
||||||
accounts.store_for_tests(0, &keypair0.pubkey(), &account0);
|
accounts.store_for_tests(0, &keypair0.pubkey(), &account0);
|
||||||
accounts.store_for_tests(0, &keypair1.pubkey(), &account1);
|
accounts.store_for_tests(0, &keypair1.pubkey(), &account1);
|
||||||
accounts.store_for_tests(0, &keypair2.pubkey(), &account2);
|
accounts.store_for_tests(0, &keypair2.pubkey(), &account2);
|
||||||
|
@ -1692,12 +1639,13 @@ mod tests {
|
||||||
|
|
||||||
let mut loaded = vec![loaded0, loaded1];
|
let mut loaded = vec![loaded0, loaded1];
|
||||||
|
|
||||||
let accounts = Accounts::new_with_config_for_tests(
|
let accounts_db = AccountsDb::new_with_config_for_tests(
|
||||||
Vec::new(),
|
Vec::new(),
|
||||||
&ClusterType::Development,
|
&ClusterType::Development,
|
||||||
AccountSecondaryIndexes::default(),
|
AccountSecondaryIndexes::default(),
|
||||||
AccountShrinkThreshold::default(),
|
AccountShrinkThreshold::default(),
|
||||||
);
|
);
|
||||||
|
let accounts = Accounts::new(Arc::new(accounts_db));
|
||||||
{
|
{
|
||||||
accounts
|
accounts
|
||||||
.account_locks
|
.account_locks
|
||||||
|
@ -1743,12 +1691,13 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn huge_clean() {
|
fn huge_clean() {
|
||||||
solana_logger::setup();
|
solana_logger::setup();
|
||||||
let accounts = Accounts::new_with_config_for_tests(
|
let accounts_db = AccountsDb::new_with_config_for_tests(
|
||||||
Vec::new(),
|
Vec::new(),
|
||||||
&ClusterType::Development,
|
&ClusterType::Development,
|
||||||
AccountSecondaryIndexes::default(),
|
AccountSecondaryIndexes::default(),
|
||||||
AccountShrinkThreshold::default(),
|
AccountShrinkThreshold::default(),
|
||||||
);
|
);
|
||||||
|
let accounts = Accounts::new(Arc::new(accounts_db));
|
||||||
let mut old_pubkey = Pubkey::default();
|
let mut old_pubkey = Pubkey::default();
|
||||||
let zero_account = AccountSharedData::new(0, 0, AccountSharedData::default().owner());
|
let zero_account = AccountSharedData::new(0, 0, AccountSharedData::default().owner());
|
||||||
info!("storing..");
|
info!("storing..");
|
||||||
|
@ -2082,12 +2031,13 @@ mod tests {
|
||||||
let mut loaded = vec![loaded];
|
let mut loaded = vec![loaded];
|
||||||
|
|
||||||
let durable_nonce = DurableNonce::from_blockhash(&Hash::new_unique());
|
let durable_nonce = DurableNonce::from_blockhash(&Hash::new_unique());
|
||||||
let accounts = Accounts::new_with_config_for_tests(
|
let accounts_db = AccountsDb::new_with_config_for_tests(
|
||||||
Vec::new(),
|
Vec::new(),
|
||||||
&ClusterType::Development,
|
&ClusterType::Development,
|
||||||
AccountSecondaryIndexes::default(),
|
AccountSecondaryIndexes::default(),
|
||||||
AccountShrinkThreshold::default(),
|
AccountShrinkThreshold::default(),
|
||||||
);
|
);
|
||||||
|
let accounts = Accounts::new(Arc::new(accounts_db));
|
||||||
let txs = vec![tx];
|
let txs = vec![tx];
|
||||||
let execution_results = vec![new_execution_result(
|
let execution_results = vec![new_execution_result(
|
||||||
Err(TransactionError::InstructionError(
|
Err(TransactionError::InstructionError(
|
||||||
|
@ -2195,12 +2145,13 @@ mod tests {
|
||||||
let mut loaded = vec![loaded];
|
let mut loaded = vec![loaded];
|
||||||
|
|
||||||
let durable_nonce = DurableNonce::from_blockhash(&Hash::new_unique());
|
let durable_nonce = DurableNonce::from_blockhash(&Hash::new_unique());
|
||||||
let accounts = Accounts::new_with_config_for_tests(
|
let accounts_db = AccountsDb::new_with_config_for_tests(
|
||||||
Vec::new(),
|
Vec::new(),
|
||||||
&ClusterType::Development,
|
&ClusterType::Development,
|
||||||
AccountSecondaryIndexes::default(),
|
AccountSecondaryIndexes::default(),
|
||||||
AccountShrinkThreshold::default(),
|
AccountShrinkThreshold::default(),
|
||||||
);
|
);
|
||||||
|
let accounts = Accounts::new(Arc::new(accounts_db));
|
||||||
let txs = vec![tx];
|
let txs = vec![tx];
|
||||||
let execution_results = vec![new_execution_result(
|
let execution_results = vec![new_execution_result(
|
||||||
Err(TransactionError::InstructionError(
|
Err(TransactionError::InstructionError(
|
||||||
|
@ -2236,12 +2187,13 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_load_largest_accounts() {
|
fn test_load_largest_accounts() {
|
||||||
let accounts = Accounts::new_with_config_for_tests(
|
let accounts_db = AccountsDb::new_with_config_for_tests(
|
||||||
Vec::new(),
|
Vec::new(),
|
||||||
&ClusterType::Development,
|
&ClusterType::Development,
|
||||||
AccountSecondaryIndexes::default(),
|
AccountSecondaryIndexes::default(),
|
||||||
AccountShrinkThreshold::default(),
|
AccountShrinkThreshold::default(),
|
||||||
);
|
);
|
||||||
|
let accounts = Accounts::new(Arc::new(accounts_db));
|
||||||
|
|
||||||
/* This test assumes pubkey0 < pubkey1 < pubkey2.
|
/* This test assumes pubkey0 < pubkey1 < pubkey2.
|
||||||
* But the keys created with new_unique() does not gurantee this
|
* But the keys created with new_unique() does not gurantee this
|
||||||
|
|
|
@ -9522,6 +9522,40 @@ pub(crate) enum UpdateIndexThreadSelection {
|
||||||
// These functions/fields are only usable from a dev context (i.e. tests and benches)
|
// These functions/fields are only usable from a dev context (i.e. tests and benches)
|
||||||
#[cfg(feature = "dev-context-only-utils")]
|
#[cfg(feature = "dev-context-only-utils")]
|
||||||
impl AccountsDb {
|
impl AccountsDb {
|
||||||
|
pub fn new_with_config_for_tests(
|
||||||
|
paths: Vec<PathBuf>,
|
||||||
|
cluster_type: &ClusterType,
|
||||||
|
account_indexes: AccountSecondaryIndexes,
|
||||||
|
shrink_ratio: AccountShrinkThreshold,
|
||||||
|
) -> Self {
|
||||||
|
Self::new_with_config(
|
||||||
|
paths,
|
||||||
|
cluster_type,
|
||||||
|
account_indexes,
|
||||||
|
shrink_ratio,
|
||||||
|
Some(ACCOUNTS_DB_CONFIG_FOR_TESTING),
|
||||||
|
None,
|
||||||
|
Arc::default(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn new_with_config_for_benches(
|
||||||
|
paths: Vec<PathBuf>,
|
||||||
|
cluster_type: &ClusterType,
|
||||||
|
account_indexes: AccountSecondaryIndexes,
|
||||||
|
shrink_ratio: AccountShrinkThreshold,
|
||||||
|
) -> Self {
|
||||||
|
Self::new_with_config(
|
||||||
|
paths,
|
||||||
|
cluster_type,
|
||||||
|
account_indexes,
|
||||||
|
shrink_ratio,
|
||||||
|
Some(ACCOUNTS_DB_CONFIG_FOR_BENCHMARKS),
|
||||||
|
None,
|
||||||
|
Arc::default(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn load_without_fixed_root(
|
pub fn load_without_fixed_root(
|
||||||
&self,
|
&self,
|
||||||
ancestors: &Ancestors,
|
ancestors: &Ancestors,
|
||||||
|
@ -9821,23 +9855,6 @@ pub mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AccountsDb {
|
impl AccountsDb {
|
||||||
pub fn new_with_config_for_tests(
|
|
||||||
paths: Vec<PathBuf>,
|
|
||||||
cluster_type: &ClusterType,
|
|
||||||
account_indexes: AccountSecondaryIndexes,
|
|
||||||
shrink_ratio: AccountShrinkThreshold,
|
|
||||||
) -> Self {
|
|
||||||
Self::new_with_config(
|
|
||||||
paths,
|
|
||||||
cluster_type,
|
|
||||||
account_indexes,
|
|
||||||
shrink_ratio,
|
|
||||||
Some(ACCOUNTS_DB_CONFIG_FOR_TESTING),
|
|
||||||
None,
|
|
||||||
Arc::default(),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn new_sized(paths: Vec<PathBuf>, file_size: u64) -> Self {
|
pub fn new_sized(paths: Vec<PathBuf>, file_size: u64) -> Self {
|
||||||
AccountsDb {
|
AccountsDb {
|
||||||
file_size,
|
file_size,
|
||||||
|
|
|
@ -10,7 +10,7 @@ use {
|
||||||
solana_accounts_db::{
|
solana_accounts_db::{
|
||||||
accounts::{AccountAddressFilter, Accounts},
|
accounts::{AccountAddressFilter, Accounts},
|
||||||
accounts_db::{
|
accounts_db::{
|
||||||
test_utils::create_test_accounts, AccountShrinkThreshold,
|
test_utils::create_test_accounts, AccountShrinkThreshold, AccountsDb,
|
||||||
VerifyAccountsHashAndLamportsConfig,
|
VerifyAccountsHashAndLamportsConfig,
|
||||||
},
|
},
|
||||||
accounts_index::{AccountSecondaryIndexes, ScanConfig},
|
accounts_index::{AccountSecondaryIndexes, ScanConfig},
|
||||||
|
@ -99,12 +99,13 @@ fn test_accounts_squash(bencher: &mut Bencher) {
|
||||||
|
|
||||||
#[bench]
|
#[bench]
|
||||||
fn test_accounts_hash_bank_hash(bencher: &mut Bencher) {
|
fn test_accounts_hash_bank_hash(bencher: &mut Bencher) {
|
||||||
let accounts = Accounts::new_with_config_for_benches(
|
let accounts_db = AccountsDb::new_with_config_for_benches(
|
||||||
vec![PathBuf::from("bench_accounts_hash_internal")],
|
vec![PathBuf::from("bench_accounts_hash_internal")],
|
||||||
&ClusterType::Development,
|
&ClusterType::Development,
|
||||||
AccountSecondaryIndexes::default(),
|
AccountSecondaryIndexes::default(),
|
||||||
AccountShrinkThreshold::default(),
|
AccountShrinkThreshold::default(),
|
||||||
);
|
);
|
||||||
|
let accounts = Accounts::new(Arc::new(accounts_db));
|
||||||
let mut pubkeys: Vec<Pubkey> = vec![];
|
let mut pubkeys: Vec<Pubkey> = vec![];
|
||||||
let num_accounts = 60_000;
|
let num_accounts = 60_000;
|
||||||
let slot = 0;
|
let slot = 0;
|
||||||
|
@ -136,12 +137,13 @@ fn test_accounts_hash_bank_hash(bencher: &mut Bencher) {
|
||||||
#[bench]
|
#[bench]
|
||||||
fn test_update_accounts_hash(bencher: &mut Bencher) {
|
fn test_update_accounts_hash(bencher: &mut Bencher) {
|
||||||
solana_logger::setup();
|
solana_logger::setup();
|
||||||
let accounts = Accounts::new_with_config_for_benches(
|
let accounts_db = AccountsDb::new_with_config_for_benches(
|
||||||
vec![PathBuf::from("update_accounts_hash")],
|
vec![PathBuf::from("update_accounts_hash")],
|
||||||
&ClusterType::Development,
|
&ClusterType::Development,
|
||||||
AccountSecondaryIndexes::default(),
|
AccountSecondaryIndexes::default(),
|
||||||
AccountShrinkThreshold::default(),
|
AccountShrinkThreshold::default(),
|
||||||
);
|
);
|
||||||
|
let accounts = Accounts::new(Arc::new(accounts_db));
|
||||||
let mut pubkeys: Vec<Pubkey> = vec![];
|
let mut pubkeys: Vec<Pubkey> = vec![];
|
||||||
create_test_accounts(&accounts, &mut pubkeys, 50_000, 0);
|
create_test_accounts(&accounts, &mut pubkeys, 50_000, 0);
|
||||||
let ancestors = Ancestors::from(vec![0]);
|
let ancestors = Ancestors::from(vec![0]);
|
||||||
|
@ -155,12 +157,13 @@ fn test_update_accounts_hash(bencher: &mut Bencher) {
|
||||||
#[bench]
|
#[bench]
|
||||||
fn test_accounts_delta_hash(bencher: &mut Bencher) {
|
fn test_accounts_delta_hash(bencher: &mut Bencher) {
|
||||||
solana_logger::setup();
|
solana_logger::setup();
|
||||||
let accounts = Accounts::new_with_config_for_benches(
|
let accounts_db = AccountsDb::new_with_config_for_benches(
|
||||||
vec![PathBuf::from("accounts_delta_hash")],
|
vec![PathBuf::from("accounts_delta_hash")],
|
||||||
&ClusterType::Development,
|
&ClusterType::Development,
|
||||||
AccountSecondaryIndexes::default(),
|
AccountSecondaryIndexes::default(),
|
||||||
AccountShrinkThreshold::default(),
|
AccountShrinkThreshold::default(),
|
||||||
);
|
);
|
||||||
|
let accounts = Accounts::new(Arc::new(accounts_db));
|
||||||
let mut pubkeys: Vec<Pubkey> = vec![];
|
let mut pubkeys: Vec<Pubkey> = vec![];
|
||||||
create_test_accounts(&accounts, &mut pubkeys, 100_000, 0);
|
create_test_accounts(&accounts, &mut pubkeys, 100_000, 0);
|
||||||
bencher.iter(|| {
|
bencher.iter(|| {
|
||||||
|
@ -171,12 +174,13 @@ fn test_accounts_delta_hash(bencher: &mut Bencher) {
|
||||||
#[bench]
|
#[bench]
|
||||||
fn bench_delete_dependencies(bencher: &mut Bencher) {
|
fn bench_delete_dependencies(bencher: &mut Bencher) {
|
||||||
solana_logger::setup();
|
solana_logger::setup();
|
||||||
let accounts = Accounts::new_with_config_for_benches(
|
let accounts_db = AccountsDb::new_with_config_for_benches(
|
||||||
vec![PathBuf::from("accounts_delete_deps")],
|
vec![PathBuf::from("accounts_delete_deps")],
|
||||||
&ClusterType::Development,
|
&ClusterType::Development,
|
||||||
AccountSecondaryIndexes::default(),
|
AccountSecondaryIndexes::default(),
|
||||||
AccountShrinkThreshold::default(),
|
AccountShrinkThreshold::default(),
|
||||||
);
|
);
|
||||||
|
let accounts = Accounts::new(Arc::new(accounts_db));
|
||||||
let mut old_pubkey = Pubkey::default();
|
let mut old_pubkey = Pubkey::default();
|
||||||
let zero_account = AccountSharedData::new(0, 0, AccountSharedData::default().owner());
|
let zero_account = AccountSharedData::new(0, 0, AccountSharedData::default().owner());
|
||||||
for i in 0..1000 {
|
for i in 0..1000 {
|
||||||
|
@ -200,7 +204,7 @@ fn store_accounts_with_possible_contention<F: 'static>(
|
||||||
F: Fn(&Accounts, &[Pubkey]) + Send + Copy,
|
F: Fn(&Accounts, &[Pubkey]) + Send + Copy,
|
||||||
{
|
{
|
||||||
let num_readers = 5;
|
let num_readers = 5;
|
||||||
let accounts = Arc::new(Accounts::new_with_config_for_benches(
|
let accounts_db = AccountsDb::new_with_config_for_benches(
|
||||||
vec![
|
vec![
|
||||||
PathBuf::from(std::env::var("FARF_DIR").unwrap_or_else(|_| "farf".to_string()))
|
PathBuf::from(std::env::var("FARF_DIR").unwrap_or_else(|_| "farf".to_string()))
|
||||||
.join(bench_name),
|
.join(bench_name),
|
||||||
|
@ -208,7 +212,8 @@ fn store_accounts_with_possible_contention<F: 'static>(
|
||||||
&ClusterType::Development,
|
&ClusterType::Development,
|
||||||
AccountSecondaryIndexes::default(),
|
AccountSecondaryIndexes::default(),
|
||||||
AccountShrinkThreshold::default(),
|
AccountShrinkThreshold::default(),
|
||||||
));
|
);
|
||||||
|
let accounts = Arc::new(Accounts::new(Arc::new(accounts_db)));
|
||||||
let num_keys = 1000;
|
let num_keys = 1000;
|
||||||
let slot = 0;
|
let slot = 0;
|
||||||
accounts.add_root(slot);
|
accounts.add_root(slot);
|
||||||
|
@ -336,7 +341,7 @@ fn bench_rwlock_hashmap_single_reader_with_n_writers(bencher: &mut Bencher) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn setup_bench_dashmap_iter() -> (Arc<Accounts>, DashMap<Pubkey, (AccountSharedData, Hash)>) {
|
fn setup_bench_dashmap_iter() -> (Arc<Accounts>, DashMap<Pubkey, (AccountSharedData, Hash)>) {
|
||||||
let accounts = Arc::new(Accounts::new_with_config_for_benches(
|
let accounts_db = AccountsDb::new_with_config_for_benches(
|
||||||
vec![
|
vec![
|
||||||
PathBuf::from(std::env::var("FARF_DIR").unwrap_or_else(|_| "farf".to_string()))
|
PathBuf::from(std::env::var("FARF_DIR").unwrap_or_else(|_| "farf".to_string()))
|
||||||
.join("bench_dashmap_par_iter"),
|
.join("bench_dashmap_par_iter"),
|
||||||
|
@ -344,7 +349,8 @@ fn setup_bench_dashmap_iter() -> (Arc<Accounts>, DashMap<Pubkey, (AccountSharedD
|
||||||
&ClusterType::Development,
|
&ClusterType::Development,
|
||||||
AccountSecondaryIndexes::default(),
|
AccountSecondaryIndexes::default(),
|
||||||
AccountShrinkThreshold::default(),
|
AccountShrinkThreshold::default(),
|
||||||
));
|
);
|
||||||
|
let accounts = Arc::new(Accounts::new(Arc::new(accounts_db)));
|
||||||
|
|
||||||
let dashmap = DashMap::new();
|
let dashmap = DashMap::new();
|
||||||
let num_keys = std::env::var("NUM_BENCH_KEYS")
|
let num_keys = std::env::var("NUM_BENCH_KEYS")
|
||||||
|
@ -393,12 +399,13 @@ fn bench_dashmap_iter(bencher: &mut Bencher) {
|
||||||
|
|
||||||
#[bench]
|
#[bench]
|
||||||
fn bench_load_largest_accounts(b: &mut Bencher) {
|
fn bench_load_largest_accounts(b: &mut Bencher) {
|
||||||
let accounts = Accounts::new_with_config_for_benches(
|
let accounts_db = AccountsDb::new_with_config_for_benches(
|
||||||
Vec::new(),
|
Vec::new(),
|
||||||
&ClusterType::Development,
|
&ClusterType::Development,
|
||||||
AccountSecondaryIndexes::default(),
|
AccountSecondaryIndexes::default(),
|
||||||
AccountShrinkThreshold::default(),
|
AccountShrinkThreshold::default(),
|
||||||
);
|
);
|
||||||
|
let accounts = Accounts::new(Arc::new(accounts_db));
|
||||||
let mut rng = rand::thread_rng();
|
let mut rng = rand::thread_rng();
|
||||||
for _ in 0..10_000 {
|
for _ in 0..10_000 {
|
||||||
let lamports = rng.gen();
|
let lamports = rng.gen();
|
||||||
|
|
|
@ -561,7 +561,7 @@ mod tests {
|
||||||
transaction::{Result, Transaction, TransactionError},
|
transaction::{Result, Transaction, TransactionError},
|
||||||
transaction_context::TransactionAccount,
|
transaction_context::TransactionAccount,
|
||||||
},
|
},
|
||||||
std::convert::TryFrom,
|
std::{convert::TryFrom, sync::Arc},
|
||||||
};
|
};
|
||||||
|
|
||||||
fn load_accounts_with_fee_and_rent(
|
fn load_accounts_with_fee_and_rent(
|
||||||
|
@ -575,12 +575,13 @@ mod tests {
|
||||||
) -> Vec<TransactionLoadResult> {
|
) -> Vec<TransactionLoadResult> {
|
||||||
let mut hash_queue = BlockhashQueue::new(100);
|
let mut hash_queue = BlockhashQueue::new(100);
|
||||||
hash_queue.register_hash(&tx.message().recent_blockhash, lamports_per_signature);
|
hash_queue.register_hash(&tx.message().recent_blockhash, lamports_per_signature);
|
||||||
let accounts = Accounts::new_with_config_for_tests(
|
let accounts_db = AccountsDb::new_with_config_for_tests(
|
||||||
Vec::new(),
|
Vec::new(),
|
||||||
&ClusterType::Development,
|
&ClusterType::Development,
|
||||||
AccountSecondaryIndexes::default(),
|
AccountSecondaryIndexes::default(),
|
||||||
AccountShrinkThreshold::default(),
|
AccountShrinkThreshold::default(),
|
||||||
);
|
);
|
||||||
|
let accounts = Accounts::new(Arc::new(accounts_db));
|
||||||
for ka in ka.iter() {
|
for ka in ka.iter() {
|
||||||
accounts.accounts_db.store_for_tests(0, &[(&ka.0, &ka.1)]);
|
accounts.accounts_db.store_for_tests(0, &[(&ka.0, &ka.1)]);
|
||||||
}
|
}
|
||||||
|
@ -1387,12 +1388,13 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_instructions() {
|
fn test_instructions() {
|
||||||
solana_logger::setup();
|
solana_logger::setup();
|
||||||
let accounts = Accounts::new_with_config_for_tests(
|
let accounts_db = AccountsDb::new_with_config_for_tests(
|
||||||
Vec::new(),
|
Vec::new(),
|
||||||
&ClusterType::Development,
|
&ClusterType::Development,
|
||||||
AccountSecondaryIndexes::default(),
|
AccountSecondaryIndexes::default(),
|
||||||
AccountShrinkThreshold::default(),
|
AccountShrinkThreshold::default(),
|
||||||
);
|
);
|
||||||
|
let accounts = Accounts::new(Arc::new(accounts_db));
|
||||||
|
|
||||||
let instructions_key = solana_sdk::sysvar::instructions::id();
|
let instructions_key = solana_sdk::sysvar::instructions::id();
|
||||||
let keypair = Keypair::new();
|
let keypair = Keypair::new();
|
||||||
|
@ -1413,12 +1415,13 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_overrides() {
|
fn test_overrides() {
|
||||||
solana_logger::setup();
|
solana_logger::setup();
|
||||||
let accounts = Accounts::new_with_config_for_tests(
|
let accounts_db = AccountsDb::new_with_config_for_tests(
|
||||||
Vec::new(),
|
Vec::new(),
|
||||||
&ClusterType::Development,
|
&ClusterType::Development,
|
||||||
AccountSecondaryIndexes::default(),
|
AccountSecondaryIndexes::default(),
|
||||||
AccountShrinkThreshold::default(),
|
AccountShrinkThreshold::default(),
|
||||||
);
|
);
|
||||||
|
let accounts = Accounts::new(Arc::new(accounts_db));
|
||||||
let mut account_overrides = AccountOverrides::default();
|
let mut account_overrides = AccountOverrides::default();
|
||||||
let slot_history_id = sysvar::slot_history::id();
|
let slot_history_id = sysvar::slot_history::id();
|
||||||
let account = AccountSharedData::new(42, 0, &Pubkey::default());
|
let account = AccountSharedData::new(42, 0, &Pubkey::default());
|
||||||
|
|
|
@ -1100,7 +1100,7 @@ impl Bank {
|
||||||
accounts_update_notifier: Option<AccountsUpdateNotifier>,
|
accounts_update_notifier: Option<AccountsUpdateNotifier>,
|
||||||
exit: Arc<AtomicBool>,
|
exit: Arc<AtomicBool>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let accounts = Accounts::new_with_config(
|
let accounts_db = AccountsDb::new_with_config(
|
||||||
paths,
|
paths,
|
||||||
&genesis_config.cluster_type,
|
&genesis_config.cluster_type,
|
||||||
account_indexes,
|
account_indexes,
|
||||||
|
@ -1109,6 +1109,7 @@ impl Bank {
|
||||||
accounts_update_notifier,
|
accounts_update_notifier,
|
||||||
exit,
|
exit,
|
||||||
);
|
);
|
||||||
|
let accounts = Accounts::new(Arc::new(accounts_db));
|
||||||
let mut bank = Self::default_with_accounts(accounts);
|
let mut bank = Self::default_with_accounts(accounts);
|
||||||
bank.ancestors = Ancestors::from(vec![bank.slot()]);
|
bank.ancestors = Ancestors::from(vec![bank.slot()]);
|
||||||
bank.transaction_debug_keys = debug_keys;
|
bank.transaction_debug_keys = debug_keys;
|
||||||
|
@ -8173,7 +8174,9 @@ impl Bank {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn default_for_tests() -> Self {
|
pub fn default_for_tests() -> Self {
|
||||||
Self::default_with_accounts(Accounts::default_for_tests())
|
let accounts_db = AccountsDb::default_for_tests();
|
||||||
|
let accounts = Accounts::new(Arc::new(accounts_db));
|
||||||
|
Self::default_with_accounts(accounts)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_with_bank_forks_for_tests(
|
pub fn new_with_bank_forks_for_tests(
|
||||||
|
|
|
@ -223,12 +223,13 @@ mod serde_snapshot_tests {
|
||||||
fn test_accounts_serialize_style(serde_style: SerdeStyle) {
|
fn test_accounts_serialize_style(serde_style: SerdeStyle) {
|
||||||
solana_logger::setup();
|
solana_logger::setup();
|
||||||
let (_accounts_dir, paths) = get_temp_accounts_paths(4).unwrap();
|
let (_accounts_dir, paths) = get_temp_accounts_paths(4).unwrap();
|
||||||
let accounts = Accounts::new_with_config_for_tests(
|
let accounts_db = AccountsDb::new_with_config_for_tests(
|
||||||
paths,
|
paths,
|
||||||
&ClusterType::Development,
|
&ClusterType::Development,
|
||||||
AccountSecondaryIndexes::default(),
|
AccountSecondaryIndexes::default(),
|
||||||
AccountShrinkThreshold::default(),
|
AccountShrinkThreshold::default(),
|
||||||
);
|
);
|
||||||
|
let accounts = Accounts::new(Arc::new(accounts_db));
|
||||||
|
|
||||||
let slot = 0;
|
let slot = 0;
|
||||||
let mut pubkeys: Vec<Pubkey> = vec![];
|
let mut pubkeys: Vec<Pubkey> = vec![];
|
||||||
|
|
|
@ -8,7 +8,7 @@ use {
|
||||||
log::*,
|
log::*,
|
||||||
solana_accounts_db::{
|
solana_accounts_db::{
|
||||||
accounts::Accounts,
|
accounts::Accounts,
|
||||||
accounts_db::AccountStorageEntry,
|
accounts_db::{AccountStorageEntry, AccountsDb},
|
||||||
accounts_hash::{AccountsHash, AccountsHashKind},
|
accounts_hash::{AccountsHash, AccountsHashKind},
|
||||||
epoch_accounts_hash::EpochAccountsHash,
|
epoch_accounts_hash::EpochAccountsHash,
|
||||||
rent_collector::RentCollector,
|
rent_collector::RentCollector,
|
||||||
|
@ -159,6 +159,8 @@ impl AccountsPackage {
|
||||||
/// Create a new Accounts Package where basically every field is defaulted.
|
/// Create a new Accounts Package where basically every field is defaulted.
|
||||||
/// Only use for tests; many of the fields are invalid!
|
/// Only use for tests; many of the fields are invalid!
|
||||||
pub fn default_for_tests() -> Self {
|
pub fn default_for_tests() -> Self {
|
||||||
|
let accounts_db = AccountsDb::default_for_tests();
|
||||||
|
let accounts = Accounts::new(Arc::new(accounts_db));
|
||||||
Self {
|
Self {
|
||||||
package_kind: AccountsPackageKind::AccountsHashVerifier,
|
package_kind: AccountsPackageKind::AccountsHashVerifier,
|
||||||
slot: Slot::default(),
|
slot: Slot::default(),
|
||||||
|
@ -166,7 +168,7 @@ impl AccountsPackage {
|
||||||
snapshot_storages: Vec::default(),
|
snapshot_storages: Vec::default(),
|
||||||
expected_capitalization: u64::default(),
|
expected_capitalization: u64::default(),
|
||||||
accounts_hash_for_testing: Option::default(),
|
accounts_hash_for_testing: Option::default(),
|
||||||
accounts: Arc::new(Accounts::default_for_tests()),
|
accounts: Arc::new(accounts),
|
||||||
epoch_schedule: EpochSchedule::default(),
|
epoch_schedule: EpochSchedule::default(),
|
||||||
rent_collector: RentCollector::default(),
|
rent_collector: RentCollector::default(),
|
||||||
is_incremental_accounts_hash_feature_enabled: bool::default(),
|
is_incremental_accounts_hash_feature_enabled: bool::default(),
|
||||||
|
|
Loading…
Reference in New Issue