@@ -47,6 +47,7 @@ use fork_choice::{
47
47
ResetPayloadStatuses ,
48
48
} ;
49
49
use itertools:: process_results;
50
+ use lighthouse_tracing:: SPAN_RECOMPUTE_HEAD ;
50
51
use logging:: crit;
51
52
use parking_lot:: { Mutex , RwLock , RwLockReadGuard , RwLockUpgradableReadGuard , RwLockWriteGuard } ;
52
53
use slot_clock:: SlotClock ;
@@ -57,6 +58,7 @@ use store::{
57
58
Error as StoreError , KeyValueStore , KeyValueStoreOp , StoreConfig , iter:: StateRootsIterator ,
58
59
} ;
59
60
use task_executor:: { JoinHandle , ShutdownReason } ;
61
+ use tracing:: info_span;
60
62
use tracing:: { debug, error, info, instrument, warn} ;
61
63
use types:: * ;
62
64
@@ -383,6 +385,7 @@ impl<T: BeaconChainTypes> CanonicalHead<T> {
383
385
///
384
386
/// This function is **not safe** to be public. See the module-level documentation for more
385
387
/// information about protecting from deadlocks.
388
+ #[ instrument( skip_all) ]
386
389
fn cached_head_write_lock ( & self ) -> RwLockWriteGuard < ' _ , CachedHead < T :: EthSpec > > {
387
390
self . cached_head . write ( )
388
391
}
@@ -402,6 +405,7 @@ impl<T: BeaconChainTypes> CanonicalHead<T> {
402
405
}
403
406
404
407
/// Access a write-lock for fork choice.
408
+ #[ instrument( skip_all) ]
405
409
pub fn fork_choice_write_lock ( & self ) -> RwLockWriteGuard < ' _ , BeaconForkChoice < T > > {
406
410
let _timer = metrics:: start_timer ( & metrics:: FORK_CHOICE_WRITE_LOCK_AQUIRE_TIMES ) ;
407
411
self . fork_choice . write ( )
@@ -509,13 +513,21 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
509
513
/// situation can be rectified. We avoid returning an error here so that calling functions
510
514
/// can't abort block import because an error is returned here.
511
515
pub async fn recompute_head_at_slot ( self : & Arc < Self > , current_slot : Slot ) {
516
+ let span = info_span ! (
517
+ SPAN_RECOMPUTE_HEAD ,
518
+ slot = %current_slot
519
+ ) ;
520
+
512
521
metrics:: inc_counter ( & metrics:: FORK_CHOICE_REQUESTS ) ;
513
522
let _timer = metrics:: start_timer ( & metrics:: FORK_CHOICE_TIMES ) ;
514
523
515
524
let chain = self . clone ( ) ;
516
525
match self
517
526
. spawn_blocking_handle (
518
- move || chain. recompute_head_at_slot_internal ( current_slot) ,
527
+ move || {
528
+ let _guard = span. enter ( ) ;
529
+ chain. recompute_head_at_slot_internal ( current_slot)
530
+ } ,
519
531
"recompute_head_internal" ,
520
532
)
521
533
. await
@@ -773,6 +785,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
773
785
}
774
786
775
787
/// Perform updates to caches and other components after the canonical head has been changed.
788
+ #[ instrument( skip_all) ]
776
789
fn after_new_head (
777
790
self : & Arc < Self > ,
778
791
old_cached_head : & CachedHead < T :: EthSpec > ,
@@ -911,6 +924,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
911
924
///
912
925
/// This function will take a write-lock on `canonical_head.fork_choice`, therefore it would be
913
926
/// unwise to hold any lock on fork choice while calling this function.
927
+ #[ instrument( skip_all) ]
914
928
fn after_finalization (
915
929
self : & Arc < Self > ,
916
930
new_cached_head : & CachedHead < T :: EthSpec > ,
@@ -1046,6 +1060,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
1046
1060
///
1047
1061
/// This function is called whilst holding a write-lock on the `canonical_head`. To ensure dead-lock
1048
1062
/// safety, **do not take any other locks inside this function**.
1063
+ #[ instrument( skip_all) ]
1049
1064
fn check_finalized_payload_validity < T : BeaconChainTypes > (
1050
1065
chain : & BeaconChain < T > ,
1051
1066
finalized_proto_block : & ProtoBlock ,
@@ -1129,6 +1144,7 @@ fn perform_debug_logging<T: BeaconChainTypes>(
1129
1144
}
1130
1145
}
1131
1146
1147
+ #[ instrument( skip_all) ]
1132
1148
fn spawn_execution_layer_updates < T : BeaconChainTypes > (
1133
1149
chain : Arc < BeaconChain < T > > ,
1134
1150
forkchoice_update_params : ForkchoiceUpdateParameters ,
0 commit comments