From b4ab25cdb4435d75481411d2e748714d037b13c7 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Sat, 2 Mar 2024 20:29:42 -0600 Subject: [PATCH] v1.17: Remove unnecessary unwrap from `simulate_transaction_unchecked()` (backport of #35375) Remove unnecessary unwrap from `simulate_transaction_unchecked()` (#35375) Remove unnecessary unwrap from simulate_transaction_unchecked() (cherry picked from commit cb260f10d1b05743391b9b442bf175c19d894931) Co-authored-by: Pankaj Garg --- 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 4f2260f72ea17c..9a3c25b4b8ee85 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -4384,9 +4384,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 @@ -4406,7 +4404,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) = match execution_result { TransactionExecutionResult::Executed { details, .. } => {