@@ -9,7 +9,7 @@ use alloy_primitives::{
99use crossbeam_channel:: { unbounded, Receiver as CrossbeamReceiver , Sender as CrossbeamSender } ;
1010use dashmap:: DashMap ;
1111use derive_more:: derive:: Deref ;
12- use metrics:: Histogram ;
12+ use metrics:: { Gauge , Histogram } ;
1313use reth_metrics:: Metrics ;
1414use reth_revm:: state:: EvmState ;
1515use reth_trie:: {
@@ -319,8 +319,6 @@ impl MultiproofInput {
319319/// `ProofSequencer`.
320320#[ derive( Debug ) ]
321321pub struct MultiproofManager {
322- /// Currently running calculations.
323- inflight : usize ,
324322 /// Handle to the proof worker pools (storage and account).
325323 proof_worker_handle : ProofWorkerHandle ,
326324 /// Cached storage proof roots for missed leaves; this maps
@@ -349,8 +347,11 @@ impl MultiproofManager {
349347 proof_worker_handle : ProofWorkerHandle ,
350348 proof_result_tx : CrossbeamSender < ProofResultMessage > ,
351349 ) -> Self {
350+ // Initialize the max worker gauges with the worker pool sizes
351+ metrics. max_storage_workers . set ( proof_worker_handle. total_storage_workers ( ) as f64 ) ;
352+ metrics. max_account_workers . set ( proof_worker_handle. total_account_workers ( ) as f64 ) ;
353+
352354 Self {
353- inflight : 0 ,
354355 metrics,
355356 proof_worker_handle,
356357 missed_leaves_storage_roots : Default :: default ( ) ,
@@ -359,7 +360,7 @@ impl MultiproofManager {
359360 }
360361
361362 /// Dispatches a new multiproof calculation to worker pools.
362- fn dispatch ( & mut self , input : PendingMultiproofTask ) {
363+ fn dispatch ( & self , input : PendingMultiproofTask ) {
363364 // If there are no proof targets, we can just send an empty multiproof back immediately
364365 if input. proof_targets_is_empty ( ) {
365366 debug ! (
@@ -381,7 +382,7 @@ impl MultiproofManager {
381382 }
382383
383384 /// Dispatches a single storage proof calculation to worker pool.
384- fn dispatch_storage_proof ( & mut self , storage_multiproof_input : StorageMultiproofInput ) {
385+ fn dispatch_storage_proof ( & self , storage_multiproof_input : StorageMultiproofInput ) {
385386 let StorageMultiproofInput {
386387 hashed_state_update,
387388 hashed_address,
@@ -432,8 +433,12 @@ impl MultiproofManager {
432433 return ;
433434 }
434435
435- self . inflight += 1 ;
436- self . metrics . inflight_multiproofs_histogram . record ( self . inflight as f64 ) ;
436+ self . metrics
437+ . active_storage_workers_histogram
438+ . record ( self . proof_worker_handle . active_storage_workers ( ) as f64 ) ;
439+ self . metrics
440+ . active_account_workers_histogram
441+ . record ( self . proof_worker_handle . active_account_workers ( ) as f64 ) ;
437442 self . metrics
438443 . pending_storage_multiproofs_histogram
439444 . record ( self . proof_worker_handle . pending_storage_tasks ( ) as f64 ) ;
@@ -443,9 +448,13 @@ impl MultiproofManager {
443448 }
444449
445450 /// Signals that a multiproof calculation has finished.
446- fn on_calculation_complete ( & mut self ) {
447- self . inflight = self . inflight . saturating_sub ( 1 ) ;
448- self . metrics . inflight_multiproofs_histogram . record ( self . inflight as f64 ) ;
451+ fn on_calculation_complete ( & self ) {
452+ self . metrics
453+ . active_storage_workers_histogram
454+ . record ( self . proof_worker_handle . active_storage_workers ( ) as f64 ) ;
455+ self . metrics
456+ . active_account_workers_histogram
457+ . record ( self . proof_worker_handle . active_account_workers ( ) as f64 ) ;
449458 self . metrics
450459 . pending_storage_multiproofs_histogram
451460 . record ( self . proof_worker_handle . pending_storage_tasks ( ) as f64 ) ;
@@ -455,7 +464,7 @@ impl MultiproofManager {
455464 }
456465
457466 /// Dispatches a single multiproof calculation to worker pool.
458- fn dispatch_multiproof ( & mut self , multiproof_input : MultiproofInput ) {
467+ fn dispatch_multiproof ( & self , multiproof_input : MultiproofInput ) {
459468 let MultiproofInput {
460469 source,
461470 hashed_state_update,
@@ -506,8 +515,12 @@ impl MultiproofManager {
506515 return ;
507516 }
508517
509- self . inflight += 1 ;
510- self . metrics . inflight_multiproofs_histogram . record ( self . inflight as f64 ) ;
518+ self . metrics
519+ . active_storage_workers_histogram
520+ . record ( self . proof_worker_handle . active_storage_workers ( ) as f64 ) ;
521+ self . metrics
522+ . active_account_workers_histogram
523+ . record ( self . proof_worker_handle . active_account_workers ( ) as f64 ) ;
511524 self . metrics
512525 . pending_storage_multiproofs_histogram
513526 . record ( self . proof_worker_handle . pending_storage_tasks ( ) as f64 ) ;
@@ -520,8 +533,14 @@ impl MultiproofManager {
520533#[ derive( Metrics , Clone ) ]
521534#[ metrics( scope = "tree.root" ) ]
522535pub ( crate ) struct MultiProofTaskMetrics {
523- /// Histogram of inflight multiproofs.
524- pub inflight_multiproofs_histogram : Histogram ,
536+ /// Histogram of active storage workers processing proofs.
537+ pub active_storage_workers_histogram : Histogram ,
538+ /// Histogram of active account workers processing proofs.
539+ pub active_account_workers_histogram : Histogram ,
540+ /// Gauge for the maximum number of storage workers in the pool.
541+ pub max_storage_workers : Gauge ,
542+ /// Gauge for the maximum number of account workers in the pool.
543+ pub max_account_workers : Gauge ,
525544 /// Histogram of pending storage multiproofs in the queue.
526545 pub pending_storage_multiproofs_histogram : Histogram ,
527546 /// Histogram of pending account multiproofs in the queue.
@@ -583,7 +602,6 @@ pub(crate) struct MultiProofTaskMetrics {
583602/// ▼ │
584603/// ┌──────────────────────────────────────────────────────────────┐ │
585604/// │ MultiproofManager │ │
586- /// │ - Tracks inflight calculations │ │
587605/// │ - Deduplicates against fetched_proof_targets │ │
588606/// │ - Routes to appropriate worker pool │ │
589607/// └──┬───────────────────────────────────────────────────────────┘ │
@@ -624,7 +642,6 @@ pub(crate) struct MultiProofTaskMetrics {
624642///
625643/// - **[`MultiproofManager`]**: Calculation orchestrator
626644/// - Decides between fast path ([`EmptyProof`]) and worker dispatch
627- /// - Tracks inflight calculations
628645/// - Routes storage-only vs full multiproofs to appropriate workers
629646/// - Records metrics for monitoring
630647///
0 commit comments