Skip to content

Commit

Permalink
feat(XCM): add benchmarks (#716)
Browse files Browse the repository at this point in the history
Authored-by: hounsette <houssein@nodle.com>
  • Loading branch information
Hounsette committed Mar 15, 2023
1 parent e4ab801 commit 4b69e0d
Show file tree
Hide file tree
Showing 26 changed files with 1,458 additions and 807 deletions.
68 changes: 68 additions & 0 deletions .maintain/xcm.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* This file is part of the Nodle Chain distributed at https://github.com/NodleCode/chain
* Copyright (C) 2020-2022 Nodle International
*
* This program 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.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/

//! Autogenerated weights for `{{pallet}}`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION {{version}}
//! DATE: {{date}}, STEPS: `{{cmd.steps}}`, REPEAT: {{cmd.repeat}}, LOW RANGE: `{{cmd.lowest_range_values}}`, HIGH RANGE: `{{cmd.highest_range_values}}`
//! EXECUTION: {{cmd.execution}}, WASM-EXECUTION: {{cmd.wasm_execution}}, CHAIN: {{cmd.chain}}, DB CACHE: {{cmd.db_cache}}

// Executed Command:
{{#each args as |arg|}}
// {{arg}}
{{/each}}

#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]

use frame_support::{traits::Get, weights::Weight};
use sp_std::marker::PhantomData;

/// Weights for `{{pallet}}`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> WeightInfo<T> {
{{#each benchmarks as |benchmark|}}
{{#each benchmark.comments as |comment|}}
// {{comment}}
{{/each}}
pub(crate) fn {{benchmark.name~}}
(
{{~#each benchmark.components as |c| ~}}
{{~#if (not c.is_used)}}_{{/if}}{{c.name}}: u32, {{/each~}}
) -> Weight {
Weight::from_ref_time({{underscore benchmark.base_weight}}_u64)
{{#each benchmark.component_weight as |cw|}}
// Standard Error: {{underscore cw.error}}
.saturating_add(Weight::from_ref_time({{underscore cw.slope}}_u64).saturating_mul({{cw.name}}_u64))
{{/each}}
{{#if (ne benchmark.base_reads "0")}}
.saturating_add(T::DbWeight::get().reads({{benchmark.base_reads}}_u64))
{{/if}}
{{#each benchmark.component_reads as |cr|}}
.saturating_add(T::DbWeight::get().reads(({{cr.slope}}_u64).saturating_mul({{cr.name}}_u64)))
{{/each}}
{{#if (ne benchmark.base_writes "0")}}
.saturating_add(T::DbWeight::get().writes({{benchmark.base_writes}}_u64))
{{/if}}
{{#each benchmark.component_writes as |cw|}}
.saturating_add(T::DbWeight::get().writes(({{cw.slope}}_u64).saturating_mul({{cw.name}}_u64)))
{{/each}}
}
{{/each}}
}
1 change: 1 addition & 0 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub type ChainSpec = sc_service::GenericChainSpec<GenesisConfig, Extensions>;

/// Helper function to generate a crypto pair from seed
pub fn get_public_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
TPublic::Pair::from_string(&format!("//{}", seed), None)
TPublic::Pair::from_string(&format!("//{seed}"), None)
.expect("static values are valid; qed")
.public()
}
Expand Down
6 changes: 3 additions & 3 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ pub fn run() -> Result<()> {

let polkadot_config =
SubstrateCli::create_configuration(&polkadot_cli, &polkadot_cli, config.tokio_handle.clone())
.map_err(|err| format!("Relay chain argument error: {}", err))?;
.map_err(|err| format!("Relay chain argument error: {err}"))?;

cmd.run(config, polkadot_config)
})
Expand Down Expand Up @@ -303,12 +303,12 @@ pub fn run() -> Result<()> {

let state_version = Cli::native_runtime_version(&config.chain_spec).state_version();
let block: Block =
generate_genesis_block(&*config.chain_spec, state_version).map_err(|e| format!("{:?}", e))?;
generate_genesis_block(&*config.chain_spec, state_version).map_err(|e| format!("{e:?}"))?;
let genesis_state = format!("0x{:?}", HexDisplay::from(&block.header().encode()));

let tokio_handle = config.tokio_handle.clone();
let polkadot_config = SubstrateCli::create_configuration(&polkadot_cli, &polkadot_cli, tokio_handle)
.map_err(|err| format!("Relay chain argument error: {}", err))?;
.map_err(|err| format!("Relay chain argument error: {err}"))?;

info!("Parachain id: {:?}", id);
info!("Parachain Account: {}", parachain_account);
Expand Down
50 changes: 25 additions & 25 deletions pallets/allocations/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
//! Autogenerated weights for pallet_allocations
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-02-16, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2023-03-14, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! HOSTNAME: `chain-bench-012bd056`, CPU: `AMD EPYC 7B13`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024

Expand Down Expand Up @@ -65,10 +65,10 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: System Events (r:1 w:1)
/// The range of component `b` is `[1, 500]`.
fn allocate(b: u32, ) -> Weight {
// Minimum execution time: 91_910 nanoseconds.
Weight::from_ref_time(43_980_848_u64)
// Standard Error: 9_014
.saturating_add(Weight::from_ref_time(27_585_705_u64).saturating_mul(b as u64))
// Minimum execution time: 91_091 nanoseconds.
Weight::from_ref_time(21_410_078_u64)
// Standard Error: 16_392
.saturating_add(Weight::from_ref_time(27_848_716_u64).saturating_mul(b as u64))
.saturating_add(T::DbWeight::get().reads(8_u64))
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(b as u64)))
.saturating_add(T::DbWeight::get().writes(6_u64))
Expand All @@ -83,8 +83,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: System Events (r:1 w:1)
// Storage: Allocations NextSessionQuota (r:0 w:1)
fn calc_quota() -> Weight {
// Minimum execution time: 23_030 nanoseconds.
Weight::from_ref_time(23_700_000_u64)
// Minimum execution time: 22_710 nanoseconds.
Weight::from_ref_time(23_380_000_u64)
.saturating_add(T::DbWeight::get().reads(7_u64))
.saturating_add(T::DbWeight::get().writes(5_u64))
}
Expand All @@ -97,8 +97,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: System Events (r:1 w:1)
// Storage: Allocations SessionQuota (r:0 w:1)
fn renew_quota() -> Weight {
// Minimum execution time: 19_270 nanoseconds.
Weight::from_ref_time(19_810_000_u64)
// Minimum execution time: 18_670 nanoseconds.
Weight::from_ref_time(19_320_000_u64)
.saturating_add(T::DbWeight::get().reads(7_u64))
.saturating_add(T::DbWeight::get().writes(5_u64))
}
Expand All @@ -114,8 +114,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: Allocations SessionQuota (r:0 w:1)
// Storage: Allocations NextSessionQuota (r:0 w:1)
fn checked_update_session_quota() -> Weight {
// Minimum execution time: 34_590 nanoseconds.
Weight::from_ref_time(35_420_000_u64)
// Minimum execution time: 33_930 nanoseconds.
Weight::from_ref_time(34_910_000_u64)
.saturating_add(T::DbWeight::get().reads(9_u64))
.saturating_add(T::DbWeight::get().writes(7_u64))
}
Expand All @@ -124,8 +124,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: Allocations SessionQuotaCalculationSchedule (r:0 w:1)
// Storage: Allocations SessionQuotaRenewSchedule (r:0 w:1)
fn set_curve_starting_block() -> Weight {
// Minimum execution time: 11_190 nanoseconds.
Weight::from_ref_time(11_680_000_u64)
// Minimum execution time: 10_731 nanoseconds.
Weight::from_ref_time(11_130_000_u64)
.saturating_add(T::DbWeight::get().reads(1_u64))
.saturating_add(T::DbWeight::get().writes(3_u64))
}
Expand All @@ -141,10 +141,10 @@ impl WeightInfo for () {
// Storage: System Events (r:1 w:1)
/// The range of component `b` is `[1, 500]`.
fn allocate(b: u32, ) -> Weight {
// Minimum execution time: 91_910 nanoseconds.
Weight::from_ref_time(43_980_848_u64)
// Standard Error: 9_014
.saturating_add(Weight::from_ref_time(27_585_705_u64).saturating_mul(b as u64))
// Minimum execution time: 91_091 nanoseconds.
Weight::from_ref_time(21_410_078_u64)
// Standard Error: 16_392
.saturating_add(Weight::from_ref_time(27_848_716_u64).saturating_mul(b as u64))
.saturating_add(RocksDbWeight::get().reads(8_u64))
.saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(b as u64)))
.saturating_add(RocksDbWeight::get().writes(6_u64))
Expand All @@ -159,8 +159,8 @@ impl WeightInfo for () {
// Storage: System Events (r:1 w:1)
// Storage: Allocations NextSessionQuota (r:0 w:1)
fn calc_quota() -> Weight {
// Minimum execution time: 23_030 nanoseconds.
Weight::from_ref_time(23_700_000_u64)
// Minimum execution time: 22_710 nanoseconds.
Weight::from_ref_time(23_380_000_u64)
.saturating_add(RocksDbWeight::get().reads(7_u64))
.saturating_add(RocksDbWeight::get().writes(5_u64))
}
Expand All @@ -173,8 +173,8 @@ impl WeightInfo for () {
// Storage: System Events (r:1 w:1)
// Storage: Allocations SessionQuota (r:0 w:1)
fn renew_quota() -> Weight {
// Minimum execution time: 19_270 nanoseconds.
Weight::from_ref_time(19_810_000_u64)
// Minimum execution time: 18_670 nanoseconds.
Weight::from_ref_time(19_320_000_u64)
.saturating_add(RocksDbWeight::get().reads(7_u64))
.saturating_add(RocksDbWeight::get().writes(5_u64))
}
Expand All @@ -190,8 +190,8 @@ impl WeightInfo for () {
// Storage: Allocations SessionQuota (r:0 w:1)
// Storage: Allocations NextSessionQuota (r:0 w:1)
fn checked_update_session_quota() -> Weight {
// Minimum execution time: 34_590 nanoseconds.
Weight::from_ref_time(35_420_000_u64)
// Minimum execution time: 33_930 nanoseconds.
Weight::from_ref_time(34_910_000_u64)
.saturating_add(RocksDbWeight::get().reads(9_u64))
.saturating_add(RocksDbWeight::get().writes(7_u64))
}
Expand All @@ -200,8 +200,8 @@ impl WeightInfo for () {
// Storage: Allocations SessionQuotaCalculationSchedule (r:0 w:1)
// Storage: Allocations SessionQuotaRenewSchedule (r:0 w:1)
fn set_curve_starting_block() -> Weight {
// Minimum execution time: 11_190 nanoseconds.
Weight::from_ref_time(11_680_000_u64)
// Minimum execution time: 10_731 nanoseconds.
Weight::from_ref_time(11_130_000_u64)
.saturating_add(RocksDbWeight::get().reads(1_u64))
.saturating_add(RocksDbWeight::get().writes(3_u64))
}
Expand Down
34 changes: 17 additions & 17 deletions pallets/grants/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
//! Autogenerated weights for pallet_grants
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-02-16, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2023-03-14, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! HOSTNAME: `chain-bench-012bd056`, CPU: `AMD EPYC 7B13`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024

Expand Down Expand Up @@ -64,8 +64,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: System Events (r:1 w:1)
// Storage: Balances Locks (r:1 w:1)
fn add_vesting_schedule() -> Weight {
// Minimum execution time: 81_210 nanoseconds.
Weight::from_ref_time(83_410_000_u64)
// Minimum execution time: 80_800 nanoseconds.
Weight::from_ref_time(82_800_000_u64)
.saturating_add(T::DbWeight::get().reads(9_u64))
.saturating_add(T::DbWeight::get().writes(6_u64))
}
Expand All @@ -78,8 +78,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: System EventCount (r:1 w:1)
// Storage: System Events (r:1 w:1)
fn claim() -> Weight {
// Minimum execution time: 54_280 nanoseconds.
Weight::from_ref_time(55_780_000_u64)
// Minimum execution time: 53_250 nanoseconds.
Weight::from_ref_time(55_120_000_u64)
.saturating_add(T::DbWeight::get().reads(8_u64))
.saturating_add(T::DbWeight::get().writes(4_u64))
}
Expand All @@ -94,8 +94,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: System Events (r:1 w:1)
// Storage: Vesting CounterForVestingSchedules (r:1 w:1)
fn cancel_all_vesting_schedules() -> Weight {
// Minimum execution time: 108_160 nanoseconds.
Weight::from_ref_time(110_900_000_u64)
// Minimum execution time: 108_800 nanoseconds.
Weight::from_ref_time(111_970_000_u64)
.saturating_add(T::DbWeight::get().reads(11_u64))
.saturating_add(T::DbWeight::get().writes(7_u64))
}
Expand All @@ -105,8 +105,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: System Events (r:1 w:1)
// Storage: Vesting Renounced (r:0 w:1)
fn renounce() -> Weight {
// Minimum execution time: 20_149 nanoseconds.
Weight::from_ref_time(21_069_000_u64)
// Minimum execution time: 20_060 nanoseconds.
Weight::from_ref_time(21_240_000_u64)
.saturating_add(T::DbWeight::get().reads(4_u64))
.saturating_add(T::DbWeight::get().writes(3_u64))
}
Expand All @@ -122,8 +122,8 @@ impl WeightInfo for () {
// Storage: System Events (r:1 w:1)
// Storage: Balances Locks (r:1 w:1)
fn add_vesting_schedule() -> Weight {
// Minimum execution time: 81_210 nanoseconds.
Weight::from_ref_time(83_410_000_u64)
// Minimum execution time: 80_800 nanoseconds.
Weight::from_ref_time(82_800_000_u64)
.saturating_add(RocksDbWeight::get().reads(9_u64))
.saturating_add(RocksDbWeight::get().writes(6_u64))
}
Expand All @@ -136,8 +136,8 @@ impl WeightInfo for () {
// Storage: System EventCount (r:1 w:1)
// Storage: System Events (r:1 w:1)
fn claim() -> Weight {
// Minimum execution time: 54_280 nanoseconds.
Weight::from_ref_time(55_780_000_u64)
// Minimum execution time: 53_250 nanoseconds.
Weight::from_ref_time(55_120_000_u64)
.saturating_add(RocksDbWeight::get().reads(8_u64))
.saturating_add(RocksDbWeight::get().writes(4_u64))
}
Expand All @@ -152,8 +152,8 @@ impl WeightInfo for () {
// Storage: System Events (r:1 w:1)
// Storage: Vesting CounterForVestingSchedules (r:1 w:1)
fn cancel_all_vesting_schedules() -> Weight {
// Minimum execution time: 108_160 nanoseconds.
Weight::from_ref_time(110_900_000_u64)
// Minimum execution time: 108_800 nanoseconds.
Weight::from_ref_time(111_970_000_u64)
.saturating_add(RocksDbWeight::get().reads(11_u64))
.saturating_add(RocksDbWeight::get().writes(7_u64))
}
Expand All @@ -163,8 +163,8 @@ impl WeightInfo for () {
// Storage: System Events (r:1 w:1)
// Storage: Vesting Renounced (r:0 w:1)
fn renounce() -> Weight {
// Minimum execution time: 20_149 nanoseconds.
Weight::from_ref_time(21_069_000_u64)
// Minimum execution time: 20_060 nanoseconds.
Weight::from_ref_time(21_240_000_u64)
.saturating_add(RocksDbWeight::get().reads(4_u64))
.saturating_add(RocksDbWeight::get().writes(3_u64))
}
Expand Down
18 changes: 9 additions & 9 deletions pallets/reserve/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
//! Autogenerated weights for pallet_reserve
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-02-16, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2023-03-14, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! HOSTNAME: `chain-bench-012bd056`, CPU: `AMD EPYC 7B13`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024

Expand Down Expand Up @@ -59,8 +59,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: System EventCount (r:1 w:1)
// Storage: System Events (r:1 w:1)
fn tip() -> Weight {
// Minimum execution time: 27_300 nanoseconds.
Weight::from_ref_time(27_930_000_u64)
// Minimum execution time: 26_480 nanoseconds.
Weight::from_ref_time(27_550_000_u64)
.saturating_add(T::DbWeight::get().reads(6_u64))
.saturating_add(T::DbWeight::get().writes(2_u64))
}
Expand All @@ -70,8 +70,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: System EventCount (r:1 w:1)
// Storage: System Events (r:1 w:1)
fn spend() -> Weight {
// Minimum execution time: 27_400 nanoseconds.
Weight::from_ref_time(28_290_000_u64)
// Minimum execution time: 26_730 nanoseconds.
Weight::from_ref_time(27_670_000_u64)
.saturating_add(T::DbWeight::get().reads(6_u64))
.saturating_add(T::DbWeight::get().writes(2_u64))
}
Expand All @@ -84,8 +84,8 @@ impl WeightInfo for () {
// Storage: System EventCount (r:1 w:1)
// Storage: System Events (r:1 w:1)
fn tip() -> Weight {
// Minimum execution time: 27_300 nanoseconds.
Weight::from_ref_time(27_930_000_u64)
// Minimum execution time: 26_480 nanoseconds.
Weight::from_ref_time(27_550_000_u64)
.saturating_add(RocksDbWeight::get().reads(6_u64))
.saturating_add(RocksDbWeight::get().writes(2_u64))
}
Expand All @@ -95,8 +95,8 @@ impl WeightInfo for () {
// Storage: System EventCount (r:1 w:1)
// Storage: System Events (r:1 w:1)
fn spend() -> Weight {
// Minimum execution time: 27_400 nanoseconds.
Weight::from_ref_time(28_290_000_u64)
// Minimum execution time: 26_730 nanoseconds.
Weight::from_ref_time(27_670_000_u64)
.saturating_add(RocksDbWeight::get().reads(6_u64))
.saturating_add(RocksDbWeight::get().writes(2_u64))
}
Expand Down
2 changes: 1 addition & 1 deletion pallets/staking/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,6 @@ pub(crate) fn on_offence_in_session(
if NodleStaking::active_session() == session_idx {
let _ = NodleStaking::on_offence(offenders, slash_fraction, session_idx, disable_strategy);
} else {
panic!("cannot slash in session {}", session_idx);
panic!("cannot slash in session {session_idx}");
}
}

0 comments on commit 4b69e0d

Please sign in to comment.