chore: remove test-utils, arbitrary and proptest from built binary (#9332)

This commit is contained in:
joshieDo
2024-07-06 14:02:43 +02:00
committed by GitHub
parent 569555516b
commit b4577597c5
17 changed files with 53 additions and 31 deletions

View File

@ -160,6 +160,15 @@ jobs:
with: with:
cmd: jq empty etc/grafana/dashboards/overview.json 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: lint-success:
name: lint success name: lint success
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -173,6 +182,7 @@ jobs:
- book - book
- codespell - codespell
- grafana - grafana
- no-test-deps
timeout-minutes: 30 timeout-minutes: 30
steps: steps:
- name: Decide whether the needed jobs succeeded or failed - name: Decide whether the needed jobs succeeded or failed

1
Cargo.lock generated
View File

@ -3056,6 +3056,7 @@ dependencies = [
"reth-db", "reth-db",
"reth-db-api", "reth-db-api",
"reth-node-ethereum", "reth-node-ethereum",
"reth-provider",
"tokio", "tokio",
] ]

View File

@ -13,12 +13,12 @@ reth.workspace = true
reth-chainspec.workspace = true reth-chainspec.workspace = true
reth-primitives.workspace = true reth-primitives.workspace = true
reth-tracing.workspace = true reth-tracing.workspace = true
reth-db.workspace = true reth-db = { workspace = true, features = ["test-utils"] }
reth-rpc.workspace = true reth-rpc.workspace = true
reth-rpc-layer.workspace = true reth-rpc-layer.workspace = true
reth-payload-builder = { workspace = true, features = ["test-utils"] } reth-payload-builder = { workspace = true, features = ["test-utils"] }
reth-provider.workspace = true reth-provider.workspace = true
reth-node-builder.workspace = true reth-node-builder = { workspace = true, features = ["test-utils"] }
reth-tokio-util.workspace = true reth-tokio-util.workspace = true
reth-stages-types.workspace = true reth-stages-types.workspace = true
reth-network-peers.workspace = true reth-network-peers.workspace = true

View File

@ -43,3 +43,7 @@ futures.workspace = true
tokio.workspace = true tokio.workspace = true
futures-util.workspace = true futures-util.workspace = true
serde_json.workspace = true serde_json.workspace = true
[features]
default = []
test-utils = ["reth-node-builder/test-utils"]

View File

@ -24,11 +24,11 @@ reth-exex.workspace = true
reth-network.workspace = true reth-network.workspace = true
reth-node-api.workspace = true reth-node-api.workspace = true
reth-node-core.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-node-ethereum.workspace = true
reth-payload-builder.workspace = true reth-payload-builder.workspace = true
reth-primitives.workspace = true reth-primitives.workspace = true
reth-provider.workspace = true reth-provider = { workspace = true, features = ["test-utils"] }
reth-tasks.workspace = true reth-tasks.workspace = true
reth-transaction-pool = { workspace = true, features = ["test-utils"] } reth-transaction-pool = { workspace = true, features = ["test-utils"] }

View File

@ -21,7 +21,7 @@ reth-db-common.workspace = true
reth-exex.workspace = true reth-exex.workspace = true
reth-evm.workspace = true reth-evm.workspace = true
reth-provider.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-db-api.workspace = true
reth-rpc-engine-api.workspace = true reth-rpc-engine-api.workspace = true
reth-rpc.workspace = true reth-rpc.workspace = true
@ -78,3 +78,7 @@ tracing.workspace = true
[dev-dependencies] [dev-dependencies]
tempfile.workspace = true tempfile.workspace = true
[features]
default = []
test-utils = ["reth-db/test-utils"]

View File

@ -12,10 +12,6 @@ use crate::{
use futures::Future; use futures::Future;
use reth_chainspec::ChainSpec; use reth_chainspec::ChainSpec;
use reth_cli_util::get_secret_key; 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::{ use reth_db_api::{
database::Database, database::Database,
database_metrics::{DatabaseMetadata, DatabaseMetrics}, database_metrics::{DatabaseMetadata, DatabaseMetrics},
@ -26,9 +22,8 @@ use reth_network::{
}; };
use reth_node_api::{FullNodeTypes, FullNodeTypesAdapter, NodeTypes}; use reth_node_api::{FullNodeTypes, FullNodeTypesAdapter, NodeTypes};
use reth_node_core::{ use reth_node_core::{
args::DatadirArgs,
cli::config::{PayloadBuilderConfig, RethTransactionPoolConfig}, cli::config::{PayloadBuilderConfig, RethTransactionPoolConfig},
dirs::{ChainPath, DataDirPath, MaybePlatformPath}, dirs::{ChainPath, DataDirPath},
node_config::NodeConfig, node_config::NodeConfig,
primitives::Head, primitives::Head,
}; };
@ -176,19 +171,24 @@ impl<DB> NodeBuilder<DB> {
} }
/// Creates an _ephemeral_ preconfigured node for testing purposes. /// Creates an _ephemeral_ preconfigured node for testing purposes.
#[cfg(feature = "test-utils")]
pub fn testing_node( pub fn testing_node(
mut self, mut self,
task_executor: TaskExecutor, task_executor: TaskExecutor,
) -> WithLaunchContext<NodeBuilder<Arc<TempDatabase<DatabaseEnv>>>> { ) -> WithLaunchContext<NodeBuilder<Arc<reth_db::test_utils::TempDatabase<reth_db::DatabaseEnv>>>>
let path = MaybePlatformPath::<DataDirPath>::from(tempdir_path()); {
self.config = self let path = reth_node_core::dirs::MaybePlatformPath::<DataDirPath>::from(
.config reth_db::test_utils::tempdir_path(),
.with_datadir_args(DatadirArgs { datadir: path.clone(), ..Default::default() }); );
self.config = self.config.with_datadir_args(reth_node_core::args::DatadirArgs {
datadir: path.clone(),
..Default::default()
});
let data_dir = let data_dir =
path.unwrap_or_chain_default(self.config.chain.chain, self.config.datadir.clone()); 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 } WithLaunchContext { builder: self.with_database(db), task_executor }
} }

View File

@ -58,8 +58,10 @@ serde_json.workspace = true
[dev-dependencies] [dev-dependencies]
reth.workspace = true reth.workspace = true
reth-db.workspace = true reth-db.workspace = true
reth-revm = { workspace = true, features = ["test-utils"] }
reth-e2e-test-utils.workspace = true 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 tokio.workspace = true
alloy-primitives.workspace = true alloy-primitives.workspace = true
alloy-genesis.workspace = true alloy-genesis.workspace = true
@ -78,3 +80,4 @@ optimism = [
"reth-auto-seal-consensus/optimism", "reth-auto-seal-consensus/optimism",
"reth-rpc-eth-types/optimism" "reth-rpc-eth-types/optimism"
] ]
test-utils = ["reth-node-builder/test-utils"]

View File

@ -19,8 +19,8 @@ reth-rpc-api.workspace = true
reth-rpc-eth-api.workspace = true reth-rpc-eth-api.workspace = true
reth-rpc-types.workspace = true reth-rpc-types.workspace = true
reth-errors.workspace = true reth-errors.workspace = true
reth-provider = { workspace = true, features = ["test-utils"] } reth-provider.workspace = true
reth-transaction-pool = { workspace = true, features = ["test-utils"] } reth-transaction-pool.workspace = true
reth-network-api.workspace = true reth-network-api.workspace = true
reth-rpc-engine-api.workspace = true reth-rpc-engine-api.workspace = true
reth-revm.workspace = true reth-revm.workspace = true

View File

@ -172,8 +172,9 @@ impl<TX: DbTx + 'static> DatabaseProvider<TX> {
} }
impl<TX: DbTxMut + DbTx> DatabaseProvider<TX> { impl<TX: DbTxMut + DbTx> DatabaseProvider<TX> {
#[cfg(any(test, feature = "test-utils"))] // TODO: uncomment below, once `reth debug_cmd` has been feature gated with dev.
/// Inserts an historical block. Used for setting up test environments // #[cfg(any(test, feature = "test-utils"))]
/// Inserts an historical block. **Used for setting up test environments**
pub fn insert_historical_block( pub fn insert_historical_block(
&self, &self,
block: SealedBlockWithSenders, block: SealedBlockWithSenders,

View File

@ -11,7 +11,7 @@ reth.workspace = true
reth-chainspec.workspace = true reth-chainspec.workspace = true
reth-node-core.workspace = true reth-node-core.workspace = true
reth-primitives.workspace = true reth-primitives.workspace = true
reth-node-ethereum.workspace = true reth-node-ethereum = { workspace = true, features = ["test-utils"] }
futures-util.workspace = true futures-util.workspace = true
eyre.workspace = true eyre.workspace = true

View File

@ -15,7 +15,7 @@ reth-primitives.workspace = true
reth-payload-builder.workspace = true reth-payload-builder.workspace = true
reth-basic-payload-builder.workspace = true reth-basic-payload-builder.workspace = true
reth-ethereum-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 reth-tracing.workspace = true
alloy-genesis.workspace = true alloy-genesis.workspace = true

View File

@ -12,7 +12,7 @@ reth-evm-ethereum.workspace = true
reth-node-api.workspace = true reth-node-api.workspace = true
reth-node-core.workspace = true reth-node-core.workspace = true
reth-primitives.workspace = true reth-primitives.workspace = true
reth-node-ethereum.workspace = true reth-node-ethereum = { workspace = true, features = ["test-utils"] }
reth-tracing.workspace = true reth-tracing.workspace = true
alloy-genesis.workspace = true alloy-genesis.workspace = true

View File

@ -13,7 +13,7 @@ reth-eth-wire.workspace = true
reth-network.workspace = true reth-network.workspace = true
reth-network-api.workspace = true reth-network-api.workspace = true
reth-node-ethereum.workspace = true reth-node-ethereum.workspace = true
reth-provider.workspace = true reth-provider = { workspace = true, features = ["test-utils"] }
reth-primitives.workspace = true reth-primitives.workspace = true
reth-rpc-types.workspace = true reth-rpc-types.workspace = true
reth.workspace = true reth.workspace = true

View File

@ -13,5 +13,6 @@ reth-chainspec.workspace = true
reth-db.workspace = true reth-db.workspace = true
reth-db-api.workspace = true reth-db-api.workspace = true
reth-node-ethereum.workspace = true reth-node-ethereum.workspace = true
reth-provider = { workspace = true, features = ["test-utils"] }
tokio = { workspace = true, features = ["full"] } tokio = { workspace = true, features = ["full"] }
eyre.workspace = true eyre.workspace = true

View File

@ -31,11 +31,9 @@ use reth::rpc::builder::{
}; };
// Configuring the network parts, ideally also wouldn't need to think about this. // Configuring the network parts, ideally also wouldn't need to think about this.
use myrpc_ext::{MyRpcExt, MyRpcExtApiServer}; use myrpc_ext::{MyRpcExt, MyRpcExtApiServer};
use reth::{ use reth::{blockchain_tree::noop::NoopBlockchainTree, tasks::TokioTaskExecutor};
blockchain_tree::noop::NoopBlockchainTree, providers::test_utils::TestCanonStateSubscriptions,
tasks::TokioTaskExecutor,
};
use reth_node_ethereum::EthEvmConfig; use reth_node_ethereum::EthEvmConfig;
use reth_provider::test_utils::TestCanonStateSubscriptions;
// Custom rpc extension // Custom rpc extension
pub mod myrpc_ext; pub mod myrpc_ext;

View File

@ -11,7 +11,7 @@ reth-chainspec.workspace = true
reth-node-api.workspace = true reth-node-api.workspace = true
reth-node-core.workspace = true reth-node-core.workspace = true
reth-primitives.workspace = true reth-primitives.workspace = true
reth-node-ethereum.workspace = true reth-node-ethereum = { workspace = true, features = ["test-utils"] }
reth-tracing.workspace = true reth-tracing.workspace = true
alloy-genesis.workspace = true alloy-genesis.workspace = true