diff --git a/beacon_node/network/src/network_beacon_processor/gossip_methods.rs b/beacon_node/network/src/network_beacon_processor/gossip_methods.rs index 61937253233..a4125f3df07 100644 --- a/beacon_node/network/src/network_beacon_processor/gossip_methods.rs +++ b/beacon_node/network/src/network_beacon_processor/gossip_methods.rs @@ -1214,28 +1214,25 @@ impl NetworkBeaconProcessor { .verify_block_for_gossip(block.clone()) .await; - if verification_result.is_ok() { + let block_root = if let Ok(verified_block) = &verification_result { metrics::set_gauge( &metrics::BEACON_BLOCK_DELAY_GOSSIP, block_delay.as_millis() as i64, ); - } - - let block_root = if let Ok(verified_block) = &verification_result { + // Write the time the block was observed into delay cache only for gossip + // valid blocks. + self.chain.block_times_cache.write().set_time_observed( + verified_block.block_root, + block.slot(), + seen_duration, + Some(peer_id.to_string()), + Some(peer_client.to_string()), + ); verified_block.block_root } else { block.canonical_root() }; - // Write the time the block was observed into delay cache. - self.chain.block_times_cache.write().set_time_observed( - block_root, - block.slot(), - seen_duration, - Some(peer_id.to_string()), - Some(peer_client.to_string()), - ); - let verified_block = match verification_result { Ok(verified_block) => { if block_delay >= self.chain.spec.get_unaggregated_attestation_due() {