@@ -1437,6 +1437,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
14371437 ///
14381438 /// Returns `None` when the state is not found in the database or there is an error skipping
14391439 /// to a future state.
1440+ #[ instrument( level = "debug" , skip_all) ]
14401441 pub fn state_at_slot (
14411442 & self ,
14421443 slot : Slot ,
@@ -4466,6 +4467,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
44664467 }
44674468
44684469 /// If configured, wait for the fork choice run at the start of the slot to complete.
4470+ #[ instrument( level = "debug" , skip_all) ]
44694471 fn wait_for_fork_choice_before_block_production (
44704472 self : & Arc < Self > ,
44714473 slot : Slot ,
@@ -4528,10 +4530,15 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
45284530 //
45294531 // Load the parent state from disk.
45304532 let chain = self . clone ( ) ;
4533+ let span = Span :: current ( ) ;
45314534 let ( state, state_root_opt) = self
45324535 . task_executor
45334536 . spawn_blocking_handle (
4534- move || chain. load_state_for_block_production ( slot) ,
4537+ move || {
4538+ let _guard =
4539+ debug_span ! ( parent: span, "load_state_for_block_production" ) . entered ( ) ;
4540+ chain. load_state_for_block_production ( slot)
4541+ } ,
45354542 "load_state_for_block_production" ,
45364543 )
45374544 . ok_or ( BlockProductionError :: ShuttingDown ) ?
@@ -4618,6 +4625,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
46184625 /// Fetch the beacon state to use for producing a block if a 1-slot proposer re-org is viable.
46194626 ///
46204627 /// This function will return `None` if proposer re-orgs are disabled.
4628+ #[ instrument( skip_all, level = "debug" ) ]
46214629 fn get_state_for_re_org (
46224630 & self ,
46234631 slot : Slot ,
@@ -5072,6 +5080,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
50725080 /// equal to the root of `state`. Providing this value will serve as an optimization to avoid
50735081 /// performing a tree hash in some scenarios.
50745082 #[ allow( clippy:: too_many_arguments) ]
5083+ #[ instrument( level = "debug" , skip_all) ]
50755084 pub async fn produce_block_on_state (
50765085 self : & Arc < Self > ,
50775086 state : BeaconState < T :: EthSpec > ,
@@ -5091,10 +5100,13 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
50915100 . graffiti_calculator
50925101 . get_graffiti ( validator_graffiti)
50935102 . await ;
5103+ let span = Span :: current ( ) ;
50945104 let mut partial_beacon_block = self
50955105 . task_executor
50965106 . spawn_blocking_handle (
50975107 move || {
5108+ let _guard =
5109+ debug_span ! ( parent: span, "produce_partial_beacon_block" ) . entered ( ) ;
50985110 chain. produce_partial_beacon_block (
50995111 state,
51005112 state_root_opt,
@@ -5130,10 +5142,14 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
51305142 match block_contents_type {
51315143 BlockProposalContentsType :: Full ( block_contents) => {
51325144 let chain = self . clone ( ) ;
5145+ let span = Span :: current ( ) ;
51335146 let beacon_block_response = self
51345147 . task_executor
51355148 . spawn_blocking_handle (
51365149 move || {
5150+ let _guard =
5151+ debug_span ! ( parent: span, "complete_partial_beacon_block" )
5152+ . entered ( ) ;
51375153 chain. complete_partial_beacon_block (
51385154 partial_beacon_block,
51395155 Some ( block_contents) ,
@@ -5150,10 +5166,14 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
51505166 }
51515167 BlockProposalContentsType :: Blinded ( block_contents) => {
51525168 let chain = self . clone ( ) ;
5169+ let span = Span :: current ( ) ;
51535170 let beacon_block_response = self
51545171 . task_executor
51555172 . spawn_blocking_handle (
51565173 move || {
5174+ let _guard =
5175+ debug_span ! ( parent: span, "complete_partial_beacon_block" )
5176+ . entered ( ) ;
51575177 chain. complete_partial_beacon_block (
51585178 partial_beacon_block,
51595179 Some ( block_contents) ,
@@ -5171,10 +5191,13 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
51715191 }
51725192 } else {
51735193 let chain = self . clone ( ) ;
5194+ let span = Span :: current ( ) ;
51745195 let beacon_block_response = self
51755196 . task_executor
51765197 . spawn_blocking_handle (
51775198 move || {
5199+ let _guard =
5200+ debug_span ! ( parent: span, "complete_partial_beacon_block" ) . entered ( ) ;
51785201 chain. complete_partial_beacon_block (
51795202 partial_beacon_block,
51805203 None ,
@@ -5276,51 +5299,54 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
52765299
52775300 // Iterate through the naive aggregation pool and ensure all the attestations from there
52785301 // are included in the operation pool.
5279- let unagg_import_timer =
5280- metrics:: start_timer ( & metrics:: BLOCK_PRODUCTION_UNAGGREGATED_TIMES ) ;
5281- for attestation in self . naive_aggregation_pool . read ( ) . iter ( ) {
5282- let import = |attestation : & Attestation < T :: EthSpec > | {
5283- let attesting_indices =
5284- get_attesting_indices_from_state ( & state, attestation. to_ref ( ) ) ?;
5285- self . op_pool
5286- . insert_attestation ( attestation. clone ( ) , attesting_indices)
5287- } ;
5288- if let Err ( e) = import ( attestation) {
5289- // Don't stop block production if there's an error, just create a log.
5290- error ! (
5291- reason = ?e,
5292- "Attestation did not transfer to op pool"
5293- ) ;
5302+ {
5303+ let _guard = debug_span ! ( "import_naive_aggregation_pool" ) . entered ( ) ;
5304+ let _unagg_import_timer =
5305+ metrics:: start_timer ( & metrics:: BLOCK_PRODUCTION_UNAGGREGATED_TIMES ) ;
5306+ for attestation in self . naive_aggregation_pool . read ( ) . iter ( ) {
5307+ let import = |attestation : & Attestation < T :: EthSpec > | {
5308+ let attesting_indices =
5309+ get_attesting_indices_from_state ( & state, attestation. to_ref ( ) ) ?;
5310+ self . op_pool
5311+ . insert_attestation ( attestation. clone ( ) , attesting_indices)
5312+ } ;
5313+ if let Err ( e) = import ( attestation) {
5314+ // Don't stop block production if there's an error, just create a log.
5315+ error ! (
5316+ reason = ?e,
5317+ "Attestation did not transfer to op pool"
5318+ ) ;
5319+ }
52945320 }
5295- }
5296- drop ( unagg_import_timer) ;
5321+ } ;
52975322
5298- let attestation_packing_timer =
5299- metrics:: start_timer ( & metrics:: BLOCK_PRODUCTION_ATTESTATION_TIMES ) ;
5323+ let mut attestations = {
5324+ let _guard = debug_span ! ( "pack_attestations" ) . entered ( ) ;
5325+ let _attestation_packing_timer =
5326+ metrics:: start_timer ( & metrics:: BLOCK_PRODUCTION_ATTESTATION_TIMES ) ;
53005327
5301- // Epoch cache and total balance cache are required for op pool packing.
5302- state. build_total_active_balance_cache ( & self . spec ) ?;
5303- initialize_epoch_cache ( & mut state, & self . spec ) ?;
5328+ // Epoch cache and total balance cache are required for op pool packing.
5329+ state. build_total_active_balance_cache ( & self . spec ) ?;
5330+ initialize_epoch_cache ( & mut state, & self . spec ) ?;
53045331
5305- let mut prev_filter_cache = HashMap :: new ( ) ;
5306- let prev_attestation_filter = |att : & CompactAttestationRef < T :: EthSpec > | {
5307- self . filter_op_pool_attestation ( & mut prev_filter_cache, att, & state)
5308- } ;
5309- let mut curr_filter_cache = HashMap :: new ( ) ;
5310- let curr_attestation_filter = |att : & CompactAttestationRef < T :: EthSpec > | {
5311- self . filter_op_pool_attestation ( & mut curr_filter_cache, att, & state)
5312- } ;
5332+ let mut prev_filter_cache = HashMap :: new ( ) ;
5333+ let prev_attestation_filter = |att : & CompactAttestationRef < T :: EthSpec > | {
5334+ self . filter_op_pool_attestation ( & mut prev_filter_cache, att, & state)
5335+ } ;
5336+ let mut curr_filter_cache = HashMap :: new ( ) ;
5337+ let curr_attestation_filter = |att : & CompactAttestationRef < T :: EthSpec > | {
5338+ self . filter_op_pool_attestation ( & mut curr_filter_cache, att, & state)
5339+ } ;
53135340
5314- let mut attestations = self
5315- . op_pool
5316- . get_attestations (
5317- & state,
5318- prev_attestation_filter,
5319- curr_attestation_filter,
5320- & self . spec ,
5321- )
5322- . map_err ( BlockProductionError :: OpPoolError ) ?;
5323- drop ( attestation_packing_timer) ;
5341+ self . op_pool
5342+ . get_attestations (
5343+ & state,
5344+ prev_attestation_filter,
5345+ curr_attestation_filter,
5346+ & self . spec ,
5347+ )
5348+ . map_err ( BlockProductionError :: OpPoolError ) ?
5349+ } ;
53245350
53255351 // If paranoid mode is enabled re-check the signatures of every included message.
53265352 // This will be a lot slower but guards against bugs in block production and can be
0 commit comments