Patch Benchmark

This commit is contained in:
Luke Parker 2022-08-16 17:43:46 -04:00
parent f809827acd
commit 0543f3c469
No known key found for this signature in database
GPG key ID: F9F1386DB1E119B6
2 changed files with 19 additions and 10 deletions

View file

@ -1,7 +1,5 @@
use std::sync::Arc;
use sc_service::PartialComponents;
use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE};
use frame_benchmarking_cli::{ExtrinsicFactory, BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE};
use sc_cli::{ChainSpec, RuntimeVersion, SubstrateCli};
use serai_runtime::Block;
@ -9,7 +7,7 @@ use serai_runtime::Block;
use crate::{
chain_spec,
cli::{Cli, Subcommand},
command_helper::{BenchmarkExtrinsicBuilder, inherent_benchmark_data},
command_helper::{RemarkBuilder, inherent_benchmark_data},
service,
};
@ -103,11 +101,15 @@ pub fn run() -> sc_cli::Result<()> {
BenchmarkCmd::Overhead(cmd) => {
let client = service::new_partial(&config)?.client;
cmd.run(config, client.clone(), inherent_benchmark_data()?, &RemarkBuilder::new(client))
}
BenchmarkCmd::Extrinsic(cmd) => {
let PartialComponents { client, .. } = service::new_partial(&config)?;
cmd.run(
config,
client.clone(),
inherent_benchmark_data()?,
Arc::new(BenchmarkExtrinsicBuilder::new(client)),
&ExtrinsicFactory(vec![Box::new(RemarkBuilder::new(client))]),
)
}

View file

@ -14,18 +14,25 @@ use runtime::SystemCall;
use crate::service::FullClient;
pub struct BenchmarkExtrinsicBuilder {
pub struct RemarkBuilder {
client: Arc<FullClient>,
}
impl BenchmarkExtrinsicBuilder {
impl RemarkBuilder {
pub fn new(client: Arc<FullClient>) -> Self {
Self { client }
}
}
impl frame_benchmarking_cli::ExtrinsicBuilder for BenchmarkExtrinsicBuilder {
fn remark(&self, nonce: u32) -> std::result::Result<OpaqueExtrinsic, &'static str> {
impl frame_benchmarking_cli::ExtrinsicBuilder for RemarkBuilder {
fn pallet(&self) -> &str {
"system"
}
fn extrinsic(&self) -> &str {
"remark"
}
fn build(&self, nonce: u32) -> std::result::Result<OpaqueExtrinsic, &'static str> {
Ok(OpaqueExtrinsic::from(create_benchmark_extrinsic(
self.client.as_ref(),
Sr25519Keyring::Bob.pair(),