@@ -126,7 +126,7 @@ use store::{
126
126
} ;
127
127
use task_executor:: { ShutdownReason , TaskExecutor } ;
128
128
use tokio_stream:: Stream ;
129
- use tracing:: { debug, error, info, trace, warn} ;
129
+ use tracing:: { debug, debug_span , error, info, info_span , instrument , trace, warn, Span } ;
130
130
use tree_hash:: TreeHash ;
131
131
use types:: blob_sidecar:: FixedBlobSidecarList ;
132
132
use types:: data_column_sidecar:: ColumnIndex ;
@@ -2203,6 +2203,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
2203
2203
} )
2204
2204
}
2205
2205
2206
+ #[ instrument( skip_all, level = "trace" ) ]
2206
2207
pub fn verify_data_column_sidecar_for_gossip (
2207
2208
self : & Arc < Self > ,
2208
2209
data_column_sidecar : Arc < DataColumnSidecar < T :: EthSpec > > ,
@@ -2215,6 +2216,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
2215
2216
} )
2216
2217
}
2217
2218
2219
+ #[ instrument( skip_all, level = "trace" ) ]
2218
2220
pub fn verify_blob_sidecar_for_gossip (
2219
2221
self : & Arc < Self > ,
2220
2222
blob_sidecar : Arc < BlobSidecar < T :: EthSpec > > ,
@@ -2851,8 +2853,12 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
2851
2853
2852
2854
// Filter uninteresting blocks from the chain segment in a blocking task.
2853
2855
let chain = self . clone ( ) ;
2856
+ let filter_chain_segment = debug_span ! ( "filter_chain_segment" ) ;
2854
2857
let filtered_chain_segment_future = self . spawn_blocking_handle (
2855
- move || chain. filter_chain_segment ( chain_segment) ,
2858
+ move || {
2859
+ let _guard = filter_chain_segment. enter ( ) ;
2860
+ chain. filter_chain_segment ( chain_segment)
2861
+ } ,
2856
2862
"filter_chain_segment" ,
2857
2863
) ;
2858
2864
let mut filtered_chain_segment = match filtered_chain_segment_future. await {
@@ -2883,8 +2889,12 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
2883
2889
std:: mem:: swap ( & mut blocks, & mut filtered_chain_segment) ;
2884
2890
2885
2891
let chain = self . clone ( ) ;
2892
+ let current_span = Span :: current ( ) ;
2886
2893
let signature_verification_future = self . spawn_blocking_handle (
2887
- move || signature_verify_chain_segment ( blocks, & chain) ,
2894
+ move || {
2895
+ let _guard = current_span. enter ( ) ;
2896
+ signature_verify_chain_segment ( blocks, & chain)
2897
+ } ,
2888
2898
"signature_verify_chain_segment" ,
2889
2899
) ;
2890
2900
@@ -2974,10 +2984,12 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
2974
2984
block : Arc < SignedBeaconBlock < T :: EthSpec > > ,
2975
2985
) -> Result < GossipVerifiedBlock < T > , BlockError > {
2976
2986
let chain = self . clone ( ) ;
2987
+ let span = Span :: current ( ) ;
2977
2988
self . task_executor
2978
2989
. clone ( )
2979
2990
. spawn_blocking_handle (
2980
2991
move || {
2992
+ let _guard = span. enter ( ) ;
2981
2993
let slot = block. slot ( ) ;
2982
2994
let graffiti_string = block. message ( ) . body ( ) . graffiti ( ) . as_utf8_lossy ( ) ;
2983
2995
@@ -3006,7 +3018,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
3006
3018
}
3007
3019
}
3008
3020
} ,
3009
- "payload_verification_handle " ,
3021
+ "gossip_block_verification_handle " ,
3010
3022
)
3011
3023
. ok_or ( BeaconChainError :: RuntimeShutdown ) ?
3012
3024
. await
@@ -3015,6 +3027,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
3015
3027
3016
3028
/// Cache the blob in the processing cache, process it, then evict it from the cache if it was
3017
3029
/// imported or errors.
3030
+ #[ instrument( skip_all, level = "debug" ) ]
3018
3031
pub async fn process_gossip_blob (
3019
3032
self : & Arc < Self > ,
3020
3033
blob : GossipVerifiedBlob < T > ,
@@ -3088,6 +3101,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
3088
3101
3089
3102
/// Cache the blobs in the processing cache, process it, then evict it from the cache if it was
3090
3103
/// imported or errors.
3104
+ #[ instrument( skip_all, level = "debug" ) ]
3091
3105
pub async fn process_rpc_blobs (
3092
3106
self : & Arc < Self > ,
3093
3107
slot : Slot ,
@@ -3383,6 +3397,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
3383
3397
///
3384
3398
/// Returns an `Err` if the given block was invalid, or an error was encountered during
3385
3399
/// verification.
3400
+ #[ instrument( skip_all, fields( block_root = ?block_root, block_source = %block_source) ) ]
3386
3401
pub async fn process_block < B : IntoExecutionPendingBlock < T > > (
3387
3402
self : & Arc < Self > ,
3388
3403
block_root : Hash256 ,
@@ -3499,6 +3514,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
3499
3514
/// get a fully `ExecutedBlock`.
3500
3515
///
3501
3516
/// An error is returned if the verification handle couldn't be awaited.
3517
+ #[ instrument( skip_all, level = "debug" ) ]
3502
3518
pub async fn into_executed_block (
3503
3519
self : Arc < Self > ,
3504
3520
execution_pending_block : ExecutionPendingBlock < T > ,
@@ -3547,6 +3563,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
3547
3563
3548
3564
/// Checks if the block is available, and imports immediately if so, otherwise caches the block
3549
3565
/// in the data availability checker.
3566
+ #[ instrument( skip_all) ]
3550
3567
async fn check_block_availability_and_import (
3551
3568
self : & Arc < Self > ,
3552
3569
block : AvailabilityPendingExecutedBlock < T :: EthSpec > ,
@@ -3747,6 +3764,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
3747
3764
}
3748
3765
}
3749
3766
3767
+ #[ instrument( skip_all) ]
3750
3768
pub async fn import_available_block (
3751
3769
self : & Arc < Self > ,
3752
3770
block : Box < AvailableExecutedBlock < T :: EthSpec > > ,
@@ -3775,11 +3793,14 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
3775
3793
3776
3794
// TODO(das) record custody column available timestamp
3777
3795
3778
- // import
3779
- let chain = self . clone ( ) ;
3780
- let block_root = self
3781
- . spawn_blocking_handle (
3796
+ let block_root = {
3797
+ // Capture the current span before moving into the blocking task
3798
+ let current_span = tracing:: Span :: current ( ) ;
3799
+ let chain = self . clone ( ) ;
3800
+ self . spawn_blocking_handle (
3782
3801
move || {
3802
+ // Enter the captured span in the blocking thread
3803
+ let _guard = current_span. enter ( ) ;
3783
3804
chain. import_block (
3784
3805
block,
3785
3806
block_root,
@@ -3791,7 +3812,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
3791
3812
} ,
3792
3813
"payload_verification_handle" ,
3793
3814
)
3794
- . await ??;
3815
+ . await ??
3816
+ } ;
3795
3817
3796
3818
// Remove block components from da_checker AFTER completing block import. Then we can assert
3797
3819
// the following invariant:
@@ -3815,6 +3837,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
3815
3837
/// An error is returned if the block was unable to be imported. It may be partially imported
3816
3838
/// (i.e., this function is not atomic).
3817
3839
#[ allow( clippy:: too_many_arguments) ]
3840
+ #[ instrument( skip_all) ]
3818
3841
fn import_block (
3819
3842
& self ,
3820
3843
signed_block : AvailableBlock < T :: EthSpec > ,
@@ -3852,6 +3875,13 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
3852
3875
3853
3876
// Only take a write lock if there are new keys to import.
3854
3877
if state. validators ( ) . len ( ) > pubkey_cache. len ( ) {
3878
+ let _pubkey_span = debug_span ! (
3879
+ "pubkey_cache_update" ,
3880
+ new_validators = tracing:: field:: Empty ,
3881
+ cache_len_before = pubkey_cache. len( )
3882
+ )
3883
+ . entered ( ) ;
3884
+
3855
3885
parking_lot:: RwLockUpgradableReadGuard :: upgrade ( pubkey_cache)
3856
3886
. import_new_pubkeys ( & state) ?
3857
3887
} else {
@@ -3865,6 +3895,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
3865
3895
// However, latency between the VC and the BN might cause the VC to produce attestations at
3866
3896
// a previous slot.
3867
3897
if state. current_epoch ( ) . saturating_add ( 1_u64 ) >= current_epoch {
3898
+ let _attester_span = debug_span ! ( "attester_cache_update" ) . entered ( ) ;
3868
3899
self . attester_cache
3869
3900
. maybe_cache_state ( & state, block_root, & self . spec )
3870
3901
. map_err ( BeaconChainError :: from) ?;
@@ -4009,6 +4040,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
4009
4040
ops. push ( StoreOp :: PutBlock ( block_root, signed_block. clone ( ) ) ) ;
4010
4041
ops. push ( StoreOp :: PutState ( block. state_root ( ) , & state) ) ;
4011
4042
4043
+ let db_span = info_span ! ( "persist_blocks_and_blobs" ) . entered ( ) ;
4044
+
4012
4045
if let Err ( e) = self . store . do_atomically_with_block_and_blobs_cache ( ops) {
4013
4046
error ! (
4014
4047
msg = "Restoring fork choice from disk" ,
@@ -4021,6 +4054,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
4021
4054
. unwrap_or ( e. into ( ) ) ) ;
4022
4055
}
4023
4056
4057
+ drop ( db_span) ;
4058
+
4024
4059
// The fork choice write-lock is dropped *after* the on-disk database has been updated.
4025
4060
// This prevents inconsistency between the two at the expense of concurrency.
4026
4061
drop ( fork_choice) ;
@@ -4155,6 +4190,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
4155
4190
}
4156
4191
4157
4192
/// Process a block for the validator monitor, including all its constituent messages.
4193
+ #[ instrument( skip_all, level = "debug" ) ]
4158
4194
fn import_block_update_validator_monitor (
4159
4195
& self ,
4160
4196
block : BeaconBlockRef < T :: EthSpec > ,
@@ -4249,6 +4285,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
4249
4285
/// Iterate through the attestations in the block and register them as "observed".
4250
4286
///
4251
4287
/// This will stop us from propagating them on the gossip network.
4288
+ #[ instrument( skip_all, level = "debug" ) ]
4252
4289
fn import_block_observe_attestations (
4253
4290
& self ,
4254
4291
block : BeaconBlockRef < T :: EthSpec > ,
@@ -4311,6 +4348,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
4311
4348
}
4312
4349
4313
4350
/// If a slasher is configured, provide the attestations from the block.
4351
+ #[ instrument( skip_all, level = "debug" ) ]
4314
4352
fn import_block_update_slasher (
4315
4353
& self ,
4316
4354
block : BeaconBlockRef < T :: EthSpec > ,
@@ -4409,6 +4447,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
4409
4447
4410
4448
// For the current and next epoch of this state, ensure we have the shuffling from this
4411
4449
// block in our cache.
4450
+ #[ instrument( skip_all, level = "debug" ) ]
4412
4451
fn import_block_update_shuffling_cache (
4413
4452
& self ,
4414
4453
block_root : Hash256 ,
0 commit comments