Add benchmarking pipeline to node-template (#7122)

This commit is contained in:
Shawn Tabrizi
2020-09-17 10:09:59 +02:00
committed by GitHub
parent 9aa8698cfc
commit ab97e94972
8 changed files with 91 additions and 13 deletions
@@ -45,7 +45,17 @@ sc-basic-authorship = { version = "0.8.0-rc6", path = "../../../client/basic-aut
substrate-frame-rpc-system = { version = "2.0.0-rc6", path = "../../../utils/frame/rpc/system" }
pallet-transaction-payment-rpc = { version = "2.0.0-rc6", path = "../../../frame/transaction-payment/rpc/" }
# These dependencies are used for runtime benchmarking
frame-benchmarking = { version = "2.0.0-rc6", path = "../../../frame/benchmarking" }
frame-benchmarking-cli = { version = "2.0.0-rc6", path = "../../../utils/frame/benchmarking-cli" }
node-template-runtime = { version = "2.0.0-rc6", path = "../runtime" }
[build-dependencies]
substrate-build-script-utils = { version = "2.0.0-rc6", path = "../../../utils/build-script-utils" }
[features]
default = []
runtime-benchmarks = [
"node-template-runtime/runtime-benchmarks",
]
@@ -32,4 +32,8 @@ pub enum Subcommand {
/// Revert the chain to a previous state.
Revert(sc_cli::RevertCmd),
/// The custom benchmark subcommmand benchmarking runtime pallets.
#[structopt(name = "benchmark", about = "Benchmark runtime pallets.")]
Benchmark(frame_benchmarking_cli::BenchmarkCmd),
}
@@ -15,12 +15,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::chain_spec;
use crate::{chain_spec, service};
use crate::cli::{Cli, Subcommand};
use crate::service;
use sc_cli::{SubstrateCli, RuntimeVersion, Role, ChainSpec};
use sc_service::PartialComponents;
use crate::service::new_partial;
use node_template_runtime::Block;
impl SubstrateCli for Cli {
fn impl_name() -> String {
@@ -75,7 +74,7 @@ pub fn run() -> sc_cli::Result<()> {
let runner = cli.create_runner(cmd)?;
runner.async_run(|config| {
let PartialComponents { client, task_manager, import_queue, ..}
= new_partial(&config)?;
= service::new_partial(&config)?;
Ok((cmd.run(client, import_queue), task_manager))
})
},
@@ -83,7 +82,7 @@ pub fn run() -> sc_cli::Result<()> {
let runner = cli.create_runner(cmd)?;
runner.async_run(|config| {
let PartialComponents { client, task_manager, ..}
= new_partial(&config)?;
= service::new_partial(&config)?;
Ok((cmd.run(client, config.database), task_manager))
})
},
@@ -91,7 +90,7 @@ pub fn run() -> sc_cli::Result<()> {
let runner = cli.create_runner(cmd)?;
runner.async_run(|config| {
let PartialComponents { client, task_manager, ..}
= new_partial(&config)?;
= service::new_partial(&config)?;
Ok((cmd.run(client, config.chain_spec), task_manager))
})
},
@@ -99,7 +98,7 @@ pub fn run() -> sc_cli::Result<()> {
let runner = cli.create_runner(cmd)?;
runner.async_run(|config| {
let PartialComponents { client, task_manager, import_queue, ..}
= new_partial(&config)?;
= service::new_partial(&config)?;
Ok((cmd.run(client, import_queue), task_manager))
})
},
@@ -111,10 +110,20 @@ pub fn run() -> sc_cli::Result<()> {
let runner = cli.create_runner(cmd)?;
runner.async_run(|config| {
let PartialComponents { client, task_manager, backend, ..}
= new_partial(&config)?;
= service::new_partial(&config)?;
Ok((cmd.run(client, backend), task_manager))
})
},
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 {
Err("Benchmarking wasn't enabled when building the node. \
You can enable it with `--features runtime-benchmarks`.".into())
}
},
None => {
let runner = cli.create_runner(&cli.run)?;
runner.run_node_until_exit(|config| match config.role {
@@ -16,6 +16,7 @@ native_executor_instance!(
pub Executor,
node_template_runtime::api::dispatch,
node_template_runtime::native_version,
frame_benchmarking::benchmarking::HostFunctions,
);
type FullClient = sc_service::TFullClient<Block, RuntimeApi, Executor>;