Record metrics for only valid gossip blocks (#8723)

N/A


  Fixes the issue where we were setting block observed timings for blocks that were potentially gossip invalid.
Thanks @gitToki for the find


Co-Authored-By: Pawan Dhananjay <pawandhananjay@gmail.com>

Co-Authored-By: Michael Sproul <michaelsproul@users.noreply.github.com>
This commit is contained in:
Pawan Dhananjay
2026-02-09 10:53:44 +05:30
committed by GitHub
parent c4437d2927
commit b8d098685f

View File

@@ -1214,27 +1214,24 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
.verify_block_for_gossip(block.clone()) .verify_block_for_gossip(block.clone())
.await; .await;
if verification_result.is_ok() { let block_root = if let Ok(verified_block) = &verification_result {
metrics::set_gauge( metrics::set_gauge(
&metrics::BEACON_BLOCK_DELAY_GOSSIP, &metrics::BEACON_BLOCK_DELAY_GOSSIP,
block_delay.as_millis() as i64, block_delay.as_millis() as i64,
); );
} // Write the time the block was observed into delay cache only for gossip
// valid blocks.
let block_root = if let Ok(verified_block) = &verification_result {
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( self.chain.block_times_cache.write().set_time_observed(
block_root, verified_block.block_root,
block.slot(), block.slot(),
seen_duration, seen_duration,
Some(peer_id.to_string()), Some(peer_id.to_string()),
Some(peer_client.to_string()), Some(peer_client.to_string()),
); );
verified_block.block_root
} else {
block.canonical_root()
};
let verified_block = match verification_result { let verified_block = match verification_result {
Ok(verified_block) => { Ok(verified_block) => {