mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-24 22:55:43 +00:00
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.
This commit is contained in:
@@ -115,35 +115,39 @@ pub fn run() -> Result<()> {
|
|||||||
cmd.run::<Block, ExecutorDispatch>(config)
|
cmd.run::<Block, ExecutorDispatch>(config)
|
||||||
},
|
},
|
||||||
BenchmarkCmd::Block(cmd) => {
|
BenchmarkCmd::Block(cmd) => {
|
||||||
let PartialComponents { client, .. } = new_partial(&config)?;
|
// ensure that we keep the task manager alive
|
||||||
cmd.run(client)
|
let partial = new_partial(&config)?;
|
||||||
|
cmd.run(partial.client)
|
||||||
},
|
},
|
||||||
BenchmarkCmd::Storage(cmd) => {
|
BenchmarkCmd::Storage(cmd) => {
|
||||||
let PartialComponents { client, backend, .. } = new_partial(&config)?;
|
// ensure that we keep the task manager alive
|
||||||
let db = backend.expose_db();
|
let partial = new_partial(&config)?;
|
||||||
let storage = backend.expose_storage();
|
let db = partial.backend.expose_db();
|
||||||
|
let storage = partial.backend.expose_storage();
|
||||||
|
|
||||||
cmd.run(config, client, db, storage)
|
cmd.run(config, partial.client, db, storage)
|
||||||
},
|
},
|
||||||
BenchmarkCmd::Overhead(cmd) => {
|
BenchmarkCmd::Overhead(cmd) => {
|
||||||
let PartialComponents { client, .. } = new_partial(&config)?;
|
// ensure that we keep the task manager alive
|
||||||
let ext_builder = RemarkBuilder::new(client.clone());
|
let partial = new_partial(&config)?;
|
||||||
|
let ext_builder = RemarkBuilder::new(partial.client.clone());
|
||||||
|
|
||||||
cmd.run(config, client, inherent_benchmark_data()?, &ext_builder)
|
cmd.run(config, partial.client, inherent_benchmark_data()?, &ext_builder)
|
||||||
},
|
},
|
||||||
BenchmarkCmd::Extrinsic(cmd) => {
|
BenchmarkCmd::Extrinsic(cmd) => {
|
||||||
let PartialComponents { client, .. } = service::new_partial(&config)?;
|
// ensure that we keep the task manager alive
|
||||||
|
let partial = service::new_partial(&config)?;
|
||||||
// Register the *Remark* and *TKA* builders.
|
// Register the *Remark* and *TKA* builders.
|
||||||
let ext_factory = ExtrinsicFactory(vec![
|
let ext_factory = ExtrinsicFactory(vec![
|
||||||
Box::new(RemarkBuilder::new(client.clone())),
|
Box::new(RemarkBuilder::new(partial.client.clone())),
|
||||||
Box::new(TransferKeepAliveBuilder::new(
|
Box::new(TransferKeepAliveBuilder::new(
|
||||||
client.clone(),
|
partial.client.clone(),
|
||||||
Sr25519Keyring::Alice.to_account_id(),
|
Sr25519Keyring::Alice.to_account_id(),
|
||||||
ExistentialDeposit::get(),
|
ExistentialDeposit::get(),
|
||||||
)),
|
)),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
cmd.run(client, inherent_benchmark_data()?, &ext_factory)
|
cmd.run(partial.client, inherent_benchmark_data()?, &ext_factory)
|
||||||
},
|
},
|
||||||
BenchmarkCmd::Machine(cmd) =>
|
BenchmarkCmd::Machine(cmd) =>
|
||||||
cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone()),
|
cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone()),
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ impl InsertKeyCmd {
|
|||||||
let suri = utils::read_uri(self.suri.as_ref())?;
|
let suri = utils::read_uri(self.suri.as_ref())?;
|
||||||
let base_path = self
|
let base_path = self
|
||||||
.shared_params
|
.shared_params
|
||||||
.base_path()
|
.base_path()?
|
||||||
.unwrap_or_else(|| BasePath::from_project("", "", &C::executable_name()));
|
.unwrap_or_else(|| BasePath::from_project("", "", &C::executable_name()));
|
||||||
let chain_id = self.shared_params.chain_id(self.shared_params.is_dev());
|
let chain_id = self.shared_params.chain_id(self.shared_params.is_dev());
|
||||||
let chain_spec = cli.load_spec(&chain_id)?;
|
let chain_spec = cli.load_spec(&chain_id)?;
|
||||||
|
|||||||
@@ -485,7 +485,7 @@ impl CliConfiguration for RunCmd {
|
|||||||
Ok(if self.tmp {
|
Ok(if self.tmp {
|
||||||
Some(BasePath::new_temp_dir()?)
|
Some(BasePath::new_temp_dir()?)
|
||||||
} else {
|
} else {
|
||||||
match self.shared_params().base_path() {
|
match self.shared_params().base_path()? {
|
||||||
Some(r) => Some(r),
|
Some(r) => Some(r),
|
||||||
// If `dev` is enabled, we use the temp base path.
|
// If `dev` is enabled, we use the temp base path.
|
||||||
None if self.shared_params().is_dev() => Some(BasePath::new_temp_dir()?),
|
None if self.shared_params().is_dev() => Some(BasePath::new_temp_dir()?),
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ pub trait CliConfiguration<DCV: DefaultConfigurationValues = ()>: Sized {
|
|||||||
///
|
///
|
||||||
/// By default this is retrieved from `SharedParams`.
|
/// By default this is retrieved from `SharedParams`.
|
||||||
fn base_path(&self) -> Result<Option<BasePath>> {
|
fn base_path(&self) -> Result<Option<BasePath>> {
|
||||||
Ok(self.shared_params().base_path())
|
self.shared_params().base_path()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns `true` if the node is for development or not
|
/// Returns `true` if the node is for development or not
|
||||||
|
|||||||
@@ -82,8 +82,13 @@ pub struct SharedParams {
|
|||||||
|
|
||||||
impl SharedParams {
|
impl SharedParams {
|
||||||
/// Specify custom base path.
|
/// Specify custom base path.
|
||||||
pub fn base_path(&self) -> Option<BasePath> {
|
pub fn base_path(&self) -> Result<Option<BasePath>, crate::Error> {
|
||||||
self.base_path.clone().map(Into::into)
|
match &self.base_path {
|
||||||
|
Some(r) => Ok(Some(r.clone().into())),
|
||||||
|
// If `dev` is enabled, we use the temp base path.
|
||||||
|
None if self.is_dev() => Ok(Some(BasePath::new_temp_dir()?)),
|
||||||
|
None => Ok(None),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Specify the development chain.
|
/// Specify the development chain.
|
||||||
|
|||||||
Reference in New Issue
Block a user