git.delta.rocks / unique-network / refs/commits / 821aed2aa1dd

difftreelog

fix benchmarking subcommand

Yaroslav Bolyukin2022-04-29parent: #dcad7a3.patch.diff
in: master

3 files changed

modifiedMakefilediffbeforeafterboth
3131
32.PHONY: _bench32.PHONY: _bench
33_bench:33_bench:
34 cargo run --release --features runtime-benchmarks -- \34 cargo run --release --features runtime-benchmarks,unique-runtime -- \
35 benchmark --pallet pallet-$(PALLET) \35 benchmark pallet --pallet pallet-$(PALLET) \
36 --wasm-execution compiled --extrinsic '*' \36 --wasm-execution compiled --extrinsic '*' \
37 --template .maintain/frame-weight-template.hbs --steps=50 --repeat=200 --heap-pages=4096 \37 --template .maintain/frame-weight-template.hbs --steps=50 --repeat=200 --heap-pages=4096 \
38 --output=./pallets/$(PALLET)/src/weights.rs38 --output=./pallets/$(PALLET)/src/weights.rs
3939
modifiednode/cli/src/command.rsdiffbeforeafterboth
--- a/node/cli/src/command.rs
+++ b/node/cli/src/command.rs
@@ -371,8 +371,47 @@
 
 			Ok(())
 		}
+		#[cfg(feature = "unique-runtime")]
+		Some(Subcommand::Benchmark(cmd)) => {
+			use frame_benchmarking_cli::BenchmarkCmd;
+			let runner = cli.create_runner(cmd)?;
+			// Switch on the concrete benchmark sub-command-
+			match cmd {
+				BenchmarkCmd::Pallet(cmd) => {
+					if cfg!(feature = "runtime-benchmarks") {
+						runner.sync_run(|config| cmd.run::<Block, UniqueRuntimeExecutor>(config))
+					} else {
+						Err("Benchmarking wasn't enabled when building the node. \
+					You can enable it with `--features runtime-benchmarks`."
+							.into())
+					}
+				}
+				BenchmarkCmd::Block(cmd) => runner.sync_run(|config| {
+					let partials = new_partial::<
+						unique_runtime::RuntimeApi,
+						UniqueRuntimeExecutor,
+						_,
+					>(&config, crate::service::parachain_build_import_queue)?;
+					cmd.run(partials.client)
+				}),
+				BenchmarkCmd::Storage(cmd) => runner.sync_run(|config| {
+					let partials = new_partial::<
+						unique_runtime::RuntimeApi,
+						UniqueRuntimeExecutor,
+						_,
+					>(&config, crate::service::parachain_build_import_queue)?;
+					let db = partials.backend.expose_db();
+					let storage = partials.backend.expose_storage();
 
-		Some(Subcommand::Benchmark(_cmd)) => todo!(),
+					cmd.run(config, partials.client.clone(), db, storage)
+				}),
+				BenchmarkCmd::Overhead(_) => Err("Unsupported benchmarking command".into()),
+			}
+		}
+		#[cfg(not(feature = "unique-runtime"))]
+		Some(Subcommand::Benchmark(..)) => {
+			Err("benchmarking is only available with unique runtime enabled".into())
+		}
 		None => {
 			let runner = cli.create_runner(&cli.run.normalize())?;
 			let collator_options = cli.run.collator_options();
modifiedruntime/common/src/runtime_apis.rsdiffbeforeafterboth
--- a/runtime/common/src/runtime_apis.rs
+++ b/runtime/common/src/runtime_apis.rs
@@ -401,6 +401,9 @@
                         hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),
                         // System Events
                         hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),
+
+                        // Transactional depth
+                        hex_literal::hex!("3a7472616e73616374696f6e5f6c6576656c3a").to_vec().into(),
                     ];
 
                     let mut batches = Vec::<BenchmarkBatch>::new();