8000 Remove unnecessary unwrap from `simulate_transaction_unchecked()` by pgarg66 · Pull Request #35375 · solana-labs/solana · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Remove unnecessary unwrap from simulate_transaction_unchecked() #35375

Merged
merged 1 commit into from
Mar 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -4329,7 +4327,12 @@ impl Bank {

debug!("simulate 8000 _transaction: {:?}", timings);

let execution_result = execution_results.pop().unwrap();
let execution_result =
execution_results
.pop()
.unwrap_or(TransactionExecutionResult::NotExecuted(
TransactionError::InvalidProgramForExecution,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i guess this is about as generic a TransactionError as we have 🤔

prolly fine for now since this is isolated to simulation

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the other one we could use was AccountInUse. Nothing generic otherwise.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does TransactionExecutionResult::NotExecuted trigger a replay?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assuming by "replay" you mean that the tx is retryable, no. when a tx makes it to execute, it's getting fees taken and committed in a block. even if it were, this logic is in simulate, which won't be committed anyway

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant retryable yes. And I forgot that this is simulation and thus a failure is not repeated. So seems alright to me.

));
let flattened_result = execution_result.flattened_result();
let (logs, return_data, inner_instructions) = match execution_result {
TransactionExecutionResult::Executed { details, .. } => (
Expand Down
0