diff --git a/Cargo.lock b/Cargo.lock index f33f6c3d3..05457f846 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1826,7 +1826,6 @@ dependencies = [ "dvm-dynamic-fee", "dvm-rpc-runtime-api", "frame-benchmarking", - "frame-benchmarking-cli", "frame-system-rpc-runtime-api", "futures 0.3.16", "log", diff --git a/Cargo.toml b/Cargo.toml index 9b1282255..dc24dbc90 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,10 +33,7 @@ dev = [ try-runtime = ["darwinia-cli/try-runtime"] -runtime-benchmarks = [ - "darwinia-cli/runtime-benchmarks", -] - +runtime-benchmarks = ["darwinia-cli/runtime-benchmarks"] [workspace] members = [ diff --git a/cli/Cargo.toml b/cli/Cargo.toml index a31bf14a3..b0b440919 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -29,13 +29,14 @@ darwinia-cli = { optional = true, git = "https://github.com/darwinia-network/dar darwinia-service = { default-features = false, path = "../node/service" } # substrate client sc-cli = { optional = true, git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.2" } -"frame-benchmarking-cli" = { optional = true, git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.2" } sc-client-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.2" } sc-executor = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.2" } sc-network = { optional = true, git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.2" } sc-service = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.2" } sc-tracing = { optional = true, git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.2" } try-runtime-cli = { optional = true, git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.2" } +# benchmark +frame-benchmarking-cli = { optional = true, git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.2" } # substrate primitives sp-core = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.2" } # this crate is used only to enable `trie-memory-tracker` feature @@ -78,4 +79,5 @@ try-runtime = [ runtime-benchmarks = [ "frame-benchmarking-cli", + "darwinia-service/runtime-benchmarks", ] diff --git a/cli/src/command.rs b/cli/src/command.rs index 4f35df395..8e64f51f0 100644 --- a/cli/src/command.rs +++ b/cli/src/command.rs @@ -414,10 +414,12 @@ pub fn run() -> sc_cli::Result<()> { Some(Subcommand::Benchmark(cmd)) => { let runner = cli.create_runner(cmd)?; let chain_spec = &runner.config().chain_spec; + if chain_spec.is_crab() { runner.sync_run(|config| cmd.run::(config)) } else if chain_spec.is_darwinia() { - todo!() + runner + .sync_run(|config| cmd.run::(config)) } else { Err("Benchmarking wasn't enabled when building the node. \ You can enable it with `--features runtime-benchmarks`." diff --git a/file_header.txt b/file_header.txt new file mode 100644 index 000000000..0751e299c --- /dev/null +++ b/file_header.txt @@ -0,0 +1,17 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2021 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Darwinia is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Darwinia. If not, see . diff --git a/node/service/Cargo.toml b/node/service/Cargo.toml index be0174a10..a07ac5ce8 100644 --- a/node/service/Cargo.toml +++ b/node/service/Cargo.toml @@ -52,7 +52,6 @@ sc-telemetry = { git = "https://github.com/darwinia-network/substrate. sc-transaction-pool = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.2" } # substrate frame frame-benchmarking = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.2" } -frame-benchmarking-cli = { optional = true, git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.2" } frame-system-rpc-runtime-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.2" } pallet-im-online = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.2" } pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.2" } @@ -96,7 +95,6 @@ try-runtime = [ ] runtime-benchmarks = [ - "frame-benchmarking-cli", "crab-runtime/runtime-benchmarks", "darwinia-runtime/runtime-benchmarks", ] diff --git a/runtime/crab/Cargo.toml b/runtime/crab/Cargo.toml index 0b77a75b8..65efc4d5b 100644 --- a/runtime/crab/Cargo.toml +++ b/runtime/crab/Cargo.toml @@ -138,7 +138,6 @@ std = [ "dvm-dynamic-fee/std", "dvm-rpc-runtime-api/std", # --- dvm ---> - "frame-benchmarking/std", "frame-executive/std", "frame-support/std", "frame-system/std", diff --git a/runtime/crab/src/lib.rs b/runtime/crab/src/lib.rs index d86296d51..a0d007726 100644 --- a/runtime/crab/src/lib.rs +++ b/runtime/crab/src/lib.rs @@ -659,6 +659,7 @@ sp_api::impl_runtime_apis! { let mut batches = Vec::::new(); let params = (&config, &whitelist); + add_benchmark!(params, batches, frame_system, SystemBench::); if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } diff --git a/runtime/crab/src/weights/frame_system.rs b/runtime/crab/src/weights/frame_system.rs index 010cff521..23d38cfbf 100644 --- a/runtime/crab/src/weights/frame_system.rs +++ b/runtime/crab/src/weights/frame_system.rs @@ -1,40 +1,81 @@ +// Copyright 2017-2021 Parity Technologies (UK) Ltd. +// This file is part of Polkadot. + +// Polkadot is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Polkadot is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License + +//! Autogenerated weights for frame_system +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 +//! DATE: 2021-08-06, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("crab-dev"), DB CACHE: 128 + +// Executed Command: +// ./target/release/darwinia +// benchmark +// --chain=crab-dev +// --steps=50 +// --repeat=20 +// --pallet=frame_system +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --header=./file_header.txt +// --output=./runtime/crab/src/weights/ + #![allow(unused_parens)] #![allow(unused_imports)] use frame_support::{traits::Get, weights::Weight}; use sp_std::marker::PhantomData; +/// Weight functions for frame_system. pub struct WeightInfo(PhantomData); impl frame_system::WeightInfo for WeightInfo { fn remark(_b: u32) -> Weight { - (1_815_000 as Weight) + (1_058_000 as Weight) } fn remark_with_event(b: u32) -> Weight { - (9_697_000 as Weight) + (0 as Weight) // Standard Error: 0 .saturating_add((1_000 as Weight).saturating_mul(b as Weight)) + .saturating_add(T::DbWeight::get().reads(4 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) } fn set_heap_pages() -> Weight { - (2_463_000 as Weight).saturating_add(T::DbWeight::get().writes(1 as Weight)) + (1_724_000 as Weight).saturating_add(T::DbWeight::get().writes(1 as Weight)) } fn set_changes_trie_config() -> Weight { - (11_280_000 as Weight) + (9_478_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } fn set_storage(i: u32) -> Weight { (0 as Weight) - .saturating_add((821_000 as Weight).saturating_mul(i as Weight)) + // Standard Error: 1_000 + .saturating_add((669_000 as Weight).saturating_mul(i as Weight)) .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(i as Weight))) } fn kill_storage(i: u32) -> Weight { (0 as Weight) - .saturating_add((549_000 as Weight).saturating_mul(i as Weight)) + // Standard Error: 1_000 + .saturating_add((481_000 as Weight).saturating_mul(i as Weight)) .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(i as Weight))) } fn kill_prefix(p: u32) -> Weight { (0 as Weight) - .saturating_add((872_000 as Weight).saturating_mul(p as Weight)) + // Standard Error: 9_000 + .saturating_add((1_019_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(p as Weight))) } } diff --git a/runtime/darwinia/Cargo.toml b/runtime/darwinia/Cargo.toml index e7e7bb507..5c7a7599c 100644 --- a/runtime/darwinia/Cargo.toml +++ b/runtime/darwinia/Cargo.toml @@ -36,14 +36,14 @@ darwinia-support = { default-features = false, git = "https:/ darwinia-treasury = { default-features = false, git = "https://github.com/darwinia-network/darwinia-common.git", tag = "darwinia-v0.11.2" } darwinia-tron-backing = { default-features = false, git = "https://github.com/darwinia-network/darwinia-common.git", tag = "darwinia-v0.11.2" } darwinia-vesting = { default-features = false, git = "https://github.com/darwinia-network/darwinia-common.git", tag = "darwinia-v0.11.2" } -frame-benchmarking = { optional=true, default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.2" } -frame-system-benchmarking = { optional=true, default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.2" } # darwinia primitives darwinia-primitives = { default-features = false, path = "../../primitives" } ethereum-primitives = { default-features = false, git = "https://github.com/darwinia-network/darwinia-common.git", tag = "darwinia-v0.11.2" } # darwinia runtime darwinia-runtime-common = { default-features = false, path = "../common" } # substrate frame +frame-benchmarking = { optional=true, default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.2" } +frame-system-benchmarking = { optional=true, default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.2" } frame-executive = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.2" } frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.2" } frame-system = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "darwinia-v0.11.2" } @@ -120,7 +120,6 @@ std = [ "darwinia-runtime-common/std", "frame-executive/std", "frame-support/std", - "frame-benchmarking/std", "frame-system/std", "frame-system-rpc-runtime-api/std", "frame-try-runtime/std", @@ -180,8 +179,8 @@ on-chain-release-build = [ runtime-benchmarks = [ "frame-benchmarking", "frame-system-benchmarking", - "frame-system/runtime-benchmarks", "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", "pallet-collective/runtime-benchmarks", "pallet-society/runtime-benchmarks", ]