Skip to content
Snippets Groups Projects
Unverified Commit 859e8204 authored by bgallois's avatar bgallois
Browse files

use our weights

parent b759bf98
No related branches found
No related tags found
No related merge requests found
Pipeline #33775 failed
...@@ -45,7 +45,7 @@ pub const MAX_EVALUATIONS_PER_SESSION: u32 = 600; ...@@ -45,7 +45,7 @@ pub const MAX_EVALUATIONS_PER_SESSION: u32 = 600;
/// Maximum number of evaluators in a session /// Maximum number of evaluators in a session
pub const MAX_EVALUATORS_PER_SESSION: u32 = 100; pub const MAX_EVALUATORS_PER_SESSION: u32 = 100;
#[frame_support::pallet(dev_mode)] // dev mode while waiting for benchmarks #[frame_support::pallet()]
pub mod pallet { pub mod pallet {
use super::*; use super::*;
use frame_support::{pallet_prelude::*, traits::ReservableCurrency}; use frame_support::{pallet_prelude::*, traits::ReservableCurrency};
...@@ -56,7 +56,6 @@ pub mod pallet { ...@@ -56,7 +56,6 @@ pub mod pallet {
const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);
#[pallet::pallet] #[pallet::pallet]
// #[pallet::generate_store(pub(super) trait Store)] // deprecated
#[pallet::storage_version(STORAGE_VERSION)] #[pallet::storage_version(STORAGE_VERSION)]
#[pallet::without_storage_info] #[pallet::without_storage_info]
pub struct Pallet<T>(PhantomData<T>); pub struct Pallet<T>(PhantomData<T>);
...@@ -78,7 +77,7 @@ pub mod pallet { ...@@ -78,7 +77,7 @@ pub mod pallet {
/// Number of session to keep a positive evaluation result /// Number of session to keep a positive evaluation result
type ResultExpiration: Get<u32>; type ResultExpiration: Get<u32>;
// /// Type representing the weight of this pallet // /// Type representing the weight of this pallet
// type WeightInfo: WeightInfo; type WeightInfo: WeightInfo;
} }
// STORAGE // // STORAGE //
...@@ -182,8 +181,7 @@ pub mod pallet { ...@@ -182,8 +181,7 @@ pub mod pallet {
/// dummy `on_initialize` to return the weight used in `on_finalize`. /// dummy `on_initialize` to return the weight used in `on_finalize`.
fn on_initialize(_n: BlockNumberFor<T>) -> Weight { fn on_initialize(_n: BlockNumberFor<T>) -> Weight {
// weight of `on_finalize` // weight of `on_finalize`
//T::WeightInfo::on_finalize()// TODO uncomment when benchmarking <T as pallet::Config>::WeightInfo::on_finalize()
Weight::zero()
} }
/// # <weight> /// # <weight>
...@@ -201,8 +199,7 @@ pub mod pallet { ...@@ -201,8 +199,7 @@ pub mod pallet {
impl<T: Config> Pallet<T> { impl<T: Config> Pallet<T> {
/// Request an identity to be evaluated /// Request an identity to be evaluated
#[pallet::call_index(0)] #[pallet::call_index(0)]
#[pallet::weight(0)] #[pallet::weight(<T as pallet::Config>::WeightInfo::request_distance_evaluation())]
// #[pallet::weight(T::WeightInfo::request_distance_evaluation())]
pub fn request_distance_evaluation(origin: OriginFor<T>) -> DispatchResultWithPostInfo { pub fn request_distance_evaluation(origin: OriginFor<T>) -> DispatchResultWithPostInfo {
let who = ensure_signed(origin)?; let who = ensure_signed(origin)?;
...@@ -220,8 +217,7 @@ pub mod pallet { ...@@ -220,8 +217,7 @@ pub mod pallet {
/// (Inherent) Push an evaluation result to the pool /// (Inherent) Push an evaluation result to the pool
#[pallet::call_index(1)] #[pallet::call_index(1)]
#[pallet::weight(0)] #[pallet::weight(<T as pallet::Config>::WeightInfo::update_evaluation(MAX_EVALUATIONS_PER_SESSION))]
// #[pallet::weight(T::WeightInfo::update_evaluation())]
pub fn update_evaluation( pub fn update_evaluation(
origin: OriginFor<T>, origin: OriginFor<T>,
computation_result: ComputationResult, computation_result: ComputationResult,
...@@ -241,8 +237,7 @@ pub mod pallet { ...@@ -241,8 +237,7 @@ pub mod pallet {
/// Push an evaluation result to the pool /// Push an evaluation result to the pool
#[pallet::call_index(2)] #[pallet::call_index(2)]
#[pallet::weight(0)] #[pallet::weight(<T as pallet::Config>::WeightInfo::force_update_evaluation(MAX_EVALUATIONS_PER_SESSION))]
// #[pallet::weight(T::WeightInfo::force_update_evaluation())]
pub fn force_update_evaluation( pub fn force_update_evaluation(
origin: OriginFor<T>, origin: OriginFor<T>,
evaluator: <T as frame_system::Config>::AccountId, evaluator: <T as frame_system::Config>::AccountId,
...@@ -261,8 +256,7 @@ pub mod pallet { ...@@ -261,8 +256,7 @@ pub mod pallet {
/// when the evaluation completes. /// when the evaluation completes.
/// * `status.1` is the status of the evaluation. /// * `status.1` is the status of the evaluation.
#[pallet::call_index(3)] #[pallet::call_index(3)]
#[pallet::weight(0)] #[pallet::weight(<T as pallet::Config>::WeightInfo::force_set_distance_status())]
// #[pallet::weight(T::WeightInfo::force_set_distance_status())]
pub fn force_set_distance_status( pub fn force_set_distance_status(
origin: OriginFor<T>, origin: OriginFor<T>,
identity: <T as pallet_identity::Config>::IdtyIndex, identity: <T as pallet_identity::Config>::IdtyIndex,
......
...@@ -245,6 +245,8 @@ impl pallet_identity::Config for Test { ...@@ -245,6 +245,8 @@ impl pallet_identity::Config for Test {
type RevocationSignature = TestSignature; type RevocationSignature = TestSignature;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type WeightInfo = (); type WeightInfo = ();
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkSetupHandler = ();
} }
parameter_types! { parameter_types! {
...@@ -255,6 +257,7 @@ impl pallet_distance::Config for Test { ...@@ -255,6 +257,7 @@ impl pallet_distance::Config for Test {
type EvaluationPrice = frame_support::traits::ConstU64<1000>; type EvaluationPrice = frame_support::traits::ConstU64<1000>;
type MinAccessibleReferees = MinAccessibleReferees; type MinAccessibleReferees = MinAccessibleReferees;
type ResultExpiration = frame_support::traits::ConstU32<720>; type ResultExpiration = frame_support::traits::ConstU32<720>;
type WeightInfo = ();
} }
pub const NAMES: [&str; 6] = ["Alice", "Bob", "Charlie", "Dave", "Eve", "Ferdie"]; pub const NAMES: [&str; 6] = ["Alice", "Bob", "Charlie", "Dave", "Eve", "Ferdie"];
......
...@@ -16,12 +16,108 @@ ...@@ -16,12 +16,108 @@
#![allow(clippy::unnecessary_cast)] #![allow(clippy::unnecessary_cast)]
use frame_support::weights::Weight; use frame_support::weights::{constants::RocksDbWeight, Weight};
/// Weight functions needed for pallet_universal_dividend.
pub trait WeightInfo { pub trait WeightInfo {
fn request_distance_evaluation() -> Weight; fn request_distance_evaluation() -> Weight;
fn update_evaluation() -> Weight; fn update_evaluation(i: u32) -> Weight;
fn force_update_evaluation() -> Weight; fn force_update_evaluation(i: u32) -> Weight;
fn force_set_distance_status() -> Weight; fn force_set_distance_status() -> Weight;
fn on_finalize() -> Weight;
}
// Insecure weights implementation, use it for tests only!
impl WeightInfo for () {
/// Storage: Identity IdentityIndexOf (r:1 w:0)
/// Proof Skipped: Identity IdentityIndexOf (max_values: None, max_size: None, mode: Measured)
/// Storage: Distance IdentityDistanceStatus (r:1 w:1)
/// Proof Skipped: Distance IdentityDistanceStatus (max_values: None, max_size: None, mode: Measured)
/// Storage: Session CurrentIndex (r:1 w:0)
/// Proof Skipped: Session CurrentIndex (max_values: Some(1), max_size: None, mode: Measured)
/// Storage: Distance EvaluationPool2 (r:1 w:1)
/// Proof Skipped: Distance EvaluationPool2 (max_values: Some(1), max_size: None, mode: Measured)
/// Storage: System Account (r:1 w:1)
/// Proof: System Account (max_values: None, max_size: Some(121), added: 2596, mode: MaxEncodedLen)
/// Storage: Distance DistanceStatusExpireOn (r:1 w:1)
/// Proof Skipped: Distance DistanceStatusExpireOn (max_values: None, max_size: None, mode: Measured)
fn request_distance_evaluation() -> Weight {
// Proof Size summary in bytes:
// Measured: `935`
// Estimated: `4400`
// Minimum execution time: 28_469_000 picoseconds.
Weight::from_parts(30_905_000, 0)
.saturating_add(Weight::from_parts(0, 4400))
.saturating_add(RocksDbWeight::get().reads(6))
.saturating_add(RocksDbWeight::get().writes(4))
}
/// Storage: Distance DidUpdate (r:1 w:1)
/// Proof Skipped: Distance DidUpdate (max_values: Some(1), max_size: None, mode: Measured)
/// Storage: Authorship Author (r:1 w:1)
/// Proof: Authorship Author (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen)
/// Storage: System Digest (r:1 w:0)
/// Proof Skipped: System Digest (max_values: Some(1), max_size: None, mode: Measured)
/// Storage: Session CurrentIndex (r:1 w:0)
/// Proof Skipped: Session CurrentIndex (max_values: Some(1), max_size: None, mode: Measured)
/// Storage: Distance EvaluationPool0 (r:1 w:1)
/// Proof Skipped: Distance EvaluationPool0 (max_values: Some(1), max_size: None, mode: Measured)
/// The range of component `i` is `[1, 600]`.
fn update_evaluation(i: u32) -> Weight {
// Proof Size summary in bytes:
// Measured: `744 + i * (10 ±0)`
// Estimated: `2228 + i * (10 ±0)`
// Minimum execution time: 13_870_000 picoseconds.
Weight::from_parts(17_116_748, 0)
.saturating_add(Weight::from_parts(0, 2228))
// Standard Error: 684
.saturating_add(Weight::from_parts(128_989, 0).saturating_mul(i.into()))
.saturating_add(RocksDbWeight::get().reads(5))
.saturating_add(RocksDbWeight::get().writes(3))
.saturating_add(Weight::from_parts(0, 10).saturating_mul(i.into()))
}
/// Storage: Session CurrentIndex (r:1 w:0)
/// Proof Skipped: Session CurrentIndex (max_values: Some(1), max_size: None, mode: Measured)
/// Storage: Distance EvaluationPool0 (r:1 w:1)
/// Proof Skipped: Distance EvaluationPool0 (max_values: Some(1), max_size: None, mode: Measured)
/// The range of component `i` is `[1, 600]`.
fn force_update_evaluation(i: u32) -> Weight {
// Proof Size summary in bytes:
// Measured: `612 + i * (10 ±0)`
// Estimated: `2096 + i * (10 ±0)`
// Minimum execution time: 8_392_000 picoseconds.
Weight::from_parts(10_825_908, 0)
.saturating_add(Weight::from_parts(0, 2096))
// Standard Error: 326
.saturating_add(Weight::from_parts(123_200, 0).saturating_mul(i.into()))
.saturating_add(RocksDbWeight::get().reads(2))
.saturating_add(RocksDbWeight::get().writes(1))
.saturating_add(Weight::from_parts(0, 10).saturating_mul(i.into()))
}
/// Storage: Session CurrentIndex (r:1 w:0)
/// Proof Skipped: Session CurrentIndex (max_values: Some(1), max_size: None, mode: Measured)
/// Storage: Distance DistanceStatusExpireOn (r:1 w:1)
/// Proof Skipped: Distance DistanceStatusExpireOn (max_values: None, max_size: None, mode: Measured)
/// Storage: Distance IdentityDistanceStatus (r:0 w:1)
/// Proof Skipped: Distance IdentityDistanceStatus (max_values: None, max_size: None, mode: Measured)
fn force_set_distance_status() -> Weight {
// Proof Size summary in bytes:
// Measured: `586`
// Estimated: `4051`
// Minimum execution time: 8_099_000 picoseconds.
Weight::from_parts(8_786_000, 0)
.saturating_add(Weight::from_parts(0, 4051))
.saturating_add(RocksDbWeight::get().reads(2))
.saturating_add(RocksDbWeight::get().writes(2))
}
/// Storage: Distance DidUpdate (r:1 w:1)
/// Proof Skipped: Distance DidUpdate (max_values: Some(1), max_size: None, mode: Measured)
fn on_finalize() -> Weight {
// Proof Size summary in bytes:
// Measured: `170`
// Estimated: `1655`
// Minimum execution time: 3_904_000 picoseconds.
Weight::from_parts(4_132_000, 0)
.saturating_add(Weight::from_parts(0, 1655))
.saturating_add(RocksDbWeight::get().reads(1))
.saturating_add(RocksDbWeight::get().writes(1))
}
} }
...@@ -497,6 +497,7 @@ parameter_types! { ...@@ -497,6 +497,7 @@ parameter_types! {
type EvaluationPrice = frame_support::traits::ConstU64<1000>; type EvaluationPrice = frame_support::traits::ConstU64<1000>;
type MinAccessibleReferees = MinAccessibleReferees; type MinAccessibleReferees = MinAccessibleReferees;
type ResultExpiration = frame_support::traits::ConstU32<720>; type ResultExpiration = frame_support::traits::ConstU32<720>;
type WeightInfo = common_runtime::weights::pallet_distance::WeightInfo<Runtime>;
} }
// SMITHS SUB-WOT // // SMITHS SUB-WOT //
......
...@@ -25,6 +25,7 @@ pub mod frame_system; ...@@ -25,6 +25,7 @@ pub mod frame_system;
pub mod pallet_babe; pub mod pallet_babe;
pub mod pallet_balances; pub mod pallet_balances;
pub mod pallet_collective; pub mod pallet_collective;
pub mod pallet_distance;
pub mod pallet_grandpa; pub mod pallet_grandpa;
pub mod pallet_im_online; pub mod pallet_im_online;
pub mod pallet_multisig; pub mod pallet_multisig;
......
//! Autogenerated weights for `pallet_distance`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-11-02, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `bgallois-ms7d43`, CPU: `12th Gen Intel(R) Core(TM) i3-12100F`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("gdev-benchmark"), DB CACHE: 1024
// Executed Command:
// ./target/release/duniter
// benchmark
// pallet
// --chain
// gdev-benchmark
// --execution=wasm
// --wasm-execution=compiled
// --pallet
// pallet-distance
// --extrinsic
// *
// --steps
// 50
// --repeat
// 20
// --output
// runtime/common/src/weights/
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;
/// Weight functions for `pallet_distance`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_distance::WeightInfo for WeightInfo<T> {
/// Storage: Identity IdentityIndexOf (r:1 w:0)
/// Proof Skipped: Identity IdentityIndexOf (max_values: None, max_size: None, mode: Measured)
/// Storage: Distance IdentityDistanceStatus (r:1 w:1)
/// Proof Skipped: Distance IdentityDistanceStatus (max_values: None, max_size: None, mode: Measured)
/// Storage: Session CurrentIndex (r:1 w:0)
/// Proof Skipped: Session CurrentIndex (max_values: Some(1), max_size: None, mode: Measured)
/// Storage: Distance EvaluationPool2 (r:1 w:1)
/// Proof Skipped: Distance EvaluationPool2 (max_values: Some(1), max_size: None, mode: Measured)
/// Storage: System Account (r:1 w:1)
/// Proof: System Account (max_values: None, max_size: Some(121), added: 2596, mode: MaxEncodedLen)
/// Storage: Distance DistanceStatusExpireOn (r:1 w:1)
/// Proof Skipped: Distance DistanceStatusExpireOn (max_values: None, max_size: None, mode: Measured)
fn request_distance_evaluation() -> Weight {
// Proof Size summary in bytes:
// Measured: `935`
// Estimated: `4400`
// Minimum execution time: 28_469_000 picoseconds.
Weight::from_parts(30_905_000, 0)
.saturating_add(Weight::from_parts(0, 4400))
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().writes(4))
}
/// Storage: Distance DidUpdate (r:1 w:1)
/// Proof Skipped: Distance DidUpdate (max_values: Some(1), max_size: None, mode: Measured)
/// Storage: Authorship Author (r:1 w:1)
/// Proof: Authorship Author (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen)
/// Storage: System Digest (r:1 w:0)
/// Proof Skipped: System Digest (max_values: Some(1), max_size: None, mode: Measured)
/// Storage: Session CurrentIndex (r:1 w:0)
/// Proof Skipped: Session CurrentIndex (max_values: Some(1), max_size: None, mode: Measured)
/// Storage: Distance EvaluationPool0 (r:1 w:1)
/// Proof Skipped: Distance EvaluationPool0 (max_values: Some(1), max_size: None, mode: Measured)
/// The range of component `i` is `[1, 600]`.
fn update_evaluation(i: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `744 + i * (10 ±0)`
// Estimated: `2228 + i * (10 ±0)`
// Minimum execution time: 13_870_000 picoseconds.
Weight::from_parts(17_116_748, 0)
.saturating_add(Weight::from_parts(0, 2228))
// Standard Error: 684
.saturating_add(Weight::from_parts(128_989, 0).saturating_mul(i.into()))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(3))
.saturating_add(Weight::from_parts(0, 10).saturating_mul(i.into()))
}
/// Storage: Session CurrentIndex (r:1 w:0)
/// Proof Skipped: Session CurrentIndex (max_values: Some(1), max_size: None, mode: Measured)
/// Storage: Distance EvaluationPool0 (r:1 w:1)
/// Proof Skipped: Distance EvaluationPool0 (max_values: Some(1), max_size: None, mode: Measured)
/// The range of component `i` is `[1, 600]`.
fn force_update_evaluation(i: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `612 + i * (10 ±0)`
// Estimated: `2096 + i * (10 ±0)`
// Minimum execution time: 8_392_000 picoseconds.
Weight::from_parts(10_825_908, 0)
.saturating_add(Weight::from_parts(0, 2096))
// Standard Error: 326
.saturating_add(Weight::from_parts(123_200, 0).saturating_mul(i.into()))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
.saturating_add(Weight::from_parts(0, 10).saturating_mul(i.into()))
}
/// Storage: Session CurrentIndex (r:1 w:0)
/// Proof Skipped: Session CurrentIndex (max_values: Some(1), max_size: None, mode: Measured)
/// Storage: Distance DistanceStatusExpireOn (r:1 w:1)
/// Proof Skipped: Distance DistanceStatusExpireOn (max_values: None, max_size: None, mode: Measured)
/// Storage: Distance IdentityDistanceStatus (r:0 w:1)
/// Proof Skipped: Distance IdentityDistanceStatus (max_values: None, max_size: None, mode: Measured)
fn force_set_distance_status() -> Weight {
// Proof Size summary in bytes:
// Measured: `586`
// Estimated: `4051`
// Minimum execution time: 8_099_000 picoseconds.
Weight::from_parts(8_786_000, 0)
.saturating_add(Weight::from_parts(0, 4051))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: Distance DidUpdate (r:1 w:1)
/// Proof Skipped: Distance DidUpdate (max_values: Some(1), max_size: None, mode: Measured)
fn on_finalize() -> Weight {
// Proof Size summary in bytes:
// Measured: `170`
// Estimated: `1655`
// Minimum execution time: 3_904_000 picoseconds.
Weight::from_parts(4_132_000, 0)
.saturating_add(Weight::from_parts(0, 1655))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
}
...@@ -134,6 +134,7 @@ mod benches { ...@@ -134,6 +134,7 @@ mod benches {
define_benchmarks!( define_benchmarks!(
[pallet_certification, Cert] [pallet_certification, Cert]
[pallet_certification, SmithCert] [pallet_certification, SmithCert]
[pallet_distance, Distance]
[pallet_oneshot_account, OneshotAccount] [pallet_oneshot_account, OneshotAccount]
[pallet_universal_dividend, UniversalDividend] [pallet_universal_dividend, UniversalDividend]
[pallet_provide_randomness, ProvideRandomness] [pallet_provide_randomness, ProvideRandomness]
......
...@@ -139,6 +139,7 @@ mod benches { ...@@ -139,6 +139,7 @@ mod benches {
define_benchmarks!( define_benchmarks!(
[pallet_certification, Cert] [pallet_certification, Cert]
[pallet_certification, SmithCert] [pallet_certification, SmithCert]
[pallet_distance, Distance]
[pallet_oneshot_account, OneshotAccount] [pallet_oneshot_account, OneshotAccount]
[pallet_universal_dividend, UniversalDividend] [pallet_universal_dividend, UniversalDividend]
[pallet_provide_randomness, ProvideRandomness] [pallet_provide_randomness, ProvideRandomness]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment