chore: more misc tracing (#9809)

This commit is contained in:
Matthias Seitz
2024-07-25 18:44:03 +02:00
committed by GitHub
parent 93ebdf292b
commit 05135c41ef
2 changed files with 16 additions and 4 deletions

View File

@@ -515,6 +515,21 @@ pub enum NewCanonicalChain {
}
impl NewCanonicalChain {
/// Returns the length of the new chain.
pub fn new_block_count(&self) -> usize {
match self {
Self::Commit { new } | Self::Reorg { new, .. } => new.len(),
}
}
/// Returns the length of the reorged chain.
pub fn reorged_block_count(&self) -> usize {
match self {
Self::Commit { .. } => 0,
Self::Reorg { old, .. } => old.len(),
}
}
/// Converts the new chain into a notification that will be emitted to listeners
pub fn to_chain_notification(&self) -> CanonStateNotification {
// TODO: do we need to merge execution outcome for multiblock commit or reorg?

View File

@@ -272,9 +272,6 @@ impl EngineApiTreeState {
}
/// The type responsible for processing engine API requests.
///
/// TODO: design: should the engine handler functions also accept the response channel or return the
/// result and the caller redirects the response
pub trait EngineApiTreeHandler {
/// The engine type that this handler is for.
type Engine: EngineTypes;
@@ -1473,7 +1470,7 @@ where
// 2. ensure we can apply a new chain update for the head block
if let Some(chain_update) = self.state.tree_state.on_new_head(state.head_block_hash) {
trace!(target: "engine", "applying new chain update");
trace!(target: "engine", new_blocks = %chain_update.new_block_count(), reorged_blocks = %chain_update.reorged_block_count() ,"applying new chain update");
// update the tracked canonical head
self.state.tree_state.set_canonical_head(chain_update.tip().num_hash());