mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-11 22:21:07 +00:00
Add benchmarking support for digest items (#12159)
* Add benchmarking support for digest items * fmt
This commit is contained in:
@@ -139,7 +139,13 @@ pub fn run() -> sc_cli::Result<()> {
|
||||
let PartialComponents { client, .. } = service::new_partial(&config)?;
|
||||
let ext_builder = RemarkBuilder::new(client.clone());
|
||||
|
||||
cmd.run(config, client, inherent_benchmark_data()?, &ext_builder)
|
||||
cmd.run(
|
||||
config,
|
||||
client,
|
||||
inherent_benchmark_data()?,
|
||||
Vec::new(),
|
||||
&ext_builder,
|
||||
)
|
||||
},
|
||||
BenchmarkCmd::Extrinsic(cmd) => {
|
||||
let PartialComponents { client, .. } = service::new_partial(&config)?;
|
||||
@@ -153,7 +159,7 @@ pub fn run() -> sc_cli::Result<()> {
|
||||
)),
|
||||
]);
|
||||
|
||||
cmd.run(client, inherent_benchmark_data()?, &ext_factory)
|
||||
cmd.run(client, inherent_benchmark_data()?, Vec::new(), &ext_factory)
|
||||
},
|
||||
BenchmarkCmd::Machine(cmd) =>
|
||||
cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone()),
|
||||
|
||||
@@ -132,7 +132,13 @@ pub fn run() -> Result<()> {
|
||||
let partial = new_partial(&config)?;
|
||||
let ext_builder = RemarkBuilder::new(partial.client.clone());
|
||||
|
||||
cmd.run(config, partial.client, inherent_benchmark_data()?, &ext_builder)
|
||||
cmd.run(
|
||||
config,
|
||||
partial.client,
|
||||
inherent_benchmark_data()?,
|
||||
Vec::new(),
|
||||
&ext_builder,
|
||||
)
|
||||
},
|
||||
BenchmarkCmd::Extrinsic(cmd) => {
|
||||
// ensure that we keep the task manager alive
|
||||
@@ -147,7 +153,12 @@ pub fn run() -> Result<()> {
|
||||
)),
|
||||
]);
|
||||
|
||||
cmd.run(partial.client, inherent_benchmark_data()?, &ext_factory)
|
||||
cmd.run(
|
||||
partial.client,
|
||||
inherent_benchmark_data()?,
|
||||
Vec::new(),
|
||||
&ext_factory,
|
||||
)
|
||||
},
|
||||
BenchmarkCmd::Machine(cmd) =>
|
||||
cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone()),
|
||||
|
||||
@@ -28,7 +28,7 @@ use sp_blockchain::{
|
||||
use sp_runtime::{
|
||||
traits::{Block as BlockT, Zero},
|
||||
transaction_validity::{InvalidTransaction, TransactionValidityError},
|
||||
OpaqueExtrinsic,
|
||||
Digest, DigestItem, OpaqueExtrinsic,
|
||||
};
|
||||
|
||||
use clap::Args;
|
||||
@@ -65,6 +65,7 @@ pub(crate) struct Benchmark<Block, BA, C> {
|
||||
client: Arc<C>,
|
||||
params: BenchmarkParams,
|
||||
inherent_data: sp_inherents::InherentData,
|
||||
digest_items: Vec<DigestItem>,
|
||||
_p: PhantomData<(Block, BA)>,
|
||||
}
|
||||
|
||||
@@ -80,8 +81,9 @@ where
|
||||
client: Arc<C>,
|
||||
params: BenchmarkParams,
|
||||
inherent_data: sp_inherents::InherentData,
|
||||
digest_items: Vec<DigestItem>,
|
||||
) -> Self {
|
||||
Self { client, params, inherent_data, _p: PhantomData }
|
||||
Self { client, params, inherent_data, digest_items, _p: PhantomData }
|
||||
}
|
||||
|
||||
/// Benchmark a block with only inherents.
|
||||
@@ -125,7 +127,7 @@ where
|
||||
&self,
|
||||
ext_builder: Option<&dyn ExtrinsicBuilder>,
|
||||
) -> Result<(Block, Option<u64>)> {
|
||||
let mut builder = self.client.new_block(Default::default())?;
|
||||
let mut builder = self.client.new_block(Digest { logs: self.digest_items.clone() })?;
|
||||
// Create and insert the inherents.
|
||||
let inherents = builder.create_inherents(self.inherent_data.clone())?;
|
||||
for inherent in inherents {
|
||||
|
||||
@@ -19,7 +19,7 @@ use sc_block_builder::{BlockBuilderApi, BlockBuilderProvider};
|
||||
use sc_cli::{CliConfiguration, ImportParams, Result, SharedParams};
|
||||
use sc_client_api::Backend as ClientBackend;
|
||||
use sp_api::{ApiExt, ProvideRuntimeApi};
|
||||
use sp_runtime::{traits::Block as BlockT, OpaqueExtrinsic};
|
||||
use sp_runtime::{traits::Block as BlockT, DigestItem, OpaqueExtrinsic};
|
||||
|
||||
use clap::{Args, Parser};
|
||||
use log::info;
|
||||
@@ -82,6 +82,7 @@ impl ExtrinsicCmd {
|
||||
&self,
|
||||
client: Arc<C>,
|
||||
inherent_data: sp_inherents::InherentData,
|
||||
digest_items: Vec<DigestItem>,
|
||||
ext_factory: &ExtrinsicFactory,
|
||||
) -> Result<()>
|
||||
where
|
||||
@@ -109,7 +110,7 @@ impl ExtrinsicCmd {
|
||||
return Err("Unknown pallet or extrinsic. Use --list for a complete list.".into()),
|
||||
};
|
||||
|
||||
let bench = Benchmark::new(client, self.params.bench.clone(), inherent_data);
|
||||
let bench = Benchmark::new(client, self.params.bench.clone(), inherent_data, digest_items);
|
||||
let stats = bench.bench_extrinsic(ext_builder)?;
|
||||
info!(
|
||||
"Executing a {}::{} extrinsic takes[ns]:\n{:?}",
|
||||
|
||||
@@ -23,7 +23,7 @@ use sc_cli::{CliConfiguration, ImportParams, Result, SharedParams};
|
||||
use sc_client_api::Backend as ClientBackend;
|
||||
use sc_service::Configuration;
|
||||
use sp_api::{ApiExt, ProvideRuntimeApi};
|
||||
use sp_runtime::{traits::Block as BlockT, OpaqueExtrinsic};
|
||||
use sp_runtime::{traits::Block as BlockT, DigestItem, OpaqueExtrinsic};
|
||||
|
||||
use clap::{Args, Parser};
|
||||
use log::info;
|
||||
@@ -90,6 +90,7 @@ impl OverheadCmd {
|
||||
cfg: Configuration,
|
||||
client: Arc<C>,
|
||||
inherent_data: sp_inherents::InherentData,
|
||||
digest_items: Vec<DigestItem>,
|
||||
ext_builder: &dyn ExtrinsicBuilder,
|
||||
) -> Result<()>
|
||||
where
|
||||
@@ -101,7 +102,7 @@ impl OverheadCmd {
|
||||
if ext_builder.pallet() != "system" || ext_builder.extrinsic() != "remark" {
|
||||
return Err(format!("The extrinsic builder is required to build `System::Remark` extrinsics but builds `{}` extrinsics instead", ext_builder.name()).into());
|
||||
}
|
||||
let bench = Benchmark::new(client, self.params.bench.clone(), inherent_data);
|
||||
let bench = Benchmark::new(client, self.params.bench.clone(), inherent_data, digest_items);
|
||||
|
||||
// per-block execution overhead
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user