diff --git a/Cargo.lock b/Cargo.lock index bbc0af6a7786..ec68f78fc40d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6516,6 +6516,7 @@ dependencies = [ "sc-cli", "sc-executor", "sc-service", + "sc-storage-monitor", "sc-sysinfo", "sc-tracing", "sp-core", diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 0d1c55187400..feced4c148a1 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -36,6 +36,7 @@ polkadot-node-metrics = { path = "../node/metrics" } sc-tracing = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true } sc-sysinfo = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-executor = { git = "https://github.com/paritytech/substrate", branch = "master" } +sc-storage-monitor = { git = "https://github.com/paritytech/substrate", branch = "master" } [build-dependencies] substrate-build-script-utils = { git = "https://github.com/paritytech/substrate", branch = "master" } diff --git a/cli/src/cli.rs b/cli/src/cli.rs index a6b7f4a3d5c9..37083eb91278 100644 --- a/cli/src/cli.rs +++ b/cli/src/cli.rs @@ -86,7 +86,6 @@ pub struct ValidationWorkerCommand { #[derive(Debug, Parser)] #[group(skip)] pub struct RunCmd { - #[allow(missing_docs)] #[clap(flatten)] pub base: sc_cli::RunCmd, @@ -151,6 +150,10 @@ pub struct RunCmd { pub struct Cli { #[command(subcommand)] pub subcommand: Option, + #[clap(flatten)] pub run: RunCmd, + + #[clap(flatten)] + pub storage_monitor: sc_storage_monitor::StorageMonitorParams, } diff --git a/cli/src/command.rs b/cli/src/command.rs index b1fb3378c8bb..b110054957eb 100644 --- a/cli/src/command.rs +++ b/cli/src/command.rs @@ -335,7 +335,8 @@ where })) .flatten(); - service::build_full( + let database_source = config.database.clone(); + let task_manager = service::build_full( config, service::IsCollator::No, grandpa_pause, @@ -348,8 +349,15 @@ where maybe_malus_finality_delay, hwbench, ) - .map(|full| full.task_manager) - .map_err(Into::into) + .map(|full| full.task_manager)?; + + sc_storage_monitor::StorageMonitorService::try_spawn( + cli.storage_monitor, + database_source, + &task_manager.spawn_essential_handle(), + )?; + + Ok(task_manager) }) } diff --git a/cli/src/error.rs b/cli/src/error.rs index 69f38bbdd029..37ecb53d8aca 100644 --- a/cli/src/error.rs +++ b/cli/src/error.rs @@ -48,6 +48,9 @@ pub enum Error { #[error("Command is not implemented")] CommandNotImplemented, + #[error(transparent)] + Storage(#[from] sc_storage_monitor::Error), + #[error("Other: {0}")] Other(String), }