reth_stages/lib.rs
1//! Staged syncing primitives for reth.
2//!
3//! This crate contains the syncing primitives [`Pipeline`] and [`Stage`], as well as all stages
4//! that reth uses to sync.
5//!
6//! A pipeline can be configured using [`Pipeline::builder()`].
7//!
8//! For ease of use, this crate also exposes a set of [`StageSet`]s, which are collections of stages
9//! that perform specific functions during sync. Stage sets can be customized; it is possible to
10//! add, disable and replace stages in the set.
11//!
12//! # Examples
13//!
14//! ```
15//! # use std::sync::Arc;
16//! # use reth_downloaders::bodies::bodies::BodiesDownloaderBuilder;
17//! # use reth_downloaders::headers::reverse_headers::ReverseHeadersDownloaderBuilder;
18//! # use reth_network_p2p::test_utils::{TestBodiesClient, TestHeadersClient};
19//! # use reth_evm_ethereum::execute::EthExecutorProvider;
20//! # use alloy_primitives::B256;
21//! # use reth_chainspec::MAINNET;
22//! # use reth_prune_types::PruneModes;
23//! # use reth_network_peers::PeerId;
24//! # use reth_stages::Pipeline;
25//! # use reth_stages::sets::DefaultStages;
26//! # use tokio::sync::watch;
27//! # use reth_evm_ethereum::EthEvmConfig;
28//! # use reth_provider::ProviderFactory;
29//! # use reth_provider::StaticFileProviderFactory;
30//! # use reth_provider::test_utils::{create_test_provider_factory, MockNodeTypesWithDB};
31//! # use reth_static_file::StaticFileProducer;
32//! # use reth_config::config::StageConfig;
33//! # use reth_consensus::Consensus;
34//! # use reth_consensus::test_utils::TestConsensus;
35//! #
36//! # let chain_spec = MAINNET.clone();
37//! # let consensus: Arc<dyn Consensus> = Arc::new(TestConsensus::default());
38//! # let headers_downloader = ReverseHeadersDownloaderBuilder::default().build(
39//! # Arc::new(TestHeadersClient::default()),
40//! # consensus.clone().as_header_validator()
41//! # );
42//! # let provider_factory = create_test_provider_factory();
43//! # let bodies_downloader = BodiesDownloaderBuilder::default().build(
44//! # Arc::new(TestBodiesClient { responder: |_| Ok((PeerId::ZERO, vec![]).into()) }),
45//! # consensus.clone(),
46//! # provider_factory.clone()
47//! # );
48//! # let (tip_tx, tip_rx) = watch::channel(B256::default());
49//! # let executor_provider = EthExecutorProvider::mainnet();
50//! # let static_file_producer = StaticFileProducer::new(
51//! # provider_factory.clone(),
52//! # PruneModes::default()
53//! # );
54//! // Create a pipeline that can fully sync
55//! # let pipeline =
56//! Pipeline::<MockNodeTypesWithDB>::builder()
57//! .with_tip_sender(tip_tx)
58//! .add_stages(DefaultStages::new(
59//! provider_factory.clone(),
60//! tip_rx,
61//! consensus,
62//! headers_downloader,
63//! bodies_downloader,
64//! executor_provider,
65//! StageConfig::default(),
66//! PruneModes::default(),
67//! ))
68//! .build(provider_factory, static_file_producer);
69//! ```
70//!
71//! ## Feature Flags
72//!
73//! - `test-utils`: Export utilities for testing
74
75#![doc(
76 html_logo_url = "https://raw.githubusercontent.com/paradigmxyz/reth/main/assets/reth-docs.png",
77 html_favicon_url = "https://avatars0.githubusercontent.com/u/97369466?s=256",
78 issue_tracker_base_url = "https://github.com/SeismicSystems/seismic-reth/issues/"
79)]
80#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
81#![cfg_attr(not(test), warn(unused_crate_dependencies))]
82
83#[allow(missing_docs)]
84#[cfg(any(test, feature = "test-utils"))]
85pub mod test_utils;
86
87/// A re-export of common structs and traits.
88pub mod prelude;
89
90/// Implementations of stages.
91pub mod stages;
92
93pub mod sets;
94
95// re-export the stages API
96pub use reth_stages_api::*;