Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce usage of solana-sdk in accounts-db #4180

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions accounts-db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,20 @@ serde = { workspace = true, features = ["rc"] }
serde_derive = { workspace = true }
smallvec = { workspace = true, features = ["const_generics"] }
solana-bucket-map = { workspace = true }
solana-clock = { workspace = true }
solana-frozen-abi = { workspace = true, optional = true, features = [
"frozen-abi",
] }
solana-frozen-abi-macro = { workspace = true, optional = true, features = [
"frozen-abi",
] }
solana-hash = { workspace = true }
solana-inline-spl = { workspace = true }
solana-lattice-hash = { workspace = true }
solana-measure = { workspace = true }
solana-metrics = { workspace = true }
solana-nohash-hasher = { workspace = true }
solana-pubkey = { workspace = true }
solana-rayon-threadlimit = { workspace = true }
solana-sdk = { workspace = true }
solana-stake-program = { workspace = true, optional = true }
Expand Down Expand Up @@ -87,6 +90,7 @@ dev-context-only-utils = [
"dep:qualifier_attr",
"dep:solana-stake-program",
"dep:solana-vote-program",
"solana-pubkey/rand",
]
frozen-abi = [
"dep:solana-frozen-abi",
Expand Down
6 changes: 3 additions & 3 deletions accounts-db/benches/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ fn bench_delete_dependencies(bencher: &mut Bencher) {
let mut old_pubkey = Pubkey::default();
let zero_account = AccountSharedData::new(0, 0, AccountSharedData::default().owner());
for i in 0..1000 {
let pubkey = solana_sdk::pubkey::new_rand();
let pubkey = solana_pubkey::new_rand();
let account = AccountSharedData::new(i + 1, 0, AccountSharedData::default().owner());
accounts.store_slow_uncached(i, &pubkey, &account);
accounts.store_slow_uncached(i, &old_pubkey, &zero_account);
Expand All @@ -136,7 +136,7 @@ where
let num_keys = 1000;
let slot = 0;

let pubkeys: Vec<_> = std::iter::repeat_with(solana_sdk::pubkey::new_rand)
let pubkeys: Vec<_> = std::iter::repeat_with(solana_pubkey::new_rand)
.take(num_keys)
.collect();
let accounts_data: Vec<_> = std::iter::repeat(
Expand Down Expand Up @@ -169,7 +169,7 @@ where

let num_new_keys = 1000;
bencher.iter(|| {
let new_pubkeys: Vec<_> = std::iter::repeat_with(solana_sdk::pubkey::new_rand)
let new_pubkeys: Vec<_> = std::iter::repeat_with(solana_pubkey::new_rand)
.take(num_new_keys)
.collect();
let new_storable_accounts: Vec<_> = new_pubkeys.iter().zip(accounts_data.iter()).collect();
Expand Down
2 changes: 1 addition & 1 deletion accounts-db/src/account_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use {
crate::accounts_db::{AccountStorageEntry, AccountsFileId},
dashmap::DashMap,
solana_sdk::clock::Slot,
solana_clock::Slot,
std::sync::Arc,
};

Expand Down
8 changes: 4 additions & 4 deletions accounts-db/src/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -866,13 +866,13 @@ mod tests {
let accounts = Accounts::new(Arc::new(accounts_db));

// Load accounts owned by various programs into AccountsDb
let pubkey0 = solana_sdk::pubkey::new_rand();
let pubkey0 = solana_pubkey::new_rand();
let account0 = AccountSharedData::new(1, 0, &Pubkey::from([2; 32]));
accounts.store_slow_uncached(0, &pubkey0, &account0);
let pubkey1 = solana_sdk::pubkey::new_rand();
let pubkey1 = solana_pubkey::new_rand();
let account1 = AccountSharedData::new(1, 0, &Pubkey::from([2; 32]));
accounts.store_slow_uncached(0, &pubkey1, &account1);
let pubkey2 = solana_sdk::pubkey::new_rand();
let pubkey2 = solana_pubkey::new_rand();
let account2 = AccountSharedData::new(1, 0, &Pubkey::from([3; 32]));
accounts.store_slow_uncached(0, &pubkey2, &account2);

Expand Down Expand Up @@ -1292,7 +1292,7 @@ mod tests {
let zero_account = AccountSharedData::new(0, 0, AccountSharedData::default().owner());
info!("storing..");
for i in 0..2_000 {
let pubkey = solana_sdk::pubkey::new_rand();
let pubkey = solana_pubkey::new_rand();
let account = AccountSharedData::new(i + 1, 0, AccountSharedData::default().owner());
accounts.store_for_tests(i, &pubkey, &account);
accounts.store_for_tests(i, &old_pubkey, &zero_account);
Expand Down
6 changes: 3 additions & 3 deletions accounts-db/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9397,15 +9397,15 @@ impl AccountsDb {
) {
let ancestors = vec![(slot, 0)].into_iter().collect();
for t in 0..num {
let pubkey = solana_sdk::pubkey::new_rand();
let pubkey = solana_pubkey::new_rand();
let account =
AccountSharedData::new((t + 1) as u64, space, AccountSharedData::default().owner());
pubkeys.push(pubkey);
assert!(self.load_without_fixed_root(&ancestors, &pubkey).is_none());
self.store_for_tests(slot, &[(&pubkey, &account)]);
}
for t in 0..num_vote {
let pubkey = solana_sdk::pubkey::new_rand();
let pubkey = solana_pubkey::new_rand();
let account =
AccountSharedData::new((num + t + 1) as u64, space, &solana_vote_program::id());
pubkeys.push(pubkey);
Expand Down Expand Up @@ -9544,7 +9544,7 @@ pub mod test_utils {
}

for t in 0..num {
let pubkey = solana_sdk::pubkey::new_rand();
let pubkey = solana_pubkey::new_rand();
let account = AccountSharedData::new(
(t + 1) as u64,
data_size,
Expand Down
16 changes: 8 additions & 8 deletions accounts-db/src/accounts_db/geyser_plugin_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ pub mod tests {
fn test_notify_account_restore_from_snapshot_once_per_slot() {
let mut accounts = AccountsDb::new_single_for_tests();
// Account with key1 is updated twice in the store -- should only get notified once.
let key1 = solana_sdk::pubkey::new_rand();
let key1 = solana_pubkey::new_rand();
let mut account1_lamports: u64 = 1;
let account1 =
AccountSharedData::new(account1_lamports, 1, AccountSharedData::default().owner());
Expand All @@ -246,7 +246,7 @@ pub mod tests {
accounts.store_uncached(slot0, &[(&key1, &account1)]);
let notifier = GeyserTestPlugin::default();

let key2 = solana_sdk::pubkey::new_rand();
let key2 = solana_pubkey::new_rand();
let account2_lamports: u64 = 100;
let account2 =
AccountSharedData::new(account2_lamports, 1, AccountSharedData::default().owner());
Expand Down Expand Up @@ -284,14 +284,14 @@ pub mod tests {
// Account with key1 is updated twice in two different slots -- should only get notified once.
// Account with key2 is updated slot0, should get notified once
// Account with key3 is updated in slot1, should get notified once
let key1 = solana_sdk::pubkey::new_rand();
let key1 = solana_pubkey::new_rand();
let mut account1_lamports: u64 = 1;
let account1 =
AccountSharedData::new(account1_lamports, 1, AccountSharedData::default().owner());
let slot0 = 0;
accounts.store_uncached(slot0, &[(&key1, &account1)]);

let key2 = solana_sdk::pubkey::new_rand();
let key2 = solana_pubkey::new_rand();
let account2_lamports: u64 = 200;
let account2 =
AccountSharedData::new(account2_lamports, 1, AccountSharedData::default().owner());
Expand All @@ -303,7 +303,7 @@ pub mod tests {
accounts.store_uncached(slot1, &[(&key1, &account1)]);
let notifier = GeyserTestPlugin::default();

let key3 = solana_sdk::pubkey::new_rand();
let key3 = solana_pubkey::new_rand();
let account3_lamports: u64 = 300;
let account3 =
AccountSharedData::new(account3_lamports, 1, AccountSharedData::default().owner());
Expand Down Expand Up @@ -353,14 +353,14 @@ pub mod tests {
// Account with key1 is updated twice in two different slots -- should only get notified twice.
// Account with key2 is updated slot0, should get notified once
// Account with key3 is updated in slot1, should get notified once
let key1 = solana_sdk::pubkey::new_rand();
let key1 = solana_pubkey::new_rand();
let account1_lamports1: u64 = 1;
let account1 =
AccountSharedData::new(account1_lamports1, 1, AccountSharedData::default().owner());
let slot0 = 0;
accounts.store_cached((slot0, &[(&key1, &account1)][..]), None);

let key2 = solana_sdk::pubkey::new_rand();
let key2 = solana_pubkey::new_rand();
let account2_lamports: u64 = 200;
let account2 =
AccountSharedData::new(account2_lamports, 1, AccountSharedData::default().owner());
Expand All @@ -371,7 +371,7 @@ pub mod tests {
let account1 = AccountSharedData::new(account1_lamports2, 1, account1.owner());
accounts.store_cached((slot1, &[(&key1, &account1)][..]), None);

let key3 = solana_sdk::pubkey::new_rand();
let key3 = solana_pubkey::new_rand();
let account3_lamports: u64 = 300;
let account3 =
AccountSharedData::new(account3_lamports, 1, AccountSharedData::default().owner());
Expand Down
8 changes: 4 additions & 4 deletions accounts-db/src/accounts_db/scan_account_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ mod tests {
data.accounts = av;

let storage = Arc::new(data);
let pubkey = solana_sdk::pubkey::new_rand();
let pubkey = solana_pubkey::new_rand();
let acc = AccountSharedData::new(1, 48, AccountSharedData::default().owner());
let mark_alive = false;
append_single_account_with_default_hash(&storage, &pubkey, &acc, mark_alive, None);
Expand Down Expand Up @@ -583,8 +583,8 @@ mod tests {
let tf = crate::append_vec::test_utils::get_append_vec_path(
"test_accountsdb_scan_account_storage_no_bank",
);
let pubkey1 = solana_sdk::pubkey::new_rand();
let pubkey2 = solana_sdk::pubkey::new_rand();
let pubkey1 = solana_pubkey::new_rand();
let pubkey2 = solana_pubkey::new_rand();
let mark_alive = false;
let storage = sample_storage_with_entries(&tf, slot_expected, &pubkey1, mark_alive);
let lamports = storage
Expand Down Expand Up @@ -631,7 +631,7 @@ mod tests {
accounts_file_provider,
);
let storage = Arc::new(data);
let pubkey = solana_sdk::pubkey::new_rand();
let pubkey = solana_pubkey::new_rand();
let acc = AccountSharedData::new(1, 48, AccountSharedData::default().owner());
let mark_alive = false;
append_single_account_with_default_hash(&storage, &pubkey, &acc, mark_alive, None);
Expand Down
Loading
Loading