mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 21:37:56 +00:00
Runtime benchmarks: start (#136)
* runtime benchmarks: start * merge tests + benchmarks infrastructure * fix compilation * Fix compilation issues with runtime-benchmark feature flag Mainly involved pulling in correct dependencies and adding some functions which were called but didn't yet exist. * Fix broken compilation for tests * Move header signing methods into trait * Move signing related test helpers to own module * Remove comment about feature flag * Add constants to tests * Add top level comment for testing utilities Co-authored-by: Hernando Castano <castano.ha@gmail.com>
This commit is contained in:
committed by
Bastian Köcher
parent
ea45fa8da7
commit
e39ca0dc16
@@ -115,6 +115,16 @@ version = "2.0.0-rc3"
|
||||
rev = "606c56d2e2f69f68f3947551224be6a3515dff60"
|
||||
git = "https://github.com/paritytech/substrate.git"
|
||||
|
||||
[dependencies.frame-benchmarking]
|
||||
version = "2.0.0-rc3"
|
||||
rev = "606c56d2e2f69f68f3947551224be6a3515dff60"
|
||||
git = "https://github.com/paritytech/substrate.git"
|
||||
|
||||
[dependencies.frame-benchmarking-cli]
|
||||
version = "2.0.0-rc3"
|
||||
rev = "606c56d2e2f69f68f3947551224be6a3515dff60"
|
||||
git = "https://github.com/paritytech/substrate.git"
|
||||
|
||||
[build-dependencies]
|
||||
vergen = "3.1.0"
|
||||
|
||||
@@ -123,3 +133,14 @@ package = "substrate-build-script-utils"
|
||||
version = "2.0.0-rc3"
|
||||
rev = "606c56d2e2f69f68f3947551224be6a3515dff60"
|
||||
git = "https://github.com/paritytech/substrate.git"
|
||||
|
||||
[build-dependencies.frame-benchmarking-cli]
|
||||
version = "2.0.0-rc3"
|
||||
rev = "606c56d2e2f69f68f3947551224be6a3515dff60"
|
||||
git = "https://github.com/paritytech/substrate.git"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
runtime-benchmarks = [
|
||||
"bridge-node-runtime/runtime-benchmarks",
|
||||
]
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use sc_cli::{RunCmd, Subcommand};
|
||||
use sc_cli::RunCmd;
|
||||
use structopt::StructOpt;
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
@@ -25,3 +25,15 @@ pub struct Cli {
|
||||
#[structopt(flatten)]
|
||||
pub run: RunCmd,
|
||||
}
|
||||
|
||||
/// Possible subcommands of the main binary.
|
||||
#[derive(Debug, StructOpt)]
|
||||
pub enum Subcommand {
|
||||
/// A set of base subcommands handled by `sc_cli`.
|
||||
#[structopt(flatten)]
|
||||
Base(sc_cli::Subcommand),
|
||||
|
||||
/// The custom benchmark subcommmand benchmarking runtime pallets.
|
||||
#[structopt(name = "benchmark", about = "Benchmark runtime pallets.")]
|
||||
Benchmark(frame_benchmarking_cli::BenchmarkCmd),
|
||||
}
|
||||
|
||||
@@ -30,8 +30,9 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::cli::Cli;
|
||||
use crate::cli::{Cli, Subcommand};
|
||||
use crate::service;
|
||||
use bridge_node_runtime::Block;
|
||||
use sc_cli::SubstrateCli;
|
||||
use sp_consensus_aura::sr25519::AuthorityPair as AuraPair;
|
||||
|
||||
@@ -81,7 +82,20 @@ pub fn run() -> sc_cli::Result<()> {
|
||||
let cli = Cli::from_args();
|
||||
|
||||
match &cli.subcommand {
|
||||
Some(subcommand) => {
|
||||
Some(Subcommand::Benchmark(cmd)) => {
|
||||
if cfg!(feature = "runtime-benchmarks") {
|
||||
let runner = cli.create_runner(cmd)?;
|
||||
|
||||
runner.sync_run(|config| cmd.run::<Block, service::Executor>(config))
|
||||
} else {
|
||||
println!(
|
||||
"Benchmarking wasn't enabled when building the node. \
|
||||
You can enable it with `--features runtime-benchmarks`."
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
Some(Subcommand::Base(subcommand)) => {
|
||||
let runner = cli.create_runner(subcommand)?;
|
||||
runner.run_subcommand(subcommand, |config| Ok(new_full_start!(config).0))
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ native_executor_instance!(
|
||||
pub Executor,
|
||||
bridge_node_runtime::api::dispatch,
|
||||
bridge_node_runtime::native_version,
|
||||
frame_benchmarking::benchmarking::HostFunctions,
|
||||
);
|
||||
|
||||
/// Starts a `ServiceBuilder` for a full service.
|
||||
|
||||
Reference in New Issue
Block a user