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
before · Makefile
1.PHONY: _help2_help:3	@echo "regenerate_solidity - generate stubs/interfaces for contracts defined in native (via evm-coder)"4	@echo "evm_stubs - recompile contract stubs"5	@echo "bench - run frame-benchmarking"6	@echo "  bench-evm-migration"7	@echo "  bench-unique"89.PHONY: regenerate_solidity10regenerate_solidity:11	PACKAGE=pallet-fungible NAME=erc::gen_iface OUTPUT=./tests/src/eth/api/UniqueFungible.sol ./.maintain/scripts/generate_api.sh12	PACKAGE=pallet-nonfungible NAME=erc::gen_iface OUTPUT=./tests/src/eth/api/UniqueNFT.sol ./.maintain/scripts/generate_api.sh13	PACKAGE=pallet-evm-contract-helpers NAME=eth::contract_helpers_iface OUTPUT=./tests/src/eth/api/ContractHelpers.sol ./.maintain/scripts/generate_api.sh1415	PACKAGE=pallet-fungible NAME=erc::gen_impl OUTPUT=./pallets/fungible/src/stubs/UniqueFungible.sol ./.maintain/scripts/generate_api.sh16	PACKAGE=pallet-nonfungible NAME=erc::gen_impl OUTPUT=./pallets/nonfungible/src/stubs/UniqueNFT.sol ./.maintain/scripts/generate_api.sh17	PACKAGE=pallet-evm-contract-helpers NAME=eth::contract_helpers_impl OUTPUT=./pallets/evm-contract-helpers/src/stubs/ContractHelpers.sol ./.maintain/scripts/generate_api.sh1819FUNGIBLE_EVM_STUBS=./pallets/fungible/src/stubs20NONFUNGIBLE_EVM_STUBS=./pallets/nonfungible/src/stubs21CONTRACT_HELPERS_STUBS=./pallets/evm-contract-helpers/src/stubs/2223$(FUNGIBLE_EVM_STUBS)/UniqueFungible.raw: $(FUNGIBLE_EVM_STUBS)/UniqueFungible.sol24	INPUT=$< OUTPUT=$@ ./.maintain/scripts/compile_stub.sh25$(NONFUNGIBLE_EVM_STUBS)/UniqueNFT.raw: $(NONFUNGIBLE_EVM_STUBS)/UniqueNFT.sol26	INPUT=$< OUTPUT=$@ ./.maintain/scripts/compile_stub.sh27$(CONTRACT_HELPERS_STUBS)/ContractHelpers.raw: $(CONTRACT_HELPERS_STUBS)/ContractHelpers.sol28	INPUT=$< OUTPUT=$@ ./.maintain/scripts/compile_stub.sh2930evm_stubs: $(FUNGIBLE_EVM_STUBS)/UniqueFungible.raw $(NONFUNGIBLE_EVM_STUBS)/UniqueNFT.raw $(CONTRACT_HELPERS_STUBS)/ContractHelpers.raw3132.PHONY: _bench33_bench:34	cargo run --release --features runtime-benchmarks -- \35	benchmark --pallet pallet-$(PALLET) \36	--wasm-execution compiled --extrinsic '*' \37	--template .maintain/frame-weight-template.hbs --steps=50 --repeat=200 --heap-pages=4096 \38	--output=./pallets/$(PALLET)/src/weights.rs3940.PHONY: bench-evm-migration41bench-evm-migration:42	make _bench PALLET=evm-migration4344.PHONY: bench-unique45bench-unique:46	make _bench PALLET=unique4748.PHONY: bench-fungible49bench-fungible:50	make _bench PALLET=fungible5152.PHONY: bench-refungible53bench-refungible:54	make _bench PALLET=refungible5556.PHONY: bench-nonfungible57bench-nonfungible:58	make _bench PALLET=nonfungible5960.PHONY: bench61bench: bench-evm-migration bench-unique bench-fungible bench-refungible bench-nonfungible
after · Makefile
1.PHONY: _help2_help:3	@echo "regenerate_solidity - generate stubs/interfaces for contracts defined in native (via evm-coder)"4	@echo "evm_stubs - recompile contract stubs"5	@echo "bench - run frame-benchmarking"6	@echo "  bench-evm-migration"7	@echo "  bench-unique"89.PHONY: regenerate_solidity10regenerate_solidity:11	PACKAGE=pallet-fungible NAME=erc::gen_iface OUTPUT=./tests/src/eth/api/UniqueFungible.sol ./.maintain/scripts/generate_api.sh12	PACKAGE=pallet-nonfungible NAME=erc::gen_iface OUTPUT=./tests/src/eth/api/UniqueNFT.sol ./.maintain/scripts/generate_api.sh13	PACKAGE=pallet-evm-contract-helpers NAME=eth::contract_helpers_iface OUTPUT=./tests/src/eth/api/ContractHelpers.sol ./.maintain/scripts/generate_api.sh1415	PACKAGE=pallet-fungible NAME=erc::gen_impl OUTPUT=./pallets/fungible/src/stubs/UniqueFungible.sol ./.maintain/scripts/generate_api.sh16	PACKAGE=pallet-nonfungible NAME=erc::gen_impl OUTPUT=./pallets/nonfungible/src/stubs/UniqueNFT.sol ./.maintain/scripts/generate_api.sh17	PACKAGE=pallet-evm-contract-helpers NAME=eth::contract_helpers_impl OUTPUT=./pallets/evm-contract-helpers/src/stubs/ContractHelpers.sol ./.maintain/scripts/generate_api.sh1819FUNGIBLE_EVM_STUBS=./pallets/fungible/src/stubs20NONFUNGIBLE_EVM_STUBS=./pallets/nonfungible/src/stubs21CONTRACT_HELPERS_STUBS=./pallets/evm-contract-helpers/src/stubs/2223$(FUNGIBLE_EVM_STUBS)/UniqueFungible.raw: $(FUNGIBLE_EVM_STUBS)/UniqueFungible.sol24	INPUT=$< OUTPUT=$@ ./.maintain/scripts/compile_stub.sh25$(NONFUNGIBLE_EVM_STUBS)/UniqueNFT.raw: $(NONFUNGIBLE_EVM_STUBS)/UniqueNFT.sol26	INPUT=$< OUTPUT=$@ ./.maintain/scripts/compile_stub.sh27$(CONTRACT_HELPERS_STUBS)/ContractHelpers.raw: $(CONTRACT_HELPERS_STUBS)/ContractHelpers.sol28	INPUT=$< OUTPUT=$@ ./.maintain/scripts/compile_stub.sh2930evm_stubs: $(FUNGIBLE_EVM_STUBS)/UniqueFungible.raw $(NONFUNGIBLE_EVM_STUBS)/UniqueNFT.raw $(CONTRACT_HELPERS_STUBS)/ContractHelpers.raw3132.PHONY: _bench33_bench:34	cargo run --release --features runtime-benchmarks,unique-runtime -- \35	benchmark pallet --pallet pallet-$(PALLET) \36	--wasm-execution compiled --extrinsic '*' \37	--template .maintain/frame-weight-template.hbs --steps=50 --repeat=200 --heap-pages=4096 \38	--output=./pallets/$(PALLET)/src/weights.rs3940.PHONY: bench-evm-migration41bench-evm-migration:42	make _bench PALLET=evm-migration4344.PHONY: bench-unique45bench-unique:46	make _bench PALLET=unique4748.PHONY: bench-fungible49bench-fungible:50	make _bench PALLET=fungible5152.PHONY: bench-refungible53bench-refungible:54	make _bench PALLET=refungible5556.PHONY: bench-nonfungible57bench-nonfungible:58	make _bench PALLET=nonfungible5960.PHONY: bench61bench: bench-evm-migration bench-unique bench-fungible bench-refungible bench-nonfungible
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();