From 542b784041a82a68f038b90272b98cd5fa60e25d Mon Sep 17 00:00:00 2001 From: Justin Starry Date: Sun, 5 May 2024 02:44:36 +0000 Subject: [PATCH] RPC: fix numNonVoteTransactions in getPerformanceSamples --- runtime/src/bank.rs | 16 +++++++++------- runtime/src/bank/tests.rs | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index e4d708c12cd1df..ca17924a21ab16 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -686,12 +686,13 @@ pub struct Bank { /// slots to hard fork at hard_forks: Arc>, - /// The number of transactions processed without error + /// The number of committed transactions since genesis. transaction_count: AtomicU64, - /// The number of non-vote transactions processed without error since the most recent boot from - /// snapshot or genesis. This value is not shared though the network, nor retained within - /// snapshots, but is preserved in `Bank::new_from_parent`. + /// The number of non-vote transactions committed since the most + /// recent boot from snapshot or genesis. This value is only stored in + /// blockstore for the RPC method "getPerformanceSamples". It is not + /// retained within snapshots, but is preserved in `Bank::new_from_parent`. non_vote_transaction_count_since_restart: AtomicU64, /// The number of transaction errors in this slot @@ -3815,13 +3816,14 @@ impl Bank { // replay could occur signature_count += u64::from(tx.message().header().num_required_signatures); executed_transactions_count += 1; + + if !is_vote { + executed_non_vote_transactions_count += 1; + } } match execution_result.flattened_result() { Ok(()) => { - if !is_vote { - executed_non_vote_transactions_count += 1; - } executed_with_successful_result_count += 1; } Err(err) => { diff --git a/runtime/src/bank/tests.rs b/runtime/src/bank/tests.rs index ac7c44eb9ec039..3269b99782a17a 100644 --- a/runtime/src/bank/tests.rs +++ b/runtime/src/bank/tests.rs @@ -2376,7 +2376,7 @@ fn test_insufficient_funds() { // transaction_count returns the count of all committed transactions since // bank_transaction_count_fix was activated, regardless of success assert_eq!(bank.transaction_count(), 2); - assert_eq!(bank.non_vote_transaction_count_since_restart(), 1); + assert_eq!(bank.non_vote_transaction_count_since_restart(), 2); let mint_pubkey = mint_keypair.pubkey(); assert_eq!(bank.get_balance(&mint_pubkey), mint_amount - amount);