From 8a0f8cf835d9059cf334616b338fdc1ab7af4d1b Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 19 Apr 2024 14:25:11 +0200 Subject: [PATCH] chore: stages crates touchups (#7742) --- Cargo.lock | 11 +--------- Cargo.toml | 1 + crates/interfaces/Cargo.toml | 2 +- crates/net/eth-wire-types/Cargo.toml | 1 - crates/net/network/Cargo.toml | 2 +- crates/stages-api/Cargo.toml | 17 ++++++++------ crates/stages-api/src/lib.rs | 16 +++++++++++++- crates/stages-api/src/pipeline/mod.rs | 1 - .../{test_utils/stage.rs => test_utils.rs} | 5 +++++ crates/stages-api/src/test_utils/mod.rs | 2 -- crates/stages/Cargo.toml | 22 +++++-------------- crates/stages/src/lib.rs | 3 ++- crates/stages/src/sets.rs | 2 +- crates/stages/src/stages/execution.rs | 2 +- crates/stages/src/stages/mod.rs | 2 +- crates/storage/provider/Cargo.toml | 2 +- crates/transaction-pool/Cargo.toml | 2 +- crates/trie/Cargo.toml | 2 +- 18 files changed, 47 insertions(+), 48 deletions(-) rename crates/stages-api/src/{test_utils/stage.rs => test_utils.rs} (92%) delete mode 100644 crates/stages-api/src/test_utils/mod.rs diff --git a/Cargo.lock b/Cargo.lock index f63c38402..d8bde9658 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7400,41 +7400,32 @@ name = "reth-stages" version = "0.2.0-beta.5" dependencies = [ "alloy-rlp", - "aquamarine", "assert_matches", - "auto_impl", "criterion", "futures-util", "itertools 0.12.1", - "metrics", "num-traits", "paste", "pprof", "rand 0.8.5", "rayon", - "reth-blockchain-tree", "reth-codecs", "reth-config", "reth-db", "reth-downloaders", - "reth-eth-wire", "reth-etl", + "reth-evm-ethereum", "reth-interfaces", - "reth-metrics", - "reth-node-ethereum", - "reth-node-optimism", "reth-primitives", "reth-provider", "reth-revm", "reth-stages-api", "reth-static-file", - "reth-tokio-util", "reth-trie", "serde_json", "tempfile", "thiserror", "tokio", - "tokio-stream", "tracing", ] diff --git a/Cargo.toml b/Cargo.toml index 81f1c9d6e..b0402d44c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -298,6 +298,7 @@ alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "188c4f8" } alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "188c4f8" } # misc +auto_impl = "1" aquamarine = "0.5" bytes = "1.5" bitflags = "2.4" diff --git a/crates/interfaces/Cargo.toml b/crates/interfaces/Cargo.toml index 2dde42801..8f4aa494a 100644 --- a/crates/interfaces/Cargo.toml +++ b/crates/interfaces/Cargo.toml @@ -21,7 +21,7 @@ futures.workspace = true tokio = { workspace = true, features = ["sync"] } # misc -auto_impl = "1.0" +auto_impl.workspace = true thiserror.workspace = true tracing.workspace = true secp256k1 = { workspace = true, default-features = false, features = [ diff --git a/crates/net/eth-wire-types/Cargo.toml b/crates/net/eth-wire-types/Cargo.toml index 54f3763a2..7e9365d48 100644 --- a/crates/net/eth-wire-types/Cargo.toml +++ b/crates/net/eth-wire-types/Cargo.toml @@ -7,7 +7,6 @@ rust-version.workspace = true license.workspace = true homepage.workspace = true repository.workspace = true -exclude.workspace = true [lints] workspace = true diff --git a/crates/net/network/Cargo.toml b/crates/net/network/Cargo.toml index 079a43634..8e4c110bb 100644 --- a/crates/net/network/Cargo.toml +++ b/crates/net/network/Cargo.toml @@ -51,7 +51,7 @@ reth-metrics = { workspace = true, features = ["common"] } metrics.workspace = true # misc -auto_impl = "1" +auto_impl.workspace = true aquamarine.workspace = true tracing.workspace = true fnv = "1.0" diff --git a/crates/stages-api/Cargo.toml b/crates/stages-api/Cargo.toml index 8d1eccd6e..d991a47af 100644 --- a/crates/stages-api/Cargo.toml +++ b/crates/stages-api/Cargo.toml @@ -6,7 +6,9 @@ rust-version.workspace = true license.workspace = true homepage.workspace = true repository.workspace = true -exclude.workspace = true + +[lints] +workspace = true [dependencies] # reth @@ -15,7 +17,6 @@ reth-provider.workspace = true reth-db.workspace = true reth-interfaces.workspace = true reth-static-file.workspace = true -assert_matches.workspace = true reth-tokio-util.workspace = true # metrics @@ -28,13 +29,15 @@ tokio-stream.workspace = true futures-util.workspace = true # misc +aquamarine.workspace = true thiserror.workspace = true tracing.workspace = true -auto_impl = "1" -aquamarine.workspace = true +auto_impl.workspace = true + +[dev-dependencies] +assert_matches.workspace = true +reth-provider = { workspace = true, features = ["test-utils"] } +reth-interfaces = { workspace = true, features = ["test-utils"] } [features] test-utils = [] - -[lints] -workspace = true diff --git a/crates/stages-api/src/lib.rs b/crates/stages-api/src/lib.rs index fa6cd74e6..084680ce4 100644 --- a/crates/stages-api/src/lib.rs +++ b/crates/stages-api/src/lib.rs @@ -1,9 +1,21 @@ //! Staged syncing primitives for reth. +//! +//! ## Feature Flags +//! +//! - `test-utils`: Utilities for testing + +#![doc( + html_logo_url = "https://raw.githubusercontent.com/paradigmxyz/reth/main/assets/reth-docs.png", + html_favicon_url = "https://avatars0.githubusercontent.com/u/97369466?s=256", + issue_tracker_base_url = "https://github.com/paradigmxyz/reth/issues/" +)] +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] +#![cfg_attr(not(test), warn(unused_crate_dependencies))] + mod error; mod metrics; mod pipeline; mod stage; -#[allow(missing_docs)] #[cfg(any(test, feature = "test-utils"))] pub mod test_utils; mod util; @@ -12,3 +24,5 @@ pub use crate::metrics::*; pub use error::*; pub use pipeline::*; pub use stage::*; + +use aquamarine as _; diff --git a/crates/stages-api/src/pipeline/mod.rs b/crates/stages-api/src/pipeline/mod.rs index d19325a3c..7f54e13ff 100644 --- a/crates/stages-api/src/pipeline/mod.rs +++ b/crates/stages-api/src/pipeline/mod.rs @@ -2,7 +2,6 @@ mod ctrl; mod event; pub use crate::pipeline::ctrl::ControlFlow; pub use event::*; - use futures_util::Future; use reth_db::database::Database; use reth_interfaces::RethResult; diff --git a/crates/stages-api/src/test_utils/stage.rs b/crates/stages-api/src/test_utils.rs similarity index 92% rename from crates/stages-api/src/test_utils/stage.rs rename to crates/stages-api/src/test_utils.rs index a76e46e67..3caba0737 100644 --- a/crates/stages-api/src/test_utils/stage.rs +++ b/crates/stages-api/src/test_utils.rs @@ -1,9 +1,14 @@ +#![allow(missing_docs)] + use crate::{ExecInput, ExecOutput, Stage, StageError, UnwindInput, UnwindOutput}; use reth_db::database::Database; use reth_primitives::stage::StageId; use reth_provider::DatabaseProviderRW; use std::collections::VecDeque; +/// A test stage that can be used for testing. +/// +/// This can be used to mock expected outputs of [Stage::execute] and [Stage::unwind] #[derive(Debug)] pub struct TestStage { id: StageId, diff --git a/crates/stages-api/src/test_utils/mod.rs b/crates/stages-api/src/test_utils/mod.rs deleted file mode 100644 index 1a44c2fa8..000000000 --- a/crates/stages-api/src/test_utils/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -mod stage; -pub use stage::TestStage; diff --git a/crates/stages/Cargo.toml b/crates/stages/Cargo.toml index 4c9fc8dde..00aff1fd6 100644 --- a/crates/stages/Cargo.toml +++ b/crates/stages/Cargo.toml @@ -19,46 +19,33 @@ reth-db.workspace = true reth-codecs.workspace = true reth-provider.workspace = true reth-trie = { workspace = true, features = ["metrics"] } -reth-tokio-util.workspace = true reth-etl.workspace = true -reth-static-file.workspace = true reth-config.workspace = true reth-stages-api = {workspace = true , features = ["test-utils"]} # async tokio = { workspace = true, features = ["sync"] } -tokio-stream.workspace = true futures-util.workspace = true # observability tracing.workspace = true -# io -tempfile.workspace = true - -# metrics -reth-metrics.workspace = true -metrics.workspace = true - # misc thiserror.workspace = true -aquamarine.workspace = true itertools.workspace = true rayon.workspace = true num-traits = "0.2.15" -auto_impl = "1" +tempfile = { workspace = true, optional = true} [dev-dependencies] # reth reth-primitives = { workspace = true, features = ["test-utils", "arbitrary"] } reth-db = { workspace = true, features = ["test-utils", "mdbx"] } +reth-evm-ethereum.workspace = true reth-interfaces = { workspace = true, features = ["test-utils"] } reth-downloaders.workspace = true -reth-eth-wire.workspace = true # TODO(onbjerg): We only need this for [BlockBody] -reth-node-ethereum.workspace = true -reth-node-optimism.workspace = true -reth-blockchain-tree.workspace = true reth-revm.workspace = true +reth-static-file.workspace = true reth-trie = { workspace = true, features = ["test-utils"] } reth-provider = { workspace = true, features = ["test-utils"] } @@ -68,6 +55,7 @@ tokio = { workspace = true, features = ["rt", "sync", "macros"] } assert_matches.workspace = true rand.workspace = true paste.workspace = true +tempfile.workspace = true # Stage benchmarks criterion = { workspace = true, features = ["async_futures"] } @@ -79,7 +67,7 @@ serde_json.workspace = true pprof = { workspace = true, features = ["flamegraph", "frame-pointer", "criterion"] } [features] -test-utils = ["reth-interfaces/test-utils", "reth-db/test-utils", "reth-provider/test-utils", "reth-stages-api/test-utils"] +test-utils = ["reth-interfaces/test-utils", "reth-db/test-utils", "reth-provider/test-utils", "reth-stages-api/test-utils", "dep:tempfile"] [[bench]] name = "criterion" diff --git a/crates/stages/src/lib.rs b/crates/stages/src/lib.rs index e11302543..f8e427763 100644 --- a/crates/stages/src/lib.rs +++ b/crates/stages/src/lib.rs @@ -22,7 +22,7 @@ //! # use reth_stages::Pipeline; //! # use reth_stages::sets::DefaultStages; //! # use tokio::sync::watch; -//! # use reth_node_ethereum::EthEvmConfig; +//! # use reth_evm_ethereum::EthEvmConfig; //! # use reth_provider::ProviderFactory; //! # use reth_provider::HeaderSyncMode; //! # use reth_provider::test_utils::create_test_provider_factory; @@ -76,6 +76,7 @@ issue_tracker_base_url = "https://github.com/paradigmxyz/reth/issues/" )] #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] +#![cfg_attr(not(test), warn(unused_crate_dependencies))] #[allow(missing_docs)] #[cfg(any(test, feature = "test-utils"))] diff --git a/crates/stages/src/sets.rs b/crates/stages/src/sets.rs index 1185de25f..a92988af9 100644 --- a/crates/stages/src/sets.rs +++ b/crates/stages/src/sets.rs @@ -14,7 +14,7 @@ //! # use reth_stages::sets::{OfflineStages}; //! # use reth_revm::EvmProcessorFactory; //! # use reth_primitives::{PruneModes, MAINNET}; -//! # use reth_node_ethereum::EthEvmConfig; +//! # use reth_evm_ethereum::EthEvmConfig; //! # use reth_provider::test_utils::create_test_provider_factory; //! # use reth_static_file::StaticFileProducer; //! # use reth_config::config::EtlConfig; diff --git a/crates/stages/src/stages/execution.rs b/crates/stages/src/stages/execution.rs index ecaae33c3..1bb21228e 100644 --- a/crates/stages/src/stages/execution.rs +++ b/crates/stages/src/stages/execution.rs @@ -622,8 +622,8 @@ mod tests { use alloy_rlp::Decodable; use assert_matches::assert_matches; use reth_db::models::AccountBeforeTx; + use reth_evm_ethereum::EthEvmConfig; use reth_interfaces::executor::BlockValidationError; - use reth_node_ethereum::EthEvmConfig; use reth_primitives::{ address, hex_literal::hex, keccak256, stage::StageUnitCheckpoint, Account, Address, Bytecode, ChainSpecBuilder, PruneMode, ReceiptsLogPruneConfig, SealedBlock, StorageEntry, diff --git a/crates/stages/src/stages/mod.rs b/crates/stages/src/stages/mod.rs index 3539451f1..fe1012f42 100644 --- a/crates/stages/src/stages/mod.rs +++ b/crates/stages/src/stages/mod.rs @@ -50,8 +50,8 @@ mod tests { transaction::{DbTx, DbTxMut}, AccountsHistory, DatabaseEnv, }; + use reth_evm_ethereum::EthEvmConfig; use reth_interfaces::test_utils::generators::{self, random_block}; - use reth_node_ethereum::EthEvmConfig; use reth_primitives::{ address, hex_literal::hex, keccak256, Account, Bytecode, ChainSpecBuilder, PruneMode, PruneModes, SealedBlock, StaticFileSegment, U256, diff --git a/crates/storage/provider/Cargo.toml b/crates/storage/provider/Cargo.toml index c54adc050..6f9305e88 100644 --- a/crates/storage/provider/Cargo.toml +++ b/crates/storage/provider/Cargo.toml @@ -35,7 +35,7 @@ reth-metrics.workspace = true metrics.workspace = true # misc -auto_impl = "1.0" +auto_impl.workspace = true itertools.workspace = true pin-project.workspace = true parking_lot.workspace = true diff --git a/crates/transaction-pool/Cargo.toml b/crates/transaction-pool/Cargo.toml index 59af67302..5b6b85486 100644 --- a/crates/transaction-pool/Cargo.toml +++ b/crates/transaction-pool/Cargo.toml @@ -39,7 +39,7 @@ schnellru.workspace = true serde = { workspace = true, features = ["derive", "rc"], optional = true } fnv = "1.0.7" bitflags.workspace = true -auto_impl = "1.0" +auto_impl.workspace = true smallvec.workspace = true itertools.workspace = true diff --git a/crates/trie/Cargo.toml b/crates/trie/Cargo.toml index faf874523..396629086 100644 --- a/crates/trie/Cargo.toml +++ b/crates/trie/Cargo.toml @@ -27,7 +27,7 @@ tracing.workspace = true # misc thiserror.workspace = true derive_more.workspace = true -auto_impl = "1" +auto_impl.workspace = true # `metrics` feature reth-metrics = { workspace = true, optional = true }