chore(consensus): Remove associated type Consensus::Error (#20843)

Co-authored-by: Josh_dfG <126518346+JoshdfG@users.noreply.github.com>
This commit is contained in:
Emilia Hane
2026-01-08 16:54:31 +01:00
committed by GitHub
parent 13106233e4
commit 412f39e223
29 changed files with 81 additions and 109 deletions

View File

@@ -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 = <Self::Types as NodeTypes>::Primitives>;
/// The consensus type of the node.
type Consensus: FullConsensus<<Self::Types as NodeTypes>::Primitives, Error = ConsensusError>
+ Clone
+ Unpin
+ 'static;
type Consensus: FullConsensus<<Self::Types as NodeTypes>::Primitives> + Clone + Unpin + 'static;
/// Network API.
type Network: FullNetwork;

View File

@@ -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<Primitives = PrimitivesTy<Node::Types>> + 'static,
Cons:
FullConsensus<PrimitivesTy<Node::Types>, Error = ConsensusError> + Clone + Unpin + 'static,
Cons: FullConsensus<PrimitivesTy<Node::Types>> + Clone + Unpin + 'static,
{
type Components = Components<Node, Net, Pool, EVM, Cons>;

View File

@@ -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<Node: FullNodeTypes>: Send {
/// The consensus implementation to build.
type Consensus: FullConsensus<PrimitivesTy<Node::Types>, Error = ConsensusError>
+ Clone
+ Unpin
+ 'static;
type Consensus: FullConsensus<PrimitivesTy<Node::Types>> + Clone + Unpin + 'static;
/// Creates the consensus implementation.
fn build_consensus(
@@ -23,8 +20,7 @@ pub trait ConsensusBuilder<Node: FullNodeTypes>: Send {
impl<Node, F, Fut, Consensus> ConsensusBuilder<Node> for F
where
Node: FullNodeTypes,
Consensus:
FullConsensus<PrimitivesTy<Node::Types>, Error = ConsensusError> + Clone + Unpin + 'static,
Consensus: FullConsensus<PrimitivesTy<Node::Types>> + Clone + Unpin + 'static,
F: FnOnce(&BuilderContext<Node>) -> Fut + Send,
Fut: Future<Output = eyre::Result<Consensus>> + Send,
{

View File

@@ -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<T: FullNodeTypes>: Clone + Debug + Unpin + Send + Sync
type Evm: ConfigureEvm<Primitives = <T::Types as NodeTypes>::Primitives>;
/// The consensus type of the node.
type Consensus: FullConsensus<<T::Types as NodeTypes>::Primitives, Error = ConsensusError>
+ Clone
+ Unpin
+ 'static;
type Consensus: FullConsensus<<T::Types as NodeTypes>::Primitives> + Clone + Unpin + 'static;
/// Network API.
type Network: FullNetwork<Primitives: NetPrimitivesFor<<T::Types as NodeTypes>::Primitives>>;
@@ -99,8 +96,7 @@ where
+ Unpin
+ 'static,
EVM: ConfigureEvm<Primitives = PrimitivesTy<Node::Types>> + 'static,
Cons:
FullConsensus<PrimitivesTy<Node::Types>, Error = ConsensusError> + Clone + Unpin + 'static,
Cons: FullConsensus<PrimitivesTy<Node::Types>> + Clone + Unpin + 'static,
{
type Pool = Pool;
type Evm = EVM;

View File

@@ -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<N, Client, Evm>(
config: &StageConfig,
client: Client,
consensus: Arc<dyn FullConsensus<N::Primitives, Error = ConsensusError>>,
consensus: Arc<dyn FullConsensus<N::Primitives>>,
provider_factory: ProviderFactory<N>,
task_executor: &TaskExecutor,
metrics_tx: reth_stages::MetricEventsSender,
@@ -82,7 +82,7 @@ pub fn build_pipeline<N, H, B, Evm>(
stage_config: &StageConfig,
header_downloader: H,
body_downloader: B,
consensus: Arc<dyn FullConsensus<N::Primitives, Error = ConsensusError>>,
consensus: Arc<dyn FullConsensus<N::Primitives>>,
max_block: Option<u64>,
metrics_tx: reth_stages::MetricEventsSender,
prune_config: PruneConfig,

View File

@@ -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<B, Client>(
client: Client,
header: SealedHeader<B::Header>,
consensus: impl Consensus<B, Error = ConsensusError>,
consensus: impl Consensus<B>,
) -> Result<SealedBlock<B>>
where
B: Block,