Skip to main content

reth_chain_state/
execution_stats.rs

1//! Execution timing statistics for detailed block logging.
2//!
3//! This module provides types for collecting and passing execution timing statistics
4//! through the block processing pipeline, enabling unified detailed block logging after
5//! database commit.
6
7use std::time::Duration;
8
9use alloy_primitives::B256;
10
11/// Statistics collected during block execution for cross-client performance analysis.
12///
13/// These statistics are populated during block validation and carried through to
14/// persistence, where they are used to emit a single unified log entry that includes
15/// complete timing information (including commit time).
16#[derive(Debug, Clone, Default)]
17pub struct ExecutionTimingStats {
18    /// Block number
19    pub block_number: u64,
20    /// Block hash
21    pub block_hash: B256,
22    /// Total gas used by the block
23    pub gas_used: u64,
24    /// Number of transactions in the block
25    pub tx_count: usize,
26    /// Time spent executing transactions (includes state reads)
27    pub execution_duration: Duration,
28    /// Time spent fetching state during execution (subset of `execution_duration`, includes cache
29    /// hits)
30    pub state_read_duration: Duration,
31    /// Time spent computing state root hash
32    pub state_hash_duration: Duration,
33    /// Number of accounts read during execution
34    pub accounts_read: usize,
35    /// Number of storage slots read (SLOAD operations)
36    pub storage_read: usize,
37    /// Number of code reads (EXTCODE* operations)
38    pub code_read: usize,
39    /// Total bytes of code read
40    pub code_bytes_read: usize,
41    /// Number of accounts changed (balance/nonce updates)
42    pub accounts_changed: usize,
43    /// Number of accounts deleted (SELFDESTRUCT)
44    pub accounts_deleted: usize,
45    /// Number of storage slots changed (SSTORE operations)
46    pub storage_slots_changed: usize,
47    /// Number of storage slots deleted (set to zero)
48    pub storage_slots_deleted: usize,
49    /// Number of bytecodes created/changed (contract deployments)
50    pub bytecodes_changed: usize,
51    /// Total bytes of code written
52    pub code_bytes_written: usize,
53    /// Number of EIP-7702 delegations set
54    pub eip7702_delegations_set: usize,
55    /// Number of EIP-7702 delegations cleared
56    pub eip7702_delegations_cleared: usize,
57    /// Account cache hits
58    pub account_cache_hits: usize,
59    /// Account cache misses
60    pub account_cache_misses: usize,
61    /// Storage cache hits
62    pub storage_cache_hits: usize,
63    /// Storage cache misses
64    pub storage_cache_misses: usize,
65    /// Code cache hits
66    pub code_cache_hits: usize,
67    /// Code cache misses
68    pub code_cache_misses: usize,
69}