From ae4be80cd596edf647165947433c9abc59f8b147 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 2 Aug 2024 13:12:29 +0200 Subject: [PATCH] chore: better tree observability (#10014) --- crates/engine/tree/src/tree/mod.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/crates/engine/tree/src/tree/mod.rs b/crates/engine/tree/src/tree/mod.rs index f182c4ac5f..8a598fb2d6 100644 --- a/crates/engine/tree/src/tree/mod.rs +++ b/crates/engine/tree/src/tree/mod.rs @@ -1255,6 +1255,7 @@ where /// Returns an event with the appropriate action to take, such as: /// - download more missing blocks /// - try to canonicalize the target if the `block` is the tracked target (head) block. + #[instrument(level = "trace", skip_all, fields(block_hash = %block.hash(), block_num = %block.number,), target = "engine")] fn on_downloaded_block(&mut self, block: SealedBlockWithSenders) -> Option { let block_num_hash = block.num_hash(); let lowest_buffered_ancestor = self.lowest_buffered_ancestor_or(block_num_hash.hash); @@ -1274,19 +1275,27 @@ where match self.insert_block(block) { Ok(InsertPayloadOk::Inserted(BlockStatus::Valid(_))) => { if self.is_sync_target_head(block_num_hash.hash) { + trace!(target: "engine", "appended downloaded sync target block"); // we just inserted the current sync target block, we can try to make it // canonical return Some(TreeEvent::TreeAction(TreeAction::MakeCanonical( block_num_hash.hash, ))) } + trace!(target: "engine", "appended downloaded block"); + self.try_connect_buffered_blocks(block_num_hash); } Ok(InsertPayloadOk::Inserted(BlockStatus::Disconnected { head, missing_ancestor })) => { // block is not connected to the canonical head, we need to download // its missing branch first return self.on_disconnected_downloaded_block(block_num_hash, missing_ancestor, head) } - _ => {} + Ok(InsertPayloadOk::AlreadySeen(_)) => { + trace!(target: "engine", "downloaded block already executed"); + } + Err(err) => { + debug!(target: "engine", err=%err.kind(), "failed to insert downloaded block"); + } } None } @@ -1818,6 +1827,7 @@ where }; let target = self.lowest_buffered_ancestor_or(target); + trace!(target: "engine", %target, "downloading missing block"); Ok(TreeOutcome::new(OnForkChoiceUpdated::valid(PayloadStatus::from_status( PayloadStatusEnum::Syncing,