feat(engine): emit events with executed blocks (#14341)

This commit is contained in:
Roman Krasiuk
2025-02-09 12:07:10 +01:00
committed by GitHub
parent 46d3b6a32e
commit a215256075
6 changed files with 41 additions and 41 deletions

View File

@ -17,6 +17,7 @@ reth-payload-primitives.workspace = true
reth-payload-builder-primitives.workspace = true
reth-primitives.workspace = true
reth-primitives-traits.workspace = true
reth-chain-state.workspace = true
reth-trie.workspace = true
reth-errors.workspace = true

View File

@ -1,7 +1,7 @@
//! Events emitted by the beacon consensus engine.
use crate::ForkchoiceStatus;
use alloc::{boxed::Box, sync::Arc};
use alloc::boxed::Box;
use alloy_consensus::BlockHeader;
use alloy_primitives::B256;
use alloy_rpc_types_engine::ForkchoiceState;
@ -9,7 +9,8 @@ use core::{
fmt::{Display, Formatter, Result},
time::Duration,
};
use reth_primitives::{EthPrimitives, SealedBlock};
use reth_chain_state::ExecutedBlockWithTrieUpdates;
use reth_primitives::EthPrimitives;
use reth_primitives_traits::{NodePrimitives, SealedHeader};
/// Events emitted by the consensus engine.
@ -18,9 +19,9 @@ pub enum BeaconConsensusEngineEvent<N: NodePrimitives = EthPrimitives> {
/// The fork choice state was updated, and the current fork choice status
ForkchoiceUpdated(ForkchoiceState, ForkchoiceStatus),
/// A block was added to the fork chain.
ForkBlockAdded(Arc<SealedBlock<N::Block>>, Duration),
ForkBlockAdded(ExecutedBlockWithTrieUpdates<N>, Duration),
/// A block was added to the canonical chain, and the elapsed time validating the block
CanonicalBlockAdded(Arc<SealedBlock<N::Block>>, Duration),
CanonicalBlockAdded(ExecutedBlockWithTrieUpdates<N>, Duration),
/// A canonical chain was committed, and the elapsed time committing the data
CanonicalChainCommitted(Box<SealedHeader<N::BlockHeader>>, Duration),
/// The consensus engine is involved in live sync, and has specific progress
@ -48,10 +49,14 @@ where
write!(f, "ForkchoiceUpdated({state:?}, {status:?})")
}
Self::ForkBlockAdded(block, duration) => {
write!(f, "ForkBlockAdded({:?}, {duration:?})", block.num_hash())
write!(f, "ForkBlockAdded({:?}, {duration:?})", block.recovered_block.num_hash())
}
Self::CanonicalBlockAdded(block, duration) => {
write!(f, "CanonicalBlockAdded({:?}, {duration:?})", block.num_hash())
write!(
f,
"CanonicalBlockAdded({:?}, {duration:?})",
block.recovered_block.num_hash()
)
}
Self::CanonicalChainCommitted(block, duration) => {
write!(f, "CanonicalChainCommitted({:?}, {duration:?})", block.num_hash())

View File

@ -11,14 +11,21 @@
extern crate alloc;
use alloy_primitives::B256;
use reth_payload_primitives::{BuiltPayload, PayloadAttributes};
mod error;
use core::fmt::{self, Debug};
use alloy_consensus::BlockHeader;
use alloy_eips::{eip7685::Requests, Decodable2718};
use alloy_primitives::B256;
use alloy_rpc_types_engine::{ExecutionPayloadSidecar, PayloadError};
use core::fmt::{self, Debug};
use reth_payload_primitives::{
validate_execution_requests, BuiltPayload, EngineApiMessageVersion,
EngineObjectValidationError, InvalidPayloadAttributesError, PayloadAttributes,
PayloadOrAttributes, PayloadTypes,
};
use reth_primitives::{NodePrimitives, SealedBlock};
use reth_primitives_traits::Block;
use serde::{de::DeserializeOwned, Deserialize, Serialize};
mod error;
pub use error::*;
mod forkchoice;
@ -33,15 +40,6 @@ pub use event::*;
mod invalid_block_hook;
pub use invalid_block_hook::InvalidBlockHook;
use alloy_eips::{eip7685::Requests, Decodable2718};
use reth_payload_primitives::{
validate_execution_requests, EngineApiMessageVersion, EngineObjectValidationError,
InvalidPayloadAttributesError, PayloadOrAttributes, PayloadTypes,
};
use reth_primitives::{NodePrimitives, SealedBlock};
use reth_primitives_traits::Block;
use serde::{de::DeserializeOwned, Deserialize, Serialize};
/// Struct aggregating [`alloy_rpc_types_engine::ExecutionPayload`] and [`ExecutionPayloadSidecar`]
/// and encapsulating complete payload supplied for execution.
#[derive(Debug, Clone, Serialize, Deserialize)]