From ef233eaaa7aa20fbdae870fc82e37bd26f0f885d Mon Sep 17 00:00:00 2001 From: Dmitri Makarov Date: Wed, 24 Jan 2024 09:43:18 -0500 Subject: [PATCH] Refactor load_accounts to take a reference to a slice instead of vec (#34919) This is in preparation for further refactoring of Bank::load_and_execute_transactions in a separate commit. --- accounts-db/src/nonce_info.rs | 12 ++++++------ rpc/src/transaction_status_service.rs | 2 +- runtime/src/accounts/mod.rs | 8 ++++---- runtime/src/bank.rs | 2 +- runtime/src/bank/tests.rs | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/accounts-db/src/nonce_info.rs b/accounts-db/src/nonce_info.rs index 16917be15c..8a6d3a40fc 100644 --- a/accounts-db/src/nonce_info.rs +++ b/accounts-db/src/nonce_info.rs @@ -66,7 +66,7 @@ impl NonceFull { } } pub fn from_partial( - partial: NoncePartial, + partial: &NoncePartial, message: &SanitizedMessage, accounts: &[TransactionAccount], rent_debits: &RentDebits, @@ -221,8 +221,8 @@ mod tests { ), ]; - let full = NonceFull::from_partial(partial.clone(), &message, &accounts, &rent_debits) - .unwrap(); + let full = + NonceFull::from_partial(&partial, &message, &accounts, &rent_debits).unwrap(); assert_eq!(*full.address(), nonce_address); assert_eq!(*full.account(), rent_collected_nonce_account); assert_eq!(full.lamports_per_signature(), Some(lamports_per_signature)); @@ -252,8 +252,8 @@ mod tests { ), ]; - let full = NonceFull::from_partial(partial.clone(), &message, &accounts, &rent_debits) - .unwrap(); + let full = + NonceFull::from_partial(&partial, &message, &accounts, &rent_debits).unwrap(); assert_eq!(*full.address(), nonce_address); assert_eq!(*full.account(), nonce_account); assert_eq!(full.lamports_per_signature(), Some(lamports_per_signature)); @@ -264,7 +264,7 @@ mod tests { { let message = new_sanitized_message(&instructions, Some(&nonce_address)); assert_eq!( - NonceFull::from_partial(partial, &message, &[], &RentDebits::default()) + NonceFull::from_partial(&partial, &message, &[], &RentDebits::default()) .unwrap_err(), TransactionError::AccountNotFound, ); diff --git a/rpc/src/transaction_status_service.rs b/rpc/src/transaction_status_service.rs index eca53c6665..68640362b2 100644 --- a/rpc/src/transaction_status_service.rs +++ b/rpc/src/transaction_status_service.rs @@ -365,7 +365,7 @@ pub(crate) mod tests { inner_instructions: None, durable_nonce_fee: Some(DurableNonceFee::from( &NonceFull::from_partial( - rollback_partial, + &rollback_partial, &SanitizedMessage::Legacy(LegacyMessage::new(message)), &[(pubkey, nonce_account)], &rent_debits, diff --git a/runtime/src/accounts/mod.rs b/runtime/src/accounts/mod.rs index 9c99143416..28b1be0228 100644 --- a/runtime/src/accounts/mod.rs +++ b/runtime/src/accounts/mod.rs @@ -49,7 +49,7 @@ pub(super) fn load_accounts( accounts_db: &AccountsDb, ancestors: &Ancestors, txs: &[SanitizedTransaction], - lock_results: Vec, + lock_results: &[TransactionCheckResult], hash_queue: &BlockhashQueue, error_counters: &mut TransactionErrorMetrics, rent_collector: &RentCollector, @@ -123,7 +123,7 @@ pub(super) fn load_accounts( (Ok(loaded_transaction), nonce) } - (_, (Err(e), _nonce)) => (Err(e), None), + (_, (Err(e), _nonce)) => (Err(e.clone()), None), }) .collect() } @@ -544,7 +544,7 @@ mod tests { &accounts.accounts_db, &ancestors, &[sanitized_tx], - vec![(Ok(()), None)], + &[(Ok(()), None)], &hash_queue, error_counters, rent_collector, @@ -1022,7 +1022,7 @@ mod tests { &accounts.accounts_db, &ancestors, &[tx], - vec![(Ok(()), None)], + &[(Ok(()), None)], &hash_queue, &mut error_counters, &rent_collector, diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 38de7ff18d..a032fbcf42 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -5179,7 +5179,7 @@ impl Bank { &self.rc.accounts.accounts_db, &self.ancestors, sanitized_txs, - check_results, + &check_results, &self.blockhash_queue.read().unwrap(), &mut error_counters, &self.rent_collector, diff --git a/runtime/src/bank/tests.rs b/runtime/src/bank/tests.rs index efe8b1970d..763b8c7db4 100644 --- a/runtime/src/bank/tests.rs +++ b/runtime/src/bank/tests.rs @@ -10989,7 +10989,7 @@ fn test_rent_state_list_len() { &bank.accounts().accounts_db, &bank.ancestors, &[sanitized_tx.clone()], - vec![(Ok(()), None)], + &[(Ok(()), None)], &bank.blockhash_queue.read().unwrap(), &mut error_counters, &bank.rent_collector,