Companion for Substrate#14511 (#7459)

* Companion for Substrate#14511

https://github.com/paritytech/substrate/pull/14511

* Make benchmarking build without any native runtime

* Fix warning

* update lockfile for {"substrate"}

---------

Co-authored-by: parity-processbot <>
This commit is contained in:
Bastian Köcher
2023-07-05 10:08:09 +02:00
committed by GitHub
parent a37a5e47dc
commit a40417da96
7 changed files with 387 additions and 275 deletions
+364 -213
View File
File diff suppressed because it is too large Load Diff
+1 -33
View File
@@ -18,7 +18,7 @@ use crate::cli::{Cli, Subcommand};
use frame_benchmarking_cli::{BenchmarkCmd, ExtrinsicFactory, SUBSTRATE_REFERENCE_HARDWARE};
use futures::future::TryFutureExt;
use log::info;
use sc_cli::{RuntimeVersion, SubstrateCli};
use sc_cli::SubstrateCli;
use service::{
self,
benchmarking::{benchmark_inherent_data, RemarkBuilder, TransferKeepAliveBuilder},
@@ -168,38 +168,6 @@ impl SubstrateCli for Cli {
},
})
}
fn native_runtime_version(spec: &Box<dyn service::ChainSpec>) -> &'static RuntimeVersion {
#[cfg(feature = "kusama-native")]
if spec.is_kusama() {
return &service::kusama_runtime::VERSION
}
#[cfg(feature = "westend-native")]
if spec.is_westend() {
return &service::westend_runtime::VERSION
}
#[cfg(feature = "rococo-native")]
if spec.is_rococo() || spec.is_wococo() || spec.is_versi() {
return &service::rococo_runtime::VERSION
}
#[cfg(not(all(
feature = "rococo-native",
feature = "westend-native",
feature = "kusama-native"
)))]
let _ = spec;
#[cfg(feature = "polkadot-native")]
{
return &service::polkadot_runtime::VERSION
}
#[cfg(not(feature = "polkadot-native"))]
panic!("No runtime feature (polkadot, kusama, westend, rococo) is enabled")
}
}
fn set_default_ss58_version(spec: &Box<dyn service::ChainSpec>) {
+20 -7
View File
@@ -16,10 +16,8 @@
//! Code related to benchmarking a [`crate::Client`].
use codec::Encode;
use polkadot_primitives::AccountId;
use sc_client_api::UsageProvider;
use sp_core::{Pair, H256};
use sp_keyring::Sr25519Keyring;
use sp_runtime::OpaqueExtrinsic;
@@ -93,6 +91,12 @@ macro_rules! identify_chain {
#[cfg(not(feature = "westend-native"))]
{
let _ = $nonce;
let _ = $current_block;
let _ = $period;
let _ = $genesis;
let _ = $signer;
Err("`westend-native` feature not enabled")
}
},
@@ -183,6 +187,7 @@ impl frame_benchmarking_cli::ExtrinsicBuilder for TransferKeepAliveBuilder {
.unwrap_or(2) as u64;
let genesis = self.client.usage_info().chain.best_hash;
let current_block = 0;
let _dest = self.dest.clone();
identify_chain! {
self.chain,
@@ -193,7 +198,7 @@ impl frame_benchmarking_cli::ExtrinsicBuilder for TransferKeepAliveBuilder {
signer,
{
runtime::RuntimeCall::Balances(runtime::BalancesCall::transfer_keep_alive {
dest: self.dest.clone().into(),
dest: _dest.into(),
value: runtime::ExistentialDeposit::get(),
})
},
@@ -207,10 +212,12 @@ fn polkadot_sign_call(
nonce: u32,
current_block: u64,
period: u64,
genesis: H256,
genesis: sp_core::H256,
acc: sp_core::sr25519::Pair,
) -> OpaqueExtrinsic {
use codec::Encode;
use polkadot_runtime as runtime;
use sp_core::Pair;
let extra: runtime::SignedExtra = (
frame_system::CheckNonZeroSender::<runtime::Runtime>::new(),
@@ -259,9 +266,11 @@ fn westend_sign_call(
nonce: u32,
current_block: u64,
period: u64,
genesis: H256,
genesis: sp_core::H256,
acc: sp_core::sr25519::Pair,
) -> OpaqueExtrinsic {
use codec::Encode;
use sp_core::Pair;
use westend_runtime as runtime;
let extra: runtime::SignedExtra = (
@@ -309,10 +318,12 @@ fn kusama_sign_call(
nonce: u32,
current_block: u64,
period: u64,
genesis: H256,
genesis: sp_core::H256,
acc: sp_core::sr25519::Pair,
) -> OpaqueExtrinsic {
use codec::Encode;
use kusama_runtime as runtime;
use sp_core::Pair;
let extra: runtime::SignedExtra = (
frame_system::CheckNonZeroSender::<runtime::Runtime>::new(),
@@ -359,10 +370,12 @@ fn rococo_sign_call(
nonce: u32,
current_block: u64,
period: u64,
genesis: H256,
genesis: sp_core::H256,
acc: sp_core::sr25519::Pair,
) -> OpaqueExtrinsic {
use codec::Encode;
use rococo_runtime as runtime;
use sp_core::Pair;
let extra: runtime::SignedExtra = (
frame_system::CheckNonZeroSender::<runtime::Runtime>::new(),
-2
View File
@@ -27,7 +27,6 @@ use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
feature = "polkadot-native",
feature = "kusama-native",
feature = "westend-native",
feature = "rococo-native"
))]
use pallet_staking::Forcing;
use polkadot_primitives::{AccountId, AccountPublic, AssignmentId, ValidatorId};
@@ -57,7 +56,6 @@ use sp_runtime::traits::IdentifyAccount;
feature = "polkadot-native",
feature = "kusama-native",
feature = "westend-native",
feature = "rococo-native"
))]
use sp_runtime::Perbill;
#[cfg(any(
-6
View File
@@ -18,12 +18,6 @@
#![deny(unused_results)]
#[cfg(any(
feature = "polkadot-native",
feature = "kusama-native",
feature = "westend-native",
feature = "rococo-native"
))]
pub mod benchmarking;
pub mod chain_spec;
mod fake_runtime_api;
@@ -17,7 +17,7 @@
//! Polkadot CLI library.
use clap::Parser;
use sc_cli::{RuntimeVersion, SubstrateCli};
use sc_cli::SubstrateCli;
/// Sub-commands supported by the collator.
#[derive(Debug, Parser)]
@@ -105,10 +105,4 @@ impl SubstrateCli for Cli {
},
})
}
fn native_runtime_version(
_spec: &Box<dyn polkadot_service::ChainSpec>,
) -> &'static RuntimeVersion {
&polkadot_service::rococo_runtime::VERSION
}
}
@@ -17,7 +17,7 @@
//! Polkadot CLI library.
use clap::Parser;
use sc_cli::{RuntimeVersion, SubstrateCli};
use sc_cli::SubstrateCli;
/// Sub-commands supported by the collator.
#[derive(Debug, Parser)]
@@ -127,10 +127,4 @@ impl SubstrateCli for Cli {
},
})
}
fn native_runtime_version(
_spec: &Box<dyn polkadot_service::ChainSpec>,
) -> &'static RuntimeVersion {
&polkadot_service::rococo_runtime::VERSION
}
}