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.
This commit is contained in:
steviez 2023-02-13 13:51:34 -06:00 committed by GitHub
parent 2271a3920b
commit dd9d6e308c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 2 deletions

View File

@ -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,
};
}