Skip to content

feat(engine/metrics): add latest valid fcu#20628

Closed
figtracer wants to merge 3 commits intoparadigmxyz:mainfrom
figtracer:track_last_valid_state_fcu
Closed

feat(engine/metrics): add latest valid fcu#20628
figtracer wants to merge 3 commits intoparadigmxyz:mainfrom
figtracer:track_last_valid_state_fcu

Conversation

@figtracer
Copy link
Contributor

Copy link
Member

@Rjected Rjected left a comment

Choose a reason for hiding this comment

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

Should have specified this better in the issue, but I don't think it's useful to have the hash bits as a gauge. We should instead have a number for the latest valid fcu head / safe / finalized

@github-project-automation github-project-automation bot moved this from Backlog to In Progress in Reth Tracker Dec 24, 2025
@figtracer
Copy link
Contributor Author

Should have specified this better in the issue, but I don't think it's useful to have the hash bits as a gauge. We should instead have a number for the latest valid fcu head / safe / finalized

on it

@figtracer
Copy link
Contributor Author

this will run if fcu is invalid as well, but ig it's not that relevant

Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

not perfectly clear to me what the use case for this is

We should track these in metrics, so that we can see what the latest valid state is without logs

the last valid tags would track:

/// Tracks the number of the `canonical_head`.
canonical_head_number: AtomicU64,
/// The canonical head of the chain.
canonical_head: RwLock<SealedHeader<N::BlockHeader>>,
/// The block that the beacon node considers safe.
safe_block: watch::Sender<Option<SealedHeader<N::BlockHeader>>>,
/// The block that the beacon node considers finalized.
finalized_block: watch::Sender<Option<SealedHeader<N::BlockHeader>>>,

so perhaps we add the metrics there instead?

if let Some(last_valid) =
self.state.forkchoice_state_tracker.last_valid_state()
{
let block_num = |hash| {
Copy link
Collaborator

Choose a reason for hiding this comment

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

his now most likely always goes to disk for the finalized/safe block, before we send the respond

we need to avoid this

we already track the finalized/safe/head block, unsure what the use case for these metrics are here

is this just for tracking what we receive as fcu or what we actually have as finalized/safe/head @Rjected ?

because we already have:

/// Sets the canonical head of the chain.
pub fn set_canonical_head(&self, header: SealedHeader<N::BlockHeader>) {
let number = header.number();
*self.inner.canonical_head.write() = header;
// also update the atomic number.
self.inner.canonical_head_number.store(number, Ordering::Relaxed);
}
/// Sets the safe header of the chain.
pub fn set_safe(&self, header: SealedHeader<N::BlockHeader>) {
self.inner.safe_block.send_if_modified(|current_header| {
if current_header.as_ref().map(SealedHeader::hash) != Some(header.hash()) {
let _ = current_header.replace(header);
return true
}
false
});
}
/// Sets the finalized header of the chain.
pub fn set_finalized(&self, header: SealedHeader<N::BlockHeader>) {
self.inner.finalized_block.send_if_modified(|current_header| {
if current_header.as_ref().map(SealedHeader::hash) != Some(header.hash()) {
let _ = current_header.replace(header);
return true
}
false
});
}

@figtracer figtracer closed this by deleting the head repository Jan 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

3 participants