Skip to content
Snippets Groups Projects
Commit 2e943e2b authored by Benjamin Gallois's avatar Benjamin Gallois Committed by Hugo Trentesaux
Browse files

Add check that benchmark run on appropriate genesis (!170)

* fix(runtime) fix benchmarks for g1 and gtest

* feat(runtime) enforce gdev-benchmark for benchmark commands
parent a6cee971
No related branches found
No related tags found
1 merge request!170Add check that benchmark run on appropriate genesis
Pipeline #31971 failed
...@@ -42,6 +42,20 @@ lazy_static! { ...@@ -42,6 +42,20 @@ lazy_static! {
}; };
}*/ }*/
//Currently, only `gdev-benchmark` supports the benchmark of all the extrinsics. Storage and overhead are equivalent with `gdev-benchmark` and `gdev`, so we enforce `gdev-benchmark` for all benchmark-related commands.
#[cfg(feature = "runtime-benchmarks")]
fn ensure_dev(spec: &Box<dyn sc_service::ChainSpec>) -> std::result::Result<(), String> {
if spec.id() == "gdev-benchmark" {
Ok(())
} else {
Err(format!(
"{}{}",
"can only use subcommand with --chain [gdev-benchmark], got ",
spec.id()
))
}
}
/// Unwraps a [`crate::client::Client`] into the concrete runtime client. /// Unwraps a [`crate::client::Client`] into the concrete runtime client.
#[cfg(feature = "runtime-benchmarks")] #[cfg(feature = "runtime-benchmarks")]
macro_rules! unwrap_client { macro_rules! unwrap_client {
...@@ -263,6 +277,7 @@ pub fn run() -> sc_cli::Result<()> { ...@@ -263,6 +277,7 @@ pub fn run() -> sc_cli::Result<()> {
Some(Subcommand::Benchmark(cmd)) => { Some(Subcommand::Benchmark(cmd)) => {
let runner = cli.create_runner(cmd)?; let runner = cli.create_runner(cmd)?;
let chain_spec = &runner.config().chain_spec; let chain_spec = &runner.config().chain_spec;
ensure_dev(chain_spec)?;
match cmd { match cmd {
BenchmarkCmd::Storage(cmd) => runner.sync_run(|mut config| { BenchmarkCmd::Storage(cmd) => runner.sync_run(|mut config| {
......
...@@ -130,16 +130,23 @@ pub type TechnicalCommitteeInstance = Instance2; ...@@ -130,16 +130,23 @@ pub type TechnicalCommitteeInstance = Instance2;
#[cfg(feature = "runtime-benchmarks")] #[cfg(feature = "runtime-benchmarks")]
mod benches { mod benches {
define_benchmarks!( define_benchmarks!(
// Duniter // For completion, benchmarks only running on `gdev-benchmark`.
// NOTE: Make sure to prefix these with `common_runtime::` so [pallet_certification, Cert]
// the that path resolves correctly in the generated file. [pallet_certification, SmithCert]
[common_runtime::oneshot_account, OneshotAccount] [pallet_oneshot_account, OneshotAccount]
[common_runtime::universal_dividend, UniversalDividend] [pallet_universal_dividend, UniversalDividend]
[common_runtime::upgrade_origin, UpgradeOrigin] [pallet_provide_randomness, ProvideRandomness]
[pallet_upgrade_origin, UpgradeOrigin]
[pallet_duniter_account, Account]
[pallet_identity, Identity]
[pallet_membership, Membership]
[pallet_membership, SmithMembership]
[pallet_authority_members, AuthorityMembers]
// Substrate // Substrate
[pallet_balances, Balances] [pallet_balances, Balances]
[frame_benchmarking::baseline, Baseline::<Runtime>] [frame_benchmarking::baseline, Baseline::<Runtime>]
[pallet_collective, TechnicalCommittee] [pallet_collective, TechnicalCommittee]
[pallet_session, SessionBench::<Runtime>]
[pallet_im_online, ImOnline] [pallet_im_online, ImOnline]
[pallet_multisig, Multisig] [pallet_multisig, Multisig]
[pallet_preimage, Preimage] [pallet_preimage, Preimage]
......
...@@ -131,16 +131,23 @@ pub type TechnicalCommitteeInstance = Instance2; ...@@ -131,16 +131,23 @@ pub type TechnicalCommitteeInstance = Instance2;
#[cfg(feature = "runtime-benchmarks")] #[cfg(feature = "runtime-benchmarks")]
mod benches { mod benches {
define_benchmarks!( define_benchmarks!(
// Duniter // For completion, benchmarks only running on `gdev-benchmark`.
// NOTE: Make sure to prefix these with `common_runtime::` so [pallet_certification, Cert]
// the that path resolves correctly in the generated file. [pallet_certification, SmithCert]
[common_runtime::oneshot_account, OneshotAccount] [pallet_oneshot_account, OneshotAccount]
[common_runtime::universal_dividend, UniversalDividend] [pallet_universal_dividend, UniversalDividend]
[common_runtime::upgrade_origin, UpgradeOrigin] [pallet_provide_randomness, ProvideRandomness]
[pallet_upgrade_origin, UpgradeOrigin]
[pallet_duniter_account, Account]
[pallet_identity, Identity]
[pallet_membership, Membership]
[pallet_membership, SmithMembership]
[pallet_authority_members, AuthorityMembers]
// Substrate // Substrate
[pallet_balances, Balances] [pallet_balances, Balances]
[frame_benchmarking::baseline, Baseline::<Runtime>] [frame_benchmarking::baseline, Baseline::<Runtime>]
[pallet_collective, TechnicalCommittee] [pallet_collective, TechnicalCommittee]
[pallet_session, SessionBench::<Runtime>]
[pallet_im_online, ImOnline] [pallet_im_online, ImOnline]
[pallet_multisig, Multisig] [pallet_multisig, Multisig]
[pallet_preimage, Preimage] [pallet_preimage, Preimage]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment