Skip to content

Commit

Permalink
Test works
Browse files Browse the repository at this point in the history
  • Loading branch information
boundless-forest committed Aug 6, 2021
1 parent 74523df commit 1032fb7
Show file tree
Hide file tree
Showing 10 changed files with 76 additions and 21 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
4 changes: 3 additions & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -78,4 +79,5 @@ try-runtime = [

runtime-benchmarks = [
"frame-benchmarking-cli",
"darwinia-service/runtime-benchmarks",
]
4 changes: 3 additions & 1 deletion cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<crab_runtime::Block, CrabExecutor>(config))
} else if chain_spec.is_darwinia() {
todo!()
runner
.sync_run(|config| cmd.run::<darwinia_runtime::Block, DarwiniaExecutor>(config))
} else {
Err("Benchmarking wasn't enabled when building the node. \
You can enable it with `--features runtime-benchmarks`."
Expand Down
17 changes: 17 additions & 0 deletions file_header.txt
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.
2 changes: 0 additions & 2 deletions node/service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down Expand Up @@ -96,7 +95,6 @@ try-runtime = [
]

runtime-benchmarks = [
"frame-benchmarking-cli",
"crab-runtime/runtime-benchmarks",
"darwinia-runtime/runtime-benchmarks",
]
1 change: 0 additions & 1 deletion runtime/crab/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions runtime/crab/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,7 @@ sp_api::impl_runtime_apis! {
let mut batches = Vec::<BenchmarkBatch>::new();
let params = (&config, &whitelist);


add_benchmark!(params, batches, frame_system, SystemBench::<Runtime>);

if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
Expand Down
55 changes: 48 additions & 7 deletions runtime/crab/src/weights/frame_system.rs
Original file line number Diff line number Diff line change
@@ -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<T>(PhantomData<T>);
impl<T: frame_system::Config> frame_system::WeightInfo for WeightInfo<T> {
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)))
}
}
7 changes: 3 additions & 4 deletions runtime/darwinia/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
]

0 comments on commit 1032fb7

Please sign in to comment.