@@ -36,7 +36,9 @@ use tokio::sync::{mpsc, oneshot, OwnedRwLockReadGuard};
3636use tracing:: { error, instrument, trace, warn} ;
3737
3838use crate :: {
39- chain_worker:: { ChainWorkerActor , ChainWorkerConfig , ChainWorkerRequest , DeliveryNotifier } ,
39+ chain_worker:: {
40+ BlockOutcome , ChainWorkerActor , ChainWorkerConfig , ChainWorkerRequest , DeliveryNotifier ,
41+ } ,
4042 data_types:: { ChainInfoQuery , ChainInfoResponse , CrossChainRequest } ,
4143 join_set_ext:: { JoinSet , JoinSetExt } ,
4244 notifier:: Notifier ,
@@ -600,7 +602,7 @@ where
600602 & self ,
601603 certificate : ConfirmedBlockCertificate ,
602604 notify_when_messages_are_delivered : Option < oneshot:: Sender < ( ) > > ,
603- ) -> Result < ( ChainInfoResponse , NetworkActions ) , WorkerError > {
605+ ) -> Result < ( ChainInfoResponse , NetworkActions , BlockOutcome ) , WorkerError > {
604606 let chain_id = certificate. block ( ) . header . chain_id ;
605607 self . query_chain_worker ( chain_id, move |callback| {
606608 ChainWorkerRequest :: ProcessConfirmedBlock {
@@ -621,7 +623,7 @@ where
621623 async fn process_validated_block (
622624 & self ,
623625 certificate : ValidatedBlockCertificate ,
624- ) -> Result < ( ChainInfoResponse , NetworkActions , bool ) , WorkerError > {
626+ ) -> Result < ( ChainInfoResponse , NetworkActions , BlockOutcome ) , WorkerError > {
625627 let chain_id = certificate. block ( ) . header . chain_id ;
626628 self . query_chain_worker ( chain_id, move |callback| {
627629 ChainWorkerRequest :: ProcessValidatedBlock {
@@ -876,37 +878,25 @@ where
876878 ) -> Result < ( ChainInfoResponse , NetworkActions ) , WorkerError > {
877879 trace ! ( "{} <-- {:?}" , self . nickname, certificate) ;
878880 #[ cfg( with_metrics) ]
879- let metrics_data = if self
880- . chain_state_view ( certificate. block ( ) . header . chain_id )
881- . await ?
882- . tip_state
883- . get ( )
884- . next_block_height
885- == certificate. block ( ) . header . height
886- {
887- Some ( (
888- certificate. inner ( ) . to_log_str ( ) ,
889- certificate. round . type_name ( ) ,
890- certificate. round . number ( ) ,
891- certificate. block ( ) . body . transactions . len ( ) as u64 ,
892- certificate
893- . signatures ( )
894- . iter ( )
895- . map ( |( validator_name, _) | validator_name. to_string ( ) )
896- . collect :: < Vec < _ > > ( ) ,
897- ) )
898- } else {
899- // Block already processed or will only be preprocessed, no metrics to report.
900- None
901- } ;
881+ let metrics_data = (
882+ certificate. inner ( ) . to_log_str ( ) ,
883+ certificate. round . type_name ( ) ,
884+ certificate. round . number ( ) ,
885+ certificate. block ( ) . body . transactions . len ( ) as u64 ,
886+ certificate
887+ . signatures ( )
888+ . iter ( )
889+ . map ( |( validator_name, _) | validator_name. to_string ( ) )
890+ . collect :: < Vec < _ > > ( ) ,
891+ ) ;
902892
903- let result = self
893+ let ( info , actions , _outcome ) = self
904894 . process_confirmed_block ( certificate, notify_when_messages_are_delivered)
905895 . await ?;
906896
907897 #[ cfg( with_metrics) ]
908898 {
909- if let Some ( metrics_data ) = metrics_data {
899+ if matches ! ( _outcome , BlockOutcome :: Processed ) {
910900 let (
911901 certificate_log_str,
912902 round_type,
@@ -931,7 +921,7 @@ where
931921 }
932922 }
933923 }
934- Ok ( result )
924+ Ok ( ( info , actions ) )
935925 }
936926
937927 /// Processes a validated block certificate.
@@ -951,10 +941,10 @@ where
951941 #[ cfg( with_metrics) ]
952942 let cert_str = certificate. inner ( ) . to_log_str ( ) ;
953943
954- let ( info, actions, _duplicated ) = self . process_validated_block ( certificate) . await ?;
944+ let ( info, actions, _outcome ) = self . process_validated_block ( certificate) . await ?;
955945 #[ cfg( with_metrics) ]
956946 {
957- if !_duplicated {
947+ if matches ! ( _outcome , BlockOutcome :: Processed ) {
958948 metrics:: NUM_ROUNDS_IN_CERTIFICATE
959949 . with_label_values ( & [ cert_str, round. type_name ( ) ] )
960950 . observe ( round. number ( ) as f64 ) ;
0 commit comments