diff --git a/runtime/src/accounts.rs b/runtime/src/accounts.rs index 78e05cbe9cbc72..6698f3feb8df3e 100644 --- a/runtime/src/accounts.rs +++ b/runtime/src/accounts.rs @@ -98,13 +98,11 @@ pub struct Accounts { // for the load instructions pub type TransactionAccounts = Vec<(Pubkey, AccountSharedData)>; -pub type TransactionAccountDeps = Vec<(Pubkey, AccountSharedData)>; pub type TransactionRent = u64; pub type TransactionLoaders = Vec>; #[derive(PartialEq, Debug, Clone)] pub struct LoadedTransaction { pub accounts: TransactionAccounts, - pub account_deps: TransactionAccountDeps, pub loaders: TransactionLoaders, pub rent: TransactionRent, pub rent_debits: RentDebits, @@ -281,7 +279,7 @@ impl Accounts { } debug_assert_eq!(accounts.len(), message.account_keys.len()); // REFACTOR: account_deps unification - accounts.append(&mut account_deps.clone()); + accounts.append(&mut account_deps); if let Some(payer_index) = payer_index { if payer_index != 0 { @@ -332,7 +330,6 @@ impl Accounts { .collect::>()?; Ok(LoadedTransaction { accounts, - account_deps, loaders, rent: tx_rent, rent_debits, @@ -2014,7 +2011,6 @@ mod tests { let loaded0 = ( Ok(LoadedTransaction { accounts: transaction_accounts0, - account_deps: vec![], loaders: transaction_loaders0, rent: transaction_rent0, rent_debits: RentDebits::default(), @@ -2027,7 +2023,6 @@ mod tests { let loaded1 = ( Ok(LoadedTransaction { accounts: transaction_accounts1, - account_deps: vec![], loaders: transaction_loaders1, rent: transaction_rent1, rent_debits: RentDebits::default(), @@ -2411,7 +2406,6 @@ mod tests { let loaded = ( Ok(LoadedTransaction { accounts: transaction_accounts, - account_deps: vec![], loaders: transaction_loaders, rent: transaction_rent, rent_debits: RentDebits::default(), @@ -2529,7 +2523,6 @@ mod tests { let loaded = ( Ok(LoadedTransaction { accounts: transaction_accounts, - account_deps: vec![], loaders: transaction_loaders, rent: transaction_rent, rent_debits: RentDebits::default(), diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 6fa73e89691ecd..c7f00ca762a53a 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -35,8 +35,8 @@ //! already been signed and verified. use crate::{ accounts::{ - AccountAddressFilter, Accounts, TransactionAccountDeps, TransactionAccounts, - TransactionLoadResult, TransactionLoaders, + AccountAddressFilter, Accounts, TransactionAccounts, TransactionLoadResult, + TransactionLoaders, }, accounts_db::{AccountShrinkThreshold, ErrorCounters, SnapshotStorages}, accounts_index::{AccountSecondaryIndexes, IndexKey, ScanResult}, @@ -178,7 +178,6 @@ type BankStatusCache = StatusCache>; #[frozen_abi(digest = "F3Ubz2Sx973pKSYNHTEmj6LY3te1DKUo3fs3cgzQ1uqJ")] pub type BankSlotDelta = SlotDelta>; type TransactionAccountRefCells = Vec<(Pubkey, Rc>)>; -type TransactionAccountDepRefCells = Vec<(Pubkey, Rc>)>; type TransactionLoaderRefCells = Vec>)>>; // Eager rent collection repeats in cyclic manner. @@ -2947,14 +2946,9 @@ impl Bank { /// ownership by draining the source fn accounts_to_refcells( accounts: &mut TransactionAccounts, - account_deps: &mut TransactionAccountDeps, loaders: &mut TransactionLoaders, message: &Message, - ) -> ( - TransactionAccountRefCells, - TransactionAccountDepRefCells, - TransactionLoaderRefCells, - ) { + ) -> (TransactionAccountRefCells, TransactionLoaderRefCells) { let account_refcells: Vec<_> = (0..message.account_keys.len()) .zip(accounts.drain(..)) .map(|(_i, (pubkey, account))| { @@ -2962,10 +2956,6 @@ impl Bank { (pubkey, Rc::new(RefCell::new(account))) }) .collect(); - let account_dep_refcells: Vec<_> = account_deps - .drain(..) - .map(|(pubkey, account_dep)| (pubkey, Rc::new(RefCell::new(account_dep)))) - .collect(); let loader_refcells: Vec> = loaders .iter_mut() .map(|v| { @@ -2974,7 +2964,7 @@ impl Bank { .collect() }) .collect(); - (account_refcells, account_dep_refcells, loader_refcells) + (account_refcells, loader_refcells) } /// Converts back from RefCell to AccountSharedData, this involves moving @@ -3147,13 +3137,11 @@ impl Bank { signature_count += u64::from(tx.message().header.num_required_signatures); let executors = self.get_executors(&tx.message, &loaded_transaction.loaders); - let (account_refcells, account_dep_refcells, loader_refcells) = - Self::accounts_to_refcells( - &mut loaded_transaction.accounts, - &mut loaded_transaction.account_deps, - &mut loaded_transaction.loaders, - &tx.message, - ); + let (account_refcells, loader_refcells) = Self::accounts_to_refcells( + &mut loaded_transaction.accounts, + &mut loaded_transaction.loaders, + &tx.message, + ); let instruction_recorders = if enable_cpi_recording { let ix_count = tx.message.instructions.len(); @@ -3174,7 +3162,6 @@ impl Bank { tx.message(), &loader_refcells, &account_refcells, - &account_dep_refcells, &self.rent_collector, log_collector.clone(), executors.clone(), diff --git a/runtime/src/message_processor.rs b/runtime/src/message_processor.rs index db98cdb380e069..1d58a96a3c59c2 100644 --- a/runtime/src/message_processor.rs +++ b/runtime/src/message_processor.rs @@ -260,10 +260,8 @@ impl ComputeMeter for ThisComputeMeter { pub struct ThisInvokeContext<'a> { invoke_stack: Vec>, rent: Rent, - message: &'a Message, pre_accounts: Vec, accounts: &'a [(Pubkey, Rc>)], - account_deps: &'a [(Pubkey, Rc>)], programs: &'a [(Pubkey, ProcessInstructionWithContext)], logger: Rc>, bpf_compute_budget: BpfComputeBudget, @@ -286,7 +284,6 @@ impl<'a> ThisInvokeContext<'a> { instruction: &'a CompiledInstruction, executable_accounts: &'a [(Pubkey, Rc>)], accounts: &'a [(Pubkey, Rc>)], - account_deps: &'a [(Pubkey, Rc>)], programs: &'a [(Pubkey, ProcessInstructionWithContext)], log_collector: Option>, bpf_compute_budget: BpfComputeBudget, @@ -307,10 +304,8 @@ impl<'a> ThisInvokeContext<'a> { let mut invoke_context = Self { invoke_stack: Vec::with_capacity(bpf_compute_budget.max_invoke_depth), rent, - message, pre_accounts, accounts, - account_deps, programs, logger: Rc::new(RefCell::new(ThisLogger { log_collector })), bpf_compute_budget, @@ -364,25 +359,21 @@ impl<'a> InvokeContext for ThisInvokeContext<'a> { .iter() .map(|(is_signer, is_writable, search_key, account)| { // REFACTOR: account_deps unification - (0..self.message.account_keys.len()) - .map(|index| &self.accounts[index].0) - .chain(self.account_deps.iter().map(|(key, _account)| key)) - .position(|key| key == *search_key) - .map(|mut index| { + self.accounts + .iter() + .position(|(key, _account)| key == *search_key) + .map(|index| { // TODO // Currently we are constructing new accounts on the stack // before calling MessageProcessor::process_cross_program_instruction // Ideally we would recycle the existing accounts here. - let key = if index < self.message.account_keys.len() { - // REFACTOR: account_deps unification - &self.accounts[index].0 - // &self.accounts[index] as &RefCell, - } else { - index = index.saturating_sub(self.message.account_keys.len()); - &self.account_deps[index].0 - // &self.account_deps[index].1 as &RefCell, - }; - (*is_signer, *is_writable, key, transmute_lifetime(*account)) + ( + *is_signer, + *is_writable, + &self.accounts[index].0, + // &self.accounts[index] as &RefCell + transmute_lifetime(*account), + ) }) }) .collect::>>() @@ -473,12 +464,7 @@ impl<'a> InvokeContext for ThisInvokeContext<'a> { } fn get_account(&self, pubkey: &Pubkey) -> Option>> { // REFACTOR: account_deps unification - for index in 0..self.message.account_keys.len() { - if self.accounts[index].0 == *pubkey { - return Some(self.accounts[index].1.clone()); - } - } - self.account_deps.iter().find_map(|(key, account)| { + self.accounts.iter().find_map(|(key, account)| { if key == pubkey { Some(account.clone()) } else { @@ -1148,7 +1134,6 @@ impl MessageProcessor { instruction: &CompiledInstruction, executable_accounts: &[(Pubkey, Rc>)], accounts: &[(Pubkey, Rc>)], - account_deps: &[(Pubkey, Rc>)], rent_collector: &RentCollector, log_collector: Option>, executors: Rc>, @@ -1185,7 +1170,6 @@ impl MessageProcessor { instruction, executable_accounts, accounts, - account_deps, &self.programs, log_collector, bpf_compute_budget, @@ -1223,7 +1207,6 @@ impl MessageProcessor { message: &Message, loaders: &[Vec<(Pubkey, Rc>)>], accounts: &[(Pubkey, Rc>)], - account_deps: &[(Pubkey, Rc>)], rent_collector: &RentCollector, log_collector: Option>, executors: Rc>, @@ -1246,7 +1229,6 @@ impl MessageProcessor { instruction, &loaders[instruction_index], accounts, - account_deps, rent_collector, log_collector.clone(), executors.clone(), @@ -1326,7 +1308,6 @@ mod tests { &[], &accounts, &[], - &[], None, BpfComputeBudget::default(), Rc::new(RefCell::new(Executors::default())), @@ -1918,7 +1899,6 @@ mod tests { &message, &loaders, &accounts, - &[], &rent_collector, None, executors.clone(), @@ -1946,7 +1926,6 @@ mod tests { &message, &loaders, &accounts, - &[], &rent_collector, None, executors.clone(), @@ -1978,7 +1957,6 @@ mod tests { &message, &loaders, &accounts, - &[], &rent_collector, None, executors, @@ -2102,7 +2080,6 @@ mod tests { &message, &loaders, &accounts, - &[], &rent_collector, None, executors.clone(), @@ -2134,7 +2111,6 @@ mod tests { &message, &loaders, &accounts, - &[], &rent_collector, None, executors.clone(), @@ -2164,7 +2140,6 @@ mod tests { &message, &loaders, &accounts, - &[], &rent_collector, None, executors, @@ -2269,7 +2244,6 @@ mod tests { &compiled_instruction, &executable_accounts, &accounts, - &[], programs.as_slice(), None, BpfComputeBudget::default(), @@ -2328,7 +2302,6 @@ mod tests { &compiled_instruction, &executable_accounts, &accounts, - &[], programs.as_slice(), None, BpfComputeBudget::default(),