From 1c4539fd2698e4797281f100da9a698a0f8e72f1 Mon Sep 17 00:00:00 2001 From: godmodegalactus Date: Tue, 2 Jan 2024 16:16:55 +0100 Subject: [PATCH 1/2] Solana program deployment failed because blockhash was expired during simulation, So we ignore these types of errors as we are going to retry with new blockhash anyways --- ...nd_and_confirm_transactions_in_parallel.rs | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/client/src/send_and_confirm_transactions_in_parallel.rs b/client/src/send_and_confirm_transactions_in_parallel.rs index 70f79eba192389..c5824f36011527 100644 --- a/client/src/send_and_confirm_transactions_in_parallel.rs +++ b/client/src/send_and_confirm_transactions_in_parallel.rs @@ -181,6 +181,21 @@ fn progress_from_context_and_block_height( } } +fn add_transaction_error_in_context( + context: &SendingContext, + transaction_error: &TransactionError, + index: usize, +) { + match transaction_error { + TransactionError::BlockhashNotFound => { + // fall through so that we will resend with another blockhash + } + _ => { + context.error_map.insert(index, transaction_error.clone()); + } + } +} + async fn send_transaction_with_rpc_fallback( rpc_client: &RpcClient, tpu_client: &Option, @@ -205,8 +220,7 @@ async fn send_transaction_with_rpc_fallback( // fall through on io error, we will retry the transaction } ErrorKind::TransactionError(transaction_error) => { - context.error_map.insert(index, transaction_error.clone()); - return Ok(()); + add_transaction_error_in_context(context, transaction_error, index); } ErrorKind::RpcError(RpcError::RpcResponseError { data: @@ -218,8 +232,7 @@ async fn send_transaction_with_rpc_fallback( ), .. }) => { - context.error_map.insert(index, transaction_error.clone()); - return Ok(()); + add_transaction_error_in_context(context, transaction_error, index); } _ => { return Err(TpuSenderError::from(e)); From e75cf47a5051dfe547600617e28fe8ac25ac552f Mon Sep 17 00:00:00 2001 From: godmodegalactus Date: Fri, 5 Jan 2024 09:36:43 +0100 Subject: [PATCH 2/2] Creating a single pattern matching after jon's review --- ...nd_and_confirm_transactions_in_parallel.rs | 35 +++++++++---------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/client/src/send_and_confirm_transactions_in_parallel.rs b/client/src/send_and_confirm_transactions_in_parallel.rs index 5a2a9285ef5557..f97761cba14fde 100644 --- a/client/src/send_and_confirm_transactions_in_parallel.rs +++ b/client/src/send_and_confirm_transactions_in_parallel.rs @@ -181,21 +181,6 @@ fn progress_from_context_and_block_height( } } -fn add_transaction_error_in_context( - context: &SendingContext, - transaction_error: &TransactionError, - index: usize, -) { - match transaction_error { - TransactionError::BlockhashNotFound => { - // fall through so that we will resend with another blockhash - } - _ => { - context.error_map.insert(index, transaction_error.clone()); - } - } -} - async fn send_transaction_with_rpc_fallback( rpc_client: &RpcClient, tpu_client: &Option, @@ -219,10 +204,21 @@ async fn send_transaction_with_rpc_fallback( ErrorKind::Io(_) | ErrorKind::Reqwest(_) => { // fall through on io error, we will retry the transaction } - ErrorKind::TransactionError(transaction_error) => { - add_transaction_error_in_context(context, transaction_error, index); + ErrorKind::TransactionError(TransactionError::BlockhashNotFound) + | ErrorKind::RpcError(RpcError::RpcResponseError { + data: + RpcResponseErrorData::SendTransactionPreflightFailure( + RpcSimulateTransactionResult { + err: Some(TransactionError::BlockhashNotFound), + .. + }, + ), + .. + }) => { + // fall through so that we will resend with another blockhash } - ErrorKind::RpcError(RpcError::RpcResponseError { + ErrorKind::TransactionError(transaction_error) + | ErrorKind::RpcError(RpcError::RpcResponseError { data: RpcResponseErrorData::SendTransactionPreflightFailure( RpcSimulateTransactionResult { @@ -232,7 +228,8 @@ async fn send_transaction_with_rpc_fallback( ), .. }) => { - add_transaction_error_in_context(context, transaction_error, index); + // if we get other than blockhash not found error the transaction is invalid + context.error_map.insert(index, transaction_error.clone()); } _ => { return Err(TpuSenderError::from(e));