From 653083806f7c9648153a6a060e715a2478c300ff Mon Sep 17 00:00:00 2001 From: Tao Zhu <82401714+taozhu-chicago@users.noreply.github.com> Date: Thu, 23 Mar 2023 16:33:02 -0500 Subject: [PATCH] only executed transactions are used to update prioritization_fee_cache (#30868) * only executed transactions are used to update prioritization_fee_cache * Update ledger/src/blockstore_processor.rs Co-authored-by: Andrew Fitzgerald --- ledger/src/blockstore_processor.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/ledger/src/blockstore_processor.rs b/ledger/src/blockstore_processor.rs index e5be66cedc..dd7af654d6 100644 --- a/ledger/src/blockstore_processor.rs +++ b/ledger/src/blockstore_processor.rs @@ -132,6 +132,7 @@ fn execute_batch( replay_vote_sender: Option<&ReplayVoteSender>, timings: &mut ExecuteTimings, log_messages_bytes_limit: Option, + prioritization_fee_cache: &PrioritizationFeeCache, ) -> Result<()> { let TransactionBatchWithIndexes { batch, @@ -171,6 +172,12 @@ fn execute_batch( .. } = tx_results; + let executed_transactions = execution_results + .iter() + .zip(batch.sanitized_transactions()) + .filter_map(|(execution_result, tx)| execution_result.was_executed().then_some(tx)) + .collect_vec(); + if let Some(transaction_status_sender) = transaction_status_sender { let transactions = batch.sanitized_transactions().to_vec(); let post_token_balances = if record_token_balances { @@ -193,6 +200,8 @@ fn execute_batch( ); } + prioritization_fee_cache.update(bank.clone(), executed_transactions.into_iter()); + let first_err = get_first_error(batch, fee_collection_results); first_err.map(|(result, _)| result).unwrap_or(Ok(())) } @@ -210,6 +219,7 @@ fn execute_batches_internal( transaction_status_sender: Option<&TransactionStatusSender>, replay_vote_sender: Option<&ReplayVoteSender>, log_messages_bytes_limit: Option, + prioritization_fee_cache: &PrioritizationFeeCache, ) -> Result { assert!(!batches.is_empty()); inc_new_counter_debug!("bank-par_execute_entries-count", batches.len()); @@ -233,6 +243,7 @@ fn execute_batches_internal( replay_vote_sender, &mut timings, log_messages_bytes_limit, + prioritization_fee_cache, ) }, "execute_batch", @@ -302,6 +313,7 @@ fn execute_batches( replay_vote_sender: Option<&ReplayVoteSender>, confirmation_timing: &mut ConfirmationTiming, log_messages_bytes_limit: Option, + prioritization_fee_cache: &PrioritizationFeeCache, ) -> Result<()> { if batches.is_empty() { return Ok(()); @@ -383,6 +395,7 @@ fn execute_batches( transaction_status_sender, replay_vote_sender, log_messages_bytes_limit, + prioritization_fee_cache, )?; confirmation_timing.process_execute_batches_internal_metrics(execute_batches_internal_metrics); @@ -479,6 +492,7 @@ fn process_entries( replay_vote_sender, confirmation_timing, log_messages_bytes_limit, + prioritization_fee_cache, )?; batches.clear(); for hash in &tick_hashes { @@ -512,9 +526,6 @@ fn process_entries( batch, transaction_indexes, }); - // entry is scheduled to be processed, transactions in it can be used to - // update prioritization fee cache asynchronously. - prioritization_fee_cache.update(bank.clone(), transactions.iter()); // done with this entry break; } @@ -544,6 +555,7 @@ fn process_entries( replay_vote_sender, confirmation_timing, log_messages_bytes_limit, + prioritization_fee_cache, )?; batches.clear(); } @@ -558,6 +570,7 @@ fn process_entries( replay_vote_sender, confirmation_timing, log_messages_bytes_limit, + prioritization_fee_cache, )?; for hash in tick_hashes { bank.register_tick(hash);