From 952b349dacd7d56a05a79b09be5fea7758198f70 Mon Sep 17 00:00:00 2001 From: joshieDo <93316087+joshieDo@users.noreply.github.com> Date: Mon, 17 Jun 2024 19:48:04 +0200 Subject: [PATCH] remove reth_primitives --- Cargo.lock | 4 +++- crates/stages/api/Cargo.toml | 5 ++++- crates/stages/api/src/error.rs | 4 +++- crates/stages/api/src/metrics/listener.rs | 3 ++- crates/stages/api/src/pipeline/builder.rs | 2 +- crates/stages/api/src/pipeline/ctrl.rs | 3 ++- crates/stages/api/src/pipeline/event.rs | 2 +- crates/stages/api/src/pipeline/mod.rs | 19 +++++++++---------- crates/stages/api/src/pipeline/progress.rs | 2 +- crates/stages/api/src/stage.rs | 2 +- 10 files changed, 27 insertions(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d6cb12085f7d..4d9db5feed6c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8133,6 +8133,7 @@ dependencies = [ name = "reth-stages-api" version = "1.0.0-rc.1" dependencies = [ + "alloy-primitives", "aquamarine", "assert_matches", "auto_impl", @@ -8143,11 +8144,12 @@ dependencies = [ "reth-errors", "reth-metrics", "reth-network-p2p", - "reth-primitives", + "reth-primitives-traits", "reth-provider", "reth-prune", "reth-stages-types", "reth-static-file", + "reth-static-file-types", "reth-testing-utils", "reth-tokio-util", "thiserror", diff --git a/crates/stages/api/Cargo.toml b/crates/stages/api/Cargo.toml index cb58818b503c..a5db5b9fb20c 100644 --- a/crates/stages/api/Cargo.toml +++ b/crates/stages/api/Cargo.toml @@ -12,7 +12,7 @@ workspace = true [dependencies] # reth -reth-primitives.workspace = true +reth-primitives-traits.workspace = true reth-provider.workspace = true reth-db-api.workspace = true reth-static-file.workspace = true @@ -22,6 +22,9 @@ reth-consensus.workspace = true reth-prune.workspace = true reth-errors.workspace = true reth-stages-types.workspace = true +reth-static-file-types.workspace = true + +alloy-primitives.workspace = true # metrics reth-metrics.workspace = true diff --git a/crates/stages/api/src/error.rs b/crates/stages/api/src/error.rs index ab525f8f5331..2f113f2fa813 100644 --- a/crates/stages/api/src/error.rs +++ b/crates/stages/api/src/error.rs @@ -1,9 +1,11 @@ use crate::PipelineEvent; +use alloy_primitives::{BlockNumber, TxNumber}; use reth_consensus::ConsensusError; use reth_errors::{BlockExecutionError, DatabaseError, RethError}; use reth_network_p2p::error::DownloadError; -use reth_primitives::{BlockNumber, SealedHeader, StaticFileSegment, TxNumber}; +use reth_primitives_traits::SealedHeader; use reth_provider::ProviderError; +use reth_static_file_types::StaticFileSegment; use thiserror::Error; use tokio::sync::broadcast::error::SendError; diff --git a/crates/stages/api/src/metrics/listener.rs b/crates/stages/api/src/metrics/listener.rs index 408ecab4a95c..e703367bcd67 100644 --- a/crates/stages/api/src/metrics/listener.rs +++ b/crates/stages/api/src/metrics/listener.rs @@ -1,5 +1,6 @@ use crate::{metrics::SyncMetrics, StageCheckpoint, StageId}; -use reth_primitives::{constants::MGAS_TO_GAS, BlockNumber}; +use alloy_primitives::BlockNumber; +use reth_primitives_traits::constants::MGAS_TO_GAS; use std::{ future::Future, pin::Pin, diff --git a/crates/stages/api/src/pipeline/builder.rs b/crates/stages/api/src/pipeline/builder.rs index ada5ffd3734a..1e83af4c3c82 100644 --- a/crates/stages/api/src/pipeline/builder.rs +++ b/crates/stages/api/src/pipeline/builder.rs @@ -1,6 +1,6 @@ use crate::{pipeline::BoxedStage, MetricEventsSender, Pipeline, Stage, StageId, StageSet}; +use alloy_primitives::{BlockNumber, B256}; use reth_db_api::database::Database; -use reth_primitives::{BlockNumber, B256}; use reth_provider::ProviderFactory; use reth_static_file::StaticFileProducer; use tokio::sync::watch; diff --git a/crates/stages/api/src/pipeline/ctrl.rs b/crates/stages/api/src/pipeline/ctrl.rs index 83dbe0cf394c..8fc64c2ab708 100644 --- a/crates/stages/api/src/pipeline/ctrl.rs +++ b/crates/stages/api/src/pipeline/ctrl.rs @@ -1,4 +1,5 @@ -use reth_primitives::{BlockNumber, SealedHeader}; +use alloy_primitives::BlockNumber; +use reth_primitives_traits::SealedHeader; /// Determines the control flow during pipeline execution. /// diff --git a/crates/stages/api/src/pipeline/event.rs b/crates/stages/api/src/pipeline/event.rs index 9bbaaa79b468..879725886cf9 100644 --- a/crates/stages/api/src/pipeline/event.rs +++ b/crates/stages/api/src/pipeline/event.rs @@ -2,7 +2,7 @@ use crate::{ stage::{ExecOutput, UnwindInput, UnwindOutput}, StageCheckpoint, StageId, }; -use reth_primitives::BlockNumber; +use alloy_primitives::BlockNumber; use std::fmt::{Display, Formatter}; /// An event emitted by a [Pipeline][crate::Pipeline]. diff --git a/crates/stages/api/src/pipeline/mod.rs b/crates/stages/api/src/pipeline/mod.rs index 2b7fcf6cbec4..67ef53855b15 100644 --- a/crates/stages/api/src/pipeline/mod.rs +++ b/crates/stages/api/src/pipeline/mod.rs @@ -2,19 +2,18 @@ mod ctrl; mod event; pub use crate::pipeline::ctrl::ControlFlow; use crate::{PipelineTarget, StageCheckpoint, StageId}; +use alloy_primitives::{BlockNumber, B256}; pub use event::*; use futures_util::Future; use reth_db_api::database::Database; -use reth_primitives::{ - constants::BEACON_CONSENSUS_REORG_UNWIND_DEPTH, static_file::HighestStaticFiles, BlockNumber, - B256, -}; +use reth_primitives_traits::constants::BEACON_CONSENSUS_REORG_UNWIND_DEPTH; use reth_provider::{ providers::StaticFileWriter, FinalizedBlockReader, FinalizedBlockWriter, ProviderFactory, StageCheckpointReader, StageCheckpointWriter, StaticFileProviderFactory, }; use reth_prune::PrunerBuilder; use reth_static_file::StaticFileProducer; +use reth_static_file_types::HighestStaticFiles; use reth_tokio_util::{EventSender, EventStream}; use std::pin::Pin; use tokio::sync::watch; @@ -237,13 +236,13 @@ where /// Run [static file producer](StaticFileProducer) and [pruner](reth_prune::Pruner) to **move** /// all data from the database to static files for corresponding - /// [segments](reth_primitives::static_file::StaticFileSegment), according to their [stage + /// [segments](reth_static_file_types::StaticFileSegment), according to their [stage /// checkpoints](StageCheckpoint): - /// - [`StaticFileSegment::Headers`](reth_primitives::static_file::StaticFileSegment::Headers) - /// -> [`StageId::Headers`] - /// - [`StaticFileSegment::Receipts`](reth_primitives::static_file::StaticFileSegment::Receipts) - /// -> [`StageId::Execution`] - /// - [`StaticFileSegment::Transactions`](reth_primitives::static_file::StaticFileSegment::Transactions) + /// - [`StaticFileSegment::Headers`](reth_static_file_types::StaticFileSegment::Headers) -> + /// [`StageId::Headers`] + /// - [`StaticFileSegment::Receipts`](reth_static_file_types::StaticFileSegment::Receipts) -> + /// [`StageId::Execution`] + /// - [`StaticFileSegment::Transactions`](reth_static_file_types::StaticFileSegment::Transactions) /// -> [`StageId::Bodies`] /// /// CAUTION: This method locks the static file producer Mutex, hence can block the thread if the diff --git a/crates/stages/api/src/pipeline/progress.rs b/crates/stages/api/src/pipeline/progress.rs index 4bb1848543a9..4138f95ddf59 100644 --- a/crates/stages/api/src/pipeline/progress.rs +++ b/crates/stages/api/src/pipeline/progress.rs @@ -1,5 +1,5 @@ use crate::{util::opt, ControlFlow}; -use reth_primitives::BlockNumber; +use alloy_primitives::BlockNumber; #[derive(Debug, Default)] pub(crate) struct PipelineProgress { diff --git a/crates/stages/api/src/stage.rs b/crates/stages/api/src/stage.rs index 381acf5f2d99..b8178df46d51 100644 --- a/crates/stages/api/src/stage.rs +++ b/crates/stages/api/src/stage.rs @@ -1,6 +1,6 @@ use crate::{error::StageError, StageCheckpoint, StageId}; +use alloy_primitives::{BlockNumber, TxNumber}; use reth_db_api::database::Database; -use reth_primitives::{BlockNumber, TxNumber}; use reth_provider::{BlockReader, DatabaseProviderRW, ProviderError, TransactionsProvider}; use std::{ cmp::{max, min},