@@ -89,6 +89,10 @@ pub struct Finalizer<
8989 cancellation_token : CancellationToken ,
9090 _signer_marker : PhantomData < S > ,
9191 _variant_marker : PhantomData < V > ,
92+ #[ cfg( debug_assertions) ]
93+ height_gauge : Gauge ,
94+ #[ cfg( debug_assertions) ]
95+ consensus_state_stored_gauge : Gauge ,
9296}
9397
9498impl <
@@ -143,6 +147,24 @@ impl<
143147 cfg. initial_state
144148 } ;
145149
150+ // Register debug gauges before moving context into ContextCell
151+ #[ cfg( debug_assertions) ]
152+ let height_gauge = {
153+ let gauge: Gauge = Gauge :: default ( ) ;
154+ context. register ( "height" , "chain height" , gauge. clone ( ) ) ;
155+ gauge
156+ } ;
157+ #[ cfg( debug_assertions) ]
158+ let consensus_state_stored_gauge = {
159+ let gauge: Gauge = Gauge :: default ( ) ;
160+ context. register (
161+ "consensus_state_stored" ,
162+ "consensus state stored" ,
163+ gauge. clone ( ) ,
164+ ) ;
165+ gauge
166+ } ;
167+
146168 (
147169 Self {
148170 context : ContextCell :: new ( context) ,
@@ -166,6 +188,10 @@ impl<
166188 cancellation_token : cfg. cancellation_token ,
167189 _signer_marker : PhantomData ,
168190 _variant_marker : PhantomData ,
191+ #[ cfg( debug_assertions) ]
192+ height_gauge,
193+ #[ cfg( debug_assertions) ]
194+ consensus_state_stored_gauge,
169195 } ,
170196 state,
171197 FinalizerMailbox :: new ( tx) ,
@@ -353,6 +379,9 @@ impl<
353379 . await ;
354380 }
355381
382+ #[ cfg( debug_assertions) ]
383+ self . height_gauge . set ( height as i64 ) ;
384+
356385 self . canonical_state . forkchoice . safe_block_hash =
357386 self . canonical_state . forkchoice . head_block_hash ;
358387 self . canonical_state . forkchoice . finalized_block_hash =
@@ -510,6 +539,8 @@ impl<
510539 histogram ! ( "finalizer_db_consensus_state_write_micros" )
511540 . record ( consensus_state_duration) ;
512541 }
542+ #[ cfg( debug_assertions) ]
543+ self . consensus_state_stored_gauge . set ( new_height as i64 ) ;
513544
514545 // This will commit all changes to the state db
515546 #[ cfg( feature = "prom" ) ]
@@ -559,14 +590,6 @@ impl<
559590 } ) )
560591 . await ;
561592 epoch_change = true ;
562-
563- #[ cfg( debug_assertions) ]
564- {
565- let gauge: Gauge = Gauge :: default ( ) ;
566- gauge. set ( new_height as i64 ) ;
567- self . context
568- . register ( "consensus_state_stored" , "chain height" , gauge) ;
569- }
570593 }
571594
572595 if epoch_change {
@@ -1134,12 +1157,6 @@ async fn execute_block<
11341157 ) ;
11351158 }
11361159
1137- #[ cfg( debug_assertions) ]
1138- {
1139- let gauge: Gauge = Gauge :: default ( ) ;
1140- gauge. set ( new_height as i64 ) ;
1141- context. register ( "height" , "chain height" , gauge) ;
1142- }
11431160 state. set_latest_height ( new_height) ;
11441161 state. set_view ( block. view ( ) ) ;
11451162 state. head_digest = block. digest ( ) ;
0 commit comments