From c2519126522fa3ae143cbe20b79a45f2dbdb26c9 Mon Sep 17 00:00:00 2001 From: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com> Date: Fri, 27 Jan 2023 22:46:36 +0100 Subject: [PATCH] Storage monitor added to polkadot node (#6619) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Storage monitor added to polkadot node Related to: https://github.com/paritytech/substrate/issues/12399 * Cargo.lock updated * Cargo.lock update * Revert "Cargo.lock update" This reverts commit 04dfe5fe65ea7d1476d4632ad647f2c1c669ab1a. * Apply suggestions from code review Co-authored-by: Bastian Köcher * missing_docs fixes * Cargo.lock updated --------- Co-authored-by: parity-processbot <> Co-authored-by: Bastian Köcher --- polkadot/Cargo.lock | 1 + polkadot/cli/Cargo.toml | 1 + polkadot/cli/src/cli.rs | 5 ++++- polkadot/cli/src/command.rs | 14 +++++++++++--- polkadot/cli/src/error.rs | 3 +++ 5 files changed, 20 insertions(+), 4 deletions(-) diff --git a/polkadot/Cargo.lock b/polkadot/Cargo.lock index bbc0af6a77..ec68f78fc4 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 0d1c551874..feced4c148 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 a6b7f4a3d5..37083eb912 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, + #[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 b1fb3378c8..b110054957 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 69f38bbdd0..37ecb53d8a 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), }