mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-11 08:18:19 -05:00
chore(consensus): Remove associated type Consensus::Error (#20843)
Co-authored-by: Josh_dfG <126518346+JoshdfG@users.noreply.github.com>
This commit is contained in:
@@ -69,9 +69,7 @@ pub async fn import_blocks_from_file<N>(
|
||||
provider_factory: ProviderFactory<N>,
|
||||
config: &Config,
|
||||
executor: impl ConfigureEvm<Primitives = N::Primitives> + 'static,
|
||||
consensus: Arc<
|
||||
impl FullConsensus<N::Primitives, Error = reth_consensus::ConsensusError> + 'static,
|
||||
>,
|
||||
consensus: Arc<impl FullConsensus<N::Primitives> + 'static>,
|
||||
) -> eyre::Result<ImportResult>
|
||||
where
|
||||
N: ProviderNodeTypes,
|
||||
@@ -198,7 +196,7 @@ pub fn build_import_pipeline_impl<N, C, E>(
|
||||
) -> eyre::Result<(Pipeline<N>, impl futures::Stream<Item = NodeEvent<N::Primitives>> + use<N, C, E>)>
|
||||
where
|
||||
N: ProviderNodeTypes,
|
||||
C: FullConsensus<N::Primitives, Error = reth_consensus::ConsensusError> + 'static,
|
||||
C: FullConsensus<N::Primitives> + 'static,
|
||||
E: ConfigureEvm<Primitives = N::Primitives> + 'static,
|
||||
{
|
||||
if !file_client.has_canonical_blocks() {
|
||||
|
||||
@@ -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<N, E, C>(
|
||||
where
|
||||
N: ProviderNodeTypes<DB = Arc<DatabaseEnv>>,
|
||||
E: ConfigureEvm<Primitives = N::Primitives> + 'static,
|
||||
C: FullConsensus<E::Primitives, Error = ConsensusError> + 'static,
|
||||
C: FullConsensus<E::Primitives> + 'static,
|
||||
{
|
||||
let (output_db, tip_block_number) = setup(from, to, &output_datadir.db(), db_tool)?;
|
||||
|
||||
@@ -169,7 +169,7 @@ fn dry_run<N, E, C>(
|
||||
where
|
||||
N: ProviderNodeTypes,
|
||||
E: ConfigureEvm<Primitives = N::Primitives> + 'static,
|
||||
C: FullConsensus<E::Primitives, Error = ConsensusError> + 'static,
|
||||
C: FullConsensus<E::Primitives> + 'static,
|
||||
{
|
||||
info!(target: "reth::cli", "Executing stage. [dry-run]");
|
||||
|
||||
|
||||
@@ -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<N>(
|
||||
output_datadir: ChainPath<DataDirPath>,
|
||||
should_run: bool,
|
||||
evm_config: impl ConfigureEvm<Primitives = N::Primitives>,
|
||||
consensus: impl FullConsensus<N::Primitives, Error = ConsensusError> + 'static,
|
||||
consensus: impl FullConsensus<N::Primitives> + 'static,
|
||||
) -> Result<()>
|
||||
where
|
||||
N: ProviderNodeTypes<DB = Arc<DatabaseEnv>>,
|
||||
@@ -79,7 +79,7 @@ fn unwind_and_copy<N: ProviderNodeTypes>(
|
||||
tip_block_number: u64,
|
||||
output_db: &DatabaseEnv,
|
||||
evm_config: impl ConfigureEvm<Primitives = N::Primitives>,
|
||||
consensus: impl FullConsensus<N::Primitives, Error = ConsensusError> + 'static,
|
||||
consensus: impl FullConsensus<N::Primitives> + 'static,
|
||||
) -> eyre::Result<()> {
|
||||
let (from, to) = range;
|
||||
let provider = db_tool.provider_factory.database_provider_rw()?;
|
||||
|
||||
@@ -49,15 +49,12 @@ pub trait FullConsensus<N: NodePrimitives>: Consensus<N::Block> {
|
||||
/// Consensus is a protocol that chooses canonical chain.
|
||||
#[auto_impl::auto_impl(&, Arc)]
|
||||
pub trait Consensus<B: Block>: HeaderValidator<B::Header> {
|
||||
/// 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<B::Header>,
|
||||
) -> 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<B: Block>: HeaderValidator<B::Header> {
|
||||
/// **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<B>) -> Result<(), Self::Error>;
|
||||
fn validate_block_pre_execution(&self, block: &SealedBlock<B>) -> Result<(), ConsensusError>;
|
||||
}
|
||||
|
||||
/// `HeaderValidator` is a protocol that validates headers and their relationships.
|
||||
|
||||
@@ -55,19 +55,17 @@ impl<H> HeaderValidator<H> for NoopConsensus {
|
||||
}
|
||||
|
||||
impl<B: Block> Consensus<B> for NoopConsensus {
|
||||
type Error = ConsensusError;
|
||||
|
||||
/// Validates body against header (no-op implementation).
|
||||
fn validate_body_against_header(
|
||||
&self,
|
||||
_body: &B::Body,
|
||||
_header: &SealedHeader<B::Header>,
|
||||
) -> Result<(), Self::Error> {
|
||||
) -> Result<(), ConsensusError> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Validates block before execution (no-op implementation).
|
||||
fn validate_block_pre_execution(&self, _block: &SealedBlock<B>) -> Result<(), Self::Error> {
|
||||
fn validate_block_pre_execution(&self, _block: &SealedBlock<B>) -> Result<(), ConsensusError> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,13 +61,11 @@ impl<N: NodePrimitives> FullConsensus<N> for TestConsensus {
|
||||
}
|
||||
|
||||
impl<B: Block> Consensus<B> for TestConsensus {
|
||||
type Error = ConsensusError;
|
||||
|
||||
fn validate_body_against_header(
|
||||
&self,
|
||||
_body: &B::Body,
|
||||
_header: &SealedHeader<B::Header>,
|
||||
) -> Result<(), Self::Error> {
|
||||
) -> Result<(), ConsensusError> {
|
||||
if self.fail_body_against_header() {
|
||||
Err(ConsensusError::BaseFeeMissing)
|
||||
} else {
|
||||
@@ -75,7 +73,7 @@ impl<B: Block> Consensus<B> for TestConsensus {
|
||||
}
|
||||
}
|
||||
|
||||
fn validate_block_pre_execution(&self, _block: &SealedBlock<B>) -> Result<(), Self::Error> {
|
||||
fn validate_block_pre_execution(&self, _block: &SealedBlock<B>) -> Result<(), ConsensusError> {
|
||||
if self.fail_validation() {
|
||||
Err(ConsensusError::BaseFeeMissing)
|
||||
} else {
|
||||
|
||||
@@ -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<V, C>(
|
||||
consensus: Arc<dyn FullConsensus<N::Primitives, Error = ConsensusError>>,
|
||||
consensus: Arc<dyn FullConsensus<N::Primitives>>,
|
||||
chain_spec: Arc<N::ChainSpec>,
|
||||
client: Client,
|
||||
incoming_requests: EngineMessageStream<N::Payload>,
|
||||
|
||||
@@ -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<dyn Consensus<B, Error = ConsensusError>>) -> Self {
|
||||
pub fn new(client: Client, consensus: Arc<dyn Consensus<B>>) -> Self {
|
||||
Self {
|
||||
full_block_client: FullBlockClient::new(client, consensus),
|
||||
inflight_full_block_requests: Vec::new(),
|
||||
|
||||
@@ -234,7 +234,7 @@ where
|
||||
C: ConfigureEvm<Primitives = N> + 'static,
|
||||
{
|
||||
provider: P,
|
||||
consensus: Arc<dyn FullConsensus<N, Error = ConsensusError>>,
|
||||
consensus: Arc<dyn FullConsensus<N>>,
|
||||
payload_validator: V,
|
||||
/// Keeps track of internals such as executed and buffered blocks.
|
||||
state: EngineApiTreeState<N>,
|
||||
@@ -320,7 +320,7 @@ where
|
||||
#[expect(clippy::too_many_arguments)]
|
||||
pub fn new(
|
||||
provider: P,
|
||||
consensus: Arc<dyn FullConsensus<N, Error = ConsensusError>>,
|
||||
consensus: Arc<dyn FullConsensus<N>>,
|
||||
payload_validator: V,
|
||||
outgoing: UnboundedSender<EngineApiEvent<N>>,
|
||||
state: EngineApiTreeState<N>,
|
||||
@@ -362,7 +362,7 @@ where
|
||||
#[expect(clippy::complexity)]
|
||||
pub fn spawn_new(
|
||||
provider: P,
|
||||
consensus: Arc<dyn FullConsensus<N, Error = ConsensusError>>,
|
||||
consensus: Arc<dyn FullConsensus<N>>,
|
||||
payload_validator: V,
|
||||
persistence: PersistenceHandle<N>,
|
||||
payload_builder: PayloadBuilderHandle<T>,
|
||||
|
||||
@@ -111,7 +111,7 @@ where
|
||||
/// Provider for database access.
|
||||
provider: P,
|
||||
/// Consensus implementation for validation.
|
||||
consensus: Arc<dyn FullConsensus<Evm::Primitives, Error = ConsensusError>>,
|
||||
consensus: Arc<dyn FullConsensus<Evm::Primitives>>,
|
||||
/// 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<dyn FullConsensus<N, Error = ConsensusError>>,
|
||||
consensus: Arc<dyn FullConsensus<N>>,
|
||||
evm_config: Evm,
|
||||
validator: V,
|
||||
config: TreeConfig,
|
||||
|
||||
@@ -84,17 +84,15 @@ where
|
||||
B: Block,
|
||||
ChainSpec: EthChainSpec<Header = B::Header> + EthereumHardforks + Debug + Send + Sync,
|
||||
{
|
||||
type Error = ConsensusError;
|
||||
|
||||
fn validate_body_against_header(
|
||||
&self,
|
||||
body: &B::Body,
|
||||
header: &SealedHeader<B::Header>,
|
||||
) -> Result<(), Self::Error> {
|
||||
) -> Result<(), ConsensusError> {
|
||||
validate_body_against_header(body, header.header())
|
||||
}
|
||||
|
||||
fn validate_block_pre_execution(&self, block: &SealedBlock<B>) -> Result<(), Self::Error> {
|
||||
fn validate_block_pre_execution(&self, block: &SealedBlock<B>) -> Result<(), ConsensusError> {
|
||||
validate_block_pre_execution(block, &self.chain_spec)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<C>,
|
||||
/// The consensus client
|
||||
consensus: Arc<dyn Consensus<B, Error = ConsensusError>>,
|
||||
consensus: Arc<dyn Consensus<B>>,
|
||||
/// The database handle
|
||||
provider: Provider,
|
||||
/// The maximum number of non-empty blocks per one request
|
||||
@@ -577,7 +577,7 @@ impl BodiesDownloaderBuilder {
|
||||
pub fn build<B, C, Provider>(
|
||||
self,
|
||||
client: C,
|
||||
consensus: Arc<dyn Consensus<B, Error = ConsensusError>>,
|
||||
consensus: Arc<dyn Consensus<B>>,
|
||||
provider: Provider,
|
||||
) -> BodiesDownloader<B, C, Provider>
|
||||
where
|
||||
|
||||
@@ -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<C>,
|
||||
consensus: Arc<dyn Consensus<B, Error = ConsensusError>>,
|
||||
consensus: Arc<dyn Consensus<B>>,
|
||||
request: Vec<SealedHeader<B::Header>>,
|
||||
) {
|
||||
// Set last max requested block number
|
||||
|
||||
@@ -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<B: Block, C: BodiesClient<Body = B::Body>> {
|
||||
client: Arc<C>,
|
||||
consensus: Arc<dyn Consensus<B, Error = ConsensusError>>,
|
||||
consensus: Arc<dyn Consensus<B>>,
|
||||
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<C>,
|
||||
consensus: Arc<dyn Consensus<B, Error = ConsensusError>>,
|
||||
consensus: Arc<dyn Consensus<B>>,
|
||||
metrics: BodyDownloaderMetrics,
|
||||
) -> Self {
|
||||
Self {
|
||||
|
||||
@@ -42,7 +42,7 @@ impl<B: Block + 'static> TaskDownloader<B> {
|
||||
/// # 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<B: Block + 'static> TaskDownloader<B> {
|
||||
/// Provider: HeaderProvider<Header = B::Header> + Unpin + 'static,
|
||||
/// >(
|
||||
/// client: Arc<C>,
|
||||
/// consensus: Arc<dyn Consensus<B, Error = ConsensusError>>,
|
||||
/// consensus: Arc<dyn Consensus<B>>,
|
||||
/// provider: Provider,
|
||||
/// ) {
|
||||
/// let downloader =
|
||||
|
||||
@@ -86,7 +86,7 @@ impl<B: FullBlock> FileClient<B> {
|
||||
/// Create a new file client from a file path.
|
||||
pub async fn new<P: AsRef<Path>>(
|
||||
path: P,
|
||||
consensus: Arc<dyn Consensus<B, Error = ConsensusError>>,
|
||||
consensus: Arc<dyn Consensus<B>>,
|
||||
) -> Result<Self, FileClientError> {
|
||||
let file = File::open(path).await?;
|
||||
Self::from_file(file, consensus).await
|
||||
@@ -95,7 +95,7 @@ impl<B: FullBlock> FileClient<B> {
|
||||
/// Initialize the [`FileClient`] with a file directly.
|
||||
pub(crate) async fn from_file(
|
||||
mut file: File,
|
||||
consensus: Arc<dyn Consensus<B, Error = ConsensusError>>,
|
||||
consensus: Arc<dyn Consensus<B>>,
|
||||
) -> Result<Self, FileClientError> {
|
||||
// get file len from metadata before reading
|
||||
let metadata = file.metadata().await?;
|
||||
@@ -200,7 +200,7 @@ impl<B: FullBlock> FileClient<B> {
|
||||
}
|
||||
|
||||
struct FileClientBuilder<B: Block> {
|
||||
pub consensus: Arc<dyn Consensus<B, Error = ConsensusError>>,
|
||||
pub consensus: Arc<dyn Consensus<B>>,
|
||||
pub parent_header: Option<SealedHeader<B::Header>>,
|
||||
}
|
||||
|
||||
@@ -562,7 +562,7 @@ impl ChunkedFileReader {
|
||||
/// are available before processing. For plain files, it uses the original chunking logic.
|
||||
pub async fn next_chunk<B: FullBlock>(
|
||||
&mut self,
|
||||
consensus: Arc<dyn Consensus<B, Error = ConsensusError>>,
|
||||
consensus: Arc<dyn Consensus<B>>,
|
||||
parent_header: Option<SealedHeader<B::Header>>,
|
||||
) -> Result<Option<FileClient<B>>, FileClientError> {
|
||||
let Some(chunk_len) = self.read_next_chunk().await? else { return Ok(None) };
|
||||
|
||||
@@ -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<dyn Consensus<Client::Block, Error = ConsensusError>>,
|
||||
consensus: Arc<dyn Consensus<Client::Block>>,
|
||||
}
|
||||
|
||||
impl<Client> FullBlockClient<Client>
|
||||
@@ -42,10 +42,7 @@ where
|
||||
Client: BlockClient,
|
||||
{
|
||||
/// Creates a new instance of `FullBlockClient`.
|
||||
pub fn new(
|
||||
client: Client,
|
||||
consensus: Arc<dyn Consensus<Client::Block, Error = ConsensusError>>,
|
||||
) -> Self {
|
||||
pub fn new(client: Client, consensus: Arc<dyn Consensus<Client::Block>>) -> Self {
|
||||
Self { client, consensus }
|
||||
}
|
||||
|
||||
@@ -122,7 +119,7 @@ where
|
||||
Client: BlockClient,
|
||||
{
|
||||
client: Client,
|
||||
consensus: Arc<dyn Consensus<Client::Block, Error = ConsensusError>>,
|
||||
consensus: Arc<dyn Consensus<Client::Block>>,
|
||||
hash: B256,
|
||||
request: FullBlockRequest<Client>,
|
||||
header: Option<SealedHeader<Client::Header>>,
|
||||
@@ -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<dyn Consensus<Client::Block, Error = ConsensusError>>,
|
||||
consensus: Arc<dyn Consensus<Client::Block>>,
|
||||
/// The block hash to start fetching from (inclusive).
|
||||
start_hash: B256,
|
||||
/// How many blocks to fetch: `len([start_hash, ..]) == count`
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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>;
|
||||
|
||||
|
||||
@@ -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,
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -89,8 +89,6 @@ where
|
||||
B: Block,
|
||||
ChainSpec: EthChainSpec<Header = B::Header> + OpHardforks + Debug + Send + Sync,
|
||||
{
|
||||
type Error = ConsensusError;
|
||||
|
||||
fn validate_body_against_header(
|
||||
&self,
|
||||
body: &B::Body,
|
||||
|
||||
@@ -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<Primitives = N> + 'static,
|
||||
Consensus: FullConsensus<N, Error = ConsensusError> + Clone + 'static,
|
||||
Consensus: FullConsensus<N> + 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<Primitives = N> + 'static,
|
||||
Consensus: FullConsensus<N, Error = ConsensusError> + Clone + 'static,
|
||||
Consensus: FullConsensus<N> + Clone + 'static,
|
||||
{
|
||||
/// Configures the auth module that includes the
|
||||
/// * `engine_` namespace
|
||||
|
||||
@@ -59,7 +59,7 @@ where
|
||||
/// Create a new instance of the [`ValidationApi`]
|
||||
pub fn new(
|
||||
provider: Provider,
|
||||
consensus: Arc<dyn FullConsensus<E::Primitives, Error = ConsensusError>>,
|
||||
consensus: Arc<dyn FullConsensus<E::Primitives>>,
|
||||
evm_config: E,
|
||||
config: ValidationApiConfig,
|
||||
task_spawner: Box<dyn TaskSpawner>,
|
||||
@@ -561,7 +561,7 @@ pub struct ValidationApiInner<Provider, E: ConfigureEvm, T: PayloadTypes> {
|
||||
/// The provider that can interact with the chain.
|
||||
provider: Provider,
|
||||
/// Consensus implementation.
|
||||
consensus: Arc<dyn FullConsensus<E::Primitives, Error = ConsensusError>>,
|
||||
consensus: Arc<dyn FullConsensus<E::Primitives>>,
|
||||
/// Execution payload validator.
|
||||
payload_validator:
|
||||
Arc<dyn PayloadValidator<T, Block = <E::Primitives as NodePrimitives>::Block>>,
|
||||
|
||||
@@ -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<dyn FullConsensus<reth_ethereum_primitives::EthPrimitives, Error = ConsensusError>> = Arc::new(TestConsensus::default());
|
||||
//! # let consensus: Arc<dyn FullConsensus<reth_ethereum_primitives::EthPrimitives>> = Arc::new(TestConsensus::default());
|
||||
//! # let headers_downloader = ReverseHeadersDownloaderBuilder::default().build(
|
||||
//! # Arc::new(TestHeadersClient::default()),
|
||||
//! # consensus.clone()
|
||||
|
||||
@@ -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<Primitives = EthPrimitives> + 'static, consensus: impl FullConsensus<EthPrimitives, Error = ConsensusError> + 'static) {
|
||||
//! # fn create(exec: impl ConfigureEvm<Primitives = EthPrimitives> + 'static, consensus: impl FullConsensus<EthPrimitives> + '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<dyn FullConsensus<E::Primitives, Error = ConsensusError>>,
|
||||
consensus: Arc<dyn FullConsensus<E::Primitives>>,
|
||||
/// 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<B256>,
|
||||
consensus: Arc<dyn FullConsensus<E::Primitives, Error = ConsensusError>>,
|
||||
consensus: Arc<dyn FullConsensus<E::Primitives>>,
|
||||
header_downloader: H,
|
||||
body_downloader: B,
|
||||
evm_config: E,
|
||||
@@ -147,7 +147,7 @@ where
|
||||
pub fn add_offline_stages<Provider>(
|
||||
default_offline: StageSetBuilder<Provider>,
|
||||
evm_config: E,
|
||||
consensus: Arc<dyn FullConsensus<E::Primitives, Error = ConsensusError>>,
|
||||
consensus: Arc<dyn FullConsensus<E::Primitives>>,
|
||||
stages_config: StageConfig,
|
||||
prune_modes: PruneModes,
|
||||
) -> StageSetBuilder<Provider>
|
||||
@@ -304,7 +304,7 @@ pub struct OfflineStages<E: ConfigureEvm> {
|
||||
/// Executor factory needs for execution stage
|
||||
evm_config: E,
|
||||
/// Consensus instance for validating blocks.
|
||||
consensus: Arc<dyn FullConsensus<E::Primitives, Error = ConsensusError>>,
|
||||
consensus: Arc<dyn FullConsensus<E::Primitives>>,
|
||||
/// Configuration for each stage in the pipeline
|
||||
stages_config: StageConfig,
|
||||
/// Prune configuration for every segment that can be pruned
|
||||
@@ -315,7 +315,7 @@ impl<E: ConfigureEvm> OfflineStages<E> {
|
||||
/// Create a new set of offline stages with default values.
|
||||
pub const fn new(
|
||||
evm_config: E,
|
||||
consensus: Arc<dyn FullConsensus<E::Primitives, Error = ConsensusError>>,
|
||||
consensus: Arc<dyn FullConsensus<E::Primitives>>,
|
||||
stages_config: StageConfig,
|
||||
prune_modes: PruneModes,
|
||||
) -> Self {
|
||||
@@ -360,7 +360,7 @@ pub struct ExecutionStages<E: ConfigureEvm> {
|
||||
/// Executor factory that will create executors.
|
||||
evm_config: E,
|
||||
/// Consensus instance for validating blocks.
|
||||
consensus: Arc<dyn FullConsensus<E::Primitives, Error = ConsensusError>>,
|
||||
consensus: Arc<dyn FullConsensus<E::Primitives>>,
|
||||
/// Configuration for each stage in the pipeline
|
||||
stages_config: StageConfig,
|
||||
}
|
||||
@@ -369,7 +369,7 @@ impl<E: ConfigureEvm> ExecutionStages<E> {
|
||||
/// Create a new set of execution stages with default values.
|
||||
pub const fn new(
|
||||
executor_provider: E,
|
||||
consensus: Arc<dyn FullConsensus<E::Primitives, Error = ConsensusError>>,
|
||||
consensus: Arc<dyn FullConsensus<E::Primitives>>,
|
||||
stages_config: StageConfig,
|
||||
) -> Self {
|
||||
Self { evm_config: executor_provider, consensus, stages_config }
|
||||
|
||||
@@ -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<dyn FullConsensus<E::Primitives, Error = ConsensusError>>,
|
||||
consensus: Arc<dyn FullConsensus<E::Primitives>>,
|
||||
/// 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<dyn FullConsensus<E::Primitives, Error = ConsensusError>>,
|
||||
consensus: Arc<dyn FullConsensus<E::Primitives>>,
|
||||
thresholds: ExecutionStageThresholds,
|
||||
external_clean_threshold: u64,
|
||||
exex_manager_handle: ExExManagerHandle<E::Primitives>,
|
||||
@@ -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<dyn FullConsensus<E::Primitives, Error = ConsensusError>>,
|
||||
consensus: Arc<dyn FullConsensus<E::Primitives>>,
|
||||
) -> 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<dyn FullConsensus<E::Primitives, Error = ConsensusError>>,
|
||||
consensus: Arc<dyn FullConsensus<E::Primitives>>,
|
||||
config: ExecutionConfig,
|
||||
external_clean_threshold: u64,
|
||||
) -> Self {
|
||||
|
||||
Reference in New Issue
Block a user