From e7c1d6219147931101a7c11e629b655d85fc2111 Mon Sep 17 00:00:00 2001 From: nk_ysg Date: Mon, 1 Sep 2025 22:12:53 +0800 Subject: [PATCH] perf(reth-engine-primitives): box CanonicalBlockAdded --- crates/engine/primitives/src/event.rs | 4 ++-- crates/engine/tree/src/tree/mod.rs | 9 ++++++--- crates/ress/provider/src/pending_state.rs | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/crates/engine/primitives/src/event.rs b/crates/engine/primitives/src/event.rs index 7e45b5c73d3..0e70c0b8111 100644 --- a/crates/engine/primitives/src/event.rs +++ b/crates/engine/primitives/src/event.rs @@ -24,11 +24,11 @@ pub enum ConsensusEngineEvent { /// The fork choice state was updated, and the current fork choice status ForkchoiceUpdated(ForkchoiceState, ForkchoiceStatus), /// A block was added to the fork chain. - ForkBlockAdded(ExecutedBlockWithTrieUpdates, Duration), + ForkBlockAdded(Box>, Duration), /// A new block was received from the consensus engine BlockReceived(BlockNumHash), /// A block was added to the canonical chain, and the elapsed time validating the block - CanonicalBlockAdded(ExecutedBlockWithTrieUpdates, Duration), + CanonicalBlockAdded(Box>, Duration), /// A canonical chain was committed, and the elapsed time committing the data CanonicalChainCommitted(Box>, Duration), /// The consensus engine processed an invalid block. diff --git a/crates/engine/tree/src/tree/mod.rs b/crates/engine/tree/src/tree/mod.rs index aad6d6e2742..46bd3d0ad44 100644 --- a/crates/engine/tree/src/tree/mod.rs +++ b/crates/engine/tree/src/tree/mod.rs @@ -1285,7 +1285,10 @@ where self.state.tree_state.insert_executed(block.clone()); self.metrics.engine.inserted_already_executed_blocks.increment(1); self.emit_event(EngineApiEvent::BeaconConsensus( - ConsensusEngineEvent::CanonicalBlockAdded(block, now.elapsed()), + ConsensusEngineEvent::CanonicalBlockAdded( + Box::new(block), + now.elapsed(), + ), )); } EngineApiRequest::Beacon(request) => { @@ -2356,9 +2359,9 @@ where // emit insert event let elapsed = start.elapsed(); let engine_event = if is_fork { - ConsensusEngineEvent::ForkBlockAdded(executed, elapsed) + ConsensusEngineEvent::ForkBlockAdded(Box::new(executed), elapsed) } else { - ConsensusEngineEvent::CanonicalBlockAdded(executed, elapsed) + ConsensusEngineEvent::CanonicalBlockAdded(Box::new(executed), elapsed) }; self.emit_event(EngineApiEvent::BeaconConsensus(engine_event)); diff --git a/crates/ress/provider/src/pending_state.rs b/crates/ress/provider/src/pending_state.rs index e1a84661fc2..e666c4131e0 100644 --- a/crates/ress/provider/src/pending_state.rs +++ b/crates/ress/provider/src/pending_state.rs @@ -104,7 +104,7 @@ pub async fn maintain_pending_state

( ConsensusEngineEvent::CanonicalBlockAdded(block, _) | ConsensusEngineEvent::ForkBlockAdded(block, _) => { trace!(target: "reth::ress_provider", block = ? block.recovered_block().num_hash(), "Insert block into pending state"); - pending_state.insert_block(block); + pending_state.insert_block(*block); } ConsensusEngineEvent::InvalidBlock(block) => { if let Ok(block) = block.try_recover() {