@@ -340,10 +340,6 @@ pub enum BlockProcessStatus<E: EthSpec> {
340
340
ExecutionValidated ( Arc < SignedBeaconBlock < E > > ) ,
341
341
}
342
342
343
- pub struct BeaconChainMetrics {
344
- pub reqresp_pre_import_cache_len : usize ,
345
- }
346
-
347
343
pub type LightClientProducerEvent < T > = ( Hash256 , Slot , SyncAggregate < T > ) ;
348
344
349
345
pub type BeaconForkChoice < T > = ForkChoice <
@@ -363,9 +359,6 @@ pub type BeaconStore<T> = Arc<
363
359
> ,
364
360
> ;
365
361
366
- /// Cache gossip verified blocks to serve over ReqResp before they are imported
367
- type ReqRespPreImportCache < E > = HashMap < Hash256 , Arc < SignedBeaconBlock < E > > > ;
368
-
369
362
/// Represents the "Beacon Chain" component of Ethereum 2.0. Allows import of blocks and block
370
363
/// operations and chooses a canonical head.
371
364
pub struct BeaconChain < T : BeaconChainTypes > {
@@ -462,8 +455,6 @@ pub struct BeaconChain<T: BeaconChainTypes> {
462
455
pub ( crate ) attester_cache : Arc < AttesterCache > ,
463
456
/// A cache used when producing attestations whilst the head block is still being imported.
464
457
pub early_attester_cache : EarlyAttesterCache < T :: EthSpec > ,
465
- /// Cache gossip verified blocks to serve over ReqResp before they are imported
466
- pub reqresp_pre_import_cache : Arc < RwLock < ReqRespPreImportCache < T :: EthSpec > > > ,
467
458
/// A cache used to keep track of various block timings.
468
459
pub block_times_cache : Arc < RwLock < BlockTimesCache > > ,
469
460
/// A cache used to track pre-finalization block roots for quick rejection.
@@ -1289,18 +1280,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
1289
1280
/// chain. Used by sync to learn the status of a block and prevent repeated downloads /
1290
1281
/// processing attempts.
1291
1282
pub fn get_block_process_status ( & self , block_root : & Hash256 ) -> BlockProcessStatus < T :: EthSpec > {
1292
- if let Some ( block) = self
1293
- . data_availability_checker
1294
- . get_execution_valid_block ( block_root)
1295
- {
1296
- return BlockProcessStatus :: ExecutionValidated ( block) ;
1297
- }
1298
-
1299
- if let Some ( block) = self . reqresp_pre_import_cache . read ( ) . get ( block_root) {
1300
- // A block is on the `reqresp_pre_import_cache` but NOT in the
1301
- // `data_availability_checker` only if it is actively processing. We can expect a future
1302
- // event with the result of processing
1303
- return BlockProcessStatus :: NotValidated ( block. clone ( ) ) ;
1283
+ if let Some ( cached_block) = self . data_availability_checker . get_cached_block ( block_root) {
1284
+ return cached_block;
1304
1285
}
1305
1286
1306
1287
BlockProcessStatus :: Unknown
@@ -3054,8 +3035,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
3054
3035
3055
3036
self . emit_sse_blob_sidecar_events ( & block_root, std:: iter:: once ( blob. as_blob ( ) ) ) ;
3056
3037
3057
- let r = self . check_gossip_blob_availability_and_import ( blob) . await ;
3058
- self . remove_notified ( & block_root, r)
3038
+ self . check_gossip_blob_availability_and_import ( blob) . await
3059
3039
}
3060
3040
3061
3041
/// Cache the data columns in the processing cache, process it, then evict it from the cache if it was
@@ -3092,15 +3072,13 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
3092
3072
data_columns. iter ( ) . map ( |column| column. as_data_column ( ) ) ,
3093
3073
) ;
3094
3074
3095
- let r = self
3096
- . check_gossip_data_columns_availability_and_import (
3097
- slot,
3098
- block_root,
3099
- data_columns,
3100
- publish_fn,
3101
- )
3102
- . await ;
3103
- self . remove_notified ( & block_root, r)
3075
+ self . check_gossip_data_columns_availability_and_import (
3076
+ slot,
3077
+ block_root,
3078
+ data_columns,
3079
+ publish_fn,
3080
+ )
3081
+ . await
3104
3082
}
3105
3083
3106
3084
/// Cache the blobs in the processing cache, process it, then evict it from the cache if it was
@@ -3139,10 +3117,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
3139
3117
3140
3118
self . emit_sse_blob_sidecar_events ( & block_root, blobs. iter ( ) . flatten ( ) . map ( Arc :: as_ref) ) ;
3141
3119
3142
- let r = self
3143
- . check_rpc_blob_availability_and_import ( slot, block_root, blobs)
3144
- . await ;
3145
- self . remove_notified ( & block_root, r)
3120
+ self . check_rpc_blob_availability_and_import ( slot, block_root, blobs)
3121
+ . await
3146
3122
}
3147
3123
3148
3124
/// Process blobs retrieved from the EL and returns the `AvailabilityProcessingStatus`.
@@ -3174,10 +3150,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
3174
3150
}
3175
3151
}
3176
3152
3177
- let r = self
3178
- . check_engine_blobs_availability_and_import ( slot, block_root, engine_get_blobs_output)
3179
- . await ;
3180
- self . remove_notified ( & block_root, r)
3153
+ self . check_engine_blobs_availability_and_import ( slot, block_root, engine_get_blobs_output)
3154
+ . await
3181
3155
}
3182
3156
3183
3157
fn emit_sse_blob_sidecar_events < ' a , I > ( self : & Arc < Self > , block_root : & Hash256 , blobs_iter : I )
@@ -3270,10 +3244,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
3270
3244
custody_columns. iter ( ) . map ( |column| column. as_ref ( ) ) ,
3271
3245
) ;
3272
3246
3273
- let r = self
3274
- . check_rpc_custody_columns_availability_and_import ( slot, block_root, custody_columns)
3275
- . await ;
3276
- self . remove_notified ( & block_root, r)
3247
+ self . check_rpc_custody_columns_availability_and_import ( slot, block_root, custody_columns)
3248
+ . await
3277
3249
}
3278
3250
3279
3251
pub async fn reconstruct_data_columns (
@@ -3320,10 +3292,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
3320
3292
return Ok ( None ) ;
3321
3293
} ;
3322
3294
3323
- let r = self
3324
- . process_availability ( slot, availability, || Ok ( ( ) ) )
3325
- . await ;
3326
- self . remove_notified ( & block_root, r)
3295
+ self . process_availability ( slot, availability, || Ok ( ( ) ) )
3296
+ . await
3327
3297
. map ( |availability_processing_status| {
3328
3298
Some ( ( availability_processing_status, data_columns_to_publish) )
3329
3299
} )
@@ -3340,46 +3310,6 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
3340
3310
}
3341
3311
}
3342
3312
3343
- /// Remove any block components from the *processing cache* if we no longer require them. If the
3344
- /// block was imported full or erred, we no longer require them.
3345
- fn remove_notified (
3346
- & self ,
3347
- block_root : & Hash256 ,
3348
- r : Result < AvailabilityProcessingStatus , BlockError > ,
3349
- ) -> Result < AvailabilityProcessingStatus , BlockError > {
3350
- let has_missing_components =
3351
- matches ! ( r, Ok ( AvailabilityProcessingStatus :: MissingComponents ( _, _) ) ) ;
3352
- if !has_missing_components {
3353
- self . reqresp_pre_import_cache . write ( ) . remove ( block_root) ;
3354
- }
3355
- r
3356
- }
3357
-
3358
- /// Wraps `process_block` in logic to cache the block's commitments in the processing cache
3359
- /// and evict if the block was imported or errored.
3360
- pub async fn process_block_with_early_caching < B : IntoExecutionPendingBlock < T > > (
3361
- self : & Arc < Self > ,
3362
- block_root : Hash256 ,
3363
- unverified_block : B ,
3364
- block_source : BlockImportSource ,
3365
- notify_execution_layer : NotifyExecutionLayer ,
3366
- ) -> Result < AvailabilityProcessingStatus , BlockError > {
3367
- self . reqresp_pre_import_cache
3368
- . write ( )
3369
- . insert ( block_root, unverified_block. block_cloned ( ) ) ;
3370
-
3371
- let r = self
3372
- . process_block (
3373
- block_root,
3374
- unverified_block,
3375
- notify_execution_layer,
3376
- block_source,
3377
- || Ok ( ( ) ) ,
3378
- )
3379
- . await ;
3380
- self . remove_notified ( & block_root, r)
3381
- }
3382
-
3383
3313
/// Check for known and configured invalid block roots before processing.
3384
3314
pub fn check_invalid_block_roots ( & self , block_root : Hash256 ) -> Result < ( ) , BlockError > {
3385
3315
if self . config . invalid_block_roots . contains ( & block_root) {
@@ -3411,12 +3341,6 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
3411
3341
block_source : BlockImportSource ,
3412
3342
publish_fn : impl FnOnce ( ) -> Result < ( ) , BlockError > ,
3413
3343
) -> Result < AvailabilityProcessingStatus , BlockError > {
3414
- // Start the Prometheus timer.
3415
- let _full_timer = metrics:: start_timer ( & metrics:: BLOCK_PROCESSING_TIMES ) ;
3416
-
3417
- // Increment the Prometheus counter for block processing requests.
3418
- metrics:: inc_counter ( & metrics:: BLOCK_PROCESSING_REQUESTS ) ;
3419
-
3420
3344
let block_slot = unverified_block. block ( ) . slot ( ) ;
3421
3345
3422
3346
// Set observed time if not already set. Usually this should be set by gossip or RPC,
@@ -3431,6 +3355,15 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
3431
3355
) ;
3432
3356
}
3433
3357
3358
+ self . data_availability_checker
3359
+ . put_pre_execution_block ( block_root, unverified_block. block_cloned ( ) ) ?;
3360
+
3361
+ // Start the Prometheus timer.
3362
+ let _full_timer = metrics:: start_timer ( & metrics:: BLOCK_PROCESSING_TIMES ) ;
3363
+
3364
+ // Increment the Prometheus counter for block processing requests.
3365
+ metrics:: inc_counter ( & metrics:: BLOCK_PROCESSING_REQUESTS ) ;
3366
+
3434
3367
// A small closure to group the verification and import errors.
3435
3368
let chain = self . clone ( ) ;
3436
3369
let import_block = async move {
@@ -3448,7 +3381,18 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
3448
3381
. set_time_consensus_verified ( block_root, block_slot, timestamp)
3449
3382
}
3450
3383
3451
- let executed_block = chain. into_executed_block ( execution_pending) . await ?;
3384
+ let executed_block = chain
3385
+ . into_executed_block ( execution_pending)
3386
+ . await
3387
+ . inspect_err ( |_| {
3388
+ // If the block fails execution for whatever reason (e.g. engine offline),
3389
+ // and we keep it in the cache, then the node will NOT perform lookup and
3390
+ // reprocess this block until the block is evicted from DA checker, causing the
3391
+ // chain to get stuck temporarily if the block is canonical. Therefore we remove
3392
+ // it from the cache if execution fails.
3393
+ self . data_availability_checker
3394
+ . remove_block_on_execution_error ( & block_root) ;
3395
+ } ) ?;
3452
3396
3453
3397
// Record the *additional* time it took to wait for execution layer verification.
3454
3398
if let Some ( timestamp) = self . slot_clock . now_duration ( ) {
@@ -3574,9 +3518,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
3574
3518
block : AvailabilityPendingExecutedBlock < T :: EthSpec > ,
3575
3519
) -> Result < AvailabilityProcessingStatus , BlockError > {
3576
3520
let slot = block. block . slot ( ) ;
3577
- let availability = self
3578
- . data_availability_checker
3579
- . put_pending_executed_block ( block) ?;
3521
+ let availability = self . data_availability_checker . put_executed_block ( block) ?;
3580
3522
self . process_availability ( slot, availability, || Ok ( ( ) ) )
3581
3523
. await
3582
3524
}
@@ -7156,12 +7098,6 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
7156
7098
)
7157
7099
}
7158
7100
7159
- pub fn metrics ( & self ) -> BeaconChainMetrics {
7160
- BeaconChainMetrics {
7161
- reqresp_pre_import_cache_len : self . reqresp_pre_import_cache . read ( ) . len ( ) ,
7162
- }
7163
- }
7164
-
7165
7101
pub ( crate ) fn get_blobs_or_columns_store_op (
7166
7102
& self ,
7167
7103
block_root : Hash256 ,
0 commit comments