Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit e986f05

Browse files
authored
Do not drop the task_manager for benchmarking stuff (#12147)
We can not drop the `task_manager` for benchmarking stuff, because otherwise stuff that may needs this feature (like background signature verification) will fail. Besides the base path setup is moved to `SharedParams` directly. Meaning any call to `base_path` will now directly return a tmp path when `--dev` is given.
1 parent 41b6b38 commit e986f05

File tree

5 files changed

+27
-18
lines changed

5 files changed

+27
-18
lines changed

bin/node/cli/src/command.rs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -115,35 +115,39 @@ pub fn run() -> Result<()> {
115115
cmd.run::<Block, ExecutorDispatch>(config)
116116
},
117117
BenchmarkCmd::Block(cmd) => {
118-
let PartialComponents { client, .. } = new_partial(&config)?;
119-
cmd.run(client)
118+
// ensure that we keep the task manager alive
119+
let partial = new_partial(&config)?;
120+
cmd.run(partial.client)
120121
},
121122
BenchmarkCmd::Storage(cmd) => {
122-
let PartialComponents { client, backend, .. } = new_partial(&config)?;
123-
let db = backend.expose_db();
124-
let storage = backend.expose_storage();
123+
// ensure that we keep the task manager alive
124+
let partial = new_partial(&config)?;
125+
let db = partial.backend.expose_db();
126+
let storage = partial.backend.expose_storage();
125127

126-
cmd.run(config, client, db, storage)
128+
cmd.run(config, partial.client, db, storage)
127129
},
128130
BenchmarkCmd::Overhead(cmd) => {
129-
let PartialComponents { client, .. } = new_partial(&config)?;
130-
let ext_builder = RemarkBuilder::new(client.clone());
131+
// ensure that we keep the task manager alive
132+
let partial = new_partial(&config)?;
133+
let ext_builder = RemarkBuilder::new(partial.client.clone());
131134

132-
cmd.run(config, client, inherent_benchmark_data()?, &ext_builder)
135+
cmd.run(config, partial.client, inherent_benchmark_data()?, &ext_builder)
133136
},
134137
BenchmarkCmd::Extrinsic(cmd) => {
135-
let PartialComponents { client, .. } = service::new_partial(&config)?;
138+
// ensure that we keep the task manager alive
139+
let partial = service::new_partial(&config)?;
136140
// Register the *Remark* and *TKA* builders.
137141
let ext_factory = ExtrinsicFactory(vec![
138-
Box::new(RemarkBuilder::new(client.clone())),
142+
Box::new(RemarkBuilder::new(partial.client.clone())),
139143
Box::new(TransferKeepAliveBuilder::new(
140-
client.clone(),
144+
partial.client.clone(),
141145
Sr25519Keyring::Alice.to_account_id(),
142146
ExistentialDeposit::get(),
143147
)),
144148
]);
145149

146-
cmd.run(client, inherent_benchmark_data()?, &ext_factory)
150+
cmd.run(partial.client, inherent_benchmark_data()?, &ext_factory)
147151
},
148152
BenchmarkCmd::Machine(cmd) =>
149153
cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone()),

client/cli/src/commands/insert_key.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl InsertKeyCmd {
6060
let suri = utils::read_uri(self.suri.as_ref())?;
6161
let base_path = self
6262
.shared_params
63-
.base_path()
63+
.base_path()?
6464
.unwrap_or_else(|| BasePath::from_project("", "", &C::executable_name()));
6565
let chain_id = self.shared_params.chain_id(self.shared_params.is_dev());
6666
let chain_spec = cli.load_spec(&chain_id)?;

client/cli/src/commands/run_cmd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ impl CliConfiguration for RunCmd {
485485
Ok(if self.tmp {
486486
Some(BasePath::new_temp_dir()?)
487487
} else {
488-
match self.shared_params().base_path() {
488+
match self.shared_params().base_path()? {
489489
Some(r) => Some(r),
490490
// If `dev` is enabled, we use the temp base path.
491491
None if self.shared_params().is_dev() => Some(BasePath::new_temp_dir()?),

client/cli/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ pub trait CliConfiguration<DCV: DefaultConfigurationValues = ()>: Sized {
125125
///
126126
/// By default this is retrieved from `SharedParams`.
127127
fn base_path(&self) -> Result<Option<BasePath>> {
128-
Ok(self.shared_params().base_path())
128+
self.shared_params().base_path()
129129
}
130130

131131
/// Returns `true` if the node is for development or not

client/cli/src/params/shared_params.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,13 @@ pub struct SharedParams {
8282

8383
impl SharedParams {
8484
/// Specify custom base path.
85-
pub fn base_path(&self) -> Option<BasePath> {
86-
self.base_path.clone().map(Into::into)
85+
pub fn base_path(&self) -> Result<Option<BasePath>, crate::Error> {
86+
match &self.base_path {
87+
Some(r) => Ok(Some(r.clone().into())),
88+
// If `dev` is enabled, we use the temp base path.
89+
None if self.is_dev() => Ok(Some(BasePath::new_temp_dir()?)),
90+
None => Ok(None),
91+
}
8792
}
8893

8994
/// Specify the development chain.

0 commit comments

Comments
 (0)