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 2 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 @@ -179,3 +179,13 @@ jobs:
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}

no-test-deps:
joshieDo marked this conversation as resolved.
Show resolved Hide resolved
name: 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
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"]
joshieDo marked this conversation as resolved.
Show resolved Hide resolved
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
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
Loading