From 7a1c830b6665c383db899d719b3179aaf9c387b8 Mon Sep 17 00:00:00 2001 From: Pankaj Garg Date: Thu, 29 Feb 2024 08:32:43 -0800 Subject: [PATCH] Remove unnecessary unwrap from simulate_transaction_unchecked() --- runtime/src/bank.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index d72e3771cb4408..0ba4b91e5c235b 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -4305,9 +4305,7 @@ impl Bank { let post_simulation_accounts = loaded_transactions .into_iter() .next() - .unwrap() - .0 - .ok() + .and_then(|(loaded_transactions_res, _)| loaded_transactions_res.ok()) .map(|loaded_transaction| { loaded_transaction .accounts @@ -4329,7 +4327,12 @@ impl Bank { debug!("simulate_transaction: {:?}", timings); - let execution_result = execution_results.pop().unwrap(); + let execution_result = + execution_results + .pop() + .unwrap_or(TransactionExecutionResult::NotExecuted( + TransactionError::InvalidProgramForExecution, + )); let flattened_result = execution_result.flattened_result(); let (logs, return_data, inner_instructions) = match execution_result { TransactionExecutionResult::Executed { details, .. } => (