From efccfbfc65014e3d6ac71a7df66a11d9752a49cf Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 29 May 2024 11:59:00 +0200 Subject: [PATCH] chore: rm reth-interfaces from beacon (#8456) --- Cargo.lock | 4 +++- crates/consensus/beacon/Cargo.toml | 7 ++++-- crates/consensus/beacon/src/engine/error.rs | 10 ++++---- crates/consensus/beacon/src/engine/handle.rs | 2 +- .../beacon/src/engine/hooks/controller.rs | 2 +- .../consensus/beacon/src/engine/hooks/mod.rs | 2 +- .../beacon/src/engine/hooks/prune.rs | 2 +- .../beacon/src/engine/hooks/static_file.rs | 2 +- crates/consensus/beacon/src/engine/message.rs | 2 +- crates/consensus/beacon/src/engine/mod.rs | 24 +++++++++---------- crates/consensus/beacon/src/engine/sync.rs | 4 ++-- .../consensus/beacon/src/engine/test_utils.rs | 5 ++-- crates/errors/src/lib.rs | 2 +- 13 files changed, 35 insertions(+), 33 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 841f67254..3020465a0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6499,17 +6499,19 @@ dependencies = [ "futures", "metrics", "reth-blockchain-tree", + "reth-blockchain-tree-api", "reth-config", "reth-consensus", "reth-db", "reth-downloaders", "reth-engine-primitives", + "reth-errors", "reth-ethereum-consensus", "reth-ethereum-engine-primitives", "reth-evm", "reth-evm-ethereum", - "reth-interfaces", "reth-metrics", + "reth-network-p2p", "reth-payload-builder", "reth-payload-validator", "reth-primitives", diff --git a/crates/consensus/beacon/Cargo.toml b/crates/consensus/beacon/Cargo.toml index a5cef8e34..67f655858 100644 --- a/crates/consensus/beacon/Cargo.toml +++ b/crates/consensus/beacon/Cargo.toml @@ -13,9 +13,10 @@ workspace = true [dependencies] # reth reth-ethereum-consensus.workspace = true +reth-blockchain-tree-api.workspace = true reth-primitives.workspace = true -reth-interfaces.workspace = true reth-stages-api.workspace = true +reth-errors.workspace = true reth-db.workspace = true reth-provider.workspace = true reth-rpc-types.workspace = true @@ -26,6 +27,8 @@ reth-prune.workspace = true reth-static-file.workspace = true reth-tokio-util.workspace = true reth-engine-primitives.workspace = true +reth-network-p2p.workspace = true + # async tokio = { workspace = true, features = ["sync"] } @@ -46,12 +49,12 @@ schnellru.workspace = true reth-payload-builder = { workspace = true, features = ["test-utils"] } reth-primitives = { workspace = true, features = ["test-utils"] } reth-consensus = { workspace = true, features = ["test-utils"] } -reth-interfaces = { workspace = true, features = ["test-utils"] } reth-stages = { workspace = true, features = ["test-utils"] } reth-blockchain-tree = { workspace = true, features = ["test-utils"] } reth-db = { workspace = true, features = ["test-utils"] } reth-provider = { workspace = true, features = ["test-utils"] } reth-evm = { workspace = true, features = ["test-utils"] } +reth-network-p2p = { workspace = true, features = ["test-utils"] } reth-rpc-types-compat.workspace = true reth-rpc.workspace = true reth-tracing.workspace = true diff --git a/crates/consensus/beacon/src/engine/error.rs b/crates/consensus/beacon/src/engine/error.rs index 92bd031e5..aa37e8482 100644 --- a/crates/consensus/beacon/src/engine/error.rs +++ b/crates/consensus/beacon/src/engine/error.rs @@ -1,5 +1,5 @@ use crate::engine::hooks::EngineHookError; -use reth_interfaces::RethError; +use reth_errors::{DatabaseError, RethError}; use reth_rpc_types::engine::ForkchoiceUpdateError; use reth_stages_api::PipelineError; @@ -37,8 +37,8 @@ impl From for BeaconConsensusEngineError { } // for convenience in the beacon engine -impl From for BeaconConsensusEngineError { - fn from(e: reth_interfaces::db::DatabaseError) -> Self { +impl From for BeaconConsensusEngineError { + fn from(e: DatabaseError) -> Self { Self::Common(e.into()) } } @@ -72,8 +72,8 @@ impl From for BeaconForkChoiceUpdateError { Self::internal(e) } } -impl From for BeaconForkChoiceUpdateError { - fn from(e: reth_interfaces::db::DatabaseError) -> Self { +impl From for BeaconForkChoiceUpdateError { + fn from(e: DatabaseError) -> Self { Self::internal(e) } } diff --git a/crates/consensus/beacon/src/engine/handle.rs b/crates/consensus/beacon/src/engine/handle.rs index bec289bf4..420871487 100644 --- a/crates/consensus/beacon/src/engine/handle.rs +++ b/crates/consensus/beacon/src/engine/handle.rs @@ -6,7 +6,7 @@ use crate::{ }; use futures::TryFutureExt; use reth_engine_primitives::EngineTypes; -use reth_interfaces::RethResult; +use reth_errors::RethResult; use reth_rpc_types::engine::{ CancunPayloadFields, ExecutionPayload, ForkchoiceState, ForkchoiceUpdated, PayloadStatus, }; diff --git a/crates/consensus/beacon/src/engine/hooks/controller.rs b/crates/consensus/beacon/src/engine/hooks/controller.rs index a2845c9cc..41519b456 100644 --- a/crates/consensus/beacon/src/engine/hooks/controller.rs +++ b/crates/consensus/beacon/src/engine/hooks/controller.rs @@ -176,7 +176,7 @@ mod tests { EngineHooksController, }; use futures::poll; - use reth_interfaces::{RethError, RethResult}; + use reth_errors::{RethError, RethResult}; use std::{ collections::VecDeque, future::poll_fn, diff --git a/crates/consensus/beacon/src/engine/hooks/mod.rs b/crates/consensus/beacon/src/engine/hooks/mod.rs index 3e78e4848..0777186b6 100644 --- a/crates/consensus/beacon/src/engine/hooks/mod.rs +++ b/crates/consensus/beacon/src/engine/hooks/mod.rs @@ -1,4 +1,4 @@ -use reth_interfaces::{RethError, RethResult}; +use reth_errors::{RethError, RethResult}; use reth_primitives::BlockNumber; use std::{ fmt, diff --git a/crates/consensus/beacon/src/engine/hooks/prune.rs b/crates/consensus/beacon/src/engine/hooks/prune.rs index ea9078aca..e6b5306e3 100644 --- a/crates/consensus/beacon/src/engine/hooks/prune.rs +++ b/crates/consensus/beacon/src/engine/hooks/prune.rs @@ -7,7 +7,7 @@ use crate::{ use futures::FutureExt; use metrics::Counter; use reth_db::database::Database; -use reth_interfaces::{RethError, RethResult}; +use reth_errors::{RethError, RethResult}; use reth_primitives::BlockNumber; use reth_prune::{Pruner, PrunerError, PrunerWithResult}; use reth_tasks::TaskSpawner; diff --git a/crates/consensus/beacon/src/engine/hooks/static_file.rs b/crates/consensus/beacon/src/engine/hooks/static_file.rs index 3d78d51d9..5cf643216 100644 --- a/crates/consensus/beacon/src/engine/hooks/static_file.rs +++ b/crates/consensus/beacon/src/engine/hooks/static_file.rs @@ -6,7 +6,7 @@ use crate::{ }; use futures::FutureExt; use reth_db::database::Database; -use reth_interfaces::RethResult; +use reth_errors::RethResult; use reth_primitives::{static_file::HighestStaticFiles, BlockNumber}; use reth_static_file::{StaticFileProducer, StaticFileProducerWithResult}; use reth_tasks::TaskSpawner; diff --git a/crates/consensus/beacon/src/engine/message.rs b/crates/consensus/beacon/src/engine/message.rs index 108dab41e..e3433062a 100644 --- a/crates/consensus/beacon/src/engine/message.rs +++ b/crates/consensus/beacon/src/engine/message.rs @@ -1,7 +1,7 @@ use crate::engine::{error::BeaconOnNewPayloadError, forkchoice::ForkchoiceStatus}; use futures::{future::Either, FutureExt}; use reth_engine_primitives::EngineTypes; -use reth_interfaces::RethResult; +use reth_errors::RethResult; use reth_payload_builder::error::PayloadBuilderError; use reth_rpc_types::engine::{ CancunPayloadFields, ExecutionPayload, ForkChoiceUpdateResult, ForkchoiceState, diff --git a/crates/consensus/beacon/src/engine/mod.rs b/crates/consensus/beacon/src/engine/mod.rs index e29ddd624..bcf677097 100644 --- a/crates/consensus/beacon/src/engine/mod.rs +++ b/crates/consensus/beacon/src/engine/mod.rs @@ -1,16 +1,15 @@ use futures::{stream::BoxStream, Future, StreamExt}; +use reth_blockchain_tree_api::{ + error::{BlockchainTreeError, CanonicalError, InsertBlockError, InsertBlockErrorKind}, + BlockStatus, BlockValidationKind, BlockchainTreeEngine, CanonicalOutcome, InsertPayloadOk, +}; use reth_db::database::Database; use reth_engine_primitives::{EngineTypes, PayloadAttributes, PayloadBuilderAttributes}; -use reth_interfaces::{ - blockchain_tree::{ - error::{BlockchainTreeError, CanonicalError, InsertBlockError, InsertBlockErrorKind}, - BlockStatus, BlockValidationKind, BlockchainTreeEngine, CanonicalOutcome, InsertPayloadOk, - }, - executor::BlockValidationError, - p2p::{bodies::client::BodiesClient, headers::client::HeadersClient}, - provider::ProviderResult, +use reth_errors::{BlockValidationError, ProviderResult, RethError, RethResult}; +use reth_network_p2p::{ + bodies::client::BodiesClient, + headers::client::HeadersClient, sync::{NetworkSyncUpdater, SyncState}, - RethError, RethResult, }; use reth_payload_builder::PayloadBuilderHandle; use reth_payload_validator::ExecutionPayloadValidator; @@ -1957,12 +1956,12 @@ mod tests { BeaconForkChoiceUpdateError, }; use assert_matches::assert_matches; - use reth_interfaces::test_utils::generators::{self, Rng}; use reth_primitives::{stage::StageCheckpoint, ChainSpecBuilder, MAINNET}; use reth_provider::{BlockWriter, ProviderFactory}; use reth_rpc_types::engine::{ForkchoiceState, ForkchoiceUpdated, PayloadStatus}; use reth_rpc_types_compat::engine::payload::block_to_payload_v1; use reth_stages::{ExecOutput, PipelineError, StageError}; + use reth_testing_utils::generators::{self, Rng}; use std::{collections::VecDeque, sync::Arc}; use tokio::sync::oneshot::error::TryRecvError; @@ -2152,9 +2151,9 @@ mod tests { mod fork_choice_updated { use super::*; use reth_db::{tables, test_utils::create_test_static_files_dir, transaction::DbTxMut}; - use reth_interfaces::test_utils::generators::random_block; use reth_primitives::U256; use reth_rpc_types::engine::ForkchoiceUpdateError; + use reth_testing_utils::generators::random_block; #[tokio::test] async fn empty_head() { @@ -2452,10 +2451,9 @@ mod tests { mod new_payload { use super::*; use reth_db::test_utils::create_test_static_files_dir; - use reth_interfaces::test_utils::generators::random_block; use reth_primitives::{genesis::Genesis, Hardfork, U256}; use reth_provider::test_utils::blocks::BlockchainTestData; - use reth_testing_utils::GenesisAllocator; + use reth_testing_utils::{generators::random_block, GenesisAllocator}; #[tokio::test] async fn new_payload_before_forkchoice() { diff --git a/crates/consensus/beacon/src/engine/sync.rs b/crates/consensus/beacon/src/engine/sync.rs index 441c3ce03..810e3e748 100644 --- a/crates/consensus/beacon/src/engine/sync.rs +++ b/crates/consensus/beacon/src/engine/sync.rs @@ -6,7 +6,7 @@ use crate::{ }; use futures::FutureExt; use reth_db::database::Database; -use reth_interfaces::p2p::{ +use reth_network_p2p::{ bodies::client::BodiesClient, full_block::{FetchFullBlockFuture, FetchFullBlockRangeFuture, FullBlockClient}, headers::client::HeadersClient, @@ -429,7 +429,7 @@ mod tests { use assert_matches::assert_matches; use futures::poll; use reth_db::{mdbx::DatabaseEnv, test_utils::TempDatabase}; - use reth_interfaces::{p2p::either::Either, test_utils::TestFullBlockClient}; + use reth_network_p2p::{either::Either, test_utils::TestFullBlockClient}; use reth_primitives::{ constants::ETHEREUM_BLOCK_GAS_LIMIT, stage::StageCheckpoint, BlockBody, ChainSpecBuilder, Header, PruneModes, SealedHeader, MAINNET, diff --git a/crates/consensus/beacon/src/engine/test_utils.rs b/crates/consensus/beacon/src/engine/test_utils.rs index 13ffd0c4f..73777d94d 100644 --- a/crates/consensus/beacon/src/engine/test_utils.rs +++ b/crates/consensus/beacon/src/engine/test_utils.rs @@ -16,9 +16,8 @@ use reth_downloaders::{ use reth_ethereum_engine_primitives::EthEngineTypes; use reth_evm::{either::Either, test_utils::MockExecutorProvider}; use reth_evm_ethereum::execute::EthExecutorProvider; -use reth_interfaces::{ - p2p::{bodies::client::BodiesClient, headers::client::HeadersClient}, - sync::NoopSyncStateUpdater, +use reth_network_p2p::{ + bodies::client::BodiesClient, headers::client::HeadersClient, sync::NoopSyncStateUpdater, test_utils::NoopFullBlockClient, }; use reth_payload_builder::test_utils::spawn_test_payload_service; diff --git a/crates/errors/src/lib.rs b/crates/errors/src/lib.rs index 4b8b96fba..9dc0ce0ca 100644 --- a/crates/errors/src/lib.rs +++ b/crates/errors/src/lib.rs @@ -17,7 +17,7 @@ pub use error::{RethError, RethResult}; pub use reth_blockchain_tree_api::error::{BlockchainTreeError, CanonicalError}; pub use reth_consensus::ConsensusError; -pub use reth_execution_errors::BlockExecutionError; +pub use reth_execution_errors::{BlockExecutionError, BlockValidationError}; pub use reth_storage_errors::{ db::DatabaseError, provider::{ProviderError, ProviderResult},