From 412f39e2232eaedaf2b2647c12be4e2ba2e50786 Mon Sep 17 00:00:00 2001 From: Emilia Hane Date: Thu, 8 Jan 2026 16:54:31 +0100 Subject: [PATCH] chore(consensus): Remove associated type `Consensus::Error` (#20843) Co-authored-by: Josh_dfG <126518346+JoshdfG@users.noreply.github.com> --- crates/cli/commands/src/import_core.rs | 6 ++---- .../cli/commands/src/stage/dump/execution.rs | 6 +++--- crates/cli/commands/src/stage/dump/merkle.rs | 6 +++--- crates/consensus/consensus/src/lib.rs | 7 ++----- crates/consensus/consensus/src/noop.rs | 6 ++---- crates/consensus/consensus/src/test_utils.rs | 6 ++---- crates/engine/service/src/service.rs | 4 ++-- crates/engine/tree/src/download.rs | 4 ++-- crates/engine/tree/src/tree/mod.rs | 6 +++--- .../engine/tree/src/tree/payload_validator.rs | 4 ++-- crates/ethereum/consensus/src/lib.rs | 6 ++---- crates/net/downloaders/src/bodies/bodies.rs | 6 +++--- crates/net/downloaders/src/bodies/queue.rs | 4 ++-- crates/net/downloaders/src/bodies/request.rs | 6 +++--- crates/net/downloaders/src/bodies/task.rs | 4 ++-- crates/net/downloaders/src/file_client.rs | 8 ++++---- crates/net/p2p/src/full_block.rs | 13 +++++------- crates/node/api/src/node.rs | 7 ++----- crates/node/builder/src/components/builder.rs | 5 ++--- .../node/builder/src/components/consensus.rs | 10 +++------- crates/node/builder/src/components/mod.rs | 10 +++------- crates/node/builder/src/setup.rs | 6 +++--- crates/node/core/src/utils.rs | 4 ++-- crates/optimism/consensus/src/lib.rs | 2 -- crates/rpc/rpc-builder/src/lib.rs | 6 +++--- crates/rpc/rpc/src/validation.rs | 4 ++-- crates/stages/stages/src/lib.rs | 4 ++-- crates/stages/stages/src/sets.rs | 20 +++++++++---------- crates/stages/stages/src/stages/execution.rs | 10 +++++----- 29 files changed, 81 insertions(+), 109 deletions(-) diff --git a/crates/cli/commands/src/import_core.rs b/crates/cli/commands/src/import_core.rs index 98f888bb9e..b5bf55a6b5 100644 --- a/crates/cli/commands/src/import_core.rs +++ b/crates/cli/commands/src/import_core.rs @@ -69,9 +69,7 @@ pub async fn import_blocks_from_file( provider_factory: ProviderFactory, config: &Config, executor: impl ConfigureEvm + 'static, - consensus: Arc< - impl FullConsensus + 'static, - >, + consensus: Arc + 'static>, ) -> eyre::Result where N: ProviderNodeTypes, @@ -198,7 +196,7 @@ pub fn build_import_pipeline_impl( ) -> eyre::Result<(Pipeline, impl futures::Stream> + use)> where N: ProviderNodeTypes, - C: FullConsensus + 'static, + C: FullConsensus + 'static, E: ConfigureEvm + 'static, { if !file_client.has_canonical_blocks() { diff --git a/crates/cli/commands/src/stage/dump/execution.rs b/crates/cli/commands/src/stage/dump/execution.rs index dafbf7c31a..14d07ec3cc 100644 --- a/crates/cli/commands/src/stage/dump/execution.rs +++ b/crates/cli/commands/src/stage/dump/execution.rs @@ -1,5 +1,5 @@ use super::setup; -use reth_consensus::{noop::NoopConsensus, ConsensusError, FullConsensus}; +use reth_consensus::{noop::NoopConsensus, FullConsensus}; use reth_db::DatabaseEnv; use reth_db_api::{ cursor::DbCursorRO, database::Database, table::TableImporter, tables, transaction::DbTx, @@ -28,7 +28,7 @@ pub(crate) async fn dump_execution_stage( where N: ProviderNodeTypes>, E: ConfigureEvm + 'static, - C: FullConsensus + 'static, + C: FullConsensus + 'static, { let (output_db, tip_block_number) = setup(from, to, &output_datadir.db(), db_tool)?; @@ -169,7 +169,7 @@ fn dry_run( where N: ProviderNodeTypes, E: ConfigureEvm + 'static, - C: FullConsensus + 'static, + C: FullConsensus + 'static, { info!(target: "reth::cli", "Executing stage. [dry-run]"); diff --git a/crates/cli/commands/src/stage/dump/merkle.rs b/crates/cli/commands/src/stage/dump/merkle.rs index 40b9ad086c..dab8f38cb5 100644 --- a/crates/cli/commands/src/stage/dump/merkle.rs +++ b/crates/cli/commands/src/stage/dump/merkle.rs @@ -4,7 +4,7 @@ use super::setup; use alloy_primitives::{Address, BlockNumber}; use eyre::Result; use reth_config::config::EtlConfig; -use reth_consensus::{ConsensusError, FullConsensus}; +use reth_consensus::FullConsensus; use reth_db::DatabaseEnv; use reth_db_api::{database::Database, models::BlockNumberAddress, table::TableImporter, tables}; use reth_db_common::DbTool; @@ -31,7 +31,7 @@ pub(crate) async fn dump_merkle_stage( output_datadir: ChainPath, should_run: bool, evm_config: impl ConfigureEvm, - consensus: impl FullConsensus + 'static, + consensus: impl FullConsensus + 'static, ) -> Result<()> where N: ProviderNodeTypes>, @@ -79,7 +79,7 @@ fn unwind_and_copy( tip_block_number: u64, output_db: &DatabaseEnv, evm_config: impl ConfigureEvm, - consensus: impl FullConsensus + 'static, + consensus: impl FullConsensus + 'static, ) -> eyre::Result<()> { let (from, to) = range; let provider = db_tool.provider_factory.database_provider_rw()?; diff --git a/crates/consensus/consensus/src/lib.rs b/crates/consensus/consensus/src/lib.rs index a58bcc9b1d..17ab7b87bf 100644 --- a/crates/consensus/consensus/src/lib.rs +++ b/crates/consensus/consensus/src/lib.rs @@ -49,15 +49,12 @@ pub trait FullConsensus: Consensus { /// Consensus is a protocol that chooses canonical chain. #[auto_impl::auto_impl(&, Arc)] pub trait Consensus: HeaderValidator { - /// The error type related to consensus. - type Error; - /// Ensures that body field values match the header. fn validate_body_against_header( &self, body: &B::Body, header: &SealedHeader, - ) -> Result<(), Self::Error>; + ) -> Result<(), ConsensusError>; /// Validate a block disregarding world state, i.e. things that can be checked before sender /// recovery and execution. @@ -69,7 +66,7 @@ pub trait Consensus: HeaderValidator { /// **This should not be called for the genesis block**. /// /// Note: validating blocks does not include other validations of the Consensus - fn validate_block_pre_execution(&self, block: &SealedBlock) -> Result<(), Self::Error>; + fn validate_block_pre_execution(&self, block: &SealedBlock) -> Result<(), ConsensusError>; } /// `HeaderValidator` is a protocol that validates headers and their relationships. diff --git a/crates/consensus/consensus/src/noop.rs b/crates/consensus/consensus/src/noop.rs index 3d6818ca30..3e3341769d 100644 --- a/crates/consensus/consensus/src/noop.rs +++ b/crates/consensus/consensus/src/noop.rs @@ -55,19 +55,17 @@ impl HeaderValidator for NoopConsensus { } impl Consensus for NoopConsensus { - type Error = ConsensusError; - /// Validates body against header (no-op implementation). fn validate_body_against_header( &self, _body: &B::Body, _header: &SealedHeader, - ) -> Result<(), Self::Error> { + ) -> Result<(), ConsensusError> { Ok(()) } /// Validates block before execution (no-op implementation). - fn validate_block_pre_execution(&self, _block: &SealedBlock) -> Result<(), Self::Error> { + fn validate_block_pre_execution(&self, _block: &SealedBlock) -> Result<(), ConsensusError> { Ok(()) } } diff --git a/crates/consensus/consensus/src/test_utils.rs b/crates/consensus/consensus/src/test_utils.rs index ad881cc9a7..94a178abde 100644 --- a/crates/consensus/consensus/src/test_utils.rs +++ b/crates/consensus/consensus/src/test_utils.rs @@ -61,13 +61,11 @@ impl FullConsensus for TestConsensus { } impl Consensus for TestConsensus { - type Error = ConsensusError; - fn validate_body_against_header( &self, _body: &B::Body, _header: &SealedHeader, - ) -> Result<(), Self::Error> { + ) -> Result<(), ConsensusError> { if self.fail_body_against_header() { Err(ConsensusError::BaseFeeMissing) } else { @@ -75,7 +73,7 @@ impl Consensus for TestConsensus { } } - fn validate_block_pre_execution(&self, _block: &SealedBlock) -> Result<(), Self::Error> { + fn validate_block_pre_execution(&self, _block: &SealedBlock) -> Result<(), ConsensusError> { if self.fail_validation() { Err(ConsensusError::BaseFeeMissing) } else { diff --git a/crates/engine/service/src/service.rs b/crates/engine/service/src/service.rs index ff9eb66f10..cd4fbd6b00 100644 --- a/crates/engine/service/src/service.rs +++ b/crates/engine/service/src/service.rs @@ -1,7 +1,7 @@ use futures::{Stream, StreamExt}; use pin_project::pin_project; use reth_chainspec::EthChainSpec; -use reth_consensus::{ConsensusError, FullConsensus}; +use reth_consensus::FullConsensus; use reth_engine_primitives::{BeaconEngineMessage, ConsensusEngineEvent}; use reth_engine_tree::{ backfill::PipelineSync, @@ -70,7 +70,7 @@ where /// Constructor for `EngineService`. #[expect(clippy::too_many_arguments)] pub fn new( - consensus: Arc>, + consensus: Arc>, chain_spec: Arc, client: Client, incoming_requests: EngineMessageStream, diff --git a/crates/engine/tree/src/download.rs b/crates/engine/tree/src/download.rs index 5ffc23740c..d7c0843132 100644 --- a/crates/engine/tree/src/download.rs +++ b/crates/engine/tree/src/download.rs @@ -4,7 +4,7 @@ use crate::{engine::DownloadRequest, metrics::BlockDownloaderMetrics}; use alloy_consensus::BlockHeader; use alloy_primitives::B256; use futures::FutureExt; -use reth_consensus::{Consensus, ConsensusError}; +use reth_consensus::Consensus; use reth_network_p2p::{ full_block::{FetchFullBlockFuture, FetchFullBlockRangeFuture, FullBlockClient}, BlockClient, @@ -81,7 +81,7 @@ where B: Block, { /// Create a new instance - pub fn new(client: Client, consensus: Arc>) -> Self { + pub fn new(client: Client, consensus: Arc>) -> Self { Self { full_block_client: FullBlockClient::new(client, consensus), inflight_full_block_requests: Vec::new(), diff --git a/crates/engine/tree/src/tree/mod.rs b/crates/engine/tree/src/tree/mod.rs index 5ba703ff8d..8a222cf411 100644 --- a/crates/engine/tree/src/tree/mod.rs +++ b/crates/engine/tree/src/tree/mod.rs @@ -234,7 +234,7 @@ where C: ConfigureEvm + 'static, { provider: P, - consensus: Arc>, + consensus: Arc>, payload_validator: V, /// Keeps track of internals such as executed and buffered blocks. state: EngineApiTreeState, @@ -320,7 +320,7 @@ where #[expect(clippy::too_many_arguments)] pub fn new( provider: P, - consensus: Arc>, + consensus: Arc>, payload_validator: V, outgoing: UnboundedSender>, state: EngineApiTreeState, @@ -362,7 +362,7 @@ where #[expect(clippy::complexity)] pub fn spawn_new( provider: P, - consensus: Arc>, + consensus: Arc>, payload_validator: V, persistence: PersistenceHandle, payload_builder: PayloadBuilderHandle, diff --git a/crates/engine/tree/src/tree/payload_validator.rs b/crates/engine/tree/src/tree/payload_validator.rs index a067da4798..0df75e4e97 100644 --- a/crates/engine/tree/src/tree/payload_validator.rs +++ b/crates/engine/tree/src/tree/payload_validator.rs @@ -111,7 +111,7 @@ where /// Provider for database access. provider: P, /// Consensus implementation for validation. - consensus: Arc>, + consensus: Arc>, /// EVM configuration. evm_config: Evm, /// Configuration for the tree. @@ -155,7 +155,7 @@ where #[allow(clippy::too_many_arguments)] pub fn new( provider: P, - consensus: Arc>, + consensus: Arc>, evm_config: Evm, validator: V, config: TreeConfig, diff --git a/crates/ethereum/consensus/src/lib.rs b/crates/ethereum/consensus/src/lib.rs index 9d89b4a73d..ad90a14cc6 100644 --- a/crates/ethereum/consensus/src/lib.rs +++ b/crates/ethereum/consensus/src/lib.rs @@ -84,17 +84,15 @@ where B: Block, ChainSpec: EthChainSpec
+ EthereumHardforks + Debug + Send + Sync, { - type Error = ConsensusError; - fn validate_body_against_header( &self, body: &B::Body, header: &SealedHeader, - ) -> Result<(), Self::Error> { + ) -> Result<(), ConsensusError> { validate_body_against_header(body, header.header()) } - fn validate_block_pre_execution(&self, block: &SealedBlock) -> Result<(), Self::Error> { + fn validate_block_pre_execution(&self, block: &SealedBlock) -> Result<(), ConsensusError> { validate_block_pre_execution(block, &self.chain_spec) } } diff --git a/crates/net/downloaders/src/bodies/bodies.rs b/crates/net/downloaders/src/bodies/bodies.rs index 5d6bd3cf7f..698d7168d8 100644 --- a/crates/net/downloaders/src/bodies/bodies.rs +++ b/crates/net/downloaders/src/bodies/bodies.rs @@ -5,7 +5,7 @@ use alloy_primitives::BlockNumber; use futures::Stream; use futures_util::StreamExt; use reth_config::BodiesConfig; -use reth_consensus::{Consensus, ConsensusError}; +use reth_consensus::Consensus; use reth_network_p2p::{ bodies::{ client::BodiesClient, @@ -41,7 +41,7 @@ pub struct BodiesDownloader< /// The bodies client client: Arc, /// The consensus client - consensus: Arc>, + consensus: Arc>, /// The database handle provider: Provider, /// The maximum number of non-empty blocks per one request @@ -577,7 +577,7 @@ impl BodiesDownloaderBuilder { pub fn build( self, client: C, - consensus: Arc>, + consensus: Arc>, provider: Provider, ) -> BodiesDownloader where diff --git a/crates/net/downloaders/src/bodies/queue.rs b/crates/net/downloaders/src/bodies/queue.rs index 480aa6de2a..2fcaeb32c7 100644 --- a/crates/net/downloaders/src/bodies/queue.rs +++ b/crates/net/downloaders/src/bodies/queue.rs @@ -4,7 +4,7 @@ use alloy_consensus::BlockHeader; use alloy_primitives::BlockNumber; use futures::{stream::FuturesUnordered, Stream}; use futures_util::StreamExt; -use reth_consensus::{Consensus, ConsensusError}; +use reth_consensus::Consensus; use reth_network_p2p::{ bodies::{client::BodiesClient, response::BlockResponse}, error::DownloadResult, @@ -58,7 +58,7 @@ where pub(crate) fn push_new_request( &mut self, client: Arc, - consensus: Arc>, + consensus: Arc>, request: Vec>, ) { // Set last max requested block number diff --git a/crates/net/downloaders/src/bodies/request.rs b/crates/net/downloaders/src/bodies/request.rs index 2adb8a585c..c4aac2f453 100644 --- a/crates/net/downloaders/src/bodies/request.rs +++ b/crates/net/downloaders/src/bodies/request.rs @@ -2,7 +2,7 @@ use crate::metrics::{BodyDownloaderMetrics, ResponseMetrics}; use alloy_consensus::BlockHeader; use alloy_primitives::B256; use futures::{Future, FutureExt}; -use reth_consensus::{Consensus, ConsensusError}; +use reth_consensus::Consensus; use reth_network_p2p::{ bodies::{client::BodiesClient, response::BlockResponse}, error::{DownloadError, DownloadResult}, @@ -38,7 +38,7 @@ use std::{ /// and eventually disconnected. pub(crate) struct BodiesRequestFuture> { client: Arc, - consensus: Arc>, + consensus: Arc>, metrics: BodyDownloaderMetrics, /// Metrics for individual responses. This can be used to observe how the size (in bytes) of /// responses change while bodies are being downloaded. @@ -60,7 +60,7 @@ where /// Returns an empty future. Use [`BodiesRequestFuture::with_headers`] to set the request. pub(crate) fn new( client: Arc, - consensus: Arc>, + consensus: Arc>, metrics: BodyDownloaderMetrics, ) -> Self { Self { diff --git a/crates/net/downloaders/src/bodies/task.rs b/crates/net/downloaders/src/bodies/task.rs index 4da5946fff..7d9ceeb94e 100644 --- a/crates/net/downloaders/src/bodies/task.rs +++ b/crates/net/downloaders/src/bodies/task.rs @@ -42,7 +42,7 @@ impl TaskDownloader { /// # Example /// /// ``` - /// use reth_consensus::{Consensus, ConsensusError}; + /// use reth_consensus::Consensus; /// use reth_downloaders::bodies::{bodies::BodiesDownloaderBuilder, task::TaskDownloader}; /// use reth_network_p2p::bodies::client::BodiesClient; /// use reth_primitives_traits::{Block, InMemorySize}; @@ -55,7 +55,7 @@ impl TaskDownloader { /// Provider: HeaderProvider
+ Unpin + 'static, /// >( /// client: Arc, - /// consensus: Arc>, + /// consensus: Arc>, /// provider: Provider, /// ) { /// let downloader = diff --git a/crates/net/downloaders/src/file_client.rs b/crates/net/downloaders/src/file_client.rs index 4d545aec17..c3f951e1f7 100644 --- a/crates/net/downloaders/src/file_client.rs +++ b/crates/net/downloaders/src/file_client.rs @@ -86,7 +86,7 @@ impl FileClient { /// Create a new file client from a file path. pub async fn new>( path: P, - consensus: Arc>, + consensus: Arc>, ) -> Result { let file = File::open(path).await?; Self::from_file(file, consensus).await @@ -95,7 +95,7 @@ impl FileClient { /// Initialize the [`FileClient`] with a file directly. pub(crate) async fn from_file( mut file: File, - consensus: Arc>, + consensus: Arc>, ) -> Result { // get file len from metadata before reading let metadata = file.metadata().await?; @@ -200,7 +200,7 @@ impl FileClient { } struct FileClientBuilder { - pub consensus: Arc>, + pub consensus: Arc>, pub parent_header: Option>, } @@ -562,7 +562,7 @@ impl ChunkedFileReader { /// are available before processing. For plain files, it uses the original chunking logic. pub async fn next_chunk( &mut self, - consensus: Arc>, + consensus: Arc>, parent_header: Option>, ) -> Result>, FileClientError> { let Some(chunk_len) = self.read_next_chunk().await? else { return Ok(None) }; diff --git a/crates/net/p2p/src/full_block.rs b/crates/net/p2p/src/full_block.rs index 06128c6b54..0ff6c89838 100644 --- a/crates/net/p2p/src/full_block.rs +++ b/crates/net/p2p/src/full_block.rs @@ -10,7 +10,7 @@ use crate::{ use alloy_consensus::BlockHeader; use alloy_primitives::{Sealable, B256}; use core::marker::PhantomData; -use reth_consensus::{Consensus, ConsensusError}; +use reth_consensus::Consensus; use reth_eth_wire_types::{EthNetworkPrimitives, HeadersDirection, NetworkPrimitives}; use reth_network_peers::{PeerId, WithPeerId}; use reth_primitives_traits::{SealedBlock, SealedHeader}; @@ -34,7 +34,7 @@ where Client: BlockClient, { client: Client, - consensus: Arc>, + consensus: Arc>, } impl FullBlockClient @@ -42,10 +42,7 @@ where Client: BlockClient, { /// Creates a new instance of `FullBlockClient`. - pub fn new( - client: Client, - consensus: Arc>, - ) -> Self { + pub fn new(client: Client, consensus: Arc>) -> Self { Self { client, consensus } } @@ -122,7 +119,7 @@ where Client: BlockClient, { client: Client, - consensus: Arc>, + consensus: Arc>, hash: B256, request: FullBlockRequest, header: Option>, @@ -334,7 +331,7 @@ where /// The client used to fetch headers and bodies. client: Client, /// The consensus instance used to validate the blocks. - consensus: Arc>, + consensus: Arc>, /// The block hash to start fetching from (inclusive). start_hash: B256, /// How many blocks to fetch: `len([start_hash, ..]) == count` diff --git a/crates/node/api/src/node.rs b/crates/node/api/src/node.rs index a4a46d2e0a..d4e6aa4030 100644 --- a/crates/node/api/src/node.rs +++ b/crates/node/api/src/node.rs @@ -3,7 +3,7 @@ use crate::PayloadTypes; use alloy_rpc_types_engine::JwtSecret; use reth_basic_payload_builder::PayloadBuilder; -use reth_consensus::{ConsensusError, FullConsensus}; +use reth_consensus::FullConsensus; use reth_db_api::{database_metrics::DatabaseMetrics, Database}; use reth_engine_primitives::{ConsensusEngineEvent, ConsensusEngineHandle}; use reth_evm::ConfigureEvm; @@ -71,10 +71,7 @@ pub trait FullNodeComponents: FullNodeTypes + Clone + 'static { type Evm: ConfigureEvm::Primitives>; /// The consensus type of the node. - type Consensus: FullConsensus<::Primitives, Error = ConsensusError> - + Clone - + Unpin - + 'static; + type Consensus: FullConsensus<::Primitives> + Clone + Unpin + 'static; /// Network API. type Network: FullNetwork; diff --git a/crates/node/builder/src/components/builder.rs b/crates/node/builder/src/components/builder.rs index c54cc0e37f..216025d8e5 100644 --- a/crates/node/builder/src/components/builder.rs +++ b/crates/node/builder/src/components/builder.rs @@ -8,7 +8,7 @@ use crate::{ BuilderContext, ConfigureEvm, FullNodeTypes, }; use reth_chainspec::EthChainSpec; -use reth_consensus::{noop::NoopConsensus, ConsensusError, FullConsensus}; +use reth_consensus::{noop::NoopConsensus, FullConsensus}; use reth_network::{types::NetPrimitivesFor, EthNetworkPrimitives, NetworkPrimitives}; use reth_network_api::{noop::NoopNetwork, FullNetwork}; use reth_node_api::{BlockTy, BodyTy, HeaderTy, NodeTypes, PrimitivesTy, ReceiptTy, TxTy}; @@ -455,8 +455,7 @@ where + Unpin + 'static, EVM: ConfigureEvm> + 'static, - Cons: - FullConsensus, Error = ConsensusError> + Clone + Unpin + 'static, + Cons: FullConsensus> + Clone + Unpin + 'static, { type Components = Components; diff --git a/crates/node/builder/src/components/consensus.rs b/crates/node/builder/src/components/consensus.rs index 426d932e01..301d477729 100644 --- a/crates/node/builder/src/components/consensus.rs +++ b/crates/node/builder/src/components/consensus.rs @@ -1,5 +1,5 @@ //! Consensus component for the node builder. -use reth_consensus::{ConsensusError, FullConsensus}; +use reth_consensus::FullConsensus; use reth_node_api::PrimitivesTy; use crate::{BuilderContext, FullNodeTypes}; @@ -8,10 +8,7 @@ use std::future::Future; /// A type that knows how to build the consensus implementation. pub trait ConsensusBuilder: Send { /// The consensus implementation to build. - type Consensus: FullConsensus, Error = ConsensusError> - + Clone - + Unpin - + 'static; + type Consensus: FullConsensus> + Clone + Unpin + 'static; /// Creates the consensus implementation. fn build_consensus( @@ -23,8 +20,7 @@ pub trait ConsensusBuilder: Send { impl ConsensusBuilder for F where Node: FullNodeTypes, - Consensus: - FullConsensus, Error = ConsensusError> + Clone + Unpin + 'static, + Consensus: FullConsensus> + Clone + Unpin + 'static, F: FnOnce(&BuilderContext) -> Fut + Send, Fut: Future> + Send, { diff --git a/crates/node/builder/src/components/mod.rs b/crates/node/builder/src/components/mod.rs index af823f9463..8cf9794bd8 100644 --- a/crates/node/builder/src/components/mod.rs +++ b/crates/node/builder/src/components/mod.rs @@ -22,7 +22,7 @@ pub use payload::*; pub use pool::*; use crate::{ConfigureEvm, FullNodeTypes}; -use reth_consensus::{ConsensusError, FullConsensus}; +use reth_consensus::FullConsensus; use reth_network::types::NetPrimitivesFor; use reth_network_api::FullNetwork; use reth_node_api::{NodeTypes, PrimitivesTy, TxTy}; @@ -43,10 +43,7 @@ pub trait NodeComponents: Clone + Debug + Unpin + Send + Sync type Evm: ConfigureEvm::Primitives>; /// The consensus type of the node. - type Consensus: FullConsensus<::Primitives, Error = ConsensusError> - + Clone - + Unpin - + 'static; + type Consensus: FullConsensus<::Primitives> + Clone + Unpin + 'static; /// Network API. type Network: FullNetwork::Primitives>>; @@ -99,8 +96,7 @@ where + Unpin + 'static, EVM: ConfigureEvm> + 'static, - Cons: - FullConsensus, Error = ConsensusError> + Clone + Unpin + 'static, + Cons: FullConsensus> + Clone + Unpin + 'static, { type Pool = Pool; type Evm = EVM; diff --git a/crates/node/builder/src/setup.rs b/crates/node/builder/src/setup.rs index ad78ffb59a..25cc5f27be 100644 --- a/crates/node/builder/src/setup.rs +++ b/crates/node/builder/src/setup.rs @@ -5,7 +5,7 @@ use std::sync::Arc; use crate::BlockTy; use alloy_primitives::{BlockNumber, B256}; use reth_config::{config::StageConfig, PruneConfig}; -use reth_consensus::{ConsensusError, FullConsensus}; +use reth_consensus::FullConsensus; use reth_downloaders::{ bodies::bodies::BodiesDownloaderBuilder, headers::reverse_headers::ReverseHeadersDownloaderBuilder, @@ -32,7 +32,7 @@ use tokio::sync::watch; pub fn build_networked_pipeline( config: &StageConfig, client: Client, - consensus: Arc>, + consensus: Arc>, provider_factory: ProviderFactory, task_executor: &TaskExecutor, metrics_tx: reth_stages::MetricEventsSender, @@ -82,7 +82,7 @@ pub fn build_pipeline( stage_config: &StageConfig, header_downloader: H, body_downloader: B, - consensus: Arc>, + consensus: Arc>, max_block: Option, metrics_tx: reth_stages::MetricEventsSender, prune_config: PruneConfig, diff --git a/crates/node/core/src/utils.rs b/crates/node/core/src/utils.rs index fbb56b24ee..062013d85d 100644 --- a/crates/node/core/src/utils.rs +++ b/crates/node/core/src/utils.rs @@ -5,7 +5,7 @@ use alloy_consensus::BlockHeader; use alloy_eips::BlockHashOrNumber; use alloy_rpc_types_engine::{JwtError, JwtSecret}; use eyre::Result; -use reth_consensus::{Consensus, ConsensusError}; +use reth_consensus::Consensus; use reth_network_p2p::{ bodies::client::BodiesClient, headers::client::HeadersClient, priority::Priority, }; @@ -71,7 +71,7 @@ where pub async fn get_single_body( client: Client, header: SealedHeader, - consensus: impl Consensus, + consensus: impl Consensus, ) -> Result> where B: Block, diff --git a/crates/optimism/consensus/src/lib.rs b/crates/optimism/consensus/src/lib.rs index a54cf05f2f..381df23370 100644 --- a/crates/optimism/consensus/src/lib.rs +++ b/crates/optimism/consensus/src/lib.rs @@ -89,8 +89,6 @@ where B: Block, ChainSpec: EthChainSpec
+ OpHardforks + Debug + Send + Sync, { - type Error = ConsensusError; - fn validate_body_against_header( &self, body: &B::Body, diff --git a/crates/rpc/rpc-builder/src/lib.rs b/crates/rpc/rpc-builder/src/lib.rs index d91dd0fe0c..e58e1ba66b 100644 --- a/crates/rpc/rpc-builder/src/lib.rs +++ b/crates/rpc/rpc-builder/src/lib.rs @@ -31,7 +31,7 @@ use jsonrpsee::{ Methods, RpcModule, }; use reth_chainspec::{ChainSpecProvider, EthereumHardforks}; -use reth_consensus::{ConsensusError, FullConsensus}; +use reth_consensus::FullConsensus; use reth_engine_primitives::ConsensusEngineEvent; use reth_evm::ConfigureEvm; use reth_network_api::{noop::NoopNetwork, NetworkInfo, Peers}; @@ -316,7 +316,7 @@ where Pool: TransactionPool + Clone + 'static, Network: NetworkInfo + Peers + Clone + 'static, EvmConfig: ConfigureEvm + 'static, - Consensus: FullConsensus + Clone + 'static, + Consensus: FullConsensus + Clone + 'static, { /// Configures all [`RpcModule`]s specific to the given [`TransportRpcModuleConfig`] which can /// be used to start the transport server(s). @@ -849,7 +849,7 @@ where Network: NetworkInfo + Peers + Clone + 'static, EthApi: FullEthApiServer, EvmConfig: ConfigureEvm + 'static, - Consensus: FullConsensus + Clone + 'static, + Consensus: FullConsensus + Clone + 'static, { /// Configures the auth module that includes the /// * `engine_` namespace diff --git a/crates/rpc/rpc/src/validation.rs b/crates/rpc/rpc/src/validation.rs index d03846a427..78185f92ff 100644 --- a/crates/rpc/rpc/src/validation.rs +++ b/crates/rpc/rpc/src/validation.rs @@ -59,7 +59,7 @@ where /// Create a new instance of the [`ValidationApi`] pub fn new( provider: Provider, - consensus: Arc>, + consensus: Arc>, evm_config: E, config: ValidationApiConfig, task_spawner: Box, @@ -561,7 +561,7 @@ pub struct ValidationApiInner { /// The provider that can interact with the chain. provider: Provider, /// Consensus implementation. - consensus: Arc>, + consensus: Arc>, /// Execution payload validator. payload_validator: Arc::Block>>, diff --git a/crates/stages/stages/src/lib.rs b/crates/stages/stages/src/lib.rs index bdd68f03a2..89b23c0ee6 100644 --- a/crates/stages/stages/src/lib.rs +++ b/crates/stages/stages/src/lib.rs @@ -29,12 +29,12 @@ //! # use reth_provider::test_utils::{create_test_provider_factory, MockNodeTypesWithDB}; //! # use reth_static_file::StaticFileProducer; //! # use reth_config::config::StageConfig; -//! # use reth_consensus::{Consensus, ConsensusError}; +//! # use reth_consensus::Consensus; //! # use reth_consensus::test_utils::TestConsensus; //! # use reth_consensus::FullConsensus; //! # //! # let chain_spec = MAINNET.clone(); -//! # let consensus: Arc> = Arc::new(TestConsensus::default()); +//! # let consensus: Arc> = Arc::new(TestConsensus::default()); //! # let headers_downloader = ReverseHeadersDownloaderBuilder::default().build( //! # Arc::new(TestHeadersClient::default()), //! # consensus.clone() diff --git a/crates/stages/stages/src/sets.rs b/crates/stages/stages/src/sets.rs index e21a79811c..f946a622ca 100644 --- a/crates/stages/stages/src/sets.rs +++ b/crates/stages/stages/src/sets.rs @@ -22,9 +22,9 @@ //! # use reth_config::config::StageConfig; //! # use reth_ethereum_primitives::EthPrimitives; //! # use std::sync::Arc; -//! # use reth_consensus::{FullConsensus, ConsensusError}; +//! # use reth_consensus::FullConsensus; //! -//! # fn create(exec: impl ConfigureEvm + 'static, consensus: impl FullConsensus + 'static) { +//! # fn create(exec: impl ConfigureEvm + 'static, consensus: impl FullConsensus + 'static) { //! //! let provider_factory = create_test_provider_factory(); //! let static_file_producer = @@ -47,7 +47,7 @@ use crate::{ }; use alloy_primitives::B256; use reth_config::config::StageConfig; -use reth_consensus::{ConsensusError, FullConsensus}; +use reth_consensus::FullConsensus; use reth_evm::ConfigureEvm; use reth_network_p2p::{bodies::downloader::BodyDownloader, headers::downloader::HeaderDownloader}; use reth_primitives_traits::{Block, NodePrimitives}; @@ -94,7 +94,7 @@ where /// Executor factory needs for execution stage evm_config: E, /// Consensus instance - consensus: Arc>, + consensus: Arc>, /// Configuration for each stage in the pipeline stages_config: StageConfig, /// Prune configuration for every segment that can be pruned @@ -112,7 +112,7 @@ where pub fn new( provider: Provider, tip: watch::Receiver, - consensus: Arc>, + consensus: Arc>, header_downloader: H, body_downloader: B, evm_config: E, @@ -147,7 +147,7 @@ where pub fn add_offline_stages( default_offline: StageSetBuilder, evm_config: E, - consensus: Arc>, + consensus: Arc>, stages_config: StageConfig, prune_modes: PruneModes, ) -> StageSetBuilder @@ -304,7 +304,7 @@ pub struct OfflineStages { /// Executor factory needs for execution stage evm_config: E, /// Consensus instance for validating blocks. - consensus: Arc>, + consensus: Arc>, /// Configuration for each stage in the pipeline stages_config: StageConfig, /// Prune configuration for every segment that can be pruned @@ -315,7 +315,7 @@ impl OfflineStages { /// Create a new set of offline stages with default values. pub const fn new( evm_config: E, - consensus: Arc>, + consensus: Arc>, stages_config: StageConfig, prune_modes: PruneModes, ) -> Self { @@ -360,7 +360,7 @@ pub struct ExecutionStages { /// Executor factory that will create executors. evm_config: E, /// Consensus instance for validating blocks. - consensus: Arc>, + consensus: Arc>, /// Configuration for each stage in the pipeline stages_config: StageConfig, } @@ -369,7 +369,7 @@ impl ExecutionStages { /// Create a new set of execution stages with default values. pub const fn new( executor_provider: E, - consensus: Arc>, + consensus: Arc>, stages_config: StageConfig, ) -> Self { Self { evm_config: executor_provider, consensus, stages_config } diff --git a/crates/stages/stages/src/stages/execution.rs b/crates/stages/stages/src/stages/execution.rs index b4931faa9e..762a32e876 100644 --- a/crates/stages/stages/src/stages/execution.rs +++ b/crates/stages/stages/src/stages/execution.rs @@ -3,7 +3,7 @@ use alloy_consensus::BlockHeader; use alloy_primitives::BlockNumber; use num_traits::Zero; use reth_config::config::ExecutionConfig; -use reth_consensus::{ConsensusError, FullConsensus}; +use reth_consensus::FullConsensus; use reth_db::{static_file::HeaderMask, tables}; use reth_evm::{execute::Executor, metrics::ExecutorMetrics, ConfigureEvm}; use reth_execution_types::Chain; @@ -69,7 +69,7 @@ where /// The stage's internal block executor evm_config: E, /// The consensus instance for validating blocks. - consensus: Arc>, + consensus: Arc>, /// The commit thresholds of the execution stage. thresholds: ExecutionStageThresholds, /// The highest threshold (in number of blocks) for switching between incremental @@ -98,7 +98,7 @@ where /// Create new execution stage with specified config. pub fn new( evm_config: E, - consensus: Arc>, + consensus: Arc>, thresholds: ExecutionStageThresholds, external_clean_threshold: u64, exex_manager_handle: ExExManagerHandle, @@ -120,7 +120,7 @@ where /// The commit threshold will be set to [`MERKLE_STAGE_DEFAULT_INCREMENTAL_THRESHOLD`]. pub fn new_with_executor( evm_config: E, - consensus: Arc>, + consensus: Arc>, ) -> Self { Self::new( evm_config, @@ -134,7 +134,7 @@ where /// Create new instance of [`ExecutionStage`] from configuration. pub fn from_config( evm_config: E, - consensus: Arc>, + consensus: Arc>, config: ExecutionConfig, external_clean_threshold: u64, ) -> Self {