git.delta.rocks / unique-network / refs/commits / cbfc871bee98

difftreelog

source

pallets/collator-selection/src/weights.rs7.9 KiBsourcehistory
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617// Original license:18// This file is part of Substrate.1920// Copyright (C) 2021 Parity Technologies (UK) Ltd.21// SPDX-License-Identifier: Apache-2.02223// Licensed under the Apache License, Version 2.0 (the "License");24// you may not use this file except in compliance with the License.25// You may obtain a copy of the License at26//27// http://www.apache.org/licenses/LICENSE-2.028//29// Unless required by applicable law or agreed to in writing, software30// distributed under the License is distributed on an "AS IS" BASIS,31// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.32// See the License for the specific language governing permissions and33// limitations under the License.3435#![allow(unused_parens)]36#![allow(unused_imports)]3738use frame_support::{39	traits::Get,40	weights::{constants::RocksDbWeight, Weight},41};42use sp_std::marker::PhantomData;4344// todo:collator re-generate weights45// The weight info trait for `pallet_collator_selection`.46pub trait WeightInfo {47	fn add_invulnerable(_b: u32) -> Weight;48	fn remove_invulnerable(_b: u32) -> Weight;49	fn get_license(_c: u32) -> Weight;50	fn onboard(_c: u32) -> Weight;51	fn offboard(_c: u32) -> Weight;52	fn release_license(_c: u32) -> Weight;53	fn force_release_license(_c: u32) -> Weight;54	fn note_author() -> Weight;55	fn new_session(_c: u32, _r: u32) -> Weight;56}5758/// Weights for pallet_collator_selection using the Substrate node and recommended hardware.59pub struct SubstrateWeight<T>(PhantomData<T>);60impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {61	fn add_invulnerable(b: u32) -> Weight {62		Weight::from_ref_time(18_563_000 as u64)63			// Standard Error: 064			.saturating_add(Weight::from_ref_time(68_000 as u64).saturating_mul(b as u64))65			.saturating_add(T::DbWeight::get().writes(1 as u64))66	}67	fn remove_invulnerable(b: u32) -> Weight {68		Weight::from_ref_time(18_563_000 as u64)69			// Standard Error: 070			.saturating_add(Weight::from_ref_time(68_000 as u64).saturating_mul(b as u64))71			.saturating_add(T::DbWeight::get().writes(1 as u64))72	}73	fn get_license(c: u32) -> Weight {74		Weight::from_ref_time(71_196_000 as u64)75			// Standard Error: 076			.saturating_add(Weight::from_ref_time(198_000 as u64).saturating_mul(c as u64))77			.saturating_add(T::DbWeight::get().reads(4 as u64))78			.saturating_add(T::DbWeight::get().writes(2 as u64))79	}80	fn onboard(c: u32) -> Weight {81		Weight::from_ref_time(71_196_000 as u64)82			// Standard Error: 083			.saturating_add(Weight::from_ref_time(198_000 as u64).saturating_mul(c as u64))84			.saturating_add(T::DbWeight::get().reads(4 as u64))85			.saturating_add(T::DbWeight::get().writes(2 as u64))86	}87	fn offboard(c: u32) -> Weight {88		Weight::from_ref_time(55_336_000 as u64)89			// Standard Error: 090			.saturating_add(Weight::from_ref_time(151_000 as u64).saturating_mul(c as u64))91			.saturating_add(T::DbWeight::get().reads(1 as u64))92			.saturating_add(T::DbWeight::get().writes(2 as u64))93	}94	fn release_license(c: u32) -> Weight {95		Weight::from_ref_time(55_336_000 as u64)96			// Standard Error: 097			.saturating_add(Weight::from_ref_time(151_000 as u64).saturating_mul(c as u64))98			.saturating_add(T::DbWeight::get().reads(1 as u64))99			.saturating_add(T::DbWeight::get().writes(2 as u64))100	}101	fn force_release_license(c: u32) -> Weight {102		Weight::from_ref_time(55_336_000 as u64)103			// Standard Error: 0104			.saturating_add(Weight::from_ref_time(151_000 as u64).saturating_mul(c as u64))105			.saturating_add(T::DbWeight::get().reads(1 as u64))106			.saturating_add(T::DbWeight::get().writes(2 as u64))107	}108	fn note_author() -> Weight {109		Weight::from_ref_time(71_461_000 as u64)110			.saturating_add(T::DbWeight::get().reads(3 as u64))111			.saturating_add(T::DbWeight::get().writes(4 as u64))112	}113	fn new_session(r: u32, c: u32) -> Weight {114		Weight::from_ref_time(0 as u64)115			// Standard Error: 1_010_000116			.saturating_add(Weight::from_ref_time(109_961_000 as u64).saturating_mul(r as u64))117			// Standard Error: 1_010_000118			.saturating_add(Weight::from_ref_time(151_952_000 as u64).saturating_mul(c as u64))119			.saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(r as u64)))120			.saturating_add(T::DbWeight::get().reads((2 as u64).saturating_mul(c as u64)))121			.saturating_add(T::DbWeight::get().writes((2 as u64).saturating_mul(r as u64)))122			.saturating_add(T::DbWeight::get().writes((2 as u64).saturating_mul(c as u64)))123	}124}125126// For backwards compatibility and tests127impl WeightInfo for () {128	fn add_invulnerable(b: u32) -> Weight {129		Weight::from_ref_time(18_563_000 as u64)130			// Standard Error: 0131			.saturating_add(Weight::from_ref_time(68_000 as u64).saturating_mul(b as u64))132			.saturating_add(RocksDbWeight::get().writes(1 as u64))133	}134	fn remove_invulnerable(b: u32) -> Weight {135		Weight::from_ref_time(18_563_000 as u64)136			// Standard Error: 0137			.saturating_add(Weight::from_ref_time(68_000 as u64).saturating_mul(b as u64))138			.saturating_add(RocksDbWeight::get().writes(1 as u64))139	}140	fn get_license(c: u32) -> Weight {141		Weight::from_ref_time(71_196_000 as u64)142			// Standard Error: 0143			.saturating_add(Weight::from_ref_time(198_000 as u64).saturating_mul(c as u64))144			.saturating_add(RocksDbWeight::get().reads(4 as u64))145			.saturating_add(RocksDbWeight::get().writes(2 as u64))146	}147	fn onboard(c: u32) -> Weight {148		Weight::from_ref_time(71_196_000 as u64)149			// Standard Error: 0150			.saturating_add(Weight::from_ref_time(198_000 as u64).saturating_mul(c as u64))151			.saturating_add(RocksDbWeight::get().reads(4 as u64))152			.saturating_add(RocksDbWeight::get().writes(2 as u64))153	}154	fn offboard(c: u32) -> Weight {155		Weight::from_ref_time(55_336_000 as u64)156			// Standard Error: 0157			.saturating_add(Weight::from_ref_time(151_000 as u64).saturating_mul(c as u64))158			.saturating_add(RocksDbWeight::get().reads(1 as u64))159			.saturating_add(RocksDbWeight::get().writes(2 as u64))160	}161	fn release_license(c: u32) -> Weight {162		Weight::from_ref_time(55_336_000 as u64)163			// Standard Error: 0164			.saturating_add(Weight::from_ref_time(151_000 as u64).saturating_mul(c as u64))165			.saturating_add(RocksDbWeight::get().reads(1 as u64))166			.saturating_add(RocksDbWeight::get().writes(2 as u64))167	}168	fn force_release_license(c: u32) -> Weight {169		Weight::from_ref_time(55_336_000 as u64)170			// Standard Error: 0171			.saturating_add(Weight::from_ref_time(151_000 as u64).saturating_mul(c as u64))172			.saturating_add(RocksDbWeight::get().reads(1 as u64))173			.saturating_add(RocksDbWeight::get().writes(2 as u64))174	}175	fn note_author() -> Weight {176		Weight::from_ref_time(71_461_000 as u64)177			.saturating_add(RocksDbWeight::get().reads(3 as u64))178			.saturating_add(RocksDbWeight::get().writes(4 as u64))179	}180	fn new_session(r: u32, c: u32) -> Weight {181		Weight::from_ref_time(0 as u64)182			// Standard Error: 1_010_000183			.saturating_add(Weight::from_ref_time(109_961_000 as u64).saturating_mul(r as u64))184			// Standard Error: 1_010_000185			.saturating_add(Weight::from_ref_time(151_952_000 as u64).saturating_mul(c as u64))186			.saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(r as u64)))187			.saturating_add(RocksDbWeight::get().reads((2 as u64).saturating_mul(c as u64)))188			.saturating_add(RocksDbWeight::get().writes((2 as u64).saturating_mul(r as u64)))189			.saturating_add(RocksDbWeight::get().writes((2 as u64).saturating_mul(c as u64)))190	}191}