From cee99a3277c558e8ca7b0d020e4d81a2ed93a195 Mon Sep 17 00:00:00 2001 From: bgallois <benjamin@gallois.cc> Date: Fri, 28 Apr 2023 20:53:06 +0200 Subject: [PATCH] fix(pallet_treasury): fix parameters for benchmark --- runtime/common/src/pallets_config.rs | 2 +- runtime/common/src/weights.rs | 1 + runtime/common/src/weights/pallet_treasury.rs | 102 ++++++++++++++++++ runtime/gdev/src/lib.rs | 2 +- runtime/gdev/src/parameters.rs | 7 +- 5 files changed, 110 insertions(+), 4 deletions(-) create mode 100644 runtime/common/src/weights/pallet_treasury.rs diff --git a/runtime/common/src/pallets_config.rs b/runtime/common/src/pallets_config.rs index 3ee1994b3..c2bd72e0a 100644 --- a/runtime/common/src/pallets_config.rs +++ b/runtime/common/src/pallets_config.rs @@ -393,7 +393,7 @@ macro_rules! pallets_config { type SpendFunds = TreasurySpendFunds<Self>; type SpendPeriod = SpendPeriod; type SpendOrigin = frame_support::traits::NeverEnsureOrigin<u64>; - type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>; + type WeightInfo = common_runtime::weights::pallet_treasury::WeightInfo<Runtime>; } // UNIVERSAL DIVIDEND // diff --git a/runtime/common/src/weights.rs b/runtime/common/src/weights.rs index c707c56a8..531717247 100644 --- a/runtime/common/src/weights.rs +++ b/runtime/common/src/weights.rs @@ -29,6 +29,7 @@ pub mod pallet_multisig; pub mod pallet_proxy; pub mod pallet_scheduler; pub mod pallet_timestamp; +pub mod pallet_treasury; pub mod pallet_universal_dividend; pub mod pallet_upgrade_origin; pub mod pallet_provide_randomness; diff --git a/runtime/common/src/weights/pallet_treasury.rs b/runtime/common/src/weights/pallet_treasury.rs new file mode 100644 index 000000000..38bf97501 --- /dev/null +++ b/runtime/common/src/weights/pallet_treasury.rs @@ -0,0 +1,102 @@ +// Copyright 2021-2022 Axiom-Team +// +// This file is part of Duniter-v2S. +// +// Duniter-v2S is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, version 3 of the License. +// +// Duniter-v2S 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 Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>. + +//! Autogenerated weights for `pallet_treasury` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-04-28, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `benjamin-xps139380`, CPU: `Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 + +// Executed Command: +// target/release/duniter +// benchmark +// pallet +// --chain=dev +// --steps=50 +// --repeat=20 +// --pallet=pallet_treasury +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --header=./file_header.txt +// --output=./runtime/common/src/weights/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_treasury`. +pub struct WeightInfo<T>(PhantomData<T>); +impl<T: frame_system::Config> pallet_treasury::WeightInfo for WeightInfo<T> { + fn spend() -> Weight { + // Minimum execution time: 1_146 nanoseconds. + Weight::from_ref_time(1_428_000 as u64) + } + // Storage: Treasury ProposalCount (r:1 w:1) + // Storage: Treasury Proposals (r:0 w:1) + fn propose_spend() -> Weight { + // Minimum execution time: 158_571 nanoseconds. + Weight::from_ref_time(163_129_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Treasury Proposals (r:1 w:1) + // Storage: System Account (r:1 w:1) + fn reject_proposal() -> Weight { + // Minimum execution time: 226_104 nanoseconds. + Weight::from_ref_time(249_137_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Treasury Proposals (r:1 w:0) + // Storage: Treasury Approvals (r:1 w:1) + /// The range of component `p` is `[0, 99]`. + fn approve_proposal(p: u32, ) -> Weight { + // Minimum execution time: 57_029 nanoseconds. + Weight::from_ref_time(90_162_378 as u64) + // Standard Error: 40_171 + .saturating_add(Weight::from_ref_time(757_294 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: Treasury Approvals (r:1 w:1) + fn remove_approval() -> Weight { + // Minimum execution time: 53_325 nanoseconds. + Weight::from_ref_time(67_475_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: Treasury Approvals (r:1 w:1) + // Storage: Treasury Proposals (r:2 w:2) + // Storage: System Account (r:4 w:4) + // Storage: Account PendingNewAccounts (r:0 w:2) + /// The range of component `p` is `[0, 100]`. + fn on_initialize_proposals(p: u32, ) -> Weight { + // Minimum execution time: 109_965 nanoseconds. + Weight::from_ref_time(118_648_000 as u64) + // Standard Error: 1_429_278 + .saturating_add(Weight::from_ref_time(164_690_636 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().reads((3 as u64).saturating_mul(p as u64))) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + .saturating_add(T::DbWeight::get().writes((4 as u64).saturating_mul(p as u64))) + } +} diff --git a/runtime/gdev/src/lib.rs b/runtime/gdev/src/lib.rs index 8b109b04b..1c8e38c20 100644 --- a/runtime/gdev/src/lib.rs +++ b/runtime/gdev/src/lib.rs @@ -162,7 +162,7 @@ mod benches { [pallet_scheduler, Scheduler] [frame_system, SystemBench::<Runtime>] [pallet_timestamp, Timestamp] - //[pallet_treasury, Treasury] FIXME + [pallet_treasury, Treasury] [pallet_utility, Utility] ); } diff --git a/runtime/gdev/src/parameters.rs b/runtime/gdev/src/parameters.rs index 9c23a1386..f43402dc3 100644 --- a/runtime/gdev/src/parameters.rs +++ b/runtime/gdev/src/parameters.rs @@ -18,6 +18,7 @@ use crate::*; use common_runtime::constants::*; use common_runtime::{Balance, BlockNumber}; use frame_support::parameter_types; +use frame_support::traits::EitherOfDiverse; use frame_support::weights::constants::WEIGHT_PER_SECOND; use sp_arithmetic::Perbill; use sp_runtime::transaction_validity::TransactionPriority; @@ -99,7 +100,9 @@ parameter_types! { } // Treasury -pub type TreasuryApproveOrigin = - pallet_collective::EnsureProportionMoreThan<AccountId, TechnicalCommitteeInstance, 1, 2>; +pub type TreasuryApproveOrigin = EitherOfDiverse< + EnsureRoot<AccountId>, + pallet_collective::EnsureProportionMoreThan<AccountId, TechnicalCommitteeInstance, 1, 2>, +>; // Root is needed for benchmarking pub type TreasuryRejectOrigin = pallet_collective::EnsureProportionMoreThan<AccountId, TechnicalCommitteeInstance, 1, 3>; -- GitLab