diff --git a/polkadot/Cargo.lock b/polkadot/Cargo.lock index bbc0af6a77864f23bb0e83c8ad4104ca38394d18..ec68f78fc40d60c6ba30026d4f6c85f56d6debb4 100644 --- a/polkadot/Cargo.lock +++ b/polkadot/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/polkadot/cli/Cargo.toml b/polkadot/cli/Cargo.toml index 0d1c551874001baebc1e12b2dd0d7a56b54a18b5..feced4c148a12b724738f02fc5f4ccb4b78542ad 100644 --- a/polkadot/cli/Cargo.toml +++ b/polkadot/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/polkadot/cli/src/cli.rs b/polkadot/cli/src/cli.rs index a6b7f4a3d5c965703ba3a3d013281a1d927dc209..37083eb91278e2bdafe9d8f55033709a41cadf51 100644 --- a/polkadot/cli/src/cli.rs +++ b/polkadot/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<Subcommand>, + #[clap(flatten)] pub run: RunCmd, + + #[clap(flatten)] + pub storage_monitor: sc_storage_monitor::StorageMonitorParams, } diff --git a/polkadot/cli/src/command.rs b/polkadot/cli/src/command.rs index b1fb3378c8bbe58df1e0d4a04d63fad351e45ed6..b110054957ebbd946ec051582e5222a25780d8cb 100644 --- a/polkadot/cli/src/command.rs +++ b/polkadot/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/polkadot/cli/src/error.rs b/polkadot/cli/src/error.rs index 69f38bbdd029c1fafc2aa5ffcb352fd30768729e..37ecb53d8aca9980f15012143e24fe6b3035519f 100644 --- a/polkadot/cli/src/error.rs +++ b/polkadot/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), }