diff --git a/crates/consensus/beacon/src/engine/message.rs b/crates/consensus/beacon/src/engine/message.rs index f58f620b44..04f79b2d4d 100644 --- a/crates/consensus/beacon/src/engine/message.rs +++ b/crates/consensus/beacon/src/engine/message.rs @@ -8,6 +8,7 @@ use reth_rpc_types::engine::{ ForkchoiceUpdateError, ForkchoiceUpdated, PayloadId, PayloadStatus, PayloadStatusEnum, }; use std::{ + fmt::Display, future::Future, pin::Pin, task::{ready, Context, Poll}, @@ -160,3 +161,31 @@ pub enum BeaconEngineMessage { /// Message with exchanged transition configuration. TransitionConfigurationExchanged, } + +impl Display for BeaconEngineMessage { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Self::NewPayload { payload, .. } => { + write!( + f, + "NewPayload(parent: {}, number: {}, hash: {})", + payload.parent_hash(), + payload.block_number(), + payload.block_hash() + ) + } + Self::ForkchoiceUpdated { state, payload_attrs, .. } => { + // we don't want to print the entire payload attributes, because for OP this + // includes all txs + write!( + f, + "ForkchoiceUpdated {{ state: {state:?}, has_payload_attributes: {} }}", + payload_attrs.is_some() + ) + } + Self::TransitionConfigurationExchanged => { + write!(f, "TransitionConfigurationExchanged") + } + } + } +} diff --git a/crates/engine/tree/src/engine.rs b/crates/engine/tree/src/engine.rs index 8fa927d8d0..d2542e1229 100644 --- a/crates/engine/tree/src/engine.rs +++ b/crates/engine/tree/src/engine.rs @@ -12,6 +12,7 @@ use reth_engine_primitives::EngineTypes; use reth_primitives::{SealedBlockWithSenders, B256}; use std::{ collections::HashSet, + fmt::Display, sync::mpsc::Sender, task::{ready, Context, Poll}, }; @@ -228,6 +229,17 @@ pub enum EngineApiRequest { InsertExecutedBlock(ExecutedBlock), } +impl Display for EngineApiRequest { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Self::Beacon(msg) => msg.fmt(f), + Self::InsertExecutedBlock(block) => { + write!(f, "InsertExecutedBlock({:?})", block.block().num_hash()) + } + } + } +} + impl From> for EngineApiRequest { fn from(msg: BeaconEngineMessage) -> Self { Self::Beacon(msg) @@ -276,6 +288,18 @@ pub enum FromEngine { DownloadedBlocks(Vec), } +impl Display for FromEngine { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Self::Event(ev) => write!(f, "Event({ev:?})"), + Self::Request(req) => write!(f, "Request({req})"), + Self::DownloadedBlocks(blocks) => { + write!(f, "DownloadedBlocks({} blocks)", blocks.len()) + } + } + } +} + impl From for FromEngine { fn from(event: FromOrchestrator) -> Self { Self::Event(event) diff --git a/crates/engine/tree/src/tree/mod.rs b/crates/engine/tree/src/tree/mod.rs index ef7ce66c7b..a4f6228030 100644 --- a/crates/engine/tree/src/tree/mod.rs +++ b/crates/engine/tree/src/tree/mod.rs @@ -631,7 +631,7 @@ where loop { match self.try_recv_engine_message() { Ok(Some(msg)) => { - debug!(target: "engine::tree", ?msg, "received new engine message"); + debug!(target: "engine::tree", %msg, "received new engine message"); if let Err(fatal) = self.on_engine_message(msg) { error!(target: "engine::tree", %fatal, "insert block fatal error"); return