Skip to content

Refine delayed head block logging #7705

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: unstable
Choose a base branch
from

Conversation

michaelsproul
Copy link
Member

Proposed Changes

Small tweak to Delayed head block logging to make it more representative of actual issues. Previously we used the total import delay to determine whether a block was late, but this includes the time taken for IO (and now hdiff computation) which happens after the block is made attestable.

This PR changes the logic to use the attestable delay (where possible) falling back to the previous value if the block doesn't have one; e.g. if it didn't meet the conditions to make it into the attestable cache.

Additional Info

I've also applied some refactors and simplifications related to the relocation of the late_head variable.

I got rid of some raw SystemTime usage as well, which improves repeatability of test cases by removing realtime variability. In production it should be exactly equivalent.

@michaelsproul michaelsproul added ready-for-review The code is ready for review low-hanging-fruit Easy to resolve, get it before someone else does! UX-and-logs labels Jul 7, 2025
@michaelsproul michaelsproul requested a review from chong-he July 15, 2025 01:40
Copy link
Member

@chong-he chong-he left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! The code is a bit more simplified, and all changes are good.

No changes required in my opinion

Comment on lines -1457 to -1462
let block_delays = block_times_cache.get_block_delays(
head_block_root,
slot_clock
.start_of(head_block_slot)
.unwrap_or_else(|| Duration::from_secs(0)),
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good simplification, because block_delays was already defined above

@@ -1432,6 +1439,24 @@ fn observe_head_block_delays<E: EthSpec, S: SlotClock>(
set_as_head_time_ms = format_delay(&block_delays.set_as_head),
"Delayed head block"
);
if let Some(event_handler) = event_handler {
if event_handler.has_late_head_subscribers() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Because it is already in the if !block_from_sync{} and now it's put in if late_head{} arm, so the condition becomes simpler

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
low-hanging-fruit Easy to resolve, get it before someone else does! ready-for-review The code is ready for review UX-and-logs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants