Skip to content

Commit 2dd8590

Browse files
authored
Merge pull request #1744 from o1-labs/dw/node-crate-2
Node: add documentation of stats sub directory
2 parents 25e9e7c + 6f69e05 commit 2dd8590

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

node/src/stats/mod.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,44 @@
1+
//! # Statistics Module
2+
//!
3+
//! This module collects and manages runtime statistics for the node. It tracks
4+
//! three main categories of statistics that can be queried via RPC endpoints.
5+
//!
6+
//! ## Components
7+
//!
8+
//! | Sub-module | Purpose |
9+
//! |-------------------|------------------------------------------------------|
10+
//! | [`actions`] | Tracks action dispatch frequency and timing |
11+
//! | [`sync`] | Tracks blockchain synchronization progress |
12+
//! | [`block_producer`]| Tracks block production attempts and outcomes |
13+
//!
14+
//! ## Architecture
15+
//!
16+
//! The [`Stats`] struct is held by the [`Service`](crate::Service) trait
17+
//! implementation and is accessed via `store.service.stats()` in effects.
18+
//! Statistics are updated during effect execution, not in reducers, since
19+
//! they are side-effects that don't affect the core state machine.
20+
//!
21+
//! ## Usage
22+
//!
23+
//! Statistics are collected in effects throughout the codebase:
24+
//!
25+
//! - **Action stats**: Updated in [`effects()`](crate::effects()) for every
26+
//! dispatched action
27+
//! - **Sync stats**: Updated in [`transition_frontier`](crate::transition_frontier)
28+
//! effects during synchronization
29+
//! - **Block producer stats**: Updated in
30+
//! [`block_producer_effectful`](crate::block_producer_effectful) during block
31+
//! production
32+
//!
33+
//! ## RPC Endpoints
34+
//!
35+
//! Statistics are exposed via RPC for monitoring and debugging. These endpoints
36+
//! are consumed by the frontend dashboard to display node health and performance:
37+
//!
38+
//! - `ActionStatsGet` - Returns action dispatch statistics
39+
//! - `SyncStatsGet` - Returns synchronization statistics
40+
//! - `BlockProducerStatsGet` - Returns block production statistics
41+
142
mod stats_actions;
243
pub mod actions {
344
pub use super::stats_actions::*;

0 commit comments

Comments
 (0)