From b4577597c52cc187110d82a24d238992fc39b0b4 Mon Sep 17 00:00:00 2001 From: joshieDo <93316087+joshieDo@users.noreply.github.com> Date: Sat, 6 Jul 2024 14:02:43 +0200 Subject: [PATCH] chore: remove `test-utils`, `arbitrary` and `proptest` from built binary (#9332) --- .github/workflows/lint.yml | 10 ++++++++ Cargo.lock | 1 + crates/e2e-test-utils/Cargo.toml | 4 ++-- crates/ethereum/node/Cargo.toml | 4 ++++ crates/exex/test-utils/Cargo.toml | 4 ++-- crates/node/builder/Cargo.toml | 6 ++++- crates/node/builder/src/builder/mod.rs | 24 +++++++++---------- crates/optimism/node/Cargo.toml | 5 +++- crates/rpc/rpc/Cargo.toml | 4 ++-- .../src/providers/database/provider.rs | 5 ++-- examples/custom-dev-node/Cargo.toml | 2 +- examples/custom-engine-types/Cargo.toml | 2 +- examples/custom-evm/Cargo.toml | 2 +- examples/custom-rlpx-subprotocol/Cargo.toml | 2 +- examples/rpc-db/Cargo.toml | 1 + examples/rpc-db/src/main.rs | 6 ++--- examples/stateful-precompile/Cargo.toml | 2 +- 17 files changed, 53 insertions(+), 31 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index d0329aefc..3aefc21c8 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -160,6 +160,15 @@ jobs: with: cmd: jq empty etc/grafana/dashboards/overview.json + no-test-deps: + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - name: Ensure no arbitrary or proptest dependency on default build + run: cargo tree --package reth -e=features,no-dev | grep -Eq "arbitrary|proptest" && exit 1 || exit 0 + lint-success: name: lint success runs-on: ubuntu-latest @@ -173,6 +182,7 @@ jobs: - book - codespell - grafana + - no-test-deps timeout-minutes: 30 steps: - name: Decide whether the needed jobs succeeded or failed diff --git a/Cargo.lock b/Cargo.lock index 8d62a42cb..d7bc1dfa4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3056,6 +3056,7 @@ dependencies = [ "reth-db", "reth-db-api", "reth-node-ethereum", + "reth-provider", "tokio", ] diff --git a/crates/e2e-test-utils/Cargo.toml b/crates/e2e-test-utils/Cargo.toml index a610d5569..f472da06b 100644 --- a/crates/e2e-test-utils/Cargo.toml +++ b/crates/e2e-test-utils/Cargo.toml @@ -13,12 +13,12 @@ reth.workspace = true reth-chainspec.workspace = true reth-primitives.workspace = true reth-tracing.workspace = true -reth-db.workspace = true +reth-db = { workspace = true, features = ["test-utils"] } reth-rpc.workspace = true reth-rpc-layer.workspace = true reth-payload-builder = { workspace = true, features = ["test-utils"] } reth-provider.workspace = true -reth-node-builder.workspace = true +reth-node-builder = { workspace = true, features = ["test-utils"] } reth-tokio-util.workspace = true reth-stages-types.workspace = true reth-network-peers.workspace = true diff --git a/crates/ethereum/node/Cargo.toml b/crates/ethereum/node/Cargo.toml index 54e54a0eb..f053b35b9 100644 --- a/crates/ethereum/node/Cargo.toml +++ b/crates/ethereum/node/Cargo.toml @@ -43,3 +43,7 @@ futures.workspace = true tokio.workspace = true futures-util.workspace = true serde_json.workspace = true + +[features] +default = [] +test-utils = ["reth-node-builder/test-utils"] diff --git a/crates/exex/test-utils/Cargo.toml b/crates/exex/test-utils/Cargo.toml index b7db9a98f..b5b62471b 100644 --- a/crates/exex/test-utils/Cargo.toml +++ b/crates/exex/test-utils/Cargo.toml @@ -24,11 +24,11 @@ reth-exex.workspace = true reth-network.workspace = true reth-node-api.workspace = true reth-node-core.workspace = true -reth-node-builder.workspace = true +reth-node-builder = { workspace = true, features = ["test-utils"] } reth-node-ethereum.workspace = true reth-payload-builder.workspace = true reth-primitives.workspace = true -reth-provider.workspace = true +reth-provider = { workspace = true, features = ["test-utils"] } reth-tasks.workspace = true reth-transaction-pool = { workspace = true, features = ["test-utils"] } diff --git a/crates/node/builder/Cargo.toml b/crates/node/builder/Cargo.toml index f15ec8774..5a29b6e77 100644 --- a/crates/node/builder/Cargo.toml +++ b/crates/node/builder/Cargo.toml @@ -21,7 +21,7 @@ reth-db-common.workspace = true reth-exex.workspace = true reth-evm.workspace = true reth-provider.workspace = true -reth-db = { workspace = true, features = ["mdbx"] } +reth-db = { workspace = true, features = ["mdbx"], optional = true } reth-db-api.workspace = true reth-rpc-engine-api.workspace = true reth-rpc.workspace = true @@ -78,3 +78,7 @@ tracing.workspace = true [dev-dependencies] tempfile.workspace = true + +[features] +default = [] +test-utils = ["reth-db/test-utils"] diff --git a/crates/node/builder/src/builder/mod.rs b/crates/node/builder/src/builder/mod.rs index 23a18ee30..d46b73d76 100644 --- a/crates/node/builder/src/builder/mod.rs +++ b/crates/node/builder/src/builder/mod.rs @@ -12,10 +12,6 @@ use crate::{ use futures::Future; use reth_chainspec::ChainSpec; use reth_cli_util::get_secret_key; -use reth_db::{ - test_utils::{create_test_rw_db_with_path, tempdir_path, TempDatabase}, - DatabaseEnv, -}; use reth_db_api::{ database::Database, database_metrics::{DatabaseMetadata, DatabaseMetrics}, @@ -26,9 +22,8 @@ use reth_network::{ }; use reth_node_api::{FullNodeTypes, FullNodeTypesAdapter, NodeTypes}; use reth_node_core::{ - args::DatadirArgs, cli::config::{PayloadBuilderConfig, RethTransactionPoolConfig}, - dirs::{ChainPath, DataDirPath, MaybePlatformPath}, + dirs::{ChainPath, DataDirPath}, node_config::NodeConfig, primitives::Head, }; @@ -176,19 +171,24 @@ impl NodeBuilder { } /// Creates an _ephemeral_ preconfigured node for testing purposes. + #[cfg(feature = "test-utils")] pub fn testing_node( mut self, task_executor: TaskExecutor, - ) -> WithLaunchContext>>> { - let path = MaybePlatformPath::::from(tempdir_path()); - self.config = self - .config - .with_datadir_args(DatadirArgs { datadir: path.clone(), ..Default::default() }); + ) -> WithLaunchContext>>> + { + let path = reth_node_core::dirs::MaybePlatformPath::::from( + reth_db::test_utils::tempdir_path(), + ); + self.config = self.config.with_datadir_args(reth_node_core::args::DatadirArgs { + datadir: path.clone(), + ..Default::default() + }); let data_dir = path.unwrap_or_chain_default(self.config.chain.chain, self.config.datadir.clone()); - let db = create_test_rw_db_with_path(data_dir.db()); + let db = reth_db::test_utils::create_test_rw_db_with_path(data_dir.db()); WithLaunchContext { builder: self.with_database(db), task_executor } } diff --git a/crates/optimism/node/Cargo.toml b/crates/optimism/node/Cargo.toml index 5d172ec93..1a32bcad6 100644 --- a/crates/optimism/node/Cargo.toml +++ b/crates/optimism/node/Cargo.toml @@ -58,8 +58,10 @@ serde_json.workspace = true [dev-dependencies] reth.workspace = true reth-db.workspace = true -reth-revm = { workspace = true, features = ["test-utils"] } reth-e2e-test-utils.workspace = true +reth-node-builder = { workspace = true, features = ["test-utils"] } +reth-provider = { workspace = true, features = ["test-utils"] } +reth-revm = { workspace = true, features = ["test-utils"] } tokio.workspace = true alloy-primitives.workspace = true alloy-genesis.workspace = true @@ -78,3 +80,4 @@ optimism = [ "reth-auto-seal-consensus/optimism", "reth-rpc-eth-types/optimism" ] +test-utils = ["reth-node-builder/test-utils"] diff --git a/crates/rpc/rpc/Cargo.toml b/crates/rpc/rpc/Cargo.toml index df6787199..256fc156b 100644 --- a/crates/rpc/rpc/Cargo.toml +++ b/crates/rpc/rpc/Cargo.toml @@ -19,8 +19,8 @@ reth-rpc-api.workspace = true reth-rpc-eth-api.workspace = true reth-rpc-types.workspace = true reth-errors.workspace = true -reth-provider = { workspace = true, features = ["test-utils"] } -reth-transaction-pool = { workspace = true, features = ["test-utils"] } +reth-provider.workspace = true +reth-transaction-pool.workspace = true reth-network-api.workspace = true reth-rpc-engine-api.workspace = true reth-revm.workspace = true diff --git a/crates/storage/provider/src/providers/database/provider.rs b/crates/storage/provider/src/providers/database/provider.rs index 83d9da3c6..970c77b39 100644 --- a/crates/storage/provider/src/providers/database/provider.rs +++ b/crates/storage/provider/src/providers/database/provider.rs @@ -172,8 +172,9 @@ impl DatabaseProvider { } impl DatabaseProvider { - #[cfg(any(test, feature = "test-utils"))] - /// Inserts an historical block. Used for setting up test environments + // TODO: uncomment below, once `reth debug_cmd` has been feature gated with dev. + // #[cfg(any(test, feature = "test-utils"))] + /// Inserts an historical block. **Used for setting up test environments** pub fn insert_historical_block( &self, block: SealedBlockWithSenders, diff --git a/examples/custom-dev-node/Cargo.toml b/examples/custom-dev-node/Cargo.toml index cc21c97d2..d40c97ca6 100644 --- a/examples/custom-dev-node/Cargo.toml +++ b/examples/custom-dev-node/Cargo.toml @@ -11,7 +11,7 @@ reth.workspace = true reth-chainspec.workspace = true reth-node-core.workspace = true reth-primitives.workspace = true -reth-node-ethereum.workspace = true +reth-node-ethereum = { workspace = true, features = ["test-utils"] } futures-util.workspace = true eyre.workspace = true diff --git a/examples/custom-engine-types/Cargo.toml b/examples/custom-engine-types/Cargo.toml index 3b6a796ba..c00863147 100644 --- a/examples/custom-engine-types/Cargo.toml +++ b/examples/custom-engine-types/Cargo.toml @@ -15,7 +15,7 @@ reth-primitives.workspace = true reth-payload-builder.workspace = true reth-basic-payload-builder.workspace = true reth-ethereum-payload-builder.workspace = true -reth-node-ethereum.workspace = true +reth-node-ethereum = { workspace = true, features = ["test-utils"] } reth-tracing.workspace = true alloy-genesis.workspace = true diff --git a/examples/custom-evm/Cargo.toml b/examples/custom-evm/Cargo.toml index a85b6ce8a..7642dc80c 100644 --- a/examples/custom-evm/Cargo.toml +++ b/examples/custom-evm/Cargo.toml @@ -12,7 +12,7 @@ reth-evm-ethereum.workspace = true reth-node-api.workspace = true reth-node-core.workspace = true reth-primitives.workspace = true -reth-node-ethereum.workspace = true +reth-node-ethereum = { workspace = true, features = ["test-utils"] } reth-tracing.workspace = true alloy-genesis.workspace = true diff --git a/examples/custom-rlpx-subprotocol/Cargo.toml b/examples/custom-rlpx-subprotocol/Cargo.toml index ae3a7c088..d2d1caab6 100644 --- a/examples/custom-rlpx-subprotocol/Cargo.toml +++ b/examples/custom-rlpx-subprotocol/Cargo.toml @@ -13,7 +13,7 @@ reth-eth-wire.workspace = true reth-network.workspace = true reth-network-api.workspace = true reth-node-ethereum.workspace = true -reth-provider.workspace = true +reth-provider = { workspace = true, features = ["test-utils"] } reth-primitives.workspace = true reth-rpc-types.workspace = true reth.workspace = true diff --git a/examples/rpc-db/Cargo.toml b/examples/rpc-db/Cargo.toml index 8bcab0e2b..007a488b8 100644 --- a/examples/rpc-db/Cargo.toml +++ b/examples/rpc-db/Cargo.toml @@ -13,5 +13,6 @@ reth-chainspec.workspace = true reth-db.workspace = true reth-db-api.workspace = true reth-node-ethereum.workspace = true +reth-provider = { workspace = true, features = ["test-utils"] } tokio = { workspace = true, features = ["full"] } eyre.workspace = true diff --git a/examples/rpc-db/src/main.rs b/examples/rpc-db/src/main.rs index 6d18640f7..85ad28d6a 100644 --- a/examples/rpc-db/src/main.rs +++ b/examples/rpc-db/src/main.rs @@ -31,11 +31,9 @@ use reth::rpc::builder::{ }; // Configuring the network parts, ideally also wouldn't need to think about this. use myrpc_ext::{MyRpcExt, MyRpcExtApiServer}; -use reth::{ - blockchain_tree::noop::NoopBlockchainTree, providers::test_utils::TestCanonStateSubscriptions, - tasks::TokioTaskExecutor, -}; +use reth::{blockchain_tree::noop::NoopBlockchainTree, tasks::TokioTaskExecutor}; use reth_node_ethereum::EthEvmConfig; +use reth_provider::test_utils::TestCanonStateSubscriptions; // Custom rpc extension pub mod myrpc_ext; diff --git a/examples/stateful-precompile/Cargo.toml b/examples/stateful-precompile/Cargo.toml index c983ef80d..2ae4656ee 100644 --- a/examples/stateful-precompile/Cargo.toml +++ b/examples/stateful-precompile/Cargo.toml @@ -11,7 +11,7 @@ reth-chainspec.workspace = true reth-node-api.workspace = true reth-node-core.workspace = true reth-primitives.workspace = true -reth-node-ethereum.workspace = true +reth-node-ethereum = { workspace = true, features = ["test-utils"] } reth-tracing.workspace = true alloy-genesis.workspace = true