solana_svm/
transaction_error_metrics.rs

1use solana_sdk::saturating_add_assign;
2
3#[derive(Debug, Default)]
4pub struct TransactionErrorMetrics {
5    pub total: usize,
6    pub account_in_use: usize,
7    pub too_many_account_locks: usize,
8    pub account_loaded_twice: usize,
9    pub account_not_found: usize,
10    pub blockhash_not_found: usize,
11    pub blockhash_too_old: usize,
12    pub call_chain_too_deep: usize,
13    pub already_processed: usize,
14    pub instruction_error: usize,
15    pub insufficient_funds: usize,
16    pub invalid_account_for_fee: usize,
17    pub invalid_account_index: usize,
18    pub invalid_program_for_execution: usize,
19    pub invalid_compute_budget: usize,
20    pub not_allowed_during_cluster_maintenance: usize,
21    pub invalid_writable_account: usize,
22    pub invalid_rent_paying_account: usize,
23    pub would_exceed_max_block_cost_limit: usize,
24    pub would_exceed_max_account_cost_limit: usize,
25    pub would_exceed_max_vote_cost_limit: usize,
26    pub would_exceed_account_data_block_limit: usize,
27    pub max_loaded_accounts_data_size_exceeded: usize,
28    pub program_execution_temporarily_restricted: usize,
29}
30
31impl TransactionErrorMetrics {
32    pub fn new() -> Self {
33        Self::default()
34    }
35
36    pub fn accumulate(&mut self, other: &TransactionErrorMetrics) {
37        saturating_add_assign!(self.total, other.total);
38        saturating_add_assign!(self.account_in_use, other.account_in_use);
39        saturating_add_assign!(self.too_many_account_locks, other.too_many_account_locks);
40        saturating_add_assign!(self.account_loaded_twice, other.account_loaded_twice);
41        saturating_add_assign!(self.account_not_found, other.account_not_found);
42        saturating_add_assign!(self.blockhash_not_found, other.blockhash_not_found);
43        saturating_add_assign!(self.blockhash_too_old, other.blockhash_too_old);
44        saturating_add_assign!(self.call_chain_too_deep, other.call_chain_too_deep);
45        saturating_add_assign!(self.already_processed, other.already_processed);
46        saturating_add_assign!(self.instruction_error, other.instruction_error);
47        saturating_add_assign!(self.insufficient_funds, other.insufficient_funds);
48        saturating_add_assign!(self.invalid_account_for_fee, other.invalid_account_for_fee);
49        saturating_add_assign!(self.invalid_account_index, other.invalid_account_index);
50        saturating_add_assign!(
51            self.invalid_program_for_execution,
52            other.invalid_program_for_execution
53        );
54        saturating_add_assign!(self.invalid_compute_budget, other.invalid_compute_budget);
55        saturating_add_assign!(
56            self.not_allowed_during_cluster_maintenance,
57            other.not_allowed_during_cluster_maintenance
58        );
59        saturating_add_assign!(
60            self.invalid_writable_account,
61            other.invalid_writable_account
62        );
63        saturating_add_assign!(
64            self.invalid_rent_paying_account,
65            other.invalid_rent_paying_account
66        );
67        saturating_add_assign!(
68            self.would_exceed_max_block_cost_limit,
69            other.would_exceed_max_block_cost_limit
70        );
71        saturating_add_assign!(
72            self.would_exceed_max_account_cost_limit,
73            other.would_exceed_max_account_cost_limit
74        );
75        saturating_add_assign!(
76            self.would_exceed_max_vote_cost_limit,
77            other.would_exceed_max_vote_cost_limit
78        );
79        saturating_add_assign!(
80            self.would_exceed_account_data_block_limit,
81            other.would_exceed_account_data_block_limit
82        );
83        saturating_add_assign!(
84            self.max_loaded_accounts_data_size_exceeded,
85            other.max_loaded_accounts_data_size_exceeded
86        );
87        saturating_add_assign!(
88            self.program_execution_temporarily_restricted,
89            other.program_execution_temporarily_restricted
90        );
91    }
92}