chore: rm reth-interfaces from downloaders (#8436)

This commit is contained in:
Matthias Seitz
2024-05-28 18:33:47 +02:00
committed by GitHub
parent de4e0ba041
commit 3b7089782f
15 changed files with 39 additions and 36 deletions

3
Cargo.lock generated
View File

@ -6797,12 +6797,13 @@ dependencies = [
"reth-config",
"reth-consensus",
"reth-db",
"reth-interfaces",
"reth-metrics",
"reth-network-p2p",
"reth-network-types",
"reth-primitives",
"reth-provider",
"reth-tasks",
"reth-testing-utils",
"reth-tracing",
"tempfile",
"thiserror",

View File

@ -13,14 +13,21 @@ workspace = true
[dependencies]
# reth
reth-interfaces.workspace = true
reth-primitives.workspace = true
reth-network-p2p.workspace = true
reth-tasks.workspace = true
reth-provider.workspace = true
reth-config.workspace = true
reth-consensus.workspace = true
reth-network-types.workspace = true
# optional deps for the test-utils feature
reth-db = { workspace = true, optional = true }
reth-testing-utils = { workspace = true, optional = true }
# eth
alloy-rlp.workspace = true
# async
futures.workspace = true
futures-util.workspace = true
@ -38,17 +45,15 @@ tracing.workspace = true
rayon.workspace = true
thiserror.workspace = true
# optional deps for the test-utils feature
reth-db = { workspace = true, optional = true }
alloy-rlp.workspace = true
tempfile = { workspace = true, optional = true }
itertools.workspace = true
[dev-dependencies]
reth-db = { workspace = true, features = ["test-utils"] }
reth-consensus = { workspace = true, features = ["test-utils"] }
reth-interfaces = { workspace = true, features = ["test-utils"] }
reth-network-p2p = { workspace = true, features = ["test-utils"] }
reth-provider = { workspace = true, features = ["test-utils"] }
reth-testing-utils.workspace = true
reth-tracing.workspace = true
assert_matches.workspace = true
@ -60,5 +65,5 @@ rand.workspace = true
tempfile.workspace = true
[features]
test-utils = ["dep:tempfile", "reth-db/test-utils", "reth-consensus/test-utils", "reth-interfaces/test-utils"]
test-utils = ["dep:tempfile", "reth-db/test-utils", "reth-consensus/test-utils", "reth-network-p2p/test-utils", "reth-testing-utils"]

View File

@ -4,7 +4,7 @@ use futures::Stream;
use futures_util::StreamExt;
use reth_config::BodiesConfig;
use reth_consensus::Consensus;
use reth_interfaces::p2p::{
use reth_network_p2p::{
bodies::{
client::BodiesClient,
downloader::{BodyDownloader, BodyDownloaderResult},
@ -606,9 +606,9 @@ mod tests {
use assert_matches::assert_matches;
use reth_consensus::test_utils::TestConsensus;
use reth_db::test_utils::{create_test_rw_db, create_test_static_files_dir};
use reth_interfaces::test_utils::{generators, generators::random_block_range};
use reth_primitives::{BlockBody, B256, MAINNET};
use reth_provider::ProviderFactory;
use reth_testing_utils::{generators, generators::random_block_range};
use std::collections::HashMap;
// Check that the blocks are emitted in order of block number, not in order of

View File

@ -1,5 +1,5 @@
use futures::Stream;
use reth_interfaces::p2p::{
use reth_network_p2p::{
bodies::{downloader::BodyDownloader, response::BlockResponse},
error::{DownloadError, DownloadResult},
};

View File

@ -3,7 +3,7 @@ use crate::metrics::BodyDownloaderMetrics;
use futures::{stream::FuturesUnordered, Stream};
use futures_util::StreamExt;
use reth_consensus::Consensus;
use reth_interfaces::p2p::{
use reth_network_p2p::{
bodies::{client::BodiesClient, response::BlockResponse},
error::DownloadResult,
};

View File

@ -1,7 +1,7 @@
use crate::metrics::{BodyDownloaderMetrics, ResponseMetrics};
use futures::{Future, FutureExt};
use reth_consensus::Consensus;
use reth_interfaces::p2p::{
use reth_network_p2p::{
bodies::{client::BodiesClient, response::BlockResponse},
error::{DownloadError, DownloadResult},
priority::Priority,
@ -255,7 +255,7 @@ mod tests {
test_utils::{generate_bodies, TestBodiesClient},
};
use reth_consensus::test_utils::TestConsensus;
use reth_interfaces::test_utils::{generators, generators::random_header_range};
use reth_testing_utils::{generators, generators::random_header_range};
/// Check if future returns empty bodies without dispatching any requests.
#[tokio::test]

View File

@ -1,7 +1,7 @@
use futures::Stream;
use futures_util::{FutureExt, StreamExt};
use pin_project::pin_project;
use reth_interfaces::p2p::{
use reth_network_p2p::{
bodies::downloader::{BodyDownloader, BodyDownloaderResult},
error::DownloadResult,
};
@ -44,7 +44,7 @@ impl TaskDownloader {
/// ```
/// use reth_consensus::Consensus;
/// use reth_downloaders::bodies::{bodies::BodiesDownloaderBuilder, task::TaskDownloader};
/// use reth_interfaces::p2p::bodies::client::BodiesClient;
/// use reth_network_p2p::bodies::client::BodiesClient;
/// use reth_provider::HeaderProvider;
/// use std::sync::Arc;
///
@ -171,7 +171,7 @@ mod tests {
};
use assert_matches::assert_matches;
use reth_consensus::test_utils::TestConsensus;
use reth_interfaces::p2p::error::DownloadError;
use reth_network_p2p::error::DownloadError;
use reth_provider::test_utils::create_test_provider_factory;
use std::sync::Arc;

View File

@ -3,7 +3,7 @@
#![allow(dead_code)]
use reth_db::{database::Database, tables, transaction::DbTxMut, DatabaseEnv};
use reth_interfaces::{db, p2p::bodies::response::BlockResponse};
use reth_network_p2p::bodies::response::BlockResponse;
use reth_primitives::{Block, BlockBody, SealedBlock, SealedHeader, B256};
use std::collections::HashMap;
@ -45,13 +45,11 @@ pub(crate) fn create_raw_bodies<'a>(
#[inline]
pub(crate) fn insert_headers(db: &DatabaseEnv, headers: &[SealedHeader]) {
db.update(|tx| -> Result<(), db::DatabaseError> {
db.update(|tx| {
for header in headers {
tx.put::<tables::CanonicalHeaders>(header.number, header.hash())?;
tx.put::<tables::Headers>(header.number, header.clone().unseal())?;
tx.put::<tables::CanonicalHeaders>(header.number, header.hash()).unwrap();
tx.put::<tables::Headers>(header.number, header.clone().unseal()).unwrap();
}
Ok(())
})
.expect("failed to commit")
.expect("failed to insert headers");
}

View File

@ -1,7 +1,7 @@
use super::file_codec::BlockFileCodec;
use futures::Future;
use itertools::Either;
use reth_interfaces::p2p::{
use reth_network_p2p::{
bodies::client::{BodiesClient, BodiesFut},
download::DownloadClient,
error::RequestError,
@ -483,7 +483,7 @@ mod tests {
use futures_util::stream::StreamExt;
use rand::Rng;
use reth_consensus::test_utils::TestConsensus;
use reth_interfaces::p2p::{
use reth_network_p2p::{
bodies::downloader::BodyDownloader,
headers::downloader::{HeaderDownloader, SyncTarget},
};

View File

@ -1,5 +1,5 @@
use futures::Stream;
use reth_interfaces::p2p::headers::{
use reth_network_p2p::headers::{
downloader::{HeaderDownloader, SyncTarget},
error::HeadersDownloaderError,
};

View File

@ -7,7 +7,7 @@ use futures_util::{stream::FuturesUnordered, StreamExt};
use rayon::prelude::*;
use reth_config::config::HeadersConfig;
use reth_consensus::Consensus;
use reth_interfaces::p2p::{
use reth_network_p2p::{
error::{DownloadError, DownloadResult, PeerRequestResult},
headers::{
client::{HeadersClient, HeadersRequest},
@ -1220,11 +1220,10 @@ fn calc_next_request(
#[cfg(test)]
mod tests {
use super::*;
use crate::headers::test_utils::child_header;
use assert_matches::assert_matches;
use reth_consensus::test_utils::TestConsensus;
use reth_interfaces::test_utils::TestHeadersClient;
use reth_network_p2p::test_utils::TestHeadersClient;
/// Tests that `replace_number` works the same way as Option::replace
#[test]

View File

@ -1,7 +1,7 @@
use futures::{FutureExt, Stream};
use futures_util::StreamExt;
use pin_project::pin_project;
use reth_interfaces::p2p::headers::{
use reth_network_p2p::headers::{
downloader::{HeaderDownloader, SyncTarget},
error::HeadersDownloaderResult,
};
@ -45,7 +45,7 @@ impl TaskDownloader {
/// # use reth_downloaders::headers::reverse_headers::ReverseHeadersDownloader;
/// # use reth_downloaders::headers::task::TaskDownloader;
/// # use reth_consensus::Consensus;
/// # use reth_interfaces::p2p::headers::client::HeadersClient;
/// # use reth_network_p2p::headers::client::HeadersClient;
/// # fn t<H: HeadersClient + 'static>(consensus:Arc<dyn Consensus>, client: Arc<H>) {
/// let downloader = ReverseHeadersDownloader::<H>::builder().build(
/// client,
@ -184,7 +184,7 @@ mod tests {
reverse_headers::ReverseHeadersDownloaderBuilder, test_utils::child_header,
};
use reth_consensus::test_utils::TestConsensus;
use reth_interfaces::test_utils::TestHeadersClient;
use reth_network_p2p::test_utils::TestHeadersClient;
use std::sync::Arc;
#[tokio::test(flavor = "multi_thread")]

View File

@ -1,15 +1,15 @@
use reth_interfaces::p2p::error::DownloadError;
use reth_metrics::{
metrics::{Counter, Gauge},
Metrics,
};
use reth_network_p2p::error::DownloadError;
/// Common body downloader metrics.
///
/// These metrics will be initialized with the `downloaders.bodies` scope.
/// ```
/// use reth_downloaders::metrics::BodyDownloaderMetrics;
/// use reth_interfaces::p2p::error::DownloadError;
/// use reth_network_p2p::error::DownloadError;
///
/// // Initialize metrics.
/// let metrics = BodyDownloaderMetrics::default();
@ -80,7 +80,7 @@ pub struct ResponseMetrics {
/// These metrics will be initialized with the `downloaders.headers` scope.
/// ```
/// use reth_downloaders::metrics::HeaderDownloaderMetrics;
/// use reth_interfaces::p2p::error::DownloadError;
/// use reth_network_p2p::error::DownloadError;
///
/// // Initialize metrics.
/// let metrics = HeaderDownloaderMetrics::default();

View File

@ -1,4 +1,4 @@
use reth_interfaces::p2p::{
use reth_network_p2p::{
bodies::client::{BodiesClient, BodiesFut},
download::DownloadClient,
priority::Priority,

View File

@ -4,8 +4,8 @@
use crate::{bodies::test_utils::create_raw_bodies, file_codec::BlockFileCodec};
use futures::SinkExt;
use reth_interfaces::test_utils::{generators, generators::random_block_range};
use reth_primitives::{BlockBody, SealedHeader, B256};
use reth_testing_utils::{generators, generators::random_block_range};
use std::{collections::HashMap, io::SeekFrom, ops::RangeInclusive};
use tokio::{fs::File, io::AsyncSeekExt};
use tokio_util::codec::FramedWrite;