From 3881bbd1b542279b5cd18296d78b8000f6204c9b Mon Sep 17 00:00:00 2001 From: btwiuse <54848194+btwiuse@users.noreply.github.com> Date: Fri, 8 Dec 2023 08:11:52 +0800 Subject: [PATCH] squash: joshy no rocks db (#2) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Remove `testnets-common` (#2620) `testnets-common` was introduced recently to start to separate testnet parachain configurations from those of Polkadot and Kusama. The `locks-review` and `polkadot-review` requirements are removed from `parachains-common` in https://github.com/paritytech/polkadot-sdk/pull/2564 and there are [plans](https://github.com/paritytech/polkadot-sdk/pull/2564#discussion_r1410882115) to move the Polkadot and Kusama contents of that package to the fellowship, `testnets-common` is no longer needed. This PR removes the crate and replaces uses of it in `collectives-westend`, the only place it is currently used. * cumulus-client-cli * substrate-test-utils * checkpoint * remove outdated comment * fmt * polkadot-cli * try-runtime * bunch of cumulus stuff * cumulus-test-client * Mke cumulus test service use paritydb * josh: disable db feature --------- Co-authored-by: Dónal Murray Co-authored-by: Joshy Orndorff --- Cargo.lock | 1 - cumulus/client/cli/Cargo.toml | 4 +-- .../Cargo.toml | 4 +-- .../relay-chain-minimal-node/Cargo.toml | 2 +- .../relay-chain-rpc-interface/Cargo.toml | 2 +- cumulus/client/service/Cargo.toml | 4 ++- cumulus/test/client/Cargo.toml | 2 +- cumulus/test/service/Cargo.toml | 12 +++---- cumulus/test/service/src/lib.rs | 2 +- polkadot/cli/Cargo.toml | 16 ++++++---- polkadot/node/metrics/Cargo.toml | 8 ++--- polkadot/node/service/Cargo.toml | 11 +++---- polkadot/node/service/src/lib.rs | 31 ++++++++++++++----- .../node/service/src/parachains_db/mod.rs | 6 ++++ .../node/service/src/parachains_db/upgrade.rs | 20 +++++++++--- polkadot/node/test/client/Cargo.toml | 2 +- polkadot/node/test/service/Cargo.toml | 5 +-- polkadot/node/test/service/src/lib.rs | 3 ++ substrate/client/db/Cargo.toml | 4 ++- substrate/test-utils/Cargo.toml | 4 +-- .../utils/frame/try-runtime/cli/Cargo.toml | 4 +-- 21 files changed, 95 insertions(+), 52 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c06bd4f1d3f2..5cfd9248c872 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19836,7 +19836,6 @@ dependencies = [ "sp-transaction-storage-proof", "sp-version", "sp-weights", - "substrate-cli-test-utils", "substrate-rpc-client", "tempfile", "tokio", diff --git a/cumulus/client/cli/Cargo.toml b/cumulus/client/cli/Cargo.toml index 35945bf4052f..6bf1b39f18f3 100644 --- a/cumulus/client/cli/Cargo.toml +++ b/cumulus/client/cli/Cargo.toml @@ -12,9 +12,9 @@ codec = { package = "parity-scale-codec", version = "3.0.0" } url = "2.4.0" # Substrate -sc-cli = { path = "../../../substrate/client/cli" } +sc-cli = { default-features = false, path = "../../../substrate/client/cli" } sc-client-api = { path = "../../../substrate/client/api" } sc-chain-spec = { path = "../../../substrate/client/chain-spec" } -sc-service = { path = "../../../substrate/client/service" } +sc-service = { default-features = false, path = "../../../substrate/client/service" } sp-core = { path = "../../../substrate/primitives/core" } sp-runtime = { path = "../../../substrate/primitives/runtime" } diff --git a/cumulus/client/relay-chain-inprocess-interface/Cargo.toml b/cumulus/client/relay-chain-inprocess-interface/Cargo.toml index 1d4147365032..cd7b4caa884c 100644 --- a/cumulus/client/relay-chain-inprocess-interface/Cargo.toml +++ b/cumulus/client/relay-chain-inprocess-interface/Cargo.toml @@ -12,7 +12,7 @@ futures = "0.3.28" futures-timer = "3.0.2" # Substrate -sc-cli = { path = "../../../substrate/client/cli" } +sc-cli = { path = "../../../substrate/client/cli", default-features = false } sc-client-api = { path = "../../../substrate/client/api" } sc-telemetry = { path = "../../../substrate/client/telemetry" } sc-tracing = { path = "../../../substrate/client/tracing" } @@ -25,7 +25,7 @@ sp-state-machine = { path = "../../../substrate/primitives/state-machine" } # Polkadot polkadot-cli = { path = "../../../polkadot/cli", default-features = false, features = ["cli"] } -polkadot-service = { path = "../../../polkadot/node/service" } +polkadot-service = { path = "../../../polkadot/node/service", default-features = false } # Cumulus cumulus-primitives-core = { path = "../../primitives/core" } diff --git a/cumulus/client/relay-chain-minimal-node/Cargo.toml b/cumulus/client/relay-chain-minimal-node/Cargo.toml index acaed5a4f6c1..e51697d61a2e 100644 --- a/cumulus/client/relay-chain-minimal-node/Cargo.toml +++ b/cumulus/client/relay-chain-minimal-node/Cargo.toml @@ -26,8 +26,8 @@ polkadot-node-core-prospective-parachains = { path = "../../../polkadot/node/cor sc-authority-discovery = { path = "../../../substrate/client/authority-discovery" } sc-network = { path = "../../../substrate/client/network" } sc-network-common = { path = "../../../substrate/client/network/common" } -sc-service = { path = "../../../substrate/client/service" } sc-client-api = { path = "../../../substrate/client/api" } +sc-service = { path = "../../../substrate/client/service", default-features = false } substrate-prometheus-endpoint = { path = "../../../substrate/utils/prometheus" } sc-tracing = { path = "../../../substrate/client/tracing" } sc-utils = { path = "../../../substrate/client/utils" } diff --git a/cumulus/client/relay-chain-rpc-interface/Cargo.toml b/cumulus/client/relay-chain-rpc-interface/Cargo.toml index 11d8bc9b4df8..22f13cb004bd 100644 --- a/cumulus/client/relay-chain-rpc-interface/Cargo.toml +++ b/cumulus/client/relay-chain-rpc-interface/Cargo.toml @@ -23,7 +23,7 @@ sp-runtime = { path = "../../../substrate/primitives/runtime" } sp-version = { path = "../../../substrate/primitives/version" } sc-client-api = { path = "../../../substrate/client/api" } sc-rpc-api = { path = "../../../substrate/client/rpc-api" } -sc-service = { path = "../../../substrate/client/service" } +sc-service = { path = "../../../substrate/client/service", default-features = false } tokio = { version = "1.32.0", features = ["sync"] } tokio-util = { version = "0.7.8", features = ["compat"] } diff --git a/cumulus/client/service/Cargo.toml b/cumulus/client/service/Cargo.toml index 55623276eaf5..0f36e99c629a 100644 --- a/cumulus/client/service/Cargo.toml +++ b/cumulus/client/service/Cargo.toml @@ -14,7 +14,7 @@ sc-client-api = { path = "../../../substrate/client/api" } sc-consensus = { path = "../../../substrate/client/consensus/common" } sc-transaction-pool = { path = "../../../substrate/client/transaction-pool" } sc-rpc = { path = "../../../substrate/client/rpc" } -sc-service = { path = "../../../substrate/client/service" } +sc-service = { path = "../../../substrate/client/service", default-features = false } sc-sysinfo = { path = "../../../substrate/client/sysinfo" } sc-telemetry = { path = "../../../substrate/client/telemetry" } sc-network = { path = "../../../substrate/client/network" } @@ -33,6 +33,8 @@ polkadot-primitives = { path = "../../../polkadot/primitives" } # Cumulus cumulus-client-cli = { path = "../cli" } + +# For some reason I can enable the collator here, even though it appears to leak rocks on its own... cumulus-client-collator = { path = "../collator" } cumulus-client-consensus-common = { path = "../consensus/common" } cumulus-client-pov-recovery = { path = "../pov-recovery" } diff --git a/cumulus/test/client/Cargo.toml b/cumulus/test/client/Cargo.toml index 037b8600db63..7145277b937a 100644 --- a/cumulus/test/client/Cargo.toml +++ b/cumulus/test/client/Cargo.toml @@ -9,7 +9,7 @@ publish = false codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } # Substrate -sc-service = { path = "../../../substrate/client/service" } +sc-service = { path = "../../../substrate/client/service", default-features = false } sc-consensus = { path = "../../../substrate/client/consensus/common" } sc-block-builder = { path = "../../../substrate/client/block-builder" } sc-executor = { path = "../../../substrate/client/executor" } diff --git a/cumulus/test/service/Cargo.toml b/cumulus/test/service/Cargo.toml index 271c450539bf..e8dcb984ef1f 100644 --- a/cumulus/test/service/Cargo.toml +++ b/cumulus/test/service/Cargo.toml @@ -33,7 +33,7 @@ sc-client-api = { path = "../../../substrate/client/api" } sc-consensus = { path = "../../../substrate/client/consensus/common" } sc-executor = { path = "../../../substrate/client/executor" } sc-network = { path = "../../../substrate/client/network" } -sc-service = { path = "../../../substrate/client/service" } +sc-service = { path = "../../../substrate/client/service", default-features = false } sc-tracing = { path = "../../../substrate/client/tracing" } sc-transaction-pool = { path = "../../../substrate/client/transaction-pool" } sc-transaction-pool-api = { path = "../../../substrate/client/transaction-pool/api" } @@ -50,16 +50,16 @@ sp-tracing = { path = "../../../substrate/primitives/tracing" } sp-timestamp = { path = "../../../substrate/primitives/timestamp" } sp-consensus = { path = "../../../substrate/primitives/consensus/common" } substrate-test-client = { path = "../../../substrate/test-utils/client" } -sc-cli = { path = "../../../substrate/client/cli" } +sc-cli = { path = "../../../substrate/client/cli", default-features = false } sc-block-builder = { path = "../../../substrate/client/block-builder" } sc-executor-wasmtime = { path = "../../../substrate/client/executor/wasmtime" } sc-executor-common = { path = "../../../substrate/client/executor/common" } # Polkadot polkadot-primitives = { path = "../../../polkadot/primitives" } -polkadot-service = { path = "../../../polkadot/node/service" } +polkadot-service = { path = "../../../polkadot/node/service", default-features = false } polkadot-test-service = { path = "../../../polkadot/node/test/service" } -polkadot-cli = { path = "../../../polkadot/cli" } +polkadot-cli = { path = "../../../polkadot/cli", default-features = false } polkadot-node-subsystem = { path = "../../../polkadot/node/subsystem" } polkadot-overseer = { path = "../../../polkadot/node/overseer" } @@ -90,10 +90,10 @@ sp-authority-discovery = { path = "../../../substrate/primitives/authority-disco cumulus-test-client = { path = "../client" } # Polkadot dependencies -polkadot-test-service = { path = "../../../polkadot/node/test/service" } +polkadot-test-service = { path = "../../../polkadot/node/test/service", default-features = false } # Substrate dependencies -sc-cli = { path = "../../../substrate/client/cli" } +sc-cli = { path = "../../../substrate/client/cli", default-features = false } substrate-test-utils = { path = "../../../substrate/test-utils" } [features] diff --git a/cumulus/test/service/src/lib.rs b/cumulus/test/service/src/lib.rs index 627d060d8a0c..fb9911c629b3 100644 --- a/cumulus/test/service/src/lib.rs +++ b/cumulus/test/service/src/lib.rs @@ -784,7 +784,7 @@ pub fn node_config( transaction_pool: Default::default(), network: network_config, keystore: KeystoreConfig::InMemory, - database: DatabaseSource::RocksDb { path: root.join("db"), cache_size: 128 }, + database: DatabaseSource::ParityDb { path: root.join("db") }, trie_cache_maximum_size: Some(64 * 1024 * 1024), state_pruning: Some(PruningMode::ArchiveAll), blocks_pruning: BlocksPruning::KeepAll, diff --git a/polkadot/cli/Cargo.toml b/polkadot/cli/Cargo.toml index 72b2a18f36b3..62be0bdd14a6 100644 --- a/polkadot/cli/Cargo.toml +++ b/polkadot/cli/Cargo.toml @@ -29,10 +29,10 @@ sp-core = { path = "../../substrate/primitives/core" } sp-io = { path = "../../substrate/primitives/io" } sp-keyring = { path = "../../substrate/primitives/keyring" } sp-maybe-compressed-blob = { path = "../../substrate/primitives/maybe-compressed-blob" } -frame-benchmarking-cli = { path = "../../substrate/utils/frame/benchmarking-cli", optional = true } -try-runtime-cli = { path = "../../substrate/utils/frame/try-runtime/cli", optional = true } -sc-cli = { path = "../../substrate/client/cli", optional = true } -sc-service = { path = "../../substrate/client/service", optional = true } +frame-benchmarking-cli = { path = "../../substrate/utils/frame/benchmarking-cli", default-features = false, optional = true } +try-runtime-cli = { path = "../../substrate/utils/frame/try-runtime/cli", default-features = false, optional = true } +sc-cli = { path = "../../substrate/client/cli", default-features = false, optional = true } +sc-service = { path = "../../substrate/client/service", default-features = false, optional = true } polkadot-node-metrics = { path = "../node/metrics" } polkadot-node-primitives = { path = "../node/primitives" } sc-tracing = { path = "../../substrate/client/tracing", optional = true } @@ -44,8 +44,12 @@ sc-storage-monitor = { path = "../../substrate/client/storage-monitor" } substrate-build-script-utils = { path = "../../substrate/utils/build-script-utils" } [features] -default = ["cli", "db", "full-node"] -db = ["service/db"] +default = [ "cli", "full-node" ] +db = [ + "sc-cli?/rocksdb", + "sc-service?/rocksdb", + "service?/db", +] cli = [ "clap", "frame-benchmarking-cli", diff --git a/polkadot/node/metrics/Cargo.toml b/polkadot/node/metrics/Cargo.toml index e8e00a64c056..22fec8c5d09c 100644 --- a/polkadot/node/metrics/Cargo.toml +++ b/polkadot/node/metrics/Cargo.toml @@ -13,8 +13,9 @@ gum = { package = "tracing-gum", path = "../gum" } metered = { package = "prioritized-metered-channel", version = "0.5.1", default-features = false, features = ["futures_channel"] } # Both `sc-service` and `sc-cli` are required by runtime metrics `logger_hook()`. -sc-service = { path = "../../../substrate/client/service" } -sc-cli = { path = "../../../substrate/client/cli" } +# Regarding the above comment, should they be optional dependencies then? +sc-service = { path = "../../../substrate/client/service", default-features = false } +sc-cli = { path = "../../../substrate/client/cli", default-features = false } substrate-prometheus-endpoint = { path = "../../../substrate/utils/prometheus" } sc-tracing = { path = "../../../substrate/client/tracing" } @@ -28,9 +29,8 @@ assert_cmd = "2.0.4" tempfile = "3.2.0" hyper = { version = "0.14.20", default-features = false, features = ["http1", "tcp"] } tokio = "1.24.2" -polkadot-test-service = { path = "../test/service", features = ["runtime-metrics"] } +polkadot-test-service = { path = "../test/service", features = ["runtime-metrics"], default-features = false } substrate-test-utils = { path = "../../../substrate/test-utils" } -sc-service = { path = "../../../substrate/client/service" } sp-keyring = { path = "../../../substrate/primitives/keyring" } prometheus-parse = { version = "0.2.2" } diff --git a/polkadot/node/service/Cargo.toml b/polkadot/node/service/Cargo.toml index 448ab605aa92..bcd5955fbea0 100644 --- a/polkadot/node/service/Cargo.toml +++ b/polkadot/node/service/Cargo.toml @@ -18,7 +18,7 @@ sp-mmr-primitives = { path = "../../../substrate/primitives/merkle-mountain-rang sc-block-builder = { path = "../../../substrate/client/block-builder" } sc-chain-spec = { path = "../../../substrate/client/chain-spec" } sc-client-api = { path = "../../../substrate/client/api" } -sc-client-db = { path = "../../../substrate/client/db" } +sc-client-db = { default-features = false, path = "../../../substrate/client/db" } sc-consensus = { path = "../../../substrate/client/consensus/common" } sc-consensus-slots = { path = "../../../substrate/client/consensus/slots" } sc-executor = { path = "../../../substrate/client/executor" } @@ -71,8 +71,8 @@ frame-system = { path = "../../../substrate/frame/system" } frame-system-rpc-runtime-api = { path = "../../../substrate/frame/system/rpc/runtime-api" } prometheus-endpoint = { package = "substrate-prometheus-endpoint", path = "../../../substrate/utils/prometheus" } frame-support = { path = "../../../substrate/frame/support" } -frame-benchmarking-cli = { path = "../../../substrate/utils/frame/benchmarking-cli" } -frame-benchmarking = { path = "../../../substrate/frame/benchmarking" } +frame-benchmarking-cli = { path = "../../../substrate/utils/frame/benchmarking-cli", default-features = false } +frame-benchmarking = { path = "../../../substrate/frame/benchmarking", default-features = false } # External Crates async-trait = "0.1.57" @@ -148,12 +148,11 @@ serial_test = "2.0.0" tempfile = "3.2" [features] -default = ["db", "full-node"] +default = [ "full-node" ] -db = ["service/rocksdb"] +db = [ "service/rocksdb", "sc-client-db/rocksdb", "frame-benchmarking-cli/rocksdb", "kvdb-rocksdb" ] full-node = [ - "kvdb-rocksdb", "parity-db", "polkadot-approval-distribution", "polkadot-availability-bitfield-distribution", diff --git a/polkadot/node/service/src/lib.rs b/polkadot/node/service/src/lib.rs index e92e15fc0e00..c2a317936a22 100644 --- a/polkadot/node/service/src/lib.rs +++ b/polkadot/node/service/src/lib.rs @@ -337,6 +337,7 @@ impl IdentifyVariant for Box { #[cfg(feature = "full-node")] pub fn open_database(db_source: &DatabaseSource) -> Result, Error> { let parachains_db = match db_source { + #[cfg(feature = "db")] DatabaseSource::RocksDb { path, .. } => parachains_db::open_creating_rocksdb( path.clone(), parachains_db::CacheSizes::default(), @@ -345,19 +346,33 @@ pub fn open_database(db_source: &DatabaseSource) -> Result, Er path.parent().ok_or(Error::DatabasePathRequired)?.into(), parachains_db::CacheSizes::default(), )?, - DatabaseSource::Auto { paritydb_path, rocksdb_path, .. } => { + DatabaseSource::Auto { + paritydb_path, + #[cfg(feature = "db")] + rocksdb_path, + .. + } => if paritydb_path.is_dir() && paritydb_path.exists() { parachains_db::open_creating_paritydb( paritydb_path.parent().ok_or(Error::DatabasePathRequired)?.into(), parachains_db::CacheSizes::default(), )? } else { - parachains_db::open_creating_rocksdb( - rocksdb_path.clone(), - parachains_db::CacheSizes::default(), - )? - } - }, + #[cfg(feature = "db")] + { + parachains_db::open_creating_rocksdb( + rocksdb_path.clone(), + parachains_db::CacheSizes::default(), + )? + } + #[cfg(not(feature = "db"))] + { + parachains_db::open_creating_paritydb( + paritydb_path.parent().ok_or(Error::DatabasePathRequired)?.into(), + parachains_db::CacheSizes::default(), + )? + } + }, DatabaseSource::Custom { .. } => { unimplemented!("No polkadot subsystem db for custom source."); }, @@ -1414,6 +1429,7 @@ pub fn revert_backend( Ok(()) } +#[cfg(feature = "full-node")] fn revert_chain_selection(db: Arc, hash: Hash) -> sp_blockchain::Result<()> { let config = chain_selection_subsystem::Config { col_data: parachains_db::REAL_COLUMNS.col_chain_selection_data, @@ -1428,6 +1444,7 @@ fn revert_chain_selection(db: Arc, hash: Hash) -> sp_blockchain::R .map_err(|err| sp_blockchain::Error::Backend(err.to_string())) } +#[cfg(feature = "full-node")] fn revert_approval_voting(db: Arc, hash: Hash) -> sp_blockchain::Result<()> { let config = approval_voting_subsystem::Config { col_approval_data: parachains_db::REAL_COLUMNS.col_approval_data, diff --git a/polkadot/node/service/src/parachains_db/mod.rs b/polkadot/node/service/src/parachains_db/mod.rs index 92f3f167f22f..575c3da87648 100644 --- a/polkadot/node/service/src/parachains_db/mod.rs +++ b/polkadot/node/service/src/parachains_db/mod.rs @@ -26,6 +26,10 @@ const LOG_TARGET: &str = "parachain::db"; /// Column configuration per version. #[cfg(any(test, feature = "full-node"))] pub(crate) mod columns { + // This v0 module is only used in tests for parity_db; not in main code. But it is + // used in both tests and main code for rocks db. This feature gating makes sure there + // is never a warning, but perhaps there is a better way? + #[cfg(any(test, feature = "db"))] pub mod v0 { pub const NUM_COLUMNS: u32 = 3; } @@ -91,6 +95,7 @@ pub const REAL_COLUMNS: ColumnsConfig = ColumnsConfig { #[derive(PartialEq, Copy, Clone)] pub(crate) enum DatabaseKind { ParityDB, + #[cfg(feature = "db")] RocksDB, } @@ -125,6 +130,7 @@ pub(crate) fn other_io_error(err: String) -> io::Error { /// Open the database on disk, creating it if it doesn't exist. #[cfg(feature = "full-node")] +#[cfg(feature = "db")] pub fn open_creating_rocksdb( root: PathBuf, cache_sizes: CacheSizes, diff --git a/polkadot/node/service/src/parachains_db/upgrade.rs b/polkadot/node/service/src/parachains_db/upgrade.rs index 1d76c79d3e32..50b455901150 100644 --- a/polkadot/node/service/src/parachains_db/upgrade.rs +++ b/polkadot/node/service/src/parachains_db/upgrade.rs @@ -107,6 +107,7 @@ pub(crate) fn try_upgrade_db_to_next_version( // This is an arbitrary future version, we don't handle it. Some(v) => return Err(Error::FutureVersion { current: CURRENT_VERSION, got: v }), // No version file. For `RocksDB` we dont need to do anything. + #[cfg(feature = "db")] None if db_kind == DatabaseKind::RocksDB => CURRENT_VERSION, // No version file. `ParityDB` did not previously have a version defined. // We handle this as a `0 -> 1` migration. @@ -153,6 +154,7 @@ fn migrate_from_version_0_to_1(path: &Path, db_kind: DatabaseKind) -> Result paritydb_migrate_from_version_0_to_1(path), + #[cfg(feature = "db")] DatabaseKind::RocksDB => rocksdb_migrate_from_version_0_to_1(path), } .and_then(|result| { @@ -166,6 +168,7 @@ fn migrate_from_version_1_to_2(path: &Path, db_kind: DatabaseKind) -> Result paritydb_migrate_from_version_1_to_2(path), + #[cfg(feature = "db")] DatabaseKind::RocksDB => rocksdb_migrate_from_version_1_to_2(path), } .and_then(|result| { @@ -178,9 +181,9 @@ fn migrate_from_version_1_to_2(path: &Path, db_kind: DatabaseKind) -> Result Result { gum::info!(target: LOG_TARGET, "Migrating parachains db from version 3 to version 4 ..."); - use polkadot_node_subsystem_util::database::{ - kvdb_impl::DbAdapter as RocksDbAdapter, paritydb_impl::DbAdapter as ParityDbAdapter, - }; + #[cfg(feature = "db")] + use polkadot_node_subsystem_util::database::kvdb_impl::DbAdapter as RocksDbAdapter; + use polkadot_node_subsystem_util::database::paritydb_impl::DbAdapter as ParityDbAdapter; use std::sync::Arc; let approval_db_config = @@ -196,6 +199,7 @@ fn migrate_from_version_3_to_4(path: &Path, db_kind: DatabaseKind) -> Result { let db_path = path .to_str() @@ -219,6 +223,7 @@ fn migrate_from_version_2_to_3(path: &Path, db_kind: DatabaseKind) -> Result paritydb_migrate_from_version_2_to_3(path), + #[cfg(feature = "db")] DatabaseKind::RocksDB => rocksdb_migrate_from_version_2_to_3(path), } .and_then(|result| { @@ -229,6 +234,7 @@ fn migrate_from_version_2_to_3(path: &Path, db_kind: DatabaseKind) -> Result Result { use kvdb_rocksdb::{Database, DatabaseConfig}; @@ -246,6 +252,7 @@ fn rocksdb_migrate_from_version_0_to_1(path: &Path) -> Result { /// Migration from version 1 to version 2: /// * the number of columns has changed from 5 to 6; +#[cfg(feature = "db")] fn rocksdb_migrate_from_version_1_to_2(path: &Path) -> Result { use kvdb_rocksdb::{Database, DatabaseConfig}; @@ -260,6 +267,7 @@ fn rocksdb_migrate_from_version_1_to_2(path: &Path) -> Result { Ok(2) } +#[cfg(feature = "db")] fn rocksdb_migrate_from_version_2_to_3(path: &Path) -> Result { use kvdb_rocksdb::{Database, DatabaseConfig}; @@ -520,6 +528,7 @@ mod tests { ); } + #[cfg(feature = "db")] #[test] fn test_rocksdb_migrate_1_to_2() { use kvdb::{DBKey, DBOp}; @@ -579,8 +588,9 @@ mod tests { ); } + #[cfg(feature = "db")] #[test] - fn test_migrate_3_to_4() { + fn test_rocksdb_migrate_3_to_4() { use kvdb_rocksdb::{Database, DatabaseConfig}; use polkadot_node_core_approval_voting::approval_db::v2::migration_helpers::v1_to_v2_sanity_check; use polkadot_node_subsystem_util::database::kvdb_impl::DbAdapter; @@ -613,6 +623,7 @@ mod tests { v1_to_v2_sanity_check(std::sync::Arc::new(db), approval_cfg, expected_candidates).unwrap(); } + #[cfg(feature = "db")] #[test] fn test_rocksdb_migrate_0_to_4() { use kvdb_rocksdb::{Database, DatabaseConfig}; @@ -682,6 +693,7 @@ mod tests { assert_eq!(db.num_columns(), columns::v3::NUM_COLUMNS as u8); } + #[cfg(feature = "db")] #[test] fn test_rocksdb_migrate_2_to_3() { use kvdb_rocksdb::{Database, DatabaseConfig}; diff --git a/polkadot/node/test/client/Cargo.toml b/polkadot/node/test/client/Cargo.toml index 646f1ea97325..048319afdb3d 100644 --- a/polkadot/node/test/client/Cargo.toml +++ b/polkadot/node/test/client/Cargo.toml @@ -17,7 +17,7 @@ polkadot-node-subsystem = { path = "../../subsystem" } # Substrate dependencies substrate-test-client = { path = "../../../../substrate/test-utils/client" } -sc-service = { path = "../../../../substrate/client/service" } +sc-service = { path = "../../../../substrate/client/service", default-features = false } sc-block-builder = { path = "../../../../substrate/client/block-builder" } sc-consensus = { path = "../../../../substrate/client/consensus/common" } sc-offchain = { path = "../../../../substrate/client/offchain" } diff --git a/polkadot/node/test/service/Cargo.toml b/polkadot/node/test/service/Cargo.toml index aa143f40300d..3235f82ef93c 100644 --- a/polkadot/node/test/service/Cargo.toml +++ b/polkadot/node/test/service/Cargo.toml @@ -21,7 +21,8 @@ polkadot-primitives = { path = "../../../primitives" } polkadot-parachain-primitives = { path = "../../../parachain" } polkadot-rpc = { path = "../../../rpc" } polkadot-runtime-common = { path = "../../../runtime/common" } -polkadot-service = { path = "../../service" } +# polkadot-service = { path = "../../service" } +polkadot-service = { default-features = false, features = ["full-node"], path = "../../service" } polkadot-node-subsystem = { path = "../../subsystem" } polkadot-node-primitives = { path = "../../primitives" } polkadot-test-runtime = { path = "../../../runtime/test-runtime" } @@ -42,7 +43,7 @@ pallet-staking = { path = "../../../../substrate/frame/staking" } pallet-balances = { path = "../../../../substrate/frame/balances" } pallet-transaction-payment = { path = "../../../../substrate/frame/transaction-payment" } sc-chain-spec = { path = "../../../../substrate/client/chain-spec" } -sc-cli = { path = "../../../../substrate/client/cli" } +sc-cli = { path = "../../../../substrate/client/cli", default-features = false } sc-client-api = { path = "../../../../substrate/client/api" } sc-consensus = { path = "../../../../substrate/client/consensus/common" } sc-network = { path = "../../../../substrate/client/network" } diff --git a/polkadot/node/test/service/src/lib.rs b/polkadot/node/test/service/src/lib.rs index e9423d513bf0..ccb55a1c939b 100644 --- a/polkadot/node/test/service/src/lib.rs +++ b/polkadot/node/test/service/src/lib.rs @@ -164,7 +164,10 @@ pub fn node_config( transaction_pool: Default::default(), network: network_config, keystore: KeystoreConfig::InMemory, + #[cfg(feature = "db")] database: DatabaseSource::RocksDb { path: root.join("db"), cache_size: 128 }, + #[cfg(not(feature = "db"))] + database: DatabaseSource::ParityDb { path: root.join("db") }, trie_cache_maximum_size: Some(64 * 1024 * 1024), state_pruning: Default::default(), blocks_pruning: BlocksPruning::KeepFinalized, diff --git a/substrate/client/db/Cargo.toml b/substrate/client/db/Cargo.toml index bb22ff4c6c19..a0ee20bc240c 100644 --- a/substrate/client/db/Cargo.toml +++ b/substrate/client/db/Cargo.toml @@ -37,7 +37,9 @@ sp-trie = { path = "../../primitives/trie" } [dev-dependencies] criterion = "0.4.0" -kvdb-rocksdb = "0.19.0" +# TODO Remove this comment +# For now it serves as a reminder that I completely removed a dev dependency on kvdb-rocksdb +# I guess that should be okay following the logic of the first comment in https://stackoverflow.com/questions/62989096 rand = "0.8.5" tempfile = "3.1.0" quickcheck = { version = "1.0.3", default-features = false } diff --git a/substrate/test-utils/Cargo.toml b/substrate/test-utils/Cargo.toml index 17696e8229c0..3bcc9d96131f 100644 --- a/substrate/test-utils/Cargo.toml +++ b/substrate/test-utils/Cargo.toml @@ -17,5 +17,5 @@ futures = "0.3.16" tokio = { version = "1.22.0", features = ["macros", "time"] } [dev-dependencies] -trybuild = { version = "1.0.74", features = ["diff"] } -sc-service = { path = "../client/service" } +trybuild = { version = "1.0.74", features = [ "diff" ] } +sc-service = { path = "../client/service", default-features = false } diff --git a/substrate/utils/frame/try-runtime/cli/Cargo.toml b/substrate/utils/frame/try-runtime/cli/Cargo.toml index 31e95a8be417..a09b7e9edebe 100644 --- a/substrate/utils/frame/try-runtime/cli/Cargo.toml +++ b/substrate/utils/frame/try-runtime/cli/Cargo.toml @@ -13,7 +13,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] remote-externalities = { package = "frame-remote-externalities", path = "../../remote-externalities" } -sc-cli = { path = "../../../../client/cli" } +sc-cli = { path = "../../../../client/cli", default-features = false } sc-executor = { path = "../../../../client/executor" } sp-consensus-aura = { path = "../../../../primitives/consensus/aura" } sp-consensus-babe = { path = "../../../../primitives/consensus/babe" } @@ -47,7 +47,6 @@ zstd = { version = "0.12.4", default-features = false } assert_cmd = "2.0.10" node-primitives = { path = "../../../../bin/node/primitives" } regex = "1.7.3" -substrate-cli-test-utils = { path = "../../../../test-utils/cli" } tempfile = "3.1.0" tokio = "1.27.0" @@ -56,5 +55,4 @@ try-runtime = [ "frame-try-runtime/try-runtime", "sp-debug-derive/force-debug", "sp-runtime/try-runtime", - "substrate-cli-test-utils/try-runtime", ]