@@ -128,8 +128,7 @@ impl ValidatorSubmitter {
128128 . await ;
129129
130130 self . metrics
131- . latest_checkpoint_observed
132- . set ( latest_checkpoint. index as i64 ) ;
131+ . set_latest_checkpoint_observed ( & latest_checkpoint) ;
133132
134133 if should_log_checkpoint_info ( ) {
135134 info ! (
@@ -476,6 +475,7 @@ fn tree_exceeds_checkpoint(checkpoint: &Checkpoint, tree: &IncrementalMerkle) ->
476475
477476#[ derive( Clone ) ]
478477pub ( crate ) struct ValidatorSubmitterMetrics {
478+ latest_checkpoint_observed_block_height : IntGauge ,
479479 latest_checkpoint_observed : IntGauge ,
480480 latest_checkpoint_processed : IntGauge ,
481481 backfill_complete : IntGauge ,
@@ -486,6 +486,9 @@ impl ValidatorSubmitterMetrics {
486486 pub fn new ( metrics : & CoreMetrics , mailbox_chain : & HyperlaneDomain ) -> Self {
487487 let chain_name = mailbox_chain. name ( ) ;
488488 Self {
489+ latest_checkpoint_observed_block_height : metrics
490+ . latest_checkpoint ( )
491+ . with_label_values ( & [ "validator_observed_block_height" , chain_name] ) ,
489492 latest_checkpoint_observed : metrics
490493 . latest_checkpoint ( )
491494 . with_label_values ( & [ "validator_observed" , chain_name] ) ,
@@ -498,6 +501,31 @@ impl ValidatorSubmitterMetrics {
498501 . with_label_values ( & [ chain_name] ) ,
499502 }
500503 }
504+
505+ fn set_latest_checkpoint_observed ( & self , checkpoint : & CheckpointAtBlock ) {
506+ let prev_checkpoint_index = self . latest_checkpoint_observed . get ( ) ;
507+
508+ if prev_checkpoint_index > checkpoint. index as i64 {
509+ tracing:: warn!(
510+ ?checkpoint,
511+ prev_checkpoint_index,
512+ checkpoint_index=checkpoint. index, "Observed a checkpoint with index that is lower than previous checkpoint. Did a reorg occur?" ) ;
513+ }
514+ self . latest_checkpoint_observed . set ( checkpoint. index as i64 ) ;
515+
516+ if let Some ( block_height) = checkpoint. block_height {
517+ let block_height = block_height as i64 ;
518+ let prev_block_height = self . latest_checkpoint_observed_block_height . get ( ) ;
519+ if prev_block_height > block_height {
520+ tracing:: warn!(
521+ ?checkpoint,
522+ prev_block_height,
523+ block_height, "Observed a checkpoint with block height that is lower than previous checkpoint. Did a reorg occur?" ) ;
524+ }
525+ self . latest_checkpoint_observed_block_height
526+ . set ( block_height) ;
527+ }
528+ }
501529}
502530
503531#[ cfg( test) ]
0 commit comments