@@ -14,7 +14,7 @@ use parking_lot::RwLock;
14
14
use std:: cmp:: Ordering ;
15
15
use std:: num:: NonZeroUsize ;
16
16
use std:: sync:: Arc ;
17
- use tracing:: debug;
17
+ use tracing:: { debug, debug_span , Span } ;
18
18
use types:: blob_sidecar:: BlobIdentifier ;
19
19
use types:: {
20
20
BlobSidecar , ChainSpec , ColumnIndex , DataColumnSidecar , DataColumnSidecarList , Epoch , EthSpec ,
@@ -31,6 +31,7 @@ pub struct PendingComponents<E: EthSpec> {
31
31
pub verified_data_columns : Vec < KzgVerifiedCustodyDataColumn < E > > ,
32
32
pub executed_block : Option < DietAvailabilityPendingExecutedBlock < E > > ,
33
33
pub reconstruction_started : bool ,
34
+ span : Span ,
34
35
}
35
36
36
37
impl < E : EthSpec > PendingComponents < E > {
@@ -87,14 +88,18 @@ impl<E: EthSpec> PendingComponents<E> {
87
88
88
89
/// Inserts a block into the cache.
89
90
pub fn insert_block ( & mut self , block : DietAvailabilityPendingExecutedBlock < E > ) {
91
+ let _guard = self . span . clone ( ) . entered ( ) ;
92
+ debug ! ( "Block added to pending components" ) ;
90
93
* self . get_cached_block_mut ( ) = Some ( block)
91
94
}
92
95
93
96
/// Inserts a blob at a specific index in the cache.
94
97
///
95
98
/// Existing blob at the index will be replaced.
96
99
pub fn insert_blob_at_index ( & mut self , blob_index : usize , blob : KzgVerifiedBlob < E > ) {
100
+ let _guard = self . span . clone ( ) . entered ( ) ;
97
101
if let Some ( b) = self . get_cached_blobs_mut ( ) . get_mut ( blob_index) {
102
+ debug ! ( blob_index, "Blob added to pending components" ) ;
98
103
* b = Some ( blob) ;
99
104
}
100
105
}
@@ -134,11 +139,17 @@ impl<E: EthSpec> PendingComponents<E> {
134
139
& mut self ,
135
140
kzg_verified_data_columns : I ,
136
141
) -> Result < ( ) , AvailabilityCheckError > {
142
+ let _guard = self . span . clone ( ) . entered ( ) ;
137
143
for data_column in kzg_verified_data_columns {
138
144
if self . get_cached_data_column ( data_column. index ( ) ) . is_none ( ) {
145
+ debug ! (
146
+ column_index = data_column. index( ) ,
147
+ "Data column added to pending components"
148
+ ) ;
139
149
self . verified_data_columns . push ( data_column) ;
140
150
}
141
151
}
152
+
142
153
Ok ( ( ) )
143
154
}
144
155
@@ -165,6 +176,7 @@ impl<E: EthSpec> PendingComponents<E> {
165
176
where
166
177
R : FnOnce (
167
178
DietAvailabilityPendingExecutedBlock < E > ,
179
+ & Span ,
168
180
) -> Result < AvailabilityPendingExecutedBlock < E > , AvailabilityCheckError > ,
169
181
{
170
182
let Some ( block) = & self . executed_block else {
@@ -255,7 +267,7 @@ impl<E: EthSpec> PendingComponents<E> {
255
267
block,
256
268
import_data,
257
269
payload_verification_outcome,
258
- } = recover ( block. clone ( ) ) ?;
270
+ } = recover ( block. clone ( ) , & self . span ) ?;
259
271
260
272
let available_block = AvailableBlock {
261
273
block_root : self . block_root ,
@@ -264,6 +276,10 @@ impl<E: EthSpec> PendingComponents<E> {
264
276
blobs_available_timestamp,
265
277
spec : spec. clone ( ) ,
266
278
} ;
279
+
280
+ self . span . in_scope ( || {
281
+ debug ! ( "Block and all data components are available" ) ;
282
+ } ) ;
267
283
Ok ( Some ( AvailableExecutedBlock :: new (
268
284
available_block,
269
285
import_data,
@@ -273,12 +289,15 @@ impl<E: EthSpec> PendingComponents<E> {
273
289
274
290
/// Returns an empty `PendingComponents` object with the given block root.
275
291
pub fn empty ( block_root : Hash256 , max_len : usize ) -> Self {
292
+ let span = debug_span ! ( "pending_components" , %block_root) ;
293
+ let _guard = span. clone ( ) . entered ( ) ;
276
294
Self {
277
295
block_root,
278
296
verified_blobs : RuntimeFixedVector :: new ( vec ! [ None ; max_len] ) ,
279
297
verified_data_columns : vec ! [ ] ,
280
298
executed_block : None ,
281
299
reconstruction_started : false ,
300
+ span,
282
301
}
283
302
}
284
303
@@ -483,7 +502,7 @@ impl<T: BeaconChainTypes> DataAvailabilityCheckerInner<T> {
483
502
& self . spec ,
484
503
self . custody_context
485
504
. num_of_data_columns_to_sample ( Some ( epoch) , & self . spec ) ,
486
- |block| self . state_cache . recover_pending_executed_block ( block) ,
505
+ |block, span | self . state_cache . recover_pending_executed_block ( block, span ) ,
487
506
) ? {
488
507
// We keep the pending components in the availability cache during block import (#5845).
489
508
write_lock. put ( block_root, pending_components) ;
@@ -538,8 +557,8 @@ impl<T: BeaconChainTypes> DataAvailabilityCheckerInner<T> {
538
557
) ;
539
558
540
559
if let Some ( available_block) =
541
- pending_components. make_available ( & self . spec , num_expected_columns, |block| {
542
- self . state_cache . recover_pending_executed_block ( block)
560
+ pending_components. make_available ( & self . spec , num_expected_columns, |block, span | {
561
+ self . state_cache . recover_pending_executed_block ( block, span )
543
562
} ) ?
544
563
{
545
564
// We keep the pending components in the availability cache during block import (#5845).
@@ -637,8 +656,8 @@ impl<T: BeaconChainTypes> DataAvailabilityCheckerInner<T> {
637
656
638
657
// Check if we have all components and entire set is consistent.
639
658
if let Some ( available_block) =
640
- pending_components. make_available ( & self . spec , num_expected_columns, |block| {
641
- self . state_cache . recover_pending_executed_block ( block)
659
+ pending_components. make_available ( & self . spec , num_expected_columns, |block, span | {
660
+ self . state_cache . recover_pending_executed_block ( block, span )
642
661
} ) ?
643
662
{
644
663
// We keep the pending components in the availability cache during block import (#5845).
@@ -712,7 +731,7 @@ mod test {
712
731
use std:: collections:: VecDeque ;
713
732
use store:: { database:: interface:: BeaconNodeBackend , HotColdDB , ItemStore , StoreConfig } ;
714
733
use tempfile:: { tempdir, TempDir } ;
715
- use tracing:: info;
734
+ use tracing:: { debug_span , info} ;
716
735
use types:: non_zero_usize:: new_non_zero_usize;
717
736
use types:: { ExecPayload , MinimalEthSpec } ;
718
737
@@ -1107,7 +1126,7 @@ mod test {
1107
1126
// reconstruct the pending block by replaying the block on the parent state
1108
1127
let recovered_pending_block = cache
1109
1128
. state_lru_cache ( )
1110
- . recover_pending_executed_block ( diet_block)
1129
+ . recover_pending_executed_block ( diet_block, & debug_span ! ( "test" ) )
1111
1130
. expect ( "should reconstruct pending block" ) ;
1112
1131
1113
1132
// assert the recovered state is the same as the original
@@ -1133,7 +1152,7 @@ mod test {
1133
1152
// recover the pending block from the cache
1134
1153
let recovered_pending_block = cache
1135
1154
. state_lru_cache ( )
1136
- . recover_pending_executed_block ( diet_block)
1155
+ . recover_pending_executed_block ( diet_block, & debug_span ! ( "test" ) )
1137
1156
. expect ( "should reconstruct pending block" ) ;
1138
1157
// assert the recovered state is the same as the original
1139
1158
assert_eq ! (
0 commit comments