From dd9d6e308c52190c24584e204897a9d5296da543 Mon Sep 17 00:00:00 2001 From: steviez Date: Mon, 13 Feb 2023 13:51:34 -0600 Subject: [PATCH] Fix transactions counts stored by SamplePerformanceService (#30280) A recent change to this service to store the number of non-vote transactions introduced a bug in the computation of the number of transactions during the time interval. This resulted in bogus values being stored in Blockstore and eventually getting served through RPC for the TPS chart on explorer. --- core/src/sample_performance_service.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/core/src/sample_performance_service.rs b/core/src/sample_performance_service.rs index 8357a62dbf..a82b433450 100644 --- a/core/src/sample_performance_service.rs +++ b/core/src/sample_performance_service.rs @@ -56,6 +56,9 @@ impl SamplePerformanceService { (forks.root_bank(), forks.highest_slot()) }; + // Store the absolute transaction counts to that we can compute the + // difference between these values at points in time to figure out + // how many transactions occurred in that timespan. let mut snapshot = SamplePerformanceSnapshot { num_transactions: bank.transaction_count(), num_non_vote_transactions: bank.non_vote_transaction_count_since_restart(), @@ -96,9 +99,11 @@ impl SamplePerformanceService { error!("write_perf_sample failed: slot {:?} {:?}", highest_slot, e); } + // Same as above, store the absolute transaction counts to use + // as comparison for the next iteration of this loop. snapshot = SamplePerformanceSnapshot { - num_transactions, - num_non_vote_transactions, + num_transactions: bank.transaction_count(), + num_non_vote_transactions: bank.non_vote_transaction_count_since_restart(), highest_slot, }; }