diff --git a/accounts-db/benches/bench_accounts_file.rs b/accounts-db/benches/bench_accounts_file.rs index 4efdd5550552a7..dee4f00a859b87 100644 --- a/accounts-db/benches/bench_accounts_file.rs +++ b/accounts-db/benches/bench_accounts_file.rs @@ -42,7 +42,10 @@ fn bench_write_accounts_file(c: &mut Criterion) { }) .take(accounts_count) .collect(); - let accounts_refs: Vec<_> = accounts.iter().collect(); + let accounts_refs: Vec<_> = accounts + .iter() + .map(|(pubkey, account)| (pubkey, account)) + .collect(); let storable_accounts = (Slot::MAX, accounts_refs.as_slice()); group.bench_function(BenchmarkId::new("append_vec", accounts_count), |b| { diff --git a/accounts-db/src/storable_accounts.rs b/accounts-db/src/storable_accounts.rs index b988b5d014187d..92d67495c00843 100644 --- a/accounts-db/src/storable_accounts.rs +++ b/accounts-db/src/storable_accounts.rs @@ -169,11 +169,7 @@ where } } -impl<'a: 'b, 'b, T: ReadableAccount + Sync + 'a> StorableAccounts<'a> - for (Slot, &'b [(&'a Pubkey, &'a T)]) -where - AccountForStorage<'a>: From<(&'a Pubkey, &'a T)>, -{ +impl<'a: 'b, 'b> StorableAccounts<'a> for (Slot, &'b [(&'a Pubkey, &'a AccountSharedData)]) { fn account( &self, index: usize, @@ -192,29 +188,6 @@ where self.1.len() } } -impl<'a, T: ReadableAccount + Sync> StorableAccounts<'a> for (Slot, &'a [&'a (Pubkey, T)]) -where - AccountForStorage<'a>: From<(&'a Pubkey, &'a T)>, -{ - fn account( - &self, - index: usize, - mut callback: impl for<'local> FnMut(AccountForStorage<'local>) -> Ret, - ) -> Ret { - callback((&self.1[index].0, &self.1[index].1).into()) - } - fn slot(&self, _index: usize) -> Slot { - // per-index slot is not unique per slot when per-account slot is not included in the source data - self.target_slot() - } - fn target_slot(&self) -> Slot { - self.0 - } - fn len(&self) -> usize { - self.1.len() - } -} - impl<'a> StorableAccounts<'a> for (Slot, &'a [&'a StoredAccountMeta<'a>]) { fn account( &self, @@ -234,7 +207,6 @@ impl<'a> StorableAccounts<'a> for (Slot, &'a [&'a StoredAccountMeta<'a>]) { self.1.len() } } - /// holds slices of accounts being moved FROM a common source slot to 'target_slot' pub struct StorableAccountsBySlot<'a> { target_slot: Slot, @@ -359,6 +331,30 @@ pub mod tests { }, }; + /// this is no longer used. It is very tricky to get these right. There are already tests for this. It is likely worth it to leave this here for a while until everything has settled. + impl<'a, T: ReadableAccount + Sync> StorableAccounts<'a> for (Slot, &'a [&'a (Pubkey, T)]) + where + AccountForStorage<'a>: From<(&'a Pubkey, &'a T)>, + { + fn account( + &self, + index: usize, + mut callback: impl for<'local> FnMut(AccountForStorage<'local>) -> Ret, + ) -> Ret { + callback((&self.1[index].0, &self.1[index].1).into()) + } + fn slot(&self, _index: usize) -> Slot { + // per-index slot is not unique per slot when per-account slot is not included in the source data + self.target_slot() + } + fn target_slot(&self) -> Slot { + self.0 + } + fn len(&self) -> usize { + self.1.len() + } + } + fn compare<'a>(a: &impl StorableAccounts<'a>, b: &impl StorableAccounts<'a>) { assert_eq!(a.target_slot(), b.target_slot()); assert_eq!(a.len(), b.len()); diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 84b1aee9f76731..5c117487f5a795 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -80,7 +80,7 @@ use { accounts_hash::{ AccountHash, AccountsHash, CalcAccountsHashConfig, HashStats, IncrementalAccountsHash, }, - accounts_index::{AccountSecondaryIndexes, IndexKey, ScanConfig, ScanResult, ZeroLamport}, + accounts_index::{AccountSecondaryIndexes, IndexKey, ScanConfig, ScanResult}, accounts_partition::{self, Partition, PartitionIndex}, accounts_update_notifier_interface::AccountsUpdateNotifier, ancestors::{Ancestors, AncestorsForSerialization}, @@ -88,7 +88,7 @@ use { epoch_accounts_hash::EpochAccountsHash, sorted_storages::SortedStorages, stake_rewards::StakeReward, - storable_accounts::{AccountForStorage, StorableAccounts}, + storable_accounts::StorableAccounts, }, solana_bpf_loader_program::syscalls::create_program_runtime_environment_v1, solana_cost_model::cost_tracker::CostTracker, @@ -5062,13 +5062,7 @@ impl Bank { /// fn store the single `account` with `pubkey`. /// Uses `store_accounts`, which works on a vector of accounts. - pub fn store_account<'a, T: ReadableAccount + Sync + ZeroLamport + 'a>( - &self, - pubkey: &'a Pubkey, - account: &'a T, - ) where - AccountForStorage<'a>: From<(&'a Pubkey, &'a T)>, - { + pub fn store_account(&self, pubkey: &Pubkey, account: &AccountSharedData) { self.store_accounts((self.slot(), &[(pubkey, account)][..])) }