From 26d0a99a7b7871c2fa6977df28621eba97d8bf0c Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Sun, 24 May 2026 17:13:46 +0300 Subject: [PATCH] cleanup --- beacon_node/beacon_chain/src/canonical_head.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/beacon_node/beacon_chain/src/canonical_head.rs b/beacon_node/beacon_chain/src/canonical_head.rs index ba89703fb9..258fffdc13 100644 --- a/beacon_node/beacon_chain/src/canonical_head.rs +++ b/beacon_node/beacon_chain/src/canonical_head.rs @@ -190,12 +190,21 @@ impl CachedHead { /// Returns the execution block number of the block at the head of the chain. /// /// Returns an error if the chain is prior to Gloas. - pub fn head_block_number_gloas(&self) -> Result { - self.snapshot + pub fn head_block_number_gloas(&self) -> Option { + if let Some(head_block_number) = self + .snapshot .execution_envelope .as_ref() .map(|envelope| envelope.message.payload.block_number) - .ok() + { + Some(head_block_number) + } else { + // This fallback is strictly for the fork boundary case when self.snapshot.execution_envelope is `None`. + // Note: If there is a missed/orphaned envelope at the fork boundary we wont be able to get the block number using this fallback. + // We could try handling that edge case but it doesn't seem worth it. Returning `None` here just means that we don't + // emit a payload attributes SSE event further upstream. + self.head_block_number().ok() + } } /// Returns the active validator count for the current epoch of the head state.