diff --git a/Cargo.lock b/Cargo.lock index 83c40e9a4c7a..b3eefe1826c9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10315,10 +10315,12 @@ dependencies = [ name = "pallet-collective" version = "28.0.0" dependencies = [ + "docify", "frame-benchmarking", "frame-support", "frame-system", "log", + "pallet-balances", "parity-scale-codec", "scale-info", "sp-core", diff --git a/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs b/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs index 21206d26dd57..dea2eb03db3a 100644 --- a/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs @@ -552,6 +552,9 @@ impl pallet_collective::Config for Runtime { type SetMembersOrigin = EnsureRoot; type WeightInfo = weights::pallet_collective::WeightInfo; type MaxProposalWeight = MaxProposalWeight; + type DisapproveOrigin = EnsureRoot; + type KillOrigin = EnsureRoot; + type Consideration = (); } pub const MAX_FELLOWS: u32 = ALLIANCE_MAX_MEMBERS; diff --git a/cumulus/parachains/runtimes/collectives/collectives-westend/src/weights/pallet_collective.rs b/cumulus/parachains/runtimes/collectives/collectives-westend/src/weights/pallet_collective.rs index 9133baa6120c..d456f5b8c460 100644 --- a/cumulus/parachains/runtimes/collectives/collectives-westend/src/weights/pallet_collective.rs +++ b/cumulus/parachains/runtimes/collectives/collectives-westend/src/weights/pallet_collective.rs @@ -1,42 +1,41 @@ // Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 +// This file is part of Cumulus. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Cumulus 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. + +// Cumulus 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 Cumulus. If not, see . //! Autogenerated weights for `pallet_collective` //! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-07-31, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 +//! DATE: 2024-08-29, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `runner-ynta1nyy-project-238-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` -//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("collectives-polkadot-dev")`, DB CACHE: 1024 +//! HOSTNAME: `runner-svzsllib-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("collectives-westend-dev")`, DB CACHE: 1024 // Executed Command: -// ./target/production/polkadot-parachain +// target/production/polkadot-parachain // benchmark // pallet -// --chain=collectives-polkadot-dev -// --wasm-execution=compiled -// --pallet=pallet_collective -// --no-storage-info -// --no-median-slopes -// --no-min-squares -// --extrinsic=* // --steps=50 // --repeat=20 -// --json -// --header=./file_header.txt -// --output=./parachains/runtimes/collectives/collectives-polkadot/src/weights/ +// --extrinsic=* +// --wasm-execution=compiled +// --heap-pages=4096 +// --json-file=/builds/parity/mirrors/polkadot-sdk/.git/.artifacts/bench.json +// --pallet=pallet_collective +// --chain=collectives-westend-dev +// --header=./cumulus/file_header.txt +// --output=./cumulus/parachains/runtimes/collectives/collectives-westend/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -63,14 +62,14 @@ impl pallet_collective::WeightInfo for WeightInfo { fn set_members(m: u32, _n: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0 + m * (3232 ±0) + p * (3190 ±0)` - // Estimated: `15691 + m * (1967 ±23) + p * (4332 ±23)` - // Minimum execution time: 16_410_000 picoseconds. - Weight::from_parts(16_816_000, 0) - .saturating_add(Weight::from_parts(0, 15691)) - // Standard Error: 59_812 - .saturating_add(Weight::from_parts(4_516_537, 0).saturating_mul(m.into())) - // Standard Error: 59_812 - .saturating_add(Weight::from_parts(7_992_168, 0).saturating_mul(p.into())) + // Estimated: `15728 + m * (1967 ±23) + p * (4332 ±23)` + // Minimum execution time: 16_539_000 picoseconds. + Weight::from_parts(16_884_000, 0) + .saturating_add(Weight::from_parts(0, 15728)) + // Standard Error: 65_205 + .saturating_add(Weight::from_parts(4_926_489, 0).saturating_mul(m.into())) + // Standard Error: 65_205 + .saturating_add(Weight::from_parts(9_044_204, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(p.into()))) .saturating_add(T::DbWeight::get().writes(2)) @@ -84,15 +83,15 @@ impl pallet_collective::WeightInfo for WeightInfo { /// The range of component `m` is `[1, 100]`. fn execute(b: u32, m: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `32 + m * (32 ±0)` - // Estimated: `1518 + m * (32 ±0)` - // Minimum execution time: 14_418_000 picoseconds. - Weight::from_parts(13_588_617, 0) - .saturating_add(Weight::from_parts(0, 1518)) - // Standard Error: 21 - .saturating_add(Weight::from_parts(1_711, 0).saturating_mul(b.into())) - // Standard Error: 223 - .saturating_add(Weight::from_parts(13_836, 0).saturating_mul(m.into())) + // Measured: `69 + m * (32 ±0)` + // Estimated: `1555 + m * (32 ±0)` + // Minimum execution time: 16_024_000 picoseconds. + Weight::from_parts(15_295_443, 0) + .saturating_add(Weight::from_parts(0, 1555)) + // Standard Error: 22 + .saturating_add(Weight::from_parts(1_501, 0).saturating_mul(b.into())) + // Standard Error: 229 + .saturating_add(Weight::from_parts(12_430, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(Weight::from_parts(0, 32).saturating_mul(m.into())) } @@ -104,15 +103,15 @@ impl pallet_collective::WeightInfo for WeightInfo { /// The range of component `m` is `[1, 100]`. fn propose_execute(b: u32, m: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `32 + m * (32 ±0)` - // Estimated: `3498 + m * (32 ±0)` - // Minimum execution time: 17_174_000 picoseconds. - Weight::from_parts(16_192_764, 0) - .saturating_add(Weight::from_parts(0, 3498)) - // Standard Error: 27 - .saturating_add(Weight::from_parts(1_672, 0).saturating_mul(b.into())) - // Standard Error: 280 - .saturating_add(Weight::from_parts(24_343, 0).saturating_mul(m.into())) + // Measured: `69 + m * (32 ±0)` + // Estimated: `3535 + m * (32 ±0)` + // Minimum execution time: 18_277_000 picoseconds. + Weight::from_parts(17_322_061, 0) + .saturating_add(Weight::from_parts(0, 3535)) + // Standard Error: 29 + .saturating_add(Weight::from_parts(1_725, 0).saturating_mul(b.into())) + // Standard Error: 309 + .saturating_add(Weight::from_parts(25_640, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(Weight::from_parts(0, 32).saturating_mul(m.into())) } @@ -131,17 +130,17 @@ impl pallet_collective::WeightInfo for WeightInfo { /// The range of component `p` is `[1, 100]`. fn propose_proposed(b: u32, m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `322 + m * (32 ±0) + p * (36 ±0)` - // Estimated: `3714 + m * (33 ±0) + p * (36 ±0)` - // Minimum execution time: 23_970_000 picoseconds. - Weight::from_parts(23_004_052, 0) - .saturating_add(Weight::from_parts(0, 3714)) - // Standard Error: 123 - .saturating_add(Weight::from_parts(2_728, 0).saturating_mul(b.into())) - // Standard Error: 1_291 - .saturating_add(Weight::from_parts(32_731, 0).saturating_mul(m.into())) - // Standard Error: 1_275 - .saturating_add(Weight::from_parts(199_537, 0).saturating_mul(p.into())) + // Measured: `359 + m * (32 ±0) + p * (36 ±0)` + // Estimated: `3751 + m * (33 ±0) + p * (36 ±0)` + // Minimum execution time: 23_915_000 picoseconds. + Weight::from_parts(22_895_005, 0) + .saturating_add(Weight::from_parts(0, 3751)) + // Standard Error: 116 + .saturating_add(Weight::from_parts(4_047, 0).saturating_mul(b.into())) + // Standard Error: 1_211 + .saturating_add(Weight::from_parts(37_038, 0).saturating_mul(m.into())) + // Standard Error: 1_196 + .saturating_add(Weight::from_parts(203_435, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(4)) .saturating_add(Weight::from_parts(0, 33).saturating_mul(m.into())) @@ -154,13 +153,13 @@ impl pallet_collective::WeightInfo for WeightInfo { /// The range of component `m` is `[5, 100]`. fn vote(m: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `771 + m * (64 ±0)` - // Estimated: `4235 + m * (64 ±0)` - // Minimum execution time: 25_843_000 picoseconds. - Weight::from_parts(26_092_578, 0) - .saturating_add(Weight::from_parts(0, 4235)) - // Standard Error: 1_785 - .saturating_add(Weight::from_parts(67_298, 0).saturating_mul(m.into())) + // Measured: `808 + m * (64 ±0)` + // Estimated: `4272 + m * (64 ±0)` + // Minimum execution time: 28_571_000 picoseconds. + Weight::from_parts(29_711_839, 0) + .saturating_add(Weight::from_parts(0, 4272)) + // Standard Error: 825 + .saturating_add(Weight::from_parts(39_661, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) .saturating_add(Weight::from_parts(0, 64).saturating_mul(m.into())) @@ -177,15 +176,15 @@ impl pallet_collective::WeightInfo for WeightInfo { /// The range of component `p` is `[1, 100]`. fn close_early_disapproved(m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `360 + m * (64 ±0) + p * (36 ±0)` - // Estimated: `3805 + m * (65 ±0) + p * (36 ±0)` - // Minimum execution time: 27_543_000 picoseconds. - Weight::from_parts(26_505_473, 0) - .saturating_add(Weight::from_parts(0, 3805)) - // Standard Error: 1_054 - .saturating_add(Weight::from_parts(35_295, 0).saturating_mul(m.into())) - // Standard Error: 1_028 - .saturating_add(Weight::from_parts(190_508, 0).saturating_mul(p.into())) + // Measured: `397 + m * (64 ±0) + p * (36 ±0)` + // Estimated: `3842 + m * (65 ±0) + p * (36 ±0)` + // Minimum execution time: 27_742_000 picoseconds. + Weight::from_parts(28_014_736, 0) + .saturating_add(Weight::from_parts(0, 3842)) + // Standard Error: 1_221 + .saturating_add(Weight::from_parts(35_335, 0).saturating_mul(m.into())) + // Standard Error: 1_191 + .saturating_add(Weight::from_parts(193_513, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) .saturating_add(Weight::from_parts(0, 65).saturating_mul(m.into())) @@ -204,17 +203,17 @@ impl pallet_collective::WeightInfo for WeightInfo { /// The range of component `p` is `[1, 100]`. fn close_early_approved(b: u32, m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `662 + b * (1 ±0) + m * (64 ±0) + p * (40 ±0)` - // Estimated: `3979 + b * (1 ±0) + m * (66 ±0) + p * (40 ±0)` - // Minimum execution time: 40_375_000 picoseconds. - Weight::from_parts(34_081_294, 0) - .saturating_add(Weight::from_parts(0, 3979)) - // Standard Error: 196 - .saturating_add(Weight::from_parts(3_796, 0).saturating_mul(b.into())) - // Standard Error: 2_072 - .saturating_add(Weight::from_parts(50_954, 0).saturating_mul(m.into())) - // Standard Error: 2_020 - .saturating_add(Weight::from_parts(246_000, 0).saturating_mul(p.into())) + // Measured: `699 + b * (1 ±0) + m * (64 ±0) + p * (40 ±0)` + // Estimated: `4016 + b * (1 ±0) + m * (66 ±0) + p * (40 ±0)` + // Minimum execution time: 38_274_000 picoseconds. + Weight::from_parts(37_886_500, 0) + .saturating_add(Weight::from_parts(0, 4016)) + // Standard Error: 165 + .saturating_add(Weight::from_parts(3_242, 0).saturating_mul(b.into())) + // Standard Error: 1_753 + .saturating_add(Weight::from_parts(33_851, 0).saturating_mul(m.into())) + // Standard Error: 1_709 + .saturating_add(Weight::from_parts(229_245, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(3)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(b.into())) @@ -235,15 +234,15 @@ impl pallet_collective::WeightInfo for WeightInfo { /// The range of component `p` is `[1, 100]`. fn close_disapproved(m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `458 + m * (48 ±0) + p * (36 ±0)` - // Estimated: `3898 + m * (49 ±0) + p * (36 ±0)` - // Minimum execution time: 28_793_000 picoseconds. - Weight::from_parts(29_656_832, 0) - .saturating_add(Weight::from_parts(0, 3898)) - // Standard Error: 1_214 - .saturating_add(Weight::from_parts(22_148, 0).saturating_mul(m.into())) - // Standard Error: 1_184 - .saturating_add(Weight::from_parts(189_860, 0).saturating_mul(p.into())) + // Measured: `495 + m * (48 ±0) + p * (36 ±0)` + // Estimated: `3935 + m * (49 ±0) + p * (36 ±0)` + // Minimum execution time: 29_178_000 picoseconds. + Weight::from_parts(28_752_686, 0) + .saturating_add(Weight::from_parts(0, 3935)) + // Standard Error: 1_230 + .saturating_add(Weight::from_parts(42_254, 0).saturating_mul(m.into())) + // Standard Error: 1_200 + .saturating_add(Weight::from_parts(210_610, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(3)) .saturating_add(Weight::from_parts(0, 49).saturating_mul(m.into())) @@ -264,17 +263,17 @@ impl pallet_collective::WeightInfo for WeightInfo { /// The range of component `p` is `[1, 100]`. fn close_approved(b: u32, m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `682 + b * (1 ±0) + m * (64 ±0) + p * (40 ±0)` - // Estimated: `3999 + b * (1 ±0) + m * (66 ±0) + p * (40 ±0)` - // Minimum execution time: 40_887_000 picoseconds. - Weight::from_parts(39_529_567, 0) - .saturating_add(Weight::from_parts(0, 3999)) - // Standard Error: 191 - .saturating_add(Weight::from_parts(2_802, 0).saturating_mul(b.into())) - // Standard Error: 2_021 - .saturating_add(Weight::from_parts(35_956, 0).saturating_mul(m.into())) - // Standard Error: 1_970 - .saturating_add(Weight::from_parts(235_154, 0).saturating_mul(p.into())) + // Measured: `719 + b * (1 ±0) + m * (64 ±0) + p * (40 ±0)` + // Estimated: `4036 + b * (1 ±0) + m * (66 ±0) + p * (40 ±0)` + // Minimum execution time: 40_296_000 picoseconds. + Weight::from_parts(41_629_338, 0) + .saturating_add(Weight::from_parts(0, 4036)) + // Standard Error: 162 + .saturating_add(Weight::from_parts(2_608, 0).saturating_mul(b.into())) + // Standard Error: 1_717 + .saturating_add(Weight::from_parts(29_637, 0).saturating_mul(m.into())) + // Standard Error: 1_674 + .saturating_add(Weight::from_parts(230_371, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(3)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(b.into())) @@ -290,15 +289,54 @@ impl pallet_collective::WeightInfo for WeightInfo { /// The range of component `p` is `[1, 100]`. fn disapprove_proposal(p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `189 + p * (32 ±0)` - // Estimated: `1674 + p * (32 ±0)` - // Minimum execution time: 14_040_000 picoseconds. - Weight::from_parts(15_075_964, 0) - .saturating_add(Weight::from_parts(0, 1674)) - // Standard Error: 854 - .saturating_add(Weight::from_parts(159_597, 0).saturating_mul(p.into())) + // Measured: `226 + p * (32 ±0)` + // Estimated: `1711 + p * (32 ±0)` + // Minimum execution time: 15_385_000 picoseconds. + Weight::from_parts(17_009_286, 0) + .saturating_add(Weight::from_parts(0, 1711)) + // Standard Error: 1_192 + .saturating_add(Weight::from_parts(170_070, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(3)) .saturating_add(Weight::from_parts(0, 32).saturating_mul(p.into())) } + /// Storage: `AllianceMotion::ProposalOf` (r:1 w:1) + /// Proof: `AllianceMotion::ProposalOf` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `AllianceMotion::CostOf` (r:1 w:0) + /// Proof: `AllianceMotion::CostOf` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `AllianceMotion::Proposals` (r:1 w:1) + /// Proof: `AllianceMotion::Proposals` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `AllianceMotion::Voting` (r:0 w:1) + /// Proof: `AllianceMotion::Voting` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `d` is `[0, 1]`. + /// The range of component `p` is `[1, 100]`. + fn kill(d: u32, p: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1497 + p * (36 ±0)` + // Estimated: `4896 + d * (123 ±6) + p * (37 ±0)` + // Minimum execution time: 22_455_000 picoseconds. + Weight::from_parts(24_273_426, 0) + .saturating_add(Weight::from_parts(0, 4896)) + // Standard Error: 82_114 + .saturating_add(Weight::from_parts(996_567, 0).saturating_mul(d.into())) + // Standard Error: 1_271 + .saturating_add(Weight::from_parts(213_968, 0).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) + .saturating_add(Weight::from_parts(0, 123).saturating_mul(d.into())) + .saturating_add(Weight::from_parts(0, 37).saturating_mul(p.into())) + } + /// Storage: `AllianceMotion::ProposalOf` (r:1 w:0) + /// Proof: `AllianceMotion::ProposalOf` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `AllianceMotion::CostOf` (r:1 w:0) + /// Proof: `AllianceMotion::CostOf` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn release_proposal_cost() -> Weight { + // Proof Size summary in bytes: + // Measured: `911` + // Estimated: `4376` + // Minimum execution time: 18_273_000 picoseconds. + Weight::from_parts(19_196_000, 0) + .saturating_add(Weight::from_parts(0, 4376)) + .saturating_add(T::DbWeight::get().reads(2)) + } } diff --git a/prdoc/pr_3151.prdoc b/prdoc/pr_3151.prdoc new file mode 100644 index 000000000000..5e43b86a9753 --- /dev/null +++ b/prdoc/pr_3151.prdoc @@ -0,0 +1,49 @@ +# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 +# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json + +title: Dynamic deposit based on number of proposals + +doc: + - audience: + - Runtime User + - Runtime Dev + description: | + Introduce a dynamic proposal deposit mechanism influenced by the total number of active + proposals, with the option to set the deposit to none. + + The potential cost (e.g., balance hold) for proposal submission and storage is determined + by the implementation of the `Consideration` trait. The footprint is defined as `proposal_count`, + representing the total number of active proposals in the system, excluding the one currently + being proposed. This cost may vary based on the proposal count. The pallet also offers various + types to define a cost strategy based on the number of proposals. + + Two new calls are introduced: + - kill(origin, proposal_hash): the cancellation of a proposal, accompanied by the burning + of the associated cost/consideration ticket. + - release_proposal_cost(origin, proposal_hash): the release of the cost for a non-active proposal. + + New config parameters: + - DisapproveOrigin: origin from which a proposal in any status may be disapproved without + associated cost for a proposer; + - KillOrigin: Origin from which any malicious proposal may be killed with associated cost + for a proposer; + - Consideration: mechanism to assess the necessity of some cost for publishing and storing + a proposal. Set to unit type to have not submission cost; + + Additionally change: + - benchmarks have been upgraded to benchmarks::v2 for collective pallet; + - `ensure_successful` function added to the `Consideration` under `runtime-benchmarks` feature. + +crates: + - name: pallet-collective + bump: major + - name: collectives-westend-runtime + bump: major + - name: kitchensink-runtime + bump: major + - name: pallet-alliance + bump: patch + - name: pallet-balances + bump: patch + - name: pallet-utility + bump: patch diff --git a/substrate/bin/node/runtime/src/lib.rs b/substrate/bin/node/runtime/src/lib.rs index 31584427b3b6..001b2273c9b2 100644 --- a/substrate/bin/node/runtime/src/lib.rs +++ b/substrate/bin/node/runtime/src/lib.rs @@ -1114,6 +1114,9 @@ parameter_types! { pub const CouncilMotionDuration: BlockNumber = 5 * DAYS; pub const CouncilMaxProposals: u32 = 100; pub const CouncilMaxMembers: u32 = 100; + pub const ProposalDepositOffset: Balance = ExistentialDeposit::get() + ExistentialDeposit::get(); + pub const ProposalHoldReason: RuntimeHoldReason = + RuntimeHoldReason::Council(pallet_collective::HoldReason::ProposalSubmission); } type CouncilCollective = pallet_collective::Instance1; @@ -1128,6 +1131,18 @@ impl pallet_collective::Config for Runtime { type WeightInfo = pallet_collective::weights::SubstrateWeight; type SetMembersOrigin = EnsureRoot; type MaxProposalWeight = MaxCollectivesProposalWeight; + type DisapproveOrigin = EnsureRoot; + type KillOrigin = EnsureRoot; + type Consideration = HoldConsideration< + AccountId, + Balances, + ProposalHoldReason, + pallet_collective::deposit::Delayed< + ConstU32<2>, + pallet_collective::deposit::Linear, ProposalDepositOffset>, + >, + u32, + >; } parameter_types! { @@ -1189,6 +1204,9 @@ impl pallet_collective::Config for Runtime { type WeightInfo = pallet_collective::weights::SubstrateWeight; type SetMembersOrigin = EnsureRoot; type MaxProposalWeight = MaxCollectivesProposalWeight; + type DisapproveOrigin = EnsureRoot; + type KillOrigin = EnsureRoot; + type Consideration = (); } type EnsureRootOrHalfCouncil = EitherOfDiverse< @@ -2027,6 +2045,9 @@ impl pallet_collective::Config for Runtime { type WeightInfo = pallet_collective::weights::SubstrateWeight; type SetMembersOrigin = EnsureRoot; type MaxProposalWeight = MaxCollectivesProposalWeight; + type DisapproveOrigin = EnsureRoot; + type KillOrigin = EnsureRoot; + type Consideration = (); } parameter_types! { diff --git a/substrate/frame/alliance/src/mock.rs b/substrate/frame/alliance/src/mock.rs index 9cd96019781e..5442e8779020 100644 --- a/substrate/frame/alliance/src/mock.rs +++ b/substrate/frame/alliance/src/mock.rs @@ -77,6 +77,9 @@ impl pallet_collective::Config for Test { type WeightInfo = (); type SetMembersOrigin = EnsureRoot; type MaxProposalWeight = MaxProposalWeight; + type DisapproveOrigin = EnsureRoot; + type KillOrigin = EnsureRoot; + type Consideration = (); } parameter_types! { diff --git a/substrate/frame/balances/src/tests/fungible_tests.rs b/substrate/frame/balances/src/tests/fungible_tests.rs index ac373a351d34..4a8b213c645e 100644 --- a/substrate/frame/balances/src/tests/fungible_tests.rs +++ b/substrate/frame/balances/src/tests/fungible_tests.rs @@ -518,8 +518,9 @@ fn freeze_consideration_works() { let who = 4; // freeze amount taken somewhere outside of our (Consideration) scope. let extend_freeze = 15; - let zero_ticket = Consideration::new(&who, Footprint::from_parts(0, 0)).unwrap(); - assert!(zero_ticket.is_none()); + + let ticket = Consideration::new(&who, Footprint::from_parts(0, 0)).unwrap(); + assert!(ticket.is_none()); assert_eq!(Balances::balance_frozen(&TestId::Foo, &who), 0); let ticket = Consideration::new(&who, Footprint::from_parts(10, 1)).unwrap(); @@ -536,7 +537,6 @@ fn freeze_consideration_works() { let ticket = ticket.update(&who, Footprint::from_parts(0, 0)).unwrap(); assert!(ticket.is_none()); - assert_eq!(ticket, zero_ticket); assert_eq!(Balances::balance_frozen(&TestId::Foo, &who), 0 + extend_freeze); let ticket = Consideration::new(&who, Footprint::from_parts(10, 1)).unwrap(); @@ -565,11 +565,11 @@ fn hold_consideration_works() { // hold amount taken somewhere outside of our (Consideration) scope. let extend_hold = 15; - let zero_ticket = Consideration::new(&who, Footprint::from_parts(0, 0)).unwrap(); - assert!(zero_ticket.is_none()); + let ticket = Consideration::new(&who, Footprint::from_parts(0, 0)).unwrap(); + assert!(ticket.is_none()); assert_eq!(Balances::balance_on_hold(&TestId::Foo, &who), 0); - let ticket = Consideration::new(&who, Footprint::from_parts(10, 1)).unwrap(); + let ticket = ticket.update(&who, Footprint::from_parts(10, 1)).unwrap(); assert_eq!(Balances::balance_on_hold(&TestId::Foo, &who), 10); let ticket = ticket.update(&who, Footprint::from_parts(4, 1)).unwrap(); @@ -583,7 +583,6 @@ fn hold_consideration_works() { let ticket = ticket.update(&who, Footprint::from_parts(0, 0)).unwrap(); assert!(ticket.is_none()); - assert_eq!(ticket, zero_ticket); assert_eq!(Balances::balance_on_hold(&TestId::Foo, &who), 0 + extend_hold); let ticket = Consideration::new(&who, Footprint::from_parts(10, 1)).unwrap(); diff --git a/substrate/frame/collective/Cargo.toml b/substrate/frame/collective/Cargo.toml index f6810f26f056..59a9d23f7b19 100644 --- a/substrate/frame/collective/Cargo.toml +++ b/substrate/frame/collective/Cargo.toml @@ -17,15 +17,19 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { features = ["derive"], workspace = true } +docify = { workspace = true } log = { workspace = true } scale-info = { features = ["derive"], workspace = true } frame-benchmarking = { optional = true, workspace = true } -frame-support = { workspace = true } +frame-support = { features = ["experimental"], workspace = true } frame-system = { workspace = true } sp-core = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } +[dev-dependencies] +pallet-balances = { workspace = true, default-features = false } + [features] default = ["std"] std = [ @@ -34,6 +38,7 @@ std = [ "frame-support/std", "frame-system/std", "log/std", + "pallet-balances/std", "scale-info/std", "sp-core/std", "sp-io/std", @@ -43,10 +48,12 @@ runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", + "pallet-balances/runtime-benchmarks", "sp-runtime/runtime-benchmarks", ] try-runtime = [ "frame-support/try-runtime", "frame-system/try-runtime", + "pallet-balances/try-runtime", "sp-runtime/try-runtime", ] diff --git a/substrate/frame/collective/src/benchmarking.rs b/substrate/frame/collective/src/benchmarking.rs index 7b5df17b60a6..baf7cce8437f 100644 --- a/substrate/frame/collective/src/benchmarking.rs +++ b/substrate/frame/collective/src/benchmarking.rs @@ -23,7 +23,10 @@ use crate::Pallet as Collective; use core::mem::size_of; use sp_runtime::traits::Bounded; -use frame_benchmarking::v1::{account, benchmarks_instance_pallet, whitelisted_caller}; +use frame_benchmarking::{ + v1::{account, whitelisted_caller}, + v2::*, +}; use frame_system::{ pallet_prelude::BlockNumberFor, Call as SystemCall, Pallet as System, RawOrigin as SystemOrigin, }; @@ -36,24 +39,31 @@ fn assert_last_event, I: 'static>(generic_event: >:: frame_system::Pallet::::assert_last_event(generic_event.into()); } +fn assert_has_event, I: 'static>(generic_event: >::RuntimeEvent) { + frame_system::Pallet::::assert_has_event(generic_event.into()); +} + fn id_to_remark_data(id: u32, length: usize) -> Vec { id.to_le_bytes().into_iter().cycle().take(length).collect() } -benchmarks_instance_pallet! { - set_members { - let m in 0 .. T::MaxMembers::get(); - let n in 0 .. T::MaxMembers::get(); - let p in 0 .. T::MaxProposals::get(); +#[instance_benchmarks(where T: Config, I: 'static)] +mod benchmarks { + use super::*; + #[benchmark] + fn set_members( + m: Linear<0, { T::MaxMembers::get() }>, + n: Linear<0, { T::MaxMembers::get() }>, + p: Linear<0, { T::MaxProposals::get() }>, + ) -> Result<(), BenchmarkError> { // Set old members. // We compute the difference of old and new members, so it should influence timing. let mut old_members = vec![]; - for i in 0 .. m { + for i in 0..m { let old_member = account::("old member", i, SEED); old_members.push(old_member); } - let old_members_count = old_members.len() as u32; Collective::::set_members( SystemOrigin::Root.into(), @@ -64,24 +74,27 @@ benchmarks_instance_pallet! { // If there were any old members generate a bunch of proposals. if m > 0 { + let caller = old_members.last().unwrap().clone(); // Set a high threshold for proposals passing so that they stay around. let threshold = m.max(2); // Length of the proposals should be irrelevant to `set_members`. let length = 100; - for i in 0 .. p { + for i in 0..p { + T::Consideration::ensure_successful(&caller, i); // Proposals should be different so that different proposal hashes are generated - let proposal: T::Proposal = SystemCall::::remark { remark: id_to_remark_data(i, length) }.into(); + let proposal: T::Proposal = + SystemCall::::remark { remark: id_to_remark_data(i, length) }.into(); Collective::::propose( - SystemOrigin::Signed(old_members.last().unwrap().clone()).into(), + SystemOrigin::Signed(caller.clone()).into(), threshold, Box::new(proposal.clone()), MAX_BYTES, )?; let hash = T::Hashing::hash_of(&proposal); // Vote on the proposal to increase state relevant for `set_members`. - // Not voting for last old member because they proposed and not voting for the first member - // to keep the proposal from passing. - for j in 2 .. m - 1 { + // Not voting for last old member because they proposed and not voting for the first + // member to keep the proposal from passing. + for j in 2..m - 1 { let voter = &old_members[j as usize]; let approve = true; Collective::::vote( @@ -97,26 +110,33 @@ benchmarks_instance_pallet! { // Construct `new_members`. // It should influence timing since it will sort this vector. let mut new_members = vec![]; - for i in 0 .. n { + for i in 0..n { let member = account::("member", i, SEED); new_members.push(member); } + #[extrinsic_call] + _( + SystemOrigin::Root, + new_members.clone(), + new_members.last().cloned(), + T::MaxMembers::get(), + ); - }: _(SystemOrigin::Root, new_members.clone(), new_members.last().cloned(), T::MaxMembers::get()) - verify { new_members.sort(); assert_eq!(Members::::get(), new_members); + Ok(()) } - execute { - let b in 2 .. MAX_BYTES; - let m in 1 .. T::MaxMembers::get(); - + #[benchmark] + fn execute( + b: Linear<2, MAX_BYTES>, + m: Linear<1, { T::MaxMembers::get() }>, + ) -> Result<(), BenchmarkError> { let bytes_in_storage = b + size_of::() as u32; // Construct `members`. let mut members = vec![]; - for i in 0 .. m - 1 { + for i in 0..m - 1 { let member = account::("member", i, SEED); members.push(member); } @@ -124,29 +144,36 @@ benchmarks_instance_pallet! { let caller: T::AccountId = whitelisted_caller(); members.push(caller.clone()); - Collective::::set_members(SystemOrigin::Root.into(), members, None, T::MaxMembers::get())?; + Collective::::set_members( + SystemOrigin::Root.into(), + members, + None, + T::MaxMembers::get(), + )?; + + let proposal: T::Proposal = + SystemCall::::remark { remark: id_to_remark_data(1, b as usize) }.into(); - let proposal: T::Proposal = SystemCall::::remark { remark: id_to_remark_data(1, b as usize) }.into(); + #[extrinsic_call] + _(SystemOrigin::Signed(caller), Box::new(proposal.clone()), bytes_in_storage); - }: _(SystemOrigin::Signed(caller), Box::new(proposal.clone()), bytes_in_storage) - verify { let proposal_hash = T::Hashing::hash_of(&proposal); // Note that execution fails due to mis-matched origin - assert_last_event::( - Event::MemberExecuted { proposal_hash, result: Ok(()) }.into() - ); + assert_last_event::(Event::MemberExecuted { proposal_hash, result: Ok(()) }.into()); + Ok(()) } // This tests when execution would happen immediately after proposal - propose_execute { - let b in 2 .. MAX_BYTES; - let m in 1 .. T::MaxMembers::get(); - + #[benchmark] + fn propose_execute( + b: Linear<2, MAX_BYTES>, + m: Linear<1, { T::MaxMembers::get() }>, + ) -> Result<(), BenchmarkError> { let bytes_in_storage = b + size_of::() as u32; // Construct `members`. let mut members = vec![]; - for i in 0 .. m - 1 { + for i in 0..m - 1 { let member = account::("member", i, SEED); members.push(member); } @@ -154,43 +181,62 @@ benchmarks_instance_pallet! { let caller: T::AccountId = whitelisted_caller(); members.push(caller.clone()); - Collective::::set_members(SystemOrigin::Root.into(), members, None, T::MaxMembers::get())?; + Collective::::set_members( + SystemOrigin::Root.into(), + members, + None, + T::MaxMembers::get(), + )?; - let proposal: T::Proposal = SystemCall::::remark { remark: id_to_remark_data(1, b as usize) }.into(); + let proposal: T::Proposal = + SystemCall::::remark { remark: id_to_remark_data(1, b as usize) }.into(); let threshold = 1; - }: propose(SystemOrigin::Signed(caller), threshold, Box::new(proposal.clone()), bytes_in_storage) - verify { + #[extrinsic_call] + propose( + SystemOrigin::Signed(caller), + threshold, + Box::new(proposal.clone()), + bytes_in_storage, + ); + let proposal_hash = T::Hashing::hash_of(&proposal); // Note that execution fails due to mis-matched origin - assert_last_event::( - Event::Executed { proposal_hash, result: Ok(()) }.into() - ); + assert_last_event::(Event::Executed { proposal_hash, result: Ok(()) }.into()); + Ok(()) } // This tests when proposal is created and queued as "proposed" - propose_proposed { - let b in 2 .. MAX_BYTES; - let m in 2 .. T::MaxMembers::get(); - let p in 1 .. T::MaxProposals::get(); - + #[benchmark] + fn propose_proposed( + b: Linear<2, MAX_BYTES>, + m: Linear<2, { T::MaxMembers::get() }>, + p: Linear<1, { T::MaxProposals::get() }>, + ) -> Result<(), BenchmarkError> { let bytes_in_storage = b + size_of::() as u32; // Construct `members`. let mut members = vec![]; - for i in 0 .. m - 1 { + for i in 0..m - 1 { let member = account::("member", i, SEED); members.push(member); } let caller: T::AccountId = whitelisted_caller(); members.push(caller.clone()); - Collective::::set_members(SystemOrigin::Root.into(), members, None, T::MaxMembers::get())?; + Collective::::set_members( + SystemOrigin::Root.into(), + members, + None, + T::MaxMembers::get(), + )?; let threshold = m; // Add previous proposals. - for i in 0 .. p - 1 { + for i in 0..p - 1 { + T::Consideration::ensure_successful(&caller, i); // Proposals should be different so that different proposal hashes are generated - let proposal: T::Proposal = SystemCall::::remark { remark: id_to_remark_data(i, b as usize) }.into(); + let proposal: T::Proposal = + SystemCall::::remark { remark: id_to_remark_data(i, b as usize) }.into(); Collective::::propose( SystemOrigin::Signed(caller.clone()).into(), threshold, @@ -201,20 +247,31 @@ benchmarks_instance_pallet! { assert_eq!(Proposals::::get().len(), (p - 1) as usize); - let proposal: T::Proposal = SystemCall::::remark { remark: id_to_remark_data(p, b as usize) }.into(); + T::Consideration::ensure_successful(&caller, p); + + let proposal: T::Proposal = + SystemCall::::remark { remark: id_to_remark_data(p, b as usize) }.into(); + #[extrinsic_call] + propose( + SystemOrigin::Signed(caller.clone()), + threshold, + Box::new(proposal.clone()), + bytes_in_storage, + ); - }: propose(SystemOrigin::Signed(caller.clone()), threshold, Box::new(proposal.clone()), bytes_in_storage) - verify { // New proposal is recorded assert_eq!(Proposals::::get().len(), p as usize); let proposal_hash = T::Hashing::hash_of(&proposal); - assert_last_event::(Event::Proposed { account: caller, proposal_index: p - 1, proposal_hash, threshold }.into()); + assert_last_event::( + Event::Proposed { account: caller, proposal_index: p - 1, proposal_hash, threshold } + .into(), + ); + Ok(()) } - vote { - // We choose 5 as a minimum so we always trigger a vote in the voting loop (`for j in ...`) - let m in 5 .. T::MaxMembers::get(); - + #[benchmark] + // We choose 5 as a minimum so we always trigger a vote in the voting loop (`for j in ...`) + fn vote(m: Linear<5, { T::MaxMembers::get() }>) -> Result<(), BenchmarkError> { let p = T::MaxProposals::get(); let b = MAX_BYTES; let bytes_in_storage = b + size_of::() as u32; @@ -223,22 +280,29 @@ benchmarks_instance_pallet! { let mut members = vec![]; let proposer: T::AccountId = account::("proposer", 0, SEED); members.push(proposer.clone()); - for i in 1 .. m - 1 { + for i in 1..m - 1 { let member = account::("member", i, SEED); members.push(member); } let voter: T::AccountId = account::("voter", 0, SEED); members.push(voter.clone()); - Collective::::set_members(SystemOrigin::Root.into(), members.clone(), None, T::MaxMembers::get())?; + Collective::::set_members( + SystemOrigin::Root.into(), + members.clone(), + None, + T::MaxMembers::get(), + )?; // Threshold is 1 less than the number of members so that one person can vote nay let threshold = m - 1; // Add previous proposals let mut last_hash = T::Hash::default(); - for i in 0 .. p { + for i in 0..p { + T::Consideration::ensure_successful(&proposer, i); // Proposals should be different so that different proposal hashes are generated - let proposal: T::Proposal = SystemCall::::remark { remark: id_to_remark_data(i, b as usize) }.into(); + let proposal: T::Proposal = + SystemCall::::remark { remark: id_to_remark_data(i, b as usize) }.into(); Collective::::propose( SystemOrigin::Signed(proposer.clone()).into(), threshold, @@ -250,7 +314,7 @@ benchmarks_instance_pallet! { let index = p - 1; // Have almost everyone vote aye on last proposal, while keeping it from passing. - for j in 0 .. m - 3 { + for j in 0..m - 3 { let voter = &members[j as usize]; let approve = true; Collective::::vote( @@ -277,20 +341,24 @@ benchmarks_instance_pallet! { // Whitelist voter account from further DB operations. let voter_key = frame_system::Account::::hashed_key_for(&voter); frame_benchmarking::benchmarking::add_to_whitelist(voter_key.into()); - }: _(SystemOrigin::Signed(voter), last_hash, index, approve) - verify { + + #[extrinsic_call] + _(SystemOrigin::Signed(voter), last_hash, index, approve); + // All proposals exist and the last proposal has just been updated. assert_eq!(Proposals::::get().len(), p as usize); let voting = Voting::::get(&last_hash).ok_or("Proposal Missing")?; assert_eq!(voting.ayes.len(), (m - 3) as usize); assert_eq!(voting.nays.len(), 1); + Ok(()) } - close_early_disapproved { - // We choose 4 as a minimum so we always trigger a vote in the voting loop (`for j in ...`) - let m in 4 .. T::MaxMembers::get(); - let p in 1 .. T::MaxProposals::get(); - + // We choose 4 as a minimum so we always trigger a vote in the voting loop (`for j in ...`) + #[benchmark] + fn close_early_disapproved( + m: Linear<4, { T::MaxMembers::get() }>, + p: Linear<1, { T::MaxProposals::get() }>, + ) -> Result<(), BenchmarkError> { let bytes = 100; let bytes_in_storage = bytes + size_of::() as u32; @@ -298,22 +366,29 @@ benchmarks_instance_pallet! { let mut members = vec![]; let proposer = account::("proposer", 0, SEED); members.push(proposer.clone()); - for i in 1 .. m - 1 { + for i in 1..m - 1 { let member = account::("member", i, SEED); members.push(member); } let voter = account::("voter", 0, SEED); members.push(voter.clone()); - Collective::::set_members(SystemOrigin::Root.into(), members.clone(), None, T::MaxMembers::get())?; + Collective::::set_members( + SystemOrigin::Root.into(), + members.clone(), + None, + T::MaxMembers::get(), + )?; // Threshold is total members so that one nay will disapprove the vote let threshold = m; // Add previous proposals let mut last_hash = T::Hash::default(); - for i in 0 .. p { + for i in 0..p { + T::Consideration::ensure_successful(&proposer, i); // Proposals should be different so that different proposal hashes are generated - let proposal: T::Proposal = SystemCall::::remark { remark: id_to_remark_data(i, bytes as usize) }.into(); + let proposal: T::Proposal = + SystemCall::::remark { remark: id_to_remark_data(i, bytes as usize) }.into(); Collective::::propose( SystemOrigin::Signed(proposer.clone()).into(), threshold, @@ -325,7 +400,7 @@ benchmarks_instance_pallet! { let index = p - 1; // Have most everyone vote aye on last proposal, while keeping it from passing. - for j in 0 .. m - 2 { + for j in 0..m - 2 { let voter = &members[j as usize]; let approve = true; Collective::::vote( @@ -358,39 +433,50 @@ benchmarks_instance_pallet! { // Whitelist voter account from further DB operations. let voter_key = frame_system::Account::::hashed_key_for(&voter); frame_benchmarking::benchmarking::add_to_whitelist(voter_key.into()); - }: close(SystemOrigin::Signed(voter), last_hash, index, Weight::MAX, bytes_in_storage) - verify { + + #[extrinsic_call] + close(SystemOrigin::Signed(voter), last_hash, index, Weight::MAX, bytes_in_storage); + // The last proposal is removed. assert_eq!(Proposals::::get().len(), (p - 1) as usize); assert_last_event::(Event::Disapproved { proposal_hash: last_hash }.into()); + Ok(()) } - close_early_approved { - let b in 2 .. MAX_BYTES; - // We choose 4 as a minimum so we always trigger a vote in the voting loop (`for j in ...`) - let m in 4 .. T::MaxMembers::get(); - let p in 1 .. T::MaxProposals::get(); - + // m: we choose 4 as a minimum so we always trigger a vote in the voting loop (`for j in ...`) + #[benchmark] + fn close_early_approved( + b: Linear<2, MAX_BYTES>, + m: Linear<4, { T::MaxMembers::get() }>, + p: Linear<1, { T::MaxProposals::get() }>, + ) -> Result<(), BenchmarkError> { let bytes_in_storage = b + size_of::() as u32; // Construct `members`. let mut members = vec![]; - for i in 0 .. m - 1 { + for i in 0..m - 1 { let member = account::("member", i, SEED); members.push(member); } let caller: T::AccountId = whitelisted_caller(); members.push(caller.clone()); - Collective::::set_members(SystemOrigin::Root.into(), members.clone(), None, T::MaxMembers::get())?; + Collective::::set_members( + SystemOrigin::Root.into(), + members.clone(), + None, + T::MaxMembers::get(), + )?; // Threshold is 2 so any two ayes will approve the vote let threshold = 2; // Add previous proposals let mut last_hash = T::Hash::default(); - for i in 0 .. p { + for i in 0..p { + T::Consideration::ensure_successful(&caller, i); // Proposals should be different so that different proposal hashes are generated - let proposal: T::Proposal = SystemCall::::remark { remark: id_to_remark_data(i, b as usize) }.into(); + let proposal: T::Proposal = + SystemCall::::remark { remark: id_to_remark_data(i, b as usize) }.into(); Collective::::propose( SystemOrigin::Signed(caller.clone()).into(), threshold, @@ -400,7 +486,8 @@ benchmarks_instance_pallet! { last_hash = T::Hashing::hash_of(&proposal); } - // Caller switches vote to nay on their own proposal, allowing them to be the deciding approval vote + // Caller switches vote to nay on their own proposal, allowing them to be the deciding + // approval vote Collective::::vote( SystemOrigin::Signed(caller.clone()).into(), last_hash, @@ -409,7 +496,7 @@ benchmarks_instance_pallet! { )?; // Have almost everyone vote nay on last proposal, while keeping it from failing. - for j in 2 .. m - 1 { + for j in 2..m - 1 { let voter = &members[j as usize]; let approve = false; Collective::::vote( @@ -436,27 +523,33 @@ benchmarks_instance_pallet! { Collective::::vote( SystemOrigin::Signed(caller.clone()).into(), last_hash, - index, approve, + index, + approve, )?; - }: close(SystemOrigin::Signed(caller), last_hash, index, Weight::MAX, bytes_in_storage) - verify { + #[extrinsic_call] + close(SystemOrigin::Signed(caller), last_hash, index, Weight::MAX, bytes_in_storage); + // The last proposal is removed. assert_eq!(Proposals::::get().len(), (p - 1) as usize); - assert_last_event::(Event::Executed { proposal_hash: last_hash, result: Ok(()) }.into()); + assert_last_event::( + Event::Executed { proposal_hash: last_hash, result: Ok(()) }.into(), + ); + Ok(()) } - close_disapproved { - // We choose 4 as a minimum so we always trigger a vote in the voting loop (`for j in ...`) - let m in 4 .. T::MaxMembers::get(); - let p in 1 .. T::MaxProposals::get(); - + // m: we choose 4 as a minimum so we always trigger a vote in the voting loop (`for j in ...`) + #[benchmark] + fn close_disapproved( + m: Linear<4, { T::MaxMembers::get() }>, + p: Linear<1, { T::MaxProposals::get() }>, + ) -> Result<(), BenchmarkError> { let bytes = 100; let bytes_in_storage = bytes + size_of::() as u32; // Construct `members`. let mut members = vec![]; - for i in 0 .. m - 1 { + for i in 0..m - 1 { let member = account::("member", i, SEED); members.push(member); } @@ -474,9 +567,11 @@ benchmarks_instance_pallet! { // Add proposals let mut last_hash = T::Hash::default(); - for i in 0 .. p { + for i in 0..p { + T::Consideration::ensure_successful(&caller, i); // Proposals should be different so that different proposal hashes are generated - let proposal: T::Proposal = SystemCall::::remark { remark: id_to_remark_data(i, bytes as usize) }.into(); + let proposal: T::Proposal = + SystemCall::::remark { remark: id_to_remark_data(i, bytes as usize) }.into(); Collective::::propose( SystemOrigin::Signed(caller.clone()).into(), threshold, @@ -490,7 +585,7 @@ benchmarks_instance_pallet! { // Have almost everyone vote aye on last proposal, while keeping it from passing. // A few abstainers will be the nay votes needed to fail the vote. let mut yes_votes: MemberCount = 0; - for j in 2 .. m - 1 { + for j in 2..m - 1 { let voter = &members[j as usize]; let approve = true; yes_votes += 1; @@ -499,7 +594,8 @@ benchmarks_instance_pallet! { Some(false), yes_votes, 0, - m,) { + m, + ) { break; } Collective::::vote( @@ -522,23 +618,26 @@ benchmarks_instance_pallet! { assert_eq!(Proposals::::get().len(), p as usize); // Prime nay will close it as disapproved - }: close(SystemOrigin::Signed(caller), last_hash, index, Weight::MAX, bytes_in_storage) - verify { + #[extrinsic_call] + close(SystemOrigin::Signed(caller), last_hash, index, Weight::MAX, bytes_in_storage); + assert_eq!(Proposals::::get().len(), (p - 1) as usize); assert_last_event::(Event::Disapproved { proposal_hash: last_hash }.into()); + Ok(()) } - close_approved { - let b in 2 .. MAX_BYTES; - // We choose 4 as a minimum so we always trigger a vote in the voting loop (`for j in ...`) - let m in 4 .. T::MaxMembers::get(); - let p in 1 .. T::MaxProposals::get(); - + // m: we choose 4 as a minimum so we always trigger a vote in the voting loop (`for j in ...`) + #[benchmark] + fn close_approved( + b: Linear<2, MAX_BYTES>, + m: Linear<4, { T::MaxMembers::get() }>, + p: Linear<1, { T::MaxProposals::get() }>, + ) -> Result<(), BenchmarkError> { let bytes_in_storage = b + size_of::() as u32; // Construct `members`. let mut members = vec![]; - for i in 0 .. m - 1 { + for i in 0..m - 1 { let member = account::("member", i, SEED); members.push(member); } @@ -556,9 +655,11 @@ benchmarks_instance_pallet! { // Add proposals let mut last_hash = T::Hash::default(); - for i in 0 .. p { + for i in 0..p { + T::Consideration::ensure_successful(&caller, i); // Proposals should be different so that different proposal hashes are generated - let proposal: T::Proposal = SystemCall::::remark { remark: id_to_remark_data(i, b as usize) }.into(); + let proposal: T::Proposal = + SystemCall::::remark { remark: id_to_remark_data(i, b as usize) }.into(); Collective::::propose( SystemOrigin::Signed(caller.clone()).into(), threshold, @@ -573,19 +674,19 @@ benchmarks_instance_pallet! { SystemOrigin::Signed(caller.clone()).into(), last_hash, p - 1, - true // Vote aye. + true, // Vote aye. )?; // Have almost everyone vote nay on last proposal, while keeping it from failing. // A few abstainers will be the aye votes needed to pass the vote. - for j in 2 .. m - 1 { + for j in 2..m - 1 { let voter = &members[j as usize]; let approve = false; Collective::::vote( SystemOrigin::Signed(voter.clone()).into(), last_hash, p - 1, - approve + approve, )?; } @@ -594,22 +695,25 @@ benchmarks_instance_pallet! { assert_eq!(Proposals::::get().len(), p as usize); // Prime aye will close it as approved - }: close(SystemOrigin::Signed(caller), last_hash, p - 1, Weight::MAX, bytes_in_storage) - verify { + #[extrinsic_call] + close(SystemOrigin::Signed(caller), last_hash, p - 1, Weight::MAX, bytes_in_storage); + assert_eq!(Proposals::::get().len(), (p - 1) as usize); - assert_last_event::(Event::Executed { proposal_hash: last_hash, result: Ok(()) }.into()); + assert_last_event::( + Event::Executed { proposal_hash: last_hash, result: Ok(()) }.into(), + ); + Ok(()) } - disapprove_proposal { - let p in 1 .. T::MaxProposals::get(); - + #[benchmark] + fn disapprove_proposal(p: Linear<1, { T::MaxProposals::get() }>) -> Result<(), BenchmarkError> { let m = 3; let b = MAX_BYTES; let bytes_in_storage = b + size_of::() as u32; // Construct `members`. let mut members = vec![]; - for i in 0 .. m - 1 { + for i in 0..m - 1 { let member = account::("member", i, SEED); members.push(member); } @@ -627,9 +731,11 @@ benchmarks_instance_pallet! { // Add proposals let mut last_hash = T::Hash::default(); - for i in 0 .. p { + for i in 0..p { + T::Consideration::ensure_successful(&caller, i); // Proposals should be different so that different proposal hashes are generated - let proposal: T::Proposal = SystemCall::::remark { remark: id_to_remark_data(i, b as usize) }.into(); + let proposal: T::Proposal = + SystemCall::::remark { remark: id_to_remark_data(i, b as usize) }.into(); Collective::::propose( SystemOrigin::Signed(caller.clone()).into(), threshold, @@ -642,11 +748,150 @@ benchmarks_instance_pallet! { System::::set_block_number(BlockNumberFor::::max_value()); assert_eq!(Proposals::::get().len(), p as usize); - }: _(SystemOrigin::Root, last_hash) - verify { + let origin = + T::DisapproveOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; + + #[extrinsic_call] + _(origin as ::RuntimeOrigin, last_hash); + assert_eq!(Proposals::::get().len(), (p - 1) as usize); assert_last_event::(Event::Disapproved { proposal_hash: last_hash }.into()); + Ok(()) + } + + // d: `0` - if deposit is not present and `1` otherwise. + #[benchmark] + fn kill( + d: Linear<0, 1>, + p: Linear<1, { T::MaxProposals::get() }>, + ) -> Result<(), BenchmarkError> { + let m = 3; + let b = MAX_BYTES; + let bytes_in_storage = b + size_of::() as u32; + + // Construct `members`. + let mut members = vec![]; + for i in 0..m - 1 { + let member = account::("member", i, SEED); + members.push(member); + } + let caller = account::("caller", 0, SEED); + members.push(caller.clone()); + Collective::::set_members( + SystemOrigin::Root.into(), + members.clone(), + Some(caller.clone()), + T::MaxMembers::get(), + )?; + + // Threshold is one less than total members so that two nays will disapprove the vote + let threshold = m - 1; + + // Add proposals + let mut last_hash = T::Hash::default(); + for i in 0..p { + T::Consideration::ensure_successful(&caller, i); + + // Proposals should be different so that different proposal hashes are generated + let proposal: T::Proposal = + SystemCall::::remark { remark: id_to_remark_data(i, b as usize) }.into(); + Collective::::propose( + SystemOrigin::Signed(caller.clone()).into(), + threshold, + Box::new(proposal.clone()), + bytes_in_storage, + )?; + last_hash = T::Hashing::hash_of(&proposal); + } + + System::::set_block_number(BlockNumberFor::::max_value()); + assert_eq!(Proposals::::get().len(), p as usize); + + if d == 0 { + CostOf::::remove(last_hash); + } + let cost_present = CostOf::::get(last_hash).is_some(); + + let origin = + T::KillOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; + + #[extrinsic_call] + _(origin as ::RuntimeOrigin, last_hash); + + assert_eq!(Proposals::::get().len(), (p - 1) as usize); + assert_last_event::(Event::Killed { proposal_hash: last_hash }.into()); + if cost_present { + assert_has_event::( + Event::ProposalCostBurned { proposal_hash: last_hash, who: caller }.into(), + ); + } + Ok(()) + } + + #[benchmark] + fn release_proposal_cost() -> Result<(), BenchmarkError> { + let m = 3; + let p = T::MaxProposals::get(); + let b = MAX_BYTES; + let bytes_in_storage = b + size_of::() as u32; + + // Construct `members`. + let mut members = vec![]; + for i in 0..m - 1 { + let member = account::("member", i, SEED); + members.push(member); + } + let caller = account::("caller", 0, SEED); + members.push(caller.clone()); + Collective::::set_members( + SystemOrigin::Root.into(), + members.clone(), + Some(caller.clone()), + T::MaxMembers::get(), + )?; + + // Add proposals + let threshold = 2; + let mut last_hash = T::Hash::default(); + for i in 0..p { + T::Consideration::ensure_successful(&caller, i); + + // Proposals should be different so that different proposal hashes are generated + let proposal: T::Proposal = + SystemCall::::remark { remark: id_to_remark_data(i, b as usize) }.into(); + Collective::::propose( + SystemOrigin::Signed(caller.clone()).into(), + threshold, + Box::new(proposal.clone()), + bytes_in_storage, + )?; + last_hash = T::Hashing::hash_of(&proposal); + } + + System::::set_block_number(BlockNumberFor::::max_value()); + assert_eq!(Proposals::::get().len(), p as usize); + + assert_eq!(Proposals::::get().len(), p as usize); + let _ = Collective::::remove_proposal(last_hash); + assert_eq!(Proposals::::get().len(), (p - 1) as usize); + + let cost_present = CostOf::::get(last_hash).is_some(); + + #[extrinsic_call] + _(SystemOrigin::Signed(caller.clone()), last_hash); + + assert_eq!(CostOf::::get(last_hash), None); + if cost_present { + assert_last_event::( + Event::ProposalCostReleased { proposal_hash: last_hash, who: caller }.into(), + ); + } + Ok(()) } - impl_benchmark_test_suite!(Collective, crate::tests::ExtBuilder::default().build(), crate::tests::Test); + impl_benchmark_test_suite!( + Collective, + crate::tests::ExtBuilder::default().build(), + crate::tests::Test + ); } diff --git a/substrate/frame/collective/src/lib.rs b/substrate/frame/collective/src/lib.rs index 3544a8cddb45..79428689caaf 100644 --- a/substrate/frame/collective/src/lib.rs +++ b/substrate/frame/collective/src/lib.rs @@ -59,8 +59,8 @@ use frame_support::{ }, ensure, impl_ensure_origin_with_arg_ignoring_arg, traits::{ - Backing, ChangeMembers, EnsureOrigin, EnsureOriginWithArg, Get, GetBacking, - InitializeMembers, StorageVersion, + Backing, ChangeMembers, Consideration, EnsureOrigin, EnsureOriginWithArg, Get, GetBacking, + InitializeMembers, MaybeConsideration, StorageVersion, }, weights::Weight, }; @@ -173,6 +173,143 @@ pub struct Votes { end: BlockNumber, } +/// Types implementing various cost strategies for a given proposal count. +/// +/// These types implement [Convert](sp_runtime::traits::Convert) trait and can be used with types +/// like [HoldConsideration](`frame_support::traits::fungible::HoldConsideration`) implementing +/// [Consideration](`frame_support::traits::Consideration`) trait. +/// +/// ### Example: +/// +/// 1. Linear increasing with helper types. +#[doc = docify::embed!("src/tests.rs", deposit_types_with_linear_work)] +/// +/// 2. Geometrically increasing with helper types. +#[doc = docify::embed!("src/tests.rs", deposit_types_with_geometric_work)] +/// +/// 3. Geometrically increasing with rounding. +#[doc = docify::embed!("src/tests.rs", deposit_round_with_geometric_work)] +pub mod deposit { + use core::marker::PhantomData; + use sp_core::Get; + use sp_runtime::{traits::Convert, FixedPointNumber, FixedU128, Saturating}; + + /// Constant deposit amount regardless of current proposal count. + /// Returns `None` if configured with zero deposit. + pub struct Constant(PhantomData); + impl Convert for Constant + where + Deposit: Get, + Balance: frame_support::traits::tokens::Balance, + { + fn convert(_: u32) -> Balance { + Deposit::get() + } + } + + /// Linear increasing with some offset. + /// f(x) = ax + b, a = `Slope`, x = `proposal_count`, b = `Offset`. + pub struct Linear(PhantomData<(Slope, Offset)>); + impl Convert for Linear + where + Slope: Get, + Offset: Get, + Balance: frame_support::traits::tokens::Balance, + { + fn convert(proposal_count: u32) -> Balance { + let base: Balance = Slope::get().saturating_mul(proposal_count).into(); + Offset::get().saturating_add(base) + } + } + + /// Geometrically increasing. + /// f(x) = a * r^x, a = `Base`, x = `proposal_count`, r = `Ratio`. + pub struct Geometric(PhantomData<(Ratio, Base)>); + impl Convert for Geometric + where + Ratio: Get, + Base: Get, + Balance: frame_support::traits::tokens::Balance, + { + fn convert(proposal_count: u32) -> Balance { + Ratio::get() + .saturating_pow(proposal_count as usize) + .saturating_mul_int(Base::get()) + } + } + + /// Rounds a `Deposit` result with `Precision`. + /// Particularly useful for types like [`Geometric`] that might produce deposits with high + /// precision. + pub struct Round(PhantomData<(Precision, Deposit)>); + impl Convert for Round + where + Precision: Get, + Deposit: Convert, + Balance: frame_support::traits::tokens::Balance, + { + fn convert(proposal_count: u32) -> Balance { + let deposit = Deposit::convert(proposal_count); + if !deposit.is_zero() { + let factor: Balance = + Balance::from(10u32).saturating_pow(Precision::get() as usize); + if factor > deposit { + deposit + } else { + (deposit / factor) * factor + } + } else { + deposit + } + } + } + + /// Defines `Period` for supplied `Step` implementing [`Convert`] trait. + pub struct Stepped(PhantomData<(Period, Step)>); + impl Convert for Stepped + where + Period: Get, + Step: Convert, + Balance: frame_support::traits::tokens::Balance, + { + fn convert(proposal_count: u32) -> Balance { + let step_num = proposal_count / Period::get(); + Step::convert(step_num) + } + } + + /// Defines `Delay` for supplied `Step` implementing [`Convert`] trait. + pub struct Delayed(PhantomData<(Delay, Deposit)>); + impl Convert for Delayed + where + Delay: Get, + Deposit: Convert, + Balance: frame_support::traits::tokens::Balance, + { + fn convert(proposal_count: u32) -> Balance { + let delay = Delay::get(); + if delay > proposal_count { + return Balance::zero(); + } + let pos = proposal_count.saturating_sub(delay); + Deposit::convert(pos) + } + } + + /// Defines `Ceil` for supplied `Step` implementing [`Convert`] trait. + pub struct WithCeil(PhantomData<(Ceil, Deposit)>); + impl Convert for WithCeil + where + Ceil: Get, + Deposit: Convert, + Balance: frame_support::traits::tokens::Balance, + { + fn convert(proposal_count: u32) -> Balance { + Deposit::convert(proposal_count).min(Ceil::get()) + } + } +} + #[frame_support::pallet] pub mod pallet { use super::*; @@ -229,6 +366,27 @@ pub mod pallet { /// The maximum weight of a dispatch call that can be proposed and executed. #[pallet::constant] type MaxProposalWeight: Get; + + /// Origin from which a proposal in any status may be disapproved without associated cost + /// for a proposer. + type DisapproveOrigin: EnsureOrigin<::RuntimeOrigin>; + + /// Origin from which any malicious proposal may be killed with associated cost for a + /// proposer. + /// + /// The associated cost is set by [`Config::Consideration`] and can be none. + type KillOrigin: EnsureOrigin<::RuntimeOrigin>; + + /// Mechanism to assess the necessity of some cost for publishing and storing a proposal. + /// + /// The footprint is defined as `proposal_count`, which reflects the total number of active + /// proposals in the system, excluding the one currently being proposed. The cost may vary + /// based on this count. + /// + /// Note: If the resulting deposits are excessively high and cause benchmark failures, + /// consider using a constant cost (e.g., [`crate::deposit::Constant`]) equal to the minimum + /// balance under the `runtime-benchmarks` feature. + type Consideration: MaybeConsideration; } #[pallet::genesis_config] @@ -272,6 +430,14 @@ pub mod pallet { pub type ProposalOf, I: 'static = ()> = StorageMap<_, Identity, T::Hash, >::Proposal, OptionQuery>; + /// Consideration cost created for publishing and storing a proposal. + /// + /// Determined by [Config::Consideration] and may be not present for certain proposals (e.g. if + /// the proposal count at the time of creation was below threshold N). + #[pallet::storage] + pub type CostOf, I: 'static = ()> = + StorageMap<_, Identity, T::Hash, (T::AccountId, T::Consideration), OptionQuery>; + /// Votes on a given proposal, if it is ongoing. #[pallet::storage] pub type Voting, I: 'static = ()> = @@ -320,6 +486,12 @@ pub mod pallet { MemberExecuted { proposal_hash: T::Hash, result: DispatchResult }, /// A proposal was closed because its threshold was reached or after its duration was up. Closed { proposal_hash: T::Hash, yes: MemberCount, no: MemberCount }, + /// A proposal was killed. + Killed { proposal_hash: T::Hash }, + /// Some cost for storing a proposal was burned. + ProposalCostBurned { proposal_hash: T::Hash, who: T::AccountId }, + /// Some cost for storing a proposal was released. + ProposalCostReleased { proposal_hash: T::Hash, who: T::AccountId }, } #[pallet::error] @@ -346,6 +518,8 @@ pub mod pallet { WrongProposalLength, /// Prime account is not a member PrimeAccountNotMember, + /// Proposal is still active. + ProposalActive, } #[pallet::hooks] @@ -356,6 +530,14 @@ pub mod pallet { } } + /// A reason for the pallet placing a hold on funds. + #[pallet::composite_enum] + pub enum HoldReason { + /// Funds are held for submitting and storing a proposal. + #[codec(index = 0)] + ProposalSubmission, + } + // Note that councillor operations are assigned to the operational class. #[pallet::call] impl, I: 'static> Pallet { @@ -593,7 +775,7 @@ pub mod pallet { origin: OriginFor, proposal_hash: T::Hash, ) -> DispatchResultWithPostInfo { - ensure_root(origin)?; + T::DisapproveOrigin::ensure_origin(origin)?; let proposal_count = Self::do_disapprove_proposal(proposal_hash); Ok(Some(T::WeightInfo::disapprove_proposal(proposal_count)).into()) } @@ -648,6 +830,63 @@ pub mod pallet { Self::do_close(proposal_hash, index, proposal_weight_bound, length_bound) } + + /// Disapprove the proposal and burn the cost held for storing this proposal. + /// + /// Parameters: + /// - `origin`: must be the `KillOrigin`. + /// - `proposal_hash`: The hash of the proposal that should be killed. + /// + /// Emits `Killed` and `ProposalCostBurned` if any cost was held for a given proposal. + #[pallet::call_index(7)] + #[pallet::weight(T::WeightInfo::kill(1, T::MaxProposals::get()))] + pub fn kill(origin: OriginFor, proposal_hash: T::Hash) -> DispatchResultWithPostInfo { + T::KillOrigin::ensure_origin(origin)?; + ensure!( + ProposalOf::::get(&proposal_hash).is_some(), + Error::::ProposalMissing + ); + let burned = if let Some((who, cost)) = >::take(proposal_hash) { + cost.burn(&who); + Self::deposit_event(Event::ProposalCostBurned { proposal_hash, who }); + true + } else { + false + }; + let proposal_count = Self::remove_proposal(proposal_hash); + + Self::deposit_event(Event::Killed { proposal_hash }); + + Ok(Some(T::WeightInfo::kill(burned as u32, proposal_count)).into()) + } + + /// Release the cost held for storing a proposal once the given proposal is completed. + /// + /// If there is no associated cost for the given proposal, this call will have no effect. + /// + /// Parameters: + /// - `origin`: must be `Signed` or `Root`. + /// - `proposal_hash`: The hash of the proposal. + /// + /// Emits `ProposalCostReleased` if any cost held for a given proposal. + #[pallet::call_index(8)] + #[pallet::weight(T::WeightInfo::release_proposal_cost())] + pub fn release_proposal_cost( + origin: OriginFor, + proposal_hash: T::Hash, + ) -> DispatchResult { + let _ = ensure_signed_or_root(origin)?; + ensure!( + ProposalOf::::get(&proposal_hash).is_none(), + Error::::ProposalActive + ); + if let Some((who, cost)) = >::take(proposal_hash) { + let _ = cost.drop(&who)?; + Self::deposit_event(Event::ProposalCostReleased { proposal_hash, who }); + } + + Ok(()) + } } } @@ -718,7 +957,13 @@ impl, I: 'static> Pallet { Ok(proposals.len()) })?; + let cost = T::Consideration::new(&who, active_proposals as u32 - 1)?; + if !cost.is_none() { + >::insert(proposal_hash, (who.clone(), cost)); + } + let index = ProposalCount::::get(); + >::mutate(|i| *i += 1); >::insert(proposal_hash, proposal); let votes = { diff --git a/substrate/frame/collective/src/tests.rs b/substrate/frame/collective/src/tests.rs index 5240dc215ff7..70ce221f10d0 100644 --- a/substrate/frame/collective/src/tests.rs +++ b/substrate/frame/collective/src/tests.rs @@ -21,12 +21,19 @@ use frame_support::{ assert_noop, assert_ok, derive_impl, dispatch::Pays, parameter_types, - traits::{ConstU32, ConstU64, StorageVersion}, + traits::{ + fungible::{HoldConsideration, Inspect, Mutate}, + ConstU32, ConstU64, StorageVersion, + }, Hashable, }; use frame_system::{EnsureRoot, EventRecord, Phase}; -use sp_core::H256; -use sp_runtime::{testing::Header, traits::BlakeTwo256, BuildStorage}; +use sp_core::{ConstU128, H256}; +use sp_runtime::{ + testing::Header, + traits::{BlakeTwo256, Convert, Zero}, + BuildStorage, FixedU128, +}; pub type Block = sp_runtime::generic::Block; pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic; @@ -35,6 +42,7 @@ frame_support::construct_runtime!( pub enum Test { System: frame_system, + Balances: pallet_balances, Collective: pallet_collective::, CollectiveMajority: pallet_collective::, DefaultCollective: pallet_collective, @@ -90,7 +98,26 @@ parameter_types! { #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for Test { type Block = Block; + type AccountData = pallet_balances::AccountData; +} + +#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig as pallet_balances::DefaultConfig)] +impl pallet_balances::Config for Test { + type ReserveIdentifier = [u8; 8]; + type AccountStore = System; + type RuntimeHoldReason = RuntimeHoldReason; } + +parameter_types! { + pub ProposalDepositBase: u64 = Balances::minimum_balance() + Balances::minimum_balance(); + pub const ProposalDepositDelay: u32 = 2; + pub const ProposalHoldReason: RuntimeHoldReason = + RuntimeHoldReason::Collective(pallet_collective::HoldReason::ProposalSubmission); +} + +type CollectiveDeposit = + deposit::Delayed>; + impl Config for Test { type RuntimeOrigin = RuntimeOrigin; type Proposal = RuntimeCall; @@ -102,7 +129,14 @@ impl Config for Test { type WeightInfo = (); type SetMembersOrigin = EnsureRoot; type MaxProposalWeight = MaxProposalWeight; + type DisapproveOrigin = EnsureRoot; + type KillOrigin = EnsureRoot; + type Consideration = + HoldConsideration; } + +type CollectiveMajorityDeposit = deposit::Linear, ProposalDepositBase>; + impl Config for Test { type RuntimeOrigin = RuntimeOrigin; type Proposal = RuntimeCall; @@ -114,11 +148,22 @@ impl Config for Test { type WeightInfo = (); type SetMembersOrigin = EnsureRoot; type MaxProposalWeight = MaxProposalWeight; + // type ProposalDeposit = CollectiveMajorityDeposit; + type DisapproveOrigin = EnsureRoot; + type KillOrigin = EnsureRoot; + type Consideration = + HoldConsideration; } impl mock_democracy::Config for Test { type RuntimeEvent = RuntimeEvent; type ExternalMajorityOrigin = EnsureProportionAtLeast; } +parameter_types! { + pub const Ratio2: FixedU128 = FixedU128::from_u32(2); + pub ProposalDepositCeil: u64 = Balances::minimum_balance() * 100; +} +type DefaultCollectiveDeposit = + deposit::WithCeil>; impl Config for Test { type RuntimeOrigin = RuntimeOrigin; type Proposal = RuntimeCall; @@ -130,6 +175,12 @@ impl Config for Test { type WeightInfo = (); type SetMembersOrigin = EnsureRoot; type MaxProposalWeight = MaxProposalWeight; + // type ProposalDeposit = + // deposit::WithCeil>; + type DisapproveOrigin = EnsureRoot; + type KillOrigin = EnsureRoot; + type Consideration = + HoldConsideration; } pub struct ExtBuilder { @@ -151,6 +202,8 @@ impl ExtBuilder { pub fn build(self) -> sp_io::TestExternalities { let mut ext: sp_io::TestExternalities = RuntimeGenesisConfig { system: frame_system::GenesisConfig::default(), + // balances: pallet_balances::GenesisConfig::default(), + balances: pallet_balances::GenesisConfig { balances: vec![(1, 100), (2, 200)] }, collective: pallet_collective::GenesisConfig { members: self.collective_members, phantom: Default::default(), @@ -550,16 +603,28 @@ fn close_with_no_prime_but_majority_works() { MaxMembers::get() )); + let deposit = >::convert(0); + let ed = Balances::minimum_balance(); + let _ = Balances::mint_into(&5, ed + deposit); + System::reset_events(); + assert_ok!(CollectiveMajority::propose( - RuntimeOrigin::signed(1), + RuntimeOrigin::signed(5), 5, Box::new(proposal.clone()), proposal_len )); + assert_eq!(Balances::balance(&5), ed); + assert_ok!(CollectiveMajority::vote(RuntimeOrigin::signed(1), hash, 0, true)); assert_ok!(CollectiveMajority::vote(RuntimeOrigin::signed(2), hash, 0, true)); assert_ok!(CollectiveMajority::vote(RuntimeOrigin::signed(3), hash, 0, true)); + assert_noop!( + CollectiveMajority::release_proposal_cost(RuntimeOrigin::signed(1), hash), + Error::::ProposalActive + ); + System::set_block_number(4); assert_ok!(CollectiveMajority::close( RuntimeOrigin::signed(4), @@ -569,11 +634,14 @@ fn close_with_no_prime_but_majority_works() { proposal_len )); + assert_ok!(CollectiveMajority::release_proposal_cost(RuntimeOrigin::signed(5), hash)); + assert_eq!(Balances::balance(&5), ed + deposit); + assert_eq!( System::events(), vec![ record(RuntimeEvent::CollectiveMajority(CollectiveEvent::Proposed { - account: 1, + account: 5, proposal_index: 0, proposal_hash: hash, threshold: 5 @@ -610,6 +678,10 @@ fn close_with_no_prime_but_majority_works() { record(RuntimeEvent::CollectiveMajority(CollectiveEvent::Executed { proposal_hash: hash, result: Err(DispatchError::BadOrigin) + })), + record(RuntimeEvent::CollectiveMajority(CollectiveEvent::ProposalCostReleased { + proposal_hash: hash, + who: 5, })) ] ); @@ -757,9 +829,13 @@ fn propose_works() { #[test] fn limit_active_proposals() { ExtBuilder::default().build_and_execute(|| { + let ed = Balances::minimum_balance(); + assert_ok!(Balances::mint_into(&1, ed)); for i in 0..MaxProposals::get() { let proposal = make_proposal(i as u64); let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); + let deposit = >::convert(0); + assert_ok!(Balances::mint_into(&1, deposit)); assert_ok!(Collective::propose( RuntimeOrigin::signed(1), 3, @@ -1499,3 +1575,183 @@ fn migration_v4() { crate::migrations::v4::post_migrate::(old_pallet); }); } + +#[test] +fn kill_proposal_with_deposit() { + ExtBuilder::default().build_and_execute(|| { + let ed = Balances::minimum_balance(); + assert_ok!(Balances::mint_into(&1, ed)); + let mut last_deposit = None; + let mut last_hash = None; + for i in 0..=ProposalDepositDelay::get() { + let proposal = make_proposal(i as u64); + let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); + last_hash = Some(BlakeTwo256::hash_of(&proposal)); + let deposit = >::convert(i); + assert_ok!(Balances::mint_into(&1, deposit)); + last_deposit = Some(deposit); + + assert_ok!(Collective::propose( + RuntimeOrigin::signed(1), + 3, + Box::new(proposal.clone()), + proposal_len + )); + assert_eq!( + CostOf::::get(last_hash.unwrap()).is_none(), + deposit.is_zero() + ); + } + let balance = Balances::total_balance(&1); + System::reset_events(); + + let unpublished = make_proposal((ProposalDepositDelay::get() + 1).into()); + assert_noop!( + Collective::kill(RuntimeOrigin::root(), BlakeTwo256::hash_of(&unpublished)), + Error::::ProposalMissing + ); + + assert_ok!(Collective::kill(RuntimeOrigin::root(), last_hash.unwrap())); + assert_eq!(Balances::total_balance(&1), balance - last_deposit.unwrap()); + + assert_eq!( + System::events(), + vec![ + record(RuntimeEvent::Collective(CollectiveEvent::ProposalCostBurned { + proposal_hash: last_hash.unwrap(), + who: 1, + })), + record(RuntimeEvent::Collective(CollectiveEvent::Killed { + proposal_hash: last_hash.unwrap(), + })), + ] + ); + }) +} + +#[docify::export] +#[test] +fn deposit_types_with_linear_work() { + type LinearWithSlop2 = crate::deposit::Linear, ConstU128<10>>; + assert_eq!(>::convert(0), 10); + assert_eq!(>::convert(1), 12); + assert_eq!(>::convert(2), 14); + assert_eq!(>::convert(3), 16); + assert_eq!(>::convert(4), 18); + + type SteppedWithStep3 = crate::deposit::Stepped, LinearWithSlop2>; + assert_eq!(>::convert(0), 10); + assert_eq!(>::convert(1), 10); + assert_eq!(>::convert(2), 10); + assert_eq!(>::convert(3), 12); + assert_eq!(>::convert(4), 12); + assert_eq!(>::convert(5), 12); + assert_eq!(>::convert(6), 14); + + type DelayedWithDelay4 = crate::deposit::Delayed, SteppedWithStep3>; + assert_eq!(>::convert(0), 0); + assert_eq!(>::convert(3), 0); + assert_eq!(>::convert(4), 10); + assert_eq!(>::convert(5), 10); + assert_eq!(>::convert(6), 10); + assert_eq!(>::convert(7), 12); + assert_eq!(>::convert(9), 12); + assert_eq!(>::convert(10), 14); + assert_eq!(>::convert(13), 16); + + type WithCeil13 = crate::deposit::WithCeil, DelayedWithDelay4>; + assert_eq!(>::convert(0), 0); + assert_eq!(>::convert(4), 10); + assert_eq!(>::convert(9), 12); + assert_eq!(>::convert(10), 13); + assert_eq!(>::convert(11), 13); + assert_eq!(>::convert(13), 13); +} + +#[docify::export] +#[test] +fn deposit_types_with_geometric_work() { + parameter_types! { + pub const Ratio2: FixedU128 = FixedU128::from_u32(2); + } + type WithRatio2Base10 = crate::deposit::Geometric>; + assert_eq!(>::convert(0), 10); + assert_eq!(>::convert(1), 20); + assert_eq!(>::convert(2), 40); + assert_eq!(>::convert(3), 80); + assert_eq!(>::convert(4), 160); + assert_eq!(>::convert(5), 320); + assert_eq!(>::convert(6), 640); + assert_eq!(>::convert(7), 1280); + assert_eq!(>::convert(8), 2560); + assert_eq!(>::convert(9), 5120); + + type SteppedWithStep3 = crate::deposit::Stepped, WithRatio2Base10>; + assert_eq!(>::convert(0), 10); + assert_eq!(>::convert(1), 10); + assert_eq!(>::convert(2), 10); + assert_eq!(>::convert(3), 20); + assert_eq!(>::convert(4), 20); + assert_eq!(>::convert(5), 20); + assert_eq!(>::convert(6), 40); + + type DelayedWithDelay4 = crate::deposit::Delayed, SteppedWithStep3>; + assert_eq!(>::convert(0), 0); + assert_eq!(>::convert(3), 0); + assert_eq!(>::convert(4), 10); + assert_eq!(>::convert(5), 10); + assert_eq!(>::convert(6), 10); + assert_eq!(>::convert(7), 20); + assert_eq!(>::convert(9), 20); + assert_eq!(>::convert(10), 40); + assert_eq!(>::convert(13), 80); + + type WithCeil21 = crate::deposit::WithCeil, DelayedWithDelay4>; + assert_eq!(>::convert(0), 0); + assert_eq!(>::convert(4), 10); + assert_eq!(>::convert(9), 20); + assert_eq!(>::convert(10), 21); + assert_eq!(>::convert(11), 21); + assert_eq!(>::convert(13), 21); +} + +#[docify::export] +#[test] +fn deposit_round_with_geometric_work() { + parameter_types! { + pub const Ratio1_5: FixedU128 = FixedU128::from_rational(3, 2); + } + type WithRatio1_5Base10 = crate::deposit::Geometric>; + assert_eq!(>::convert(0), 10000); + assert_eq!(>::convert(1), 15000); + assert_eq!(>::convert(2), 22500); + assert_eq!(>::convert(3), 33750); + assert_eq!(>::convert(4), 50625); + assert_eq!(>::convert(5), 75937); + + type RoundWithPrecision3 = crate::deposit::Round, WithRatio1_5Base10>; + assert_eq!(>::convert(0), 10000); + assert_eq!(>::convert(1), 15000); + assert_eq!(>::convert(2), 22000); + assert_eq!(>::convert(3), 33000); + assert_eq!(>::convert(4), 50000); + assert_eq!(>::convert(5), 75000); +} + +#[test] +fn constant_deposit_work() { + type Constant0 = crate::deposit::Constant>; + assert_eq!(>::convert(0), 0); + assert_eq!(>::convert(1), 0); + assert_eq!(>::convert(2), 0); + + type Constant1 = crate::deposit::Constant>; + assert_eq!(>::convert(0), 1); + assert_eq!(>::convert(1), 1); + assert_eq!(>::convert(2), 1); + + type Constant12 = crate::deposit::Constant>; + assert_eq!(>::convert(0), 12); + assert_eq!(>::convert(1), 12); + assert_eq!(>::convert(2), 12); +} diff --git a/substrate/frame/collective/src/weights.rs b/substrate/frame/collective/src/weights.rs index cadfbfcbfbfb..1a7485b4ab7b 100644 --- a/substrate/frame/collective/src/weights.rs +++ b/substrate/frame/collective/src/weights.rs @@ -18,27 +18,25 @@ //! Autogenerated weights for `pallet_collective` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2024-04-08, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-09-02, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `runner-anb7yjbi-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! HOSTNAME: `runner-svzsllib-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` //! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: -// ./target/production/substrate-node +// target/production/substrate-node // benchmark // pallet -// --chain=dev // --steps=50 // --repeat=20 -// --pallet=pallet_collective -// --no-storage-info -// --no-median-slopes -// --no-min-squares // --extrinsic=* // --wasm-execution=compiled // --heap-pages=4096 -// --output=./substrate/frame/collective/src/weights.rs +// --json-file=/builds/parity/mirrors/polkadot-sdk/.git/.artifacts/bench.json +// --pallet=pallet_collective +// --chain=dev // --header=./substrate/HEADER-APACHE2 +// --output=./substrate/frame/collective/src/weights.rs // --template=./substrate/.maintain/frame-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -61,6 +59,8 @@ pub trait WeightInfo { fn close_disapproved(m: u32, p: u32, ) -> Weight; fn close_approved(b: u32, m: u32, p: u32, ) -> Weight; fn disapprove_proposal(p: u32, ) -> Weight; + fn kill(d: u32, p: u32, ) -> Weight; + fn release_proposal_cost() -> Weight; } /// Weights for `pallet_collective` using the Substrate node and recommended hardware. @@ -80,13 +80,13 @@ impl WeightInfo for SubstrateWeight { fn set_members(m: u32, _n: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0 + m * (3232 ±0) + p * (3190 ±0)` - // Estimated: `15894 + m * (1967 ±24) + p * (4332 ±24)` - // Minimum execution time: 15_780_000 picoseconds. - Weight::from_parts(16_193_000, 15894) - // Standard Error: 56_777 - .saturating_add(Weight::from_parts(4_269_920, 0).saturating_mul(m.into())) - // Standard Error: 56_777 - .saturating_add(Weight::from_parts(8_046_697, 0).saturating_mul(p.into())) + // Estimated: `15894 + m * (1967 ±23) + p * (4332 ±23)` + // Minimum execution time: 16_699_000 picoseconds. + Weight::from_parts(17_015_000, 15894) + // Standard Error: 63_844 + .saturating_add(Weight::from_parts(4_593_256, 0).saturating_mul(m.into())) + // Standard Error: 63_844 + .saturating_add(Weight::from_parts(8_935_845, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(p.into()))) .saturating_add(T::DbWeight::get().writes(2_u64)) @@ -106,12 +106,12 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `380 + m * (32 ±0)` // Estimated: `3997 + m * (32 ±0)` - // Minimum execution time: 19_760_000 picoseconds. - Weight::from_parts(18_849_113, 3997) - // Standard Error: 48 - .saturating_add(Weight::from_parts(2_076, 0).saturating_mul(b.into())) - // Standard Error: 501 - .saturating_add(Weight::from_parts(17_171, 0).saturating_mul(m.into())) + // Minimum execution time: 22_010_000 picoseconds. + Weight::from_parts(21_392_812, 3997) + // Standard Error: 34 + .saturating_add(Weight::from_parts(1_533, 0).saturating_mul(b.into())) + // Standard Error: 354 + .saturating_add(Weight::from_parts(15_866, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(Weight::from_parts(0, 32).saturating_mul(m.into())) } @@ -129,12 +129,12 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `380 + m * (32 ±0)` // Estimated: `3997 + m * (32 ±0)` - // Minimum execution time: 21_535_000 picoseconds. - Weight::from_parts(20_564_012, 3997) - // Standard Error: 66 - .saturating_add(Weight::from_parts(2_252, 0).saturating_mul(b.into())) - // Standard Error: 689 - .saturating_add(Weight::from_parts(33_509, 0).saturating_mul(m.into())) + // Minimum execution time: 24_250_000 picoseconds. + Weight::from_parts(23_545_893, 3997) + // Standard Error: 40 + .saturating_add(Weight::from_parts(1_646, 0).saturating_mul(b.into())) + // Standard Error: 421 + .saturating_add(Weight::from_parts(26_248, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(Weight::from_parts(0, 32).saturating_mul(m.into())) } @@ -144,27 +144,31 @@ impl WeightInfo for SubstrateWeight { /// Proof: `Council::ProposalOf` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `Council::Proposals` (r:1 w:1) /// Proof: `Council::Proposals` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(337), added: 2812, mode: `MaxEncodedLen`) /// Storage: `Council::ProposalCount` (r:1 w:1) /// Proof: `Council::ProposalCount` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) /// Storage: `Council::Voting` (r:0 w:1) /// Proof: `Council::Voting` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Council::CostOf` (r:0 w:1) + /// Proof: `Council::CostOf` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `b` is `[2, 1024]`. /// The range of component `m` is `[2, 100]`. /// The range of component `p` is `[1, 100]`. fn propose_proposed(b: u32, m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `525 + m * (32 ±0) + p * (36 ±0)` - // Estimated: `3917 + m * (33 ±0) + p * (36 ±0)` - // Minimum execution time: 22_759_000 picoseconds. - Weight::from_parts(21_344_363, 3917) - // Standard Error: 121 - .saturating_add(Weight::from_parts(3_231, 0).saturating_mul(b.into())) - // Standard Error: 1_265 - .saturating_add(Weight::from_parts(31_197, 0).saturating_mul(m.into())) - // Standard Error: 1_249 - .saturating_add(Weight::from_parts(200_231, 0).saturating_mul(p.into())) - .saturating_add(T::DbWeight::get().reads(4_u64)) - .saturating_add(T::DbWeight::get().writes(4_u64)) + // Measured: `618 + m * (32 ±0) + p * (36 ±0)` + // Estimated: `3991 + m * (33 ±0) + p * (36 ±0)` + // Minimum execution time: 46_538_000 picoseconds. + Weight::from_parts(63_900_448, 3991) + // Standard Error: 350 + .saturating_add(Weight::from_parts(2_827, 0).saturating_mul(b.into())) + // Standard Error: 3_658 + .saturating_add(Weight::from_parts(53_340, 0).saturating_mul(m.into())) + // Standard Error: 3_611 + .saturating_add(Weight::from_parts(213_719, 0).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(6_u64)) .saturating_add(Weight::from_parts(0, 33).saturating_mul(m.into())) .saturating_add(Weight::from_parts(0, 36).saturating_mul(p.into())) } @@ -175,12 +179,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `m` is `[5, 100]`. fn vote(m: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `974 + m * (64 ±0)` - // Estimated: `4438 + m * (64 ±0)` - // Minimum execution time: 22_935_000 picoseconds. - Weight::from_parts(23_694_302, 4438) - // Standard Error: 959 - .saturating_add(Weight::from_parts(57_721, 0).saturating_mul(m.into())) + // Measured: `1011 + m * (64 ±0)` + // Estimated: `4475 + m * (64 ±0)` + // Minimum execution time: 28_413_000 picoseconds. + Weight::from_parts(28_981_832, 4475) + // Standard Error: 665 + .saturating_add(Weight::from_parts(43_005, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 64).saturating_mul(m.into())) @@ -197,14 +201,14 @@ impl WeightInfo for SubstrateWeight { /// The range of component `p` is `[1, 100]`. fn close_early_disapproved(m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `563 + m * (64 ±0) + p * (36 ±0)` - // Estimated: `4008 + m * (65 ±0) + p * (36 ±0)` - // Minimum execution time: 25_507_000 picoseconds. - Weight::from_parts(24_849_399, 4008) - // Standard Error: 1_089 - .saturating_add(Weight::from_parts(40_933, 0).saturating_mul(m.into())) - // Standard Error: 1_062 - .saturating_add(Weight::from_parts(198_325, 0).saturating_mul(p.into())) + // Measured: `600 + m * (64 ±0) + p * (36 ±0)` + // Estimated: `4042 + m * (65 ±0) + p * (36 ±0)` + // Minimum execution time: 27_725_000 picoseconds. + Weight::from_parts(30_174_093, 4042) + // Standard Error: 1_458 + .saturating_add(Weight::from_parts(41_100, 0).saturating_mul(m.into())) + // Standard Error: 1_422 + .saturating_add(Weight::from_parts(177_303, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 65).saturating_mul(m.into())) @@ -227,16 +231,16 @@ impl WeightInfo for SubstrateWeight { /// The range of component `p` is `[1, 100]`. fn close_early_approved(b: u32, m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1010 + b * (1 ±0) + m * (64 ±0) + p * (40 ±0)` - // Estimated: `4327 + b * (1 ±0) + m * (66 ±0) + p * (40 ±0)` - // Minimum execution time: 43_927_000 picoseconds. - Weight::from_parts(43_733_720, 4327) - // Standard Error: 157 - .saturating_add(Weight::from_parts(3_737, 0).saturating_mul(b.into())) - // Standard Error: 1_664 - .saturating_add(Weight::from_parts(31_334, 0).saturating_mul(m.into())) - // Standard Error: 1_622 - .saturating_add(Weight::from_parts(222_964, 0).saturating_mul(p.into())) + // Measured: `1047 + b * (1 ±0) + m * (64 ±0) + p * (40 ±0)` + // Estimated: `4360 + b * (1 ±0) + m * (66 ±0) + p * (40 ±0)` + // Minimum execution time: 48_882_000 picoseconds. + Weight::from_parts(51_938_773, 4360) + // Standard Error: 208 + .saturating_add(Weight::from_parts(3_559, 0).saturating_mul(b.into())) + // Standard Error: 2_201 + .saturating_add(Weight::from_parts(38_678, 0).saturating_mul(m.into())) + // Standard Error: 2_145 + .saturating_add(Weight::from_parts(214_061, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(b.into())) @@ -257,14 +261,14 @@ impl WeightInfo for SubstrateWeight { /// The range of component `p` is `[1, 100]`. fn close_disapproved(m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `583 + m * (64 ±0) + p * (36 ±0)` - // Estimated: `4028 + m * (65 ±0) + p * (36 ±0)` - // Minimum execution time: 28_129_000 picoseconds. - Weight::from_parts(26_799_151, 4028) - // Standard Error: 1_325 - .saturating_add(Weight::from_parts(41_545, 0).saturating_mul(m.into())) - // Standard Error: 1_292 - .saturating_add(Weight::from_parts(224_499, 0).saturating_mul(p.into())) + // Measured: `620 + m * (64 ±0) + p * (36 ±0)` + // Estimated: `4062 + m * (65 ±0) + p * (36 ±0)` + // Minimum execution time: 30_613_000 picoseconds. + Weight::from_parts(36_174_190, 4062) + // Standard Error: 1_899 + .saturating_add(Weight::from_parts(46_781, 0).saturating_mul(m.into())) + // Standard Error: 1_851 + .saturating_add(Weight::from_parts(185_875, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 65).saturating_mul(m.into())) @@ -289,16 +293,16 @@ impl WeightInfo for SubstrateWeight { /// The range of component `p` is `[1, 100]`. fn close_approved(b: u32, m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1030 + b * (1 ±0) + m * (64 ±0) + p * (40 ±0)` - // Estimated: `4347 + b * (1 ±0) + m * (66 ±0) + p * (40 ±0)` - // Minimum execution time: 45_700_000 picoseconds. - Weight::from_parts(45_661_144, 4347) - // Standard Error: 149 - .saturating_add(Weight::from_parts(3_068, 0).saturating_mul(b.into())) - // Standard Error: 1_583 - .saturating_add(Weight::from_parts(36_426, 0).saturating_mul(m.into())) - // Standard Error: 1_543 - .saturating_add(Weight::from_parts(229_986, 0).saturating_mul(p.into())) + // Measured: `1067 + b * (1 ±0) + m * (64 ±0) + p * (40 ±0)` + // Estimated: `4380 + b * (1 ±0) + m * (66 ±0) + p * (40 ±0)` + // Minimum execution time: 51_253_000 picoseconds. + Weight::from_parts(56_399_941, 4380) + // Standard Error: 218 + .saturating_add(Weight::from_parts(2_920, 0).saturating_mul(b.into())) + // Standard Error: 2_310 + .saturating_add(Weight::from_parts(30_473, 0).saturating_mul(m.into())) + // Standard Error: 2_252 + .saturating_add(Weight::from_parts(208_468, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(b.into())) @@ -316,14 +320,62 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `392 + p * (32 ±0)` // Estimated: `1877 + p * (32 ±0)` - // Minimum execution time: 13_163_000 picoseconds. - Weight::from_parts(14_467_031, 1877) - // Standard Error: 1_073 - .saturating_add(Weight::from_parts(190_879, 0).saturating_mul(p.into())) + // Minimum execution time: 14_646_000 picoseconds. + Weight::from_parts(17_305_497, 1877) + // Standard Error: 1_331 + .saturating_add(Weight::from_parts(156_038, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 32).saturating_mul(p.into())) } + /// Storage: `Council::ProposalOf` (r:1 w:1) + /// Proof: `Council::ProposalOf` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Council::CostOf` (r:1 w:1) + /// Proof: `Council::CostOf` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(337), added: 2812, mode: `MaxEncodedLen`) + /// Storage: `Council::Proposals` (r:1 w:1) + /// Proof: `Council::Proposals` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Council::Voting` (r:0 w:1) + /// Proof: `Council::Voting` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `d` is `[0, 1]`. + /// The range of component `p` is `[1, 100]`. + fn kill(d: u32, p: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1863 + d * (212 ±0) + p * (41 ±0)` + // Estimated: `5172 + d * (1901 ±14) + p * (43 ±0)` + // Minimum execution time: 22_164_000 picoseconds. + Weight::from_parts(24_932_256, 5172) + // Standard Error: 404_014 + .saturating_add(Weight::from_parts(33_833_807, 0).saturating_mul(d.into())) + // Standard Error: 6_256 + .saturating_add(Weight::from_parts(281_910, 0).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(d.into()))) + .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(d.into()))) + .saturating_add(Weight::from_parts(0, 1901).saturating_mul(d.into())) + .saturating_add(Weight::from_parts(0, 43).saturating_mul(p.into())) + } + /// Storage: `Council::ProposalOf` (r:1 w:0) + /// Proof: `Council::ProposalOf` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Council::CostOf` (r:1 w:1) + /// Proof: `Council::CostOf` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(337), added: 2812, mode: `MaxEncodedLen`) + fn release_proposal_cost() -> Weight { + // Proof Size summary in bytes: + // Measured: `1964` + // Estimated: `5429` + // Minimum execution time: 69_220_000 picoseconds. + Weight::from_parts(70_215_000, 5429) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } } // For backwards compatibility and tests. @@ -342,13 +394,13 @@ impl WeightInfo for () { fn set_members(m: u32, _n: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0 + m * (3232 ±0) + p * (3190 ±0)` - // Estimated: `15894 + m * (1967 ±24) + p * (4332 ±24)` - // Minimum execution time: 15_780_000 picoseconds. - Weight::from_parts(16_193_000, 15894) - // Standard Error: 56_777 - .saturating_add(Weight::from_parts(4_269_920, 0).saturating_mul(m.into())) - // Standard Error: 56_777 - .saturating_add(Weight::from_parts(8_046_697, 0).saturating_mul(p.into())) + // Estimated: `15894 + m * (1967 ±23) + p * (4332 ±23)` + // Minimum execution time: 16_699_000 picoseconds. + Weight::from_parts(17_015_000, 15894) + // Standard Error: 63_844 + .saturating_add(Weight::from_parts(4_593_256, 0).saturating_mul(m.into())) + // Standard Error: 63_844 + .saturating_add(Weight::from_parts(8_935_845, 0).saturating_mul(p.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(p.into()))) .saturating_add(RocksDbWeight::get().writes(2_u64)) @@ -368,12 +420,12 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `380 + m * (32 ±0)` // Estimated: `3997 + m * (32 ±0)` - // Minimum execution time: 19_760_000 picoseconds. - Weight::from_parts(18_849_113, 3997) - // Standard Error: 48 - .saturating_add(Weight::from_parts(2_076, 0).saturating_mul(b.into())) - // Standard Error: 501 - .saturating_add(Weight::from_parts(17_171, 0).saturating_mul(m.into())) + // Minimum execution time: 22_010_000 picoseconds. + Weight::from_parts(21_392_812, 3997) + // Standard Error: 34 + .saturating_add(Weight::from_parts(1_533, 0).saturating_mul(b.into())) + // Standard Error: 354 + .saturating_add(Weight::from_parts(15_866, 0).saturating_mul(m.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(Weight::from_parts(0, 32).saturating_mul(m.into())) } @@ -391,12 +443,12 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `380 + m * (32 ±0)` // Estimated: `3997 + m * (32 ±0)` - // Minimum execution time: 21_535_000 picoseconds. - Weight::from_parts(20_564_012, 3997) - // Standard Error: 66 - .saturating_add(Weight::from_parts(2_252, 0).saturating_mul(b.into())) - // Standard Error: 689 - .saturating_add(Weight::from_parts(33_509, 0).saturating_mul(m.into())) + // Minimum execution time: 24_250_000 picoseconds. + Weight::from_parts(23_545_893, 3997) + // Standard Error: 40 + .saturating_add(Weight::from_parts(1_646, 0).saturating_mul(b.into())) + // Standard Error: 421 + .saturating_add(Weight::from_parts(26_248, 0).saturating_mul(m.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(Weight::from_parts(0, 32).saturating_mul(m.into())) } @@ -406,27 +458,31 @@ impl WeightInfo for () { /// Proof: `Council::ProposalOf` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `Council::Proposals` (r:1 w:1) /// Proof: `Council::Proposals` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(337), added: 2812, mode: `MaxEncodedLen`) /// Storage: `Council::ProposalCount` (r:1 w:1) /// Proof: `Council::ProposalCount` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) /// Storage: `Council::Voting` (r:0 w:1) /// Proof: `Council::Voting` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Council::CostOf` (r:0 w:1) + /// Proof: `Council::CostOf` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `b` is `[2, 1024]`. /// The range of component `m` is `[2, 100]`. /// The range of component `p` is `[1, 100]`. fn propose_proposed(b: u32, m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `525 + m * (32 ±0) + p * (36 ±0)` - // Estimated: `3917 + m * (33 ±0) + p * (36 ±0)` - // Minimum execution time: 22_759_000 picoseconds. - Weight::from_parts(21_344_363, 3917) - // Standard Error: 121 - .saturating_add(Weight::from_parts(3_231, 0).saturating_mul(b.into())) - // Standard Error: 1_265 - .saturating_add(Weight::from_parts(31_197, 0).saturating_mul(m.into())) - // Standard Error: 1_249 - .saturating_add(Weight::from_parts(200_231, 0).saturating_mul(p.into())) - .saturating_add(RocksDbWeight::get().reads(4_u64)) - .saturating_add(RocksDbWeight::get().writes(4_u64)) + // Measured: `618 + m * (32 ±0) + p * (36 ±0)` + // Estimated: `3991 + m * (33 ±0) + p * (36 ±0)` + // Minimum execution time: 46_538_000 picoseconds. + Weight::from_parts(63_900_448, 3991) + // Standard Error: 350 + .saturating_add(Weight::from_parts(2_827, 0).saturating_mul(b.into())) + // Standard Error: 3_658 + .saturating_add(Weight::from_parts(53_340, 0).saturating_mul(m.into())) + // Standard Error: 3_611 + .saturating_add(Weight::from_parts(213_719, 0).saturating_mul(p.into())) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(6_u64)) .saturating_add(Weight::from_parts(0, 33).saturating_mul(m.into())) .saturating_add(Weight::from_parts(0, 36).saturating_mul(p.into())) } @@ -437,12 +493,12 @@ impl WeightInfo for () { /// The range of component `m` is `[5, 100]`. fn vote(m: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `974 + m * (64 ±0)` - // Estimated: `4438 + m * (64 ±0)` - // Minimum execution time: 22_935_000 picoseconds. - Weight::from_parts(23_694_302, 4438) - // Standard Error: 959 - .saturating_add(Weight::from_parts(57_721, 0).saturating_mul(m.into())) + // Measured: `1011 + m * (64 ±0)` + // Estimated: `4475 + m * (64 ±0)` + // Minimum execution time: 28_413_000 picoseconds. + Weight::from_parts(28_981_832, 4475) + // Standard Error: 665 + .saturating_add(Weight::from_parts(43_005, 0).saturating_mul(m.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 64).saturating_mul(m.into())) @@ -459,14 +515,14 @@ impl WeightInfo for () { /// The range of component `p` is `[1, 100]`. fn close_early_disapproved(m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `563 + m * (64 ±0) + p * (36 ±0)` - // Estimated: `4008 + m * (65 ±0) + p * (36 ±0)` - // Minimum execution time: 25_507_000 picoseconds. - Weight::from_parts(24_849_399, 4008) - // Standard Error: 1_089 - .saturating_add(Weight::from_parts(40_933, 0).saturating_mul(m.into())) - // Standard Error: 1_062 - .saturating_add(Weight::from_parts(198_325, 0).saturating_mul(p.into())) + // Measured: `600 + m * (64 ±0) + p * (36 ±0)` + // Estimated: `4042 + m * (65 ±0) + p * (36 ±0)` + // Minimum execution time: 27_725_000 picoseconds. + Weight::from_parts(30_174_093, 4042) + // Standard Error: 1_458 + .saturating_add(Weight::from_parts(41_100, 0).saturating_mul(m.into())) + // Standard Error: 1_422 + .saturating_add(Weight::from_parts(177_303, 0).saturating_mul(p.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 65).saturating_mul(m.into())) @@ -489,16 +545,16 @@ impl WeightInfo for () { /// The range of component `p` is `[1, 100]`. fn close_early_approved(b: u32, m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1010 + b * (1 ±0) + m * (64 ±0) + p * (40 ±0)` - // Estimated: `4327 + b * (1 ±0) + m * (66 ±0) + p * (40 ±0)` - // Minimum execution time: 43_927_000 picoseconds. - Weight::from_parts(43_733_720, 4327) - // Standard Error: 157 - .saturating_add(Weight::from_parts(3_737, 0).saturating_mul(b.into())) - // Standard Error: 1_664 - .saturating_add(Weight::from_parts(31_334, 0).saturating_mul(m.into())) - // Standard Error: 1_622 - .saturating_add(Weight::from_parts(222_964, 0).saturating_mul(p.into())) + // Measured: `1047 + b * (1 ±0) + m * (64 ±0) + p * (40 ±0)` + // Estimated: `4360 + b * (1 ±0) + m * (66 ±0) + p * (40 ±0)` + // Minimum execution time: 48_882_000 picoseconds. + Weight::from_parts(51_938_773, 4360) + // Standard Error: 208 + .saturating_add(Weight::from_parts(3_559, 0).saturating_mul(b.into())) + // Standard Error: 2_201 + .saturating_add(Weight::from_parts(38_678, 0).saturating_mul(m.into())) + // Standard Error: 2_145 + .saturating_add(Weight::from_parts(214_061, 0).saturating_mul(p.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(b.into())) @@ -519,14 +575,14 @@ impl WeightInfo for () { /// The range of component `p` is `[1, 100]`. fn close_disapproved(m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `583 + m * (64 ±0) + p * (36 ±0)` - // Estimated: `4028 + m * (65 ±0) + p * (36 ±0)` - // Minimum execution time: 28_129_000 picoseconds. - Weight::from_parts(26_799_151, 4028) - // Standard Error: 1_325 - .saturating_add(Weight::from_parts(41_545, 0).saturating_mul(m.into())) - // Standard Error: 1_292 - .saturating_add(Weight::from_parts(224_499, 0).saturating_mul(p.into())) + // Measured: `620 + m * (64 ±0) + p * (36 ±0)` + // Estimated: `4062 + m * (65 ±0) + p * (36 ±0)` + // Minimum execution time: 30_613_000 picoseconds. + Weight::from_parts(36_174_190, 4062) + // Standard Error: 1_899 + .saturating_add(Weight::from_parts(46_781, 0).saturating_mul(m.into())) + // Standard Error: 1_851 + .saturating_add(Weight::from_parts(185_875, 0).saturating_mul(p.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 65).saturating_mul(m.into())) @@ -551,16 +607,16 @@ impl WeightInfo for () { /// The range of component `p` is `[1, 100]`. fn close_approved(b: u32, m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1030 + b * (1 ±0) + m * (64 ±0) + p * (40 ±0)` - // Estimated: `4347 + b * (1 ±0) + m * (66 ±0) + p * (40 ±0)` - // Minimum execution time: 45_700_000 picoseconds. - Weight::from_parts(45_661_144, 4347) - // Standard Error: 149 - .saturating_add(Weight::from_parts(3_068, 0).saturating_mul(b.into())) - // Standard Error: 1_583 - .saturating_add(Weight::from_parts(36_426, 0).saturating_mul(m.into())) - // Standard Error: 1_543 - .saturating_add(Weight::from_parts(229_986, 0).saturating_mul(p.into())) + // Measured: `1067 + b * (1 ±0) + m * (64 ±0) + p * (40 ±0)` + // Estimated: `4380 + b * (1 ±0) + m * (66 ±0) + p * (40 ±0)` + // Minimum execution time: 51_253_000 picoseconds. + Weight::from_parts(56_399_941, 4380) + // Standard Error: 218 + .saturating_add(Weight::from_parts(2_920, 0).saturating_mul(b.into())) + // Standard Error: 2_310 + .saturating_add(Weight::from_parts(30_473, 0).saturating_mul(m.into())) + // Standard Error: 2_252 + .saturating_add(Weight::from_parts(208_468, 0).saturating_mul(p.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(b.into())) @@ -578,12 +634,60 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `392 + p * (32 ±0)` // Estimated: `1877 + p * (32 ±0)` - // Minimum execution time: 13_163_000 picoseconds. - Weight::from_parts(14_467_031, 1877) - // Standard Error: 1_073 - .saturating_add(Weight::from_parts(190_879, 0).saturating_mul(p.into())) + // Minimum execution time: 14_646_000 picoseconds. + Weight::from_parts(17_305_497, 1877) + // Standard Error: 1_331 + .saturating_add(Weight::from_parts(156_038, 0).saturating_mul(p.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 32).saturating_mul(p.into())) } + /// Storage: `Council::ProposalOf` (r:1 w:1) + /// Proof: `Council::ProposalOf` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Council::CostOf` (r:1 w:1) + /// Proof: `Council::CostOf` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(337), added: 2812, mode: `MaxEncodedLen`) + /// Storage: `Council::Proposals` (r:1 w:1) + /// Proof: `Council::Proposals` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Council::Voting` (r:0 w:1) + /// Proof: `Council::Voting` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `d` is `[0, 1]`. + /// The range of component `p` is `[1, 100]`. + fn kill(d: u32, p: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1863 + d * (212 ±0) + p * (41 ±0)` + // Estimated: `5172 + d * (1901 ±14) + p * (43 ±0)` + // Minimum execution time: 22_164_000 picoseconds. + Weight::from_parts(24_932_256, 5172) + // Standard Error: 404_014 + .saturating_add(Weight::from_parts(33_833_807, 0).saturating_mul(d.into())) + // Standard Error: 6_256 + .saturating_add(Weight::from_parts(281_910, 0).saturating_mul(p.into())) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().reads((2_u64).saturating_mul(d.into()))) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + .saturating_add(RocksDbWeight::get().writes((3_u64).saturating_mul(d.into()))) + .saturating_add(Weight::from_parts(0, 1901).saturating_mul(d.into())) + .saturating_add(Weight::from_parts(0, 43).saturating_mul(p.into())) + } + /// Storage: `Council::ProposalOf` (r:1 w:0) + /// Proof: `Council::ProposalOf` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Council::CostOf` (r:1 w:1) + /// Proof: `Council::CostOf` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(337), added: 2812, mode: `MaxEncodedLen`) + fn release_proposal_cost() -> Weight { + // Proof Size summary in bytes: + // Measured: `1964` + // Estimated: `5429` + // Minimum execution time: 69_220_000 picoseconds. + Weight::from_parts(70_215_000, 5429) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } } diff --git a/substrate/frame/utility/src/tests.rs b/substrate/frame/utility/src/tests.rs index 0a58a92b4c9e..9755efaea41a 100644 --- a/substrate/frame/utility/src/tests.rs +++ b/substrate/frame/utility/src/tests.rs @@ -29,6 +29,7 @@ use frame_support::{ traits::{ConstU64, Contains}, weights::Weight, }; +use frame_system::EnsureRoot; use pallet_collective::{EnsureProportionAtLeast, Instance1}; use sp_runtime::{ traits::{BadOrigin, BlakeTwo256, Dispatchable, Hash}, @@ -189,6 +190,9 @@ impl pallet_collective::Config for Test { type WeightInfo = (); type SetMembersOrigin = frame_system::EnsureRoot; type MaxProposalWeight = MaxProposalWeight; + type DisapproveOrigin = EnsureRoot; + type KillOrigin = EnsureRoot; + type Consideration = (); } impl example::Config for Test {}