Skip to content
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

feat(tree): introduce reorg count metrics in new engine #11226

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions crates/engine/tree/src/tree/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1949,6 +1949,7 @@ where
let old_first = old.first().map(|first| first.block.num_hash());
trace!(target: "engine::tree", ?new_first, ?old_first, "Reorg detected, new and old first blocks");

self.update_reorg_metrics(old.len());
self.reinsert_reorged_blocks(new.clone());
self.reinsert_reorged_blocks(old.clone());
}
Expand All @@ -1970,6 +1971,12 @@ where
));
}

/// This updates metrics based on the given reorg length.
fn update_reorg_metrics(&self, old_chain_length: usize) {
self.metrics.tree.reorgs.increment(1);
self.metrics.tree.latest_reorg_depth.set(old_chain_length as f64);
}

/// This reinserts any blocks in the new chain that do not already exist in the tree
fn reinsert_reorged_blocks(&mut self, new_chain: Vec<ExecutedBlock>) {
for block in new_chain {
Expand Down
Loading