From b94019ad14b6d87b151faba0fc6d9e9cd01a042a Mon Sep 17 00:00:00 2001 From: Justin Starry Date: Fri, 9 Aug 2024 00:48:08 +0000 Subject: [PATCH] more fixes --- svm/examples/paytube/src/settler.rs | 9 ++++++--- svm/src/transaction_processing_result.rs | 8 ++++++++ svm/src/transaction_processor.rs | 5 +++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/svm/examples/paytube/src/settler.rs b/svm/examples/paytube/src/settler.rs index 5db63c4e675809..8923512ecd6915 100644 --- a/svm/examples/paytube/src/settler.rs +++ b/svm/examples/paytube/src/settler.rs @@ -18,7 +18,10 @@ use { pubkey::Pubkey, signature::Keypair, signer::Signer, system_instruction, transaction::Transaction as SolanaTransaction, }, - solana_svm::transaction_processor::LoadAndExecuteSanitizedTransactionsOutput, + solana_svm::{ + transaction_processing_result::TransactionProcessingResultExtensions, + transaction_processor::LoadAndExecuteSanitizedTransactionsOutput, + }, spl_associated_token_account::get_associated_token_address, std::collections::HashMap, }; @@ -61,11 +64,11 @@ impl Ledger { let mut ledger: HashMap = HashMap::new(); paytube_transactions .iter() - .zip(svm_output.execution_results) + .zip(svm_output.processing_results) .for_each(|(transaction, result)| { // Only append to the ledger if the PayTube transaction was // successful. - if result.was_executed_successfully() { + if result.was_processed_with_successful_result() { let mint = transaction.mint; let mut keys = [transaction.from, transaction.to]; keys.sort(); diff --git a/svm/src/transaction_processing_result.rs b/svm/src/transaction_processing_result.rs index c5e2fc5ea50b17..0ad68e0d18a803 100644 --- a/svm/src/transaction_processing_result.rs +++ b/svm/src/transaction_processing_result.rs @@ -8,6 +8,7 @@ pub type ProcessedTransaction = ExecutedTransaction; pub trait TransactionProcessingResultExtensions { fn was_processed(&self) -> bool; + fn was_processed_with_successful_result(&self) -> bool; fn processed_transaction(&self) -> Option<&ProcessedTransaction>; fn processed_transaction_mut(&mut self) -> Option<&mut ProcessedTransaction>; fn flattened_result(&self) -> TransactionResult<()>; @@ -18,6 +19,13 @@ impl TransactionProcessingResultExtensions for TransactionProcessingResult { self.is_ok() } + fn was_processed_with_successful_result(&self) -> bool { + match self { + Ok(processed_tx) => processed_tx.was_successful(), + Err(_) => false, + } + } + fn processed_transaction(&self) -> Option<&ProcessedTransaction> { match self { Ok(processed_tx) => Some(processed_tx), diff --git a/svm/src/transaction_processor.rs b/svm/src/transaction_processor.rs index 0396dc98216abc..3639882b290157 100644 --- a/svm/src/transaction_processor.rs +++ b/svm/src/transaction_processor.rs @@ -68,8 +68,9 @@ pub struct LoadAndExecuteSanitizedTransactionsOutput { pub error_metrics: TransactionErrorMetrics, /// Timings for transaction batch execution. pub execute_timings: ExecuteTimings, - // Vector of results indicating whether a transaction was executed or could not - // be executed. Note executed transactions can still have failed! + /// Vector of results indicating whether a transaction was processed or + /// could not be processed. Note processed transactions can still have a + /// failure result meaning that the transaction will be rolled back. pub processing_results: Vec, }