I am on rc-5 and trying to run benchmarks. Keep getting the following error no matter what pallet I try to benchmark unless I follow a pattern that I describe later.
Cannot create a runtime: Instantiation("Instantiation: Export ext_benchmarking_commit_db_version_1 not found")
Error: Input("Error executing runtime benchmark: Other(\"Instantiation: Export ext_benchmarking_commit_db_version_1 not found\")")
I am running the following command for benchmarking from node directory and have tried clearing the database before running
cargo run --features runtime-benchmarks -- benchmark --extrinsic=transfer --pallet=balances
Even after commenting out all benchmarking code from my modules and the add_benchmark! in dispatch_benchmark for my modules, i get the same error as above. This is how dispatch_benchmark looks (taken from substrate repo's bin/node/runtime)
fn dispatch_benchmark(
pallet: Vec<u8>,
benchmark: Vec<u8>,
lowest_range_values: Vec<u32>,
highest_range_values: Vec<u32>,
steps: Vec<u32>,
repeat: u32,
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark};
use frame_system_benchmarking::Module as SystemBench;
impl frame_system_benchmarking::Trait for Runtime {}
let whitelist = vec![];
let mut batches = Vec::<BenchmarkBatch>::new();
let params = (&pallet, &benchmark, &lowest_range_values, &highest_range_values, &steps, repeat, &whitelist);
add_benchmark!(params, batches, balances, Balances);
add_benchmark!(params, batches, frame_system, SystemBench::<Runtime>);
if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
Ok(batches)
I followed the discussion in this issue https://github.com/paritytech/substrate/issues/6644 and checked with the linked PR but don't see the difference that can cause this.
However, I can get this to work if I follow the steps in the following sequence:
cargo build) - this will workThe code I am running is here.
You are not registering the benchmarking host functions, as shown here: https://github.com/paritytech/substrate/blob/master/bin/node/executor/src/lib.rs#L30
@bkchr Thanks. Your suggestion works. I am closing this issue but can you please explain why build sequence mentioned in the issue worked?
Not sure how that worked :shrug:
Most helpful comment
You are not registering the benchmarking host functions, as shown here: https://github.com/paritytech/substrate/blob/master/bin/node/executor/src/lib.rs#L30