Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 10 commits into from
Jul 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -173,6 +182,7 @@ jobs:
- book
- codespell
- grafana
- no-test-deps
timeout-minutes: 30
steps:
- name: Decide whether the needed jobs succeeded or failed
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions crates/e2e-test-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions crates/ethereum/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
4 changes: 2 additions & 2 deletions crates/exex/test-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }

Expand Down
6 changes: 5 additions & 1 deletion crates/node/builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -78,3 +78,7 @@ tracing.workspace = true

[dev-dependencies]
tempfile.workspace = true

[features]
default = []
test-utils = ["reth-db/test-utils"]
24 changes: 12 additions & 12 deletions crates/node/builder/src/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand All @@ -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,
};
Expand Down Expand Up @@ -176,19 +171,24 @@ impl<DB> NodeBuilder<DB> {
}

/// Creates an _ephemeral_ preconfigured node for testing purposes.
#[cfg(feature = "test-utils")]
pub fn testing_node(
mut self,
task_executor: TaskExecutor,
) -> WithLaunchContext<NodeBuilder<Arc<TempDatabase<DatabaseEnv>>>> {
let path = MaybePlatformPath::<DataDirPath>::from(tempdir_path());
self.config = self
.config
.with_datadir_args(DatadirArgs { datadir: path.clone(), ..Default::default() });
) -> WithLaunchContext<NodeBuilder<Arc<reth_db::test_utils::TempDatabase<reth_db::DatabaseEnv>>>>
{
let path = reth_node_core::dirs::MaybePlatformPath::<DataDirPath>::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 }
}
Expand Down
5 changes: 4 additions & 1 deletion crates/optimism/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -78,3 +80,4 @@ optimism = [
"reth-auto-seal-consensus/optimism",
"reth-rpc-eth-types/optimism"
]
test-utils = ["reth-node-builder/test-utils"]
4 changes: 2 additions & 2 deletions crates/rpc/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions crates/storage/provider/src/providers/database/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,9 @@ impl<TX: DbTx + 'static> DatabaseProvider<TX> {
}

impl<TX: DbTxMut + DbTx> DatabaseProvider<TX> {
#[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**
Comment on lines +175 to +177
Copy link
Collaborator Author

@joshieDo joshieDo Jul 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's only being used by reth debug_cmd.

if approved, i'll will create an issue

pub fn insert_historical_block(
&self,
block: SealedBlockWithSenders,
Expand Down
2 changes: 1 addition & 1 deletion examples/custom-dev-node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/custom-engine-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion examples/custom-evm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion examples/custom-rlpx-subprotocol/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions examples/rpc-db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 2 additions & 4 deletions examples/rpc-db/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion examples/stateful-precompile/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading