Skip to content

Commit 41ed7e0

Browse files
authored
feat: Add info logs for beginning of newPayload requests (paradigmxyz#16463)
1 parent a201676 commit 41ed7e0

File tree

7 files changed

+32
-0
lines changed

7 files changed

+32
-0
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/engine/primitives/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ reth-trie-common.workspace = true
2626
alloy-primitives.workspace = true
2727
alloy-consensus.workspace = true
2828
alloy-rpc-types-engine.workspace = true
29+
alloy-eips.workspace = true
2930

3031
# async
3132
tokio = { workspace = true, features = ["sync"] }
@@ -46,6 +47,7 @@ std = [
4647
"alloy-primitives/std",
4748
"alloy-consensus/std",
4849
"alloy-rpc-types-engine/std",
50+
"alloy-eips/std",
4951
"futures/std",
5052
"serde/std",
5153
"thiserror/std",

crates/engine/primitives/src/event.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
use crate::ForkchoiceStatus;
44
use alloc::boxed::Box;
55
use alloy_consensus::BlockHeader;
6+
use alloy_eips::BlockNumHash;
67
use alloy_primitives::B256;
78
use alloy_rpc_types_engine::ForkchoiceState;
89
use core::{
@@ -20,6 +21,8 @@ pub enum BeaconConsensusEngineEvent<N: NodePrimitives = EthPrimitives> {
2021
ForkchoiceUpdated(ForkchoiceState, ForkchoiceStatus),
2122
/// A block was added to the fork chain.
2223
ForkBlockAdded(ExecutedBlockWithTrieUpdates<N>, Duration),
24+
/// A new block was received from the consensus engine
25+
BlockReceived(BlockNumHash),
2326
/// A block was added to the canonical chain, and the elapsed time validating the block
2427
CanonicalBlockAdded(ExecutedBlockWithTrieUpdates<N>, Duration),
2528
/// A canonical chain was committed, and the elapsed time committing the data
@@ -69,6 +72,9 @@ where
6972
Self::LiveSyncProgress(progress) => {
7073
write!(f, "LiveSyncProgress({progress:?})")
7174
}
75+
Self::BlockReceived(num_hash) => {
76+
write!(f, "BlockReceived({num_hash:?})")
77+
}
7278
}
7379
}
7480
}

crates/engine/tree/src/tree/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,10 @@ where
571571
}
572572
};
573573

574+
let num_hash = block.num_hash();
575+
let engine_event = BeaconConsensusEngineEvent::BlockReceived(num_hash);
576+
self.emit_event(EngineApiEvent::BeaconConsensus(engine_event));
577+
574578
let block_hash = block.hash();
575579
let mut lowest_buffered_ancestor = self.lowest_buffered_ancestor_or(block_hash);
576580
if lowest_buffered_ancestor == block_hash {

crates/engine/tree/src/tree/tests.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,18 @@ impl TestHarness {
349349
}
350350
}
351351

352+
async fn check_block_received(&mut self, hash: B256) {
353+
let event = self.from_tree_rx.recv().await.unwrap();
354+
match event {
355+
EngineApiEvent::BeaconConsensus(BeaconConsensusEngineEvent::BlockReceived(
356+
num_hash,
357+
)) => {
358+
assert_eq!(num_hash.hash, hash);
359+
}
360+
_ => panic!("Unexpected event: {event:#?}"),
361+
}
362+
}
363+
352364
fn persist_blocks(&self, blocks: Vec<RecoveredBlock<reth_ethereum_primitives::Block>>) {
353365
let mut block_data: Vec<(B256, Block)> = Vec::with_capacity(blocks.len());
354366
let mut headers_data: Vec<(B256, Header)> = Vec::with_capacity(blocks.len());
@@ -1137,6 +1149,9 @@ async fn test_engine_tree_buffered_blocks_are_eventually_connected() {
11371149
assert!(test_harness.tree.state.buffer.block(&buffered_block_hash).is_none());
11381150

11391151
// both blocks are added to the canon chain in order
1152+
// note that the buffered block is received first, but added last
1153+
test_harness.check_block_received(buffered_block_hash).await;
1154+
test_harness.check_block_received(non_buffered_block_hash).await;
11401155
test_harness.check_canon_block_added(non_buffered_block_hash).await;
11411156
test_harness.check_canon_block_added(buffered_block_hash).await;
11421157
}

crates/node/events/src/node.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,9 @@ impl NodeState {
280280
BeaconConsensusEngineEvent::InvalidBlock(block) => {
281281
warn!(number=block.number(), hash=?block.hash(), "Encountered invalid block");
282282
}
283+
BeaconConsensusEngineEvent::BlockReceived(num_hash) => {
284+
info!(number=num_hash.number, hash=?num_hash.hash, "Received block from consensus engine");
285+
}
283286
}
284287
}
285288

crates/ress/provider/src/pending_state.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ pub async fn maintain_pending_state<P>(
123123
}
124124
// ignore
125125
BeaconConsensusEngineEvent::CanonicalChainCommitted(_, _) |
126+
BeaconConsensusEngineEvent::BlockReceived(_) |
126127
BeaconConsensusEngineEvent::LiveSyncProgress(_) => (),
127128
}
128129
}

0 commit comments

Comments
 (0)