From f8d2e880e3352a212373856b264a41f4f816522d Mon Sep 17 00:00:00 2001 From: muharem Date: Wed, 26 Oct 2022 21:49:56 +0200 Subject: [PATCH 01/29] referenda metadata --- bin/node/runtime/src/lib.rs | 10 +++++ frame/referenda/src/lib.rs | 79 ++++++++++++++++++++++++++++++++++-- frame/referenda/src/mock.rs | 11 ++++- frame/referenda/src/types.rs | 16 +++++++- 4 files changed, 111 insertions(+), 5 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index f137b36eff036..20fecd02267dc 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -847,6 +847,14 @@ impl pallet_referenda::TracksInfo for TracksInfo { } pallet_referenda::impl_tracksinfo_get!(TracksInfo, Balance, BlockNumber); +#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, scale_info::TypeInfo, MaxEncodedLen)] +pub enum MetadataSchema { + IpfsJsonV1, + IpfsJsonV2, + BinJsonV1, + BinJsonV2, +} + impl pallet_referenda::Config for Runtime { type WeightInfo = pallet_referenda::weights::SubstrateWeight; type RuntimeCall = RuntimeCall; @@ -865,6 +873,7 @@ impl pallet_referenda::Config for Runtime { type AlarmInterval = AlarmInterval; type Tracks = TracksInfo; type Preimages = Preimage; + type MetadataSchema = MetadataSchema; } impl pallet_referenda::Config for Runtime { @@ -885,6 +894,7 @@ impl pallet_referenda::Config for Runtime { type AlarmInterval = AlarmInterval; type Tracks = TracksInfo; type Preimages = Preimage; + type MetadataSchema = MetadataSchema; } impl pallet_ranked_collective::Config for Runtime { diff --git a/frame/referenda/src/lib.rs b/frame/referenda/src/lib.rs index 1bdc19d49c414..9e0283ee2fa30 100644 --- a/frame/referenda/src/lib.rs +++ b/frame/referenda/src/lib.rs @@ -93,9 +93,9 @@ pub use self::{ pallet::*, types::{ BalanceOf, BoundedCallOf, CallOf, Curve, DecidingStatus, DecidingStatusOf, Deposit, - InsertSorted, NegativeImbalanceOf, PalletsOriginOf, ReferendumIndex, ReferendumInfo, - ReferendumInfoOf, ReferendumStatus, ReferendumStatusOf, ScheduleAddressOf, TallyOf, - TrackIdOf, TrackInfo, TrackInfoOf, TracksInfo, VotesOf, + InsertSorted, MetadataOf, NegativeImbalanceOf, PalletsOriginOf, ReferendumIndex, + ReferendumInfo, ReferendumInfoOf, ReferendumStatus, ReferendumStatusOf, ScheduleAddressOf, + TallyOf, TrackIdOf, TrackInfo, TrackInfoOf, TracksInfo, VotesOf, }, weights::WeightInfo, }; @@ -217,6 +217,11 @@ pub mod pallet { /// The preimage provider. type Preimages: QueryPreimage + StorePreimage; + + /// The schema type of the referendum [`MetadataOf`]. + /// e.g. enum of `IpfsJsonV1` (the hash of an off-chain IPFS json file), + /// `BinJsonV2` (on-chain json dump). + type MetadataSchema: Clone + Codec + Eq + Debug + TypeInfo + MaxEncodedLen; } /// The next free referendum index, aka the number of referenda started so far. @@ -246,6 +251,11 @@ pub mod pallet { pub type DecidingCount, I: 'static = ()> = StorageMap<_, Twox64Concat, TrackIdOf, u32, ValueQuery>; + /// The metadata of the referendum. + #[pallet::storage] + pub type MetadataFor, I: 'static = ()> = + StorageMap<_, Blake2_128Concat, ReferendumIndex, MetadataOf>; + #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event, I: 'static = ()> { @@ -342,6 +352,16 @@ pub mod pallet { /// The final tally of votes in this referendum. tally: T::Tally, }, + /// Metadata for a referendum has been set. + MetadataSet { + /// Index of the referendum. + index: ReferendumIndex, + }, + /// Metadata for a referendum has been cleared. + MetadataCleared { + /// Index of the referendum. + index: ReferendumIndex, + }, } #[pallet::error] @@ -368,6 +388,8 @@ pub mod pallet { NoPermission, /// The deposit cannot be refunded since none was made. NoDeposit, + /// The metadata preimage for a given hash does not exist. + BadMetadata, } #[pallet::call] @@ -519,6 +541,7 @@ pub mod pallet { Self::deposit_event(Event::::Killed { index, tally: status.tally }); Self::slash_deposit(Some(status.submission_deposit.clone())); Self::slash_deposit(status.decision_deposit.clone()); + Self::do_clear_metadata(index); let info = ReferendumInfo::Killed(frame_system::Pallet::::block_number()); ReferendumInfoFor::::insert(index, info); Ok(()) @@ -579,6 +602,46 @@ pub mod pallet { }; Ok(Some(branch.weight::()).into()) } + + /// Set the metadata to an ongoing referendum. + /// + /// - `origin`: Must be `Signed`, and the creator of the referendum. + /// - `index`: The index of the referendum to add metadata for. + /// - `metadata`: The metadata of the referendum. + // TODO replace the weight function + #[pallet::weight(1)] + pub fn set_metadata( + origin: OriginFor, + index: ReferendumIndex, + metadata: MetadataOf, + ) -> DispatchResult { + let who = ensure_signed(origin)?; + let status = Self::ensure_ongoing(index)?; + ensure!(status.submission_deposit.who == who, Error::::NoPermission); + ensure!(T::Preimages::len(&metadata.hash).is_some(), Error::::BadMetadata); + + T::Preimages::request(&metadata.hash); + MetadataFor::::insert(index, metadata); + + Self::deposit_event(Event::::MetadataSet { index }); + Ok(()) + } + + /// Clear the ongoing referendum metadata. + /// + /// - `origin`: Must be `Signed`. If the referendum is ongoing, it must also be the creator + /// of the referendum. + /// - `index`: The index of the ongoing referendum to clear metadata for. + // TODO replace the weight function + #[pallet::weight(1)] + pub fn clear_metadata(origin: OriginFor, index: ReferendumIndex) -> DispatchResult { + let who = ensure_signed(origin)?; + if let Some(status) = Self::ensure_ongoing(index).ok() { + ensure!(status.submission_deposit.who == who, Error::::NoPermission); + } + Self::do_clear_metadata(index); + Ok(()) + } } } @@ -1137,4 +1200,14 @@ impl, I: 'static> Pallet { support_needed.passing(x, tally.support(id)) && approval_needed.passing(x, tally.approval(id)) } + + /// Clear metadata, if `Some` and unrequest associated preimage. + fn do_clear_metadata(index: ReferendumIndex) { + if let Some(metadata) = MetadataFor::::take(index) { + if T::Preimages::is_requested(&metadata.hash) { + T::Preimages::unrequest(&metadata.hash); + } + Self::deposit_event(Event::::MetadataCleared { index }); + } + } } diff --git a/frame/referenda/src/mock.rs b/frame/referenda/src/mock.rs index c98fbf9a676b1..8b40fd0acc219 100644 --- a/frame/referenda/src/mock.rs +++ b/frame/referenda/src/mock.rs @@ -33,7 +33,7 @@ use sp_core::H256; use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup}, - DispatchResult, Perbill, + DispatchResult, Perbill, RuntimeDebug, }; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; @@ -61,6 +61,14 @@ impl Contains for BaseFilter { } } +#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo, MaxEncodedLen)] +pub enum MetadataSchema { + IpfsJsonV1, + IpfsJsonV2, + BinJsonV1, + BinJsonV2, +} + parameter_types! { pub MaxWeight: Weight = Weight::from_ref_time(2_000_000_000_000); pub BlockWeights: frame_system::limits::BlockWeights = @@ -228,6 +236,7 @@ impl Config for Test { type AlarmInterval = AlarmInterval; type Tracks = TestTracksInfo; type Preimages = Preimage; + type MetadataSchema = MetadataSchema; } pub fn new_test_ext() -> sp_io::TestExternalities { diff --git a/frame/referenda/src/types.rs b/frame/referenda/src/types.rs index 2ce93cb6adc3c..388e047d7af4a 100644 --- a/frame/referenda/src/types.rs +++ b/frame/referenda/src/types.rs @@ -20,7 +20,7 @@ use super::*; use codec::{Decode, Encode, EncodeLike, MaxEncodedLen}; use frame_support::{ - traits::{schedule::v3::Anon, Bounded}, + traits::{schedule::v3::Anon, Bounded, Hash as PreimageHash}, Parameter, }; use scale_info::TypeInfo; @@ -72,6 +72,8 @@ pub type ScheduleAddressOf = <>::Scheduler as Anon< PalletsOriginOf, >>::Address; +pub type MetadataOf = Metadata<>::MetadataSchema>; + /// A referendum index. pub type ReferendumIndex = u32; @@ -512,6 +514,18 @@ impl Debug for Curve { } } +/// General information about the item referring to the metadata. +#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo, MaxEncodedLen)] +pub struct Metadata { + /// The schema/s descriptor of the data the preimage `hash` referring to. + /// e.g. enum of `IpfsJsonV1` (the hash of an off-chain IPFS json file), + /// `BinJsonV2` (on-chain json dump). + pub(super) schema: Schema, + + /// The hash of the preimage holding the data of the `schema`. + pub(super) hash: PreimageHash, +} + #[cfg(test)] mod tests { use super::*; From cba72829797166a2a0e156c28580c0fc34adf45f Mon Sep 17 00:00:00 2001 From: muharem Date: Wed, 26 Oct 2022 21:58:17 +0200 Subject: [PATCH 02/29] todo comment --- frame/referenda/src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/frame/referenda/src/lib.rs b/frame/referenda/src/lib.rs index 9e0283ee2fa30..66fe41e5837bf 100644 --- a/frame/referenda/src/lib.rs +++ b/frame/referenda/src/lib.rs @@ -497,6 +497,8 @@ pub mod pallet { amount: deposit.amount, }; Self::deposit_event(e); + // TODO schedule (e.g. in 30 days) the preimage unregister to remove the preimage from + // the chain Ok(()) } From 40d4bc3ebe5c1dbb56ec2d236954e15d51590783 Mon Sep 17 00:00:00 2001 From: muharem Date: Thu, 27 Oct 2022 03:08:41 +0200 Subject: [PATCH 03/29] remove TODO, update rustdocs --- frame/referenda/src/lib.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/frame/referenda/src/lib.rs b/frame/referenda/src/lib.rs index 66fe41e5837bf..f98c618eda66f 100644 --- a/frame/referenda/src/lib.rs +++ b/frame/referenda/src/lib.rs @@ -221,6 +221,8 @@ pub mod pallet { /// The schema type of the referendum [`MetadataOf`]. /// e.g. enum of `IpfsJsonV1` (the hash of an off-chain IPFS json file), /// `BinJsonV2` (on-chain json dump). + /// Consider a garbage collection for [`MetadataFor`] of finished referendums + /// to `unrequest` large preimages. type MetadataSchema: Clone + Codec + Eq + Debug + TypeInfo + MaxEncodedLen; } @@ -497,8 +499,6 @@ pub mod pallet { amount: deposit.amount, }; Self::deposit_event(e); - // TODO schedule (e.g. in 30 days) the preimage unregister to remove the preimage from - // the chain Ok(()) } @@ -621,10 +621,8 @@ pub mod pallet { let status = Self::ensure_ongoing(index)?; ensure!(status.submission_deposit.who == who, Error::::NoPermission); ensure!(T::Preimages::len(&metadata.hash).is_some(), Error::::BadMetadata); - T::Preimages::request(&metadata.hash); MetadataFor::::insert(index, metadata); - Self::deposit_event(Event::::MetadataSet { index }); Ok(()) } From 9a868668817c931543eae35a064a0d47e2aa5de7 Mon Sep 17 00:00:00 2001 From: muharem Date: Thu, 27 Oct 2022 18:01:16 +0200 Subject: [PATCH 04/29] referenda clear_metadata origin signed or root --- frame/referenda/src/lib.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/frame/referenda/src/lib.rs b/frame/referenda/src/lib.rs index f98c618eda66f..35cb1675bac78 100644 --- a/frame/referenda/src/lib.rs +++ b/frame/referenda/src/lib.rs @@ -627,17 +627,19 @@ pub mod pallet { Ok(()) } - /// Clear the ongoing referendum metadata. + /// Clear the referendum metadata. /// - /// - `origin`: Must be `Signed`. If the referendum is ongoing, it must also be the creator - /// of the referendum. + /// - `origin`: Must be `Signed` or `Root`. If the referendum is ongoing, it must also be + /// the creator of the referendum. /// - `index`: The index of the ongoing referendum to clear metadata for. // TODO replace the weight function #[pallet::weight(1)] pub fn clear_metadata(origin: OriginFor, index: ReferendumIndex) -> DispatchResult { - let who = ensure_signed(origin)?; - if let Some(status) = Self::ensure_ongoing(index).ok() { - ensure!(status.submission_deposit.who == who, Error::::NoPermission); + let maybe_who = ensure_signed_or_root(origin)?; + if let Some(who) = maybe_who { + if let Some(status) = Self::ensure_ongoing(index).ok() { + ensure!(status.submission_deposit.who == who, Error::::NoPermission); + } } Self::do_clear_metadata(index); Ok(()) From 05d7b4dc0371489857ff65a25e647b3ad7863ee8 Mon Sep 17 00:00:00 2001 From: muharem Date: Thu, 27 Oct 2022 19:03:33 +0200 Subject: [PATCH 05/29] referenda metadata unit tests --- frame/referenda/src/tests.rs | 79 ++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/frame/referenda/src/tests.rs b/frame/referenda/src/tests.rs index 355ce3021b87f..1045a7e17737e 100644 --- a/frame/referenda/src/tests.rs +++ b/frame/referenda/src/tests.rs @@ -519,3 +519,82 @@ fn curve_handles_all_inputs() { let threshold = test_curve.threshold(Perbill::one()); assert_eq!(threshold, Perbill::zero()); } + +#[test] +fn set_metadata_works() { + new_test_ext().execute_with(|| { + use sp_std::borrow::Cow; + + let invalid_metadata = + MetadataOf:: { schema: MetadataSchema::IpfsJsonV1, hash: [1u8; 32].into() }; + let metadata = MetadataOf:: { + schema: MetadataSchema::IpfsJsonV1, + hash: Preimage::note(Cow::from(vec![1])).unwrap(), + }; + + // fails to set metadata for a finished referendum. + assert_ok!(Referenda::submit( + RuntimeOrigin::signed(1), + Box::new(RawOrigin::Root.into()), + set_balance_proposal_bounded(1), + DispatchTime::At(1), + )); + let index = ReferendumCount::::get() - 1; + assert_ok!(Referenda::kill(RuntimeOrigin::root(), index)); + assert_noop!( + Referenda::set_metadata(RuntimeOrigin::signed(1), index, invalid_metadata.clone(),), + Error::::NotOngoing, + ); + // no permission to set metadata + assert_ok!(Referenda::submit( + RuntimeOrigin::signed(1), + Box::new(RawOrigin::Root.into()), + set_balance_proposal_bounded(1), + DispatchTime::At(1), + )); + let index = ReferendumCount::::get() - 1; + assert_noop!( + Referenda::set_metadata(RuntimeOrigin::signed(2), index, invalid_metadata.clone(),), + Error::::NoPermission, + ); + // preimage does not exist + let index = ReferendumCount::::get() - 1; + assert_noop!( + Referenda::set_metadata(RuntimeOrigin::signed(1), index, invalid_metadata,), + Error::::BadMetadata, + ); + // metadata set + let index = ReferendumCount::::get() - 1; + assert_ok!(Referenda::set_metadata(RuntimeOrigin::signed(1), index, metadata.clone(),)); + System::assert_last_event(RuntimeEvent::Referenda(crate::Event::MetadataSet { index })); + assert!(Preimage::is_requested(&metadata.hash)); + }); +} + +#[test] +fn clear_metadata_works() { + new_test_ext().execute_with(|| { + use sp_std::borrow::Cow; + + let metadata = MetadataOf:: { + schema: MetadataSchema::IpfsJsonV1, + hash: Preimage::note(Cow::from(vec![1, 2])).unwrap(), + }; + + assert_ok!(Referenda::submit( + RuntimeOrigin::signed(1), + Box::new(RawOrigin::Root.into()), + set_balance_proposal_bounded(1), + DispatchTime::At(1), + )); + let index = ReferendumCount::::get() - 1; + assert_ok!(Referenda::set_metadata(RuntimeOrigin::signed(1), index, metadata.clone(),)); + assert!(Preimage::is_requested(&metadata.hash)); + assert_noop!( + Referenda::clear_metadata(RuntimeOrigin::signed(2), index,), + Error::::NoPermission, + ); + assert_ok!(Referenda::clear_metadata(RuntimeOrigin::signed(1), index,),); + System::assert_last_event(RuntimeEvent::Referenda(crate::Event::MetadataCleared { index })); + }); +} From 746afcf537b33a22bf37a7933d865f18673d1bb6 Mon Sep 17 00:00:00 2001 From: muharem Date: Fri, 28 Oct 2022 10:16:07 +0200 Subject: [PATCH 06/29] drop schema type for referenda metadata --- frame/referenda/src/lib.rs | 44 +++++++++++++++++------------------- frame/referenda/src/mock.rs | 11 +-------- frame/referenda/src/tests.rs | 41 ++++++++++++++------------------- frame/referenda/src/types.rs | 4 +--- 4 files changed, 40 insertions(+), 60 deletions(-) diff --git a/frame/referenda/src/lib.rs b/frame/referenda/src/lib.rs index 35cb1675bac78..d9eba38d22311 100644 --- a/frame/referenda/src/lib.rs +++ b/frame/referenda/src/lib.rs @@ -72,8 +72,8 @@ use frame_support::{ v3::{Anon as ScheduleAnon, Named as ScheduleNamed}, DispatchTime, }, - Currency, LockIdentifier, OnUnbalanced, OriginTrait, PollStatus, Polling, QueryPreimage, - ReservableCurrency, StorePreimage, VoteTally, + Currency, Hash as PreimageHash, LockIdentifier, OnUnbalanced, OriginTrait, PollStatus, + Polling, QueryPreimage, ReservableCurrency, StorePreimage, VoteTally, }, BoundedVec, }; @@ -93,9 +93,9 @@ pub use self::{ pallet::*, types::{ BalanceOf, BoundedCallOf, CallOf, Curve, DecidingStatus, DecidingStatusOf, Deposit, - InsertSorted, MetadataOf, NegativeImbalanceOf, PalletsOriginOf, ReferendumIndex, - ReferendumInfo, ReferendumInfoOf, ReferendumStatus, ReferendumStatusOf, ScheduleAddressOf, - TallyOf, TrackIdOf, TrackInfo, TrackInfoOf, TracksInfo, VotesOf, + InsertSorted, NegativeImbalanceOf, PalletsOriginOf, ReferendumIndex, ReferendumInfo, + ReferendumInfoOf, ReferendumStatus, ReferendumStatusOf, ScheduleAddressOf, TallyOf, + TrackIdOf, TrackInfo, TrackInfoOf, TracksInfo, VotesOf, }, weights::WeightInfo, }; @@ -217,13 +217,6 @@ pub mod pallet { /// The preimage provider. type Preimages: QueryPreimage + StorePreimage; - - /// The schema type of the referendum [`MetadataOf`]. - /// e.g. enum of `IpfsJsonV1` (the hash of an off-chain IPFS json file), - /// `BinJsonV2` (on-chain json dump). - /// Consider a garbage collection for [`MetadataFor`] of finished referendums - /// to `unrequest` large preimages. - type MetadataSchema: Clone + Codec + Eq + Debug + TypeInfo + MaxEncodedLen; } /// The next free referendum index, aka the number of referenda started so far. @@ -253,10 +246,15 @@ pub mod pallet { pub type DecidingCount, I: 'static = ()> = StorageMap<_, Twox64Concat, TrackIdOf, u32, ValueQuery>; - /// The metadata of the referendum. + /// The metadata is a general information concerning the referendum. + /// The `PreimageHash` refers to the preimage of the `Preimages` provider which can be a JSON + /// dump or IPFS hash of a JSON file. + /// + /// Consider a garbage collection for a metadata of finished referendums to `unrequest` (remove) + /// large preimages. #[pallet::storage] - pub type MetadataFor, I: 'static = ()> = - StorageMap<_, Blake2_128Concat, ReferendumIndex, MetadataOf>; + pub type MetadataOf, I: 'static = ()> = + StorageMap<_, Blake2_128Concat, ReferendumIndex, PreimageHash>; #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] @@ -609,20 +607,20 @@ pub mod pallet { /// /// - `origin`: Must be `Signed`, and the creator of the referendum. /// - `index`: The index of the referendum to add metadata for. - /// - `metadata`: The metadata of the referendum. + /// - `hash`: The preimage hash of an existing preimage. // TODO replace the weight function #[pallet::weight(1)] pub fn set_metadata( origin: OriginFor, index: ReferendumIndex, - metadata: MetadataOf, + hash: PreimageHash, ) -> DispatchResult { let who = ensure_signed(origin)?; let status = Self::ensure_ongoing(index)?; ensure!(status.submission_deposit.who == who, Error::::NoPermission); - ensure!(T::Preimages::len(&metadata.hash).is_some(), Error::::BadMetadata); - T::Preimages::request(&metadata.hash); - MetadataFor::::insert(index, metadata); + ensure!(T::Preimages::len(&hash).is_some(), Error::::BadMetadata); + T::Preimages::request(&hash); + MetadataOf::::insert(index, hash); Self::deposit_event(Event::::MetadataSet { index }); Ok(()) } @@ -1205,9 +1203,9 @@ impl, I: 'static> Pallet { /// Clear metadata, if `Some` and unrequest associated preimage. fn do_clear_metadata(index: ReferendumIndex) { - if let Some(metadata) = MetadataFor::::take(index) { - if T::Preimages::is_requested(&metadata.hash) { - T::Preimages::unrequest(&metadata.hash); + if let Some(hash) = MetadataOf::::take(index) { + if T::Preimages::is_requested(&hash) { + T::Preimages::unrequest(&hash); } Self::deposit_event(Event::::MetadataCleared { index }); } diff --git a/frame/referenda/src/mock.rs b/frame/referenda/src/mock.rs index 8b40fd0acc219..c98fbf9a676b1 100644 --- a/frame/referenda/src/mock.rs +++ b/frame/referenda/src/mock.rs @@ -33,7 +33,7 @@ use sp_core::H256; use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup}, - DispatchResult, Perbill, RuntimeDebug, + DispatchResult, Perbill, }; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; @@ -61,14 +61,6 @@ impl Contains for BaseFilter { } } -#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo, MaxEncodedLen)] -pub enum MetadataSchema { - IpfsJsonV1, - IpfsJsonV2, - BinJsonV1, - BinJsonV2, -} - parameter_types! { pub MaxWeight: Weight = Weight::from_ref_time(2_000_000_000_000); pub BlockWeights: frame_system::limits::BlockWeights = @@ -236,7 +228,6 @@ impl Config for Test { type AlarmInterval = AlarmInterval; type Tracks = TestTracksInfo; type Preimages = Preimage; - type MetadataSchema = MetadataSchema; } pub fn new_test_ext() -> sp_io::TestExternalities { diff --git a/frame/referenda/src/tests.rs b/frame/referenda/src/tests.rs index 1045a7e17737e..9a1e9208ee02c 100644 --- a/frame/referenda/src/tests.rs +++ b/frame/referenda/src/tests.rs @@ -524,14 +524,9 @@ fn curve_handles_all_inputs() { fn set_metadata_works() { new_test_ext().execute_with(|| { use sp_std::borrow::Cow; - - let invalid_metadata = - MetadataOf:: { schema: MetadataSchema::IpfsJsonV1, hash: [1u8; 32].into() }; - let metadata = MetadataOf:: { - schema: MetadataSchema::IpfsJsonV1, - hash: Preimage::note(Cow::from(vec![1])).unwrap(), - }; - + use frame_support::traits::Hash as PreimageHash; + // invalid preimage hash. + let invalid_hash: PreimageHash = [1u8; 32].into(); // fails to set metadata for a finished referendum. assert_ok!(Referenda::submit( RuntimeOrigin::signed(1), @@ -542,10 +537,10 @@ fn set_metadata_works() { let index = ReferendumCount::::get() - 1; assert_ok!(Referenda::kill(RuntimeOrigin::root(), index)); assert_noop!( - Referenda::set_metadata(RuntimeOrigin::signed(1), index, invalid_metadata.clone(),), + Referenda::set_metadata(RuntimeOrigin::signed(1), index, invalid_hash.clone(),), Error::::NotOngoing, ); - // no permission to set metadata + // no permission to set metadata. assert_ok!(Referenda::submit( RuntimeOrigin::signed(1), Box::new(RawOrigin::Root.into()), @@ -554,20 +549,21 @@ fn set_metadata_works() { )); let index = ReferendumCount::::get() - 1; assert_noop!( - Referenda::set_metadata(RuntimeOrigin::signed(2), index, invalid_metadata.clone(),), + Referenda::set_metadata(RuntimeOrigin::signed(2), index, invalid_hash.clone(),), Error::::NoPermission, ); - // preimage does not exist + // preimage does not exist. let index = ReferendumCount::::get() - 1; assert_noop!( - Referenda::set_metadata(RuntimeOrigin::signed(1), index, invalid_metadata,), + Referenda::set_metadata(RuntimeOrigin::signed(1), index, invalid_hash,), Error::::BadMetadata, ); - // metadata set + // metadata set. let index = ReferendumCount::::get() - 1; - assert_ok!(Referenda::set_metadata(RuntimeOrigin::signed(1), index, metadata.clone(),)); + let hash = Preimage::note(Cow::from(vec![1])).unwrap(); + assert_ok!(Referenda::set_metadata(RuntimeOrigin::signed(1), index, hash.clone(),)); System::assert_last_event(RuntimeEvent::Referenda(crate::Event::MetadataSet { index })); - assert!(Preimage::is_requested(&metadata.hash)); + assert!(Preimage::is_requested(&hash)); }); } @@ -575,12 +571,7 @@ fn set_metadata_works() { fn clear_metadata_works() { new_test_ext().execute_with(|| { use sp_std::borrow::Cow; - - let metadata = MetadataOf:: { - schema: MetadataSchema::IpfsJsonV1, - hash: Preimage::note(Cow::from(vec![1, 2])).unwrap(), - }; - + let preimage_hash = Preimage::note(Cow::from(vec![1, 2])).unwrap(); assert_ok!(Referenda::submit( RuntimeOrigin::signed(1), Box::new(RawOrigin::Root.into()), @@ -588,8 +579,10 @@ fn clear_metadata_works() { DispatchTime::At(1), )); let index = ReferendumCount::::get() - 1; - assert_ok!(Referenda::set_metadata(RuntimeOrigin::signed(1), index, metadata.clone(),)); - assert!(Preimage::is_requested(&metadata.hash)); + assert_ok!( + Referenda::set_metadata(RuntimeOrigin::signed(1), index, preimage_hash.clone(),) + ); + assert!(Preimage::is_requested(&preimage_hash)); assert_noop!( Referenda::clear_metadata(RuntimeOrigin::signed(2), index,), Error::::NoPermission, diff --git a/frame/referenda/src/types.rs b/frame/referenda/src/types.rs index 388e047d7af4a..91d8113cf73ef 100644 --- a/frame/referenda/src/types.rs +++ b/frame/referenda/src/types.rs @@ -20,7 +20,7 @@ use super::*; use codec::{Decode, Encode, EncodeLike, MaxEncodedLen}; use frame_support::{ - traits::{schedule::v3::Anon, Bounded, Hash as PreimageHash}, + traits::{schedule::v3::Anon, Bounded}, Parameter, }; use scale_info::TypeInfo; @@ -72,8 +72,6 @@ pub type ScheduleAddressOf = <>::Scheduler as Anon< PalletsOriginOf, >>::Address; -pub type MetadataOf = Metadata<>::MetadataSchema>; - /// A referendum index. pub type ReferendumIndex = u32; From 564f4833a1200af8ddc4bd54d13cbf8fe7727162 Mon Sep 17 00:00:00 2001 From: muharem Date: Fri, 28 Oct 2022 10:18:04 +0200 Subject: [PATCH 07/29] remove metadata type --- frame/referenda/src/types.rs | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/frame/referenda/src/types.rs b/frame/referenda/src/types.rs index 91d8113cf73ef..2ce93cb6adc3c 100644 --- a/frame/referenda/src/types.rs +++ b/frame/referenda/src/types.rs @@ -512,18 +512,6 @@ impl Debug for Curve { } } -/// General information about the item referring to the metadata. -#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo, MaxEncodedLen)] -pub struct Metadata { - /// The schema/s descriptor of the data the preimage `hash` referring to. - /// e.g. enum of `IpfsJsonV1` (the hash of an off-chain IPFS json file), - /// `BinJsonV2` (on-chain json dump). - pub(super) schema: Schema, - - /// The hash of the preimage holding the data of the `schema`. - pub(super) hash: PreimageHash, -} - #[cfg(test)] mod tests { use super::*; From bd9a86833b9799b22c236b50b437c276e8023049 Mon Sep 17 00:00:00 2001 From: muharem Date: Fri, 28 Oct 2022 11:22:14 +0200 Subject: [PATCH 08/29] referenda metadata benches --- bin/node/runtime/src/lib.rs | 10 -- frame/referenda/src/benchmarking.rs | 23 ++- frame/referenda/src/lib.rs | 8 +- frame/referenda/src/tests.rs | 10 +- frame/referenda/src/weights.rs | 249 ++++++++++++++++++---------- 5 files changed, 196 insertions(+), 104 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 20fecd02267dc..f137b36eff036 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -847,14 +847,6 @@ impl pallet_referenda::TracksInfo for TracksInfo { } pallet_referenda::impl_tracksinfo_get!(TracksInfo, Balance, BlockNumber); -#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, scale_info::TypeInfo, MaxEncodedLen)] -pub enum MetadataSchema { - IpfsJsonV1, - IpfsJsonV2, - BinJsonV1, - BinJsonV2, -} - impl pallet_referenda::Config for Runtime { type WeightInfo = pallet_referenda::weights::SubstrateWeight; type RuntimeCall = RuntimeCall; @@ -873,7 +865,6 @@ impl pallet_referenda::Config for Runtime { type AlarmInterval = AlarmInterval; type Tracks = TracksInfo; type Preimages = Preimage; - type MetadataSchema = MetadataSchema; } impl pallet_referenda::Config for Runtime { @@ -894,7 +885,6 @@ impl pallet_referenda::Config for Runtime { type AlarmInterval = AlarmInterval; type Tracks = TracksInfo; type Preimages = Preimage; - type MetadataSchema = MetadataSchema; } impl pallet_ranked_collective::Config for Runtime { diff --git a/frame/referenda/src/benchmarking.rs b/frame/referenda/src/benchmarking.rs index bc6fb31bf1127..fab96bc9f739d 100644 --- a/frame/referenda/src/benchmarking.rs +++ b/frame/referenda/src/benchmarking.rs @@ -31,7 +31,6 @@ use sp_runtime::traits::Bounded as ArithBounded; const SEED: u32 = 0; -#[allow(dead_code)] fn assert_last_event, I: 'static>(generic_event: >::RuntimeEvent) { frame_system::Pallet::::assert_last_event(generic_event.into()); } @@ -536,6 +535,28 @@ benchmarks_instance_pallet! { assert_matches!(info, ReferendumInfo::Rejected(..)); } + set_metadata { + use sp_std::borrow::Cow; + let (origin, index) = create_referendum::(); + let hash = T::Preimages::note(Cow::from(vec![1, 2])).unwrap(); + }: _(origin, index, hash) + verify { + assert_last_event::(Event::MetadataSet { index, hash }.into()); + } + + clear_metadata { + use sp_std::borrow::Cow; + let (origin, index) = create_referendum::(); + let hash = T::Preimages::note(Cow::from(vec![1, 2])).unwrap(); + assert_ok!( + Referenda::::set_metadata(origin.clone(), index, hash.clone(),) + ); + assert!(T::Preimages::is_requested(&hash)); + }: _(origin, index) + verify { + assert_last_event::(Event::MetadataCleared { index, hash }.into()); + } + impl_benchmark_test_suite!( Referenda, crate::mock::new_test_ext(), diff --git a/frame/referenda/src/lib.rs b/frame/referenda/src/lib.rs index d9eba38d22311..991eb0a2adb46 100644 --- a/frame/referenda/src/lib.rs +++ b/frame/referenda/src/lib.rs @@ -356,11 +356,15 @@ pub mod pallet { MetadataSet { /// Index of the referendum. index: ReferendumIndex, + /// Preimage hash. + hash: PreimageHash, }, /// Metadata for a referendum has been cleared. MetadataCleared { /// Index of the referendum. index: ReferendumIndex, + /// Preimage hash. + hash: PreimageHash, }, } @@ -621,7 +625,7 @@ pub mod pallet { ensure!(T::Preimages::len(&hash).is_some(), Error::::BadMetadata); T::Preimages::request(&hash); MetadataOf::::insert(index, hash); - Self::deposit_event(Event::::MetadataSet { index }); + Self::deposit_event(Event::::MetadataSet { index, hash }); Ok(()) } @@ -1207,7 +1211,7 @@ impl, I: 'static> Pallet { if T::Preimages::is_requested(&hash) { T::Preimages::unrequest(&hash); } - Self::deposit_event(Event::::MetadataCleared { index }); + Self::deposit_event(Event::::MetadataCleared { index, hash }); } } } diff --git a/frame/referenda/src/tests.rs b/frame/referenda/src/tests.rs index 9a1e9208ee02c..7d699c66c9a36 100644 --- a/frame/referenda/src/tests.rs +++ b/frame/referenda/src/tests.rs @@ -562,7 +562,7 @@ fn set_metadata_works() { let index = ReferendumCount::::get() - 1; let hash = Preimage::note(Cow::from(vec![1])).unwrap(); assert_ok!(Referenda::set_metadata(RuntimeOrigin::signed(1), index, hash.clone(),)); - System::assert_last_event(RuntimeEvent::Referenda(crate::Event::MetadataSet { index })); + System::assert_last_event(RuntimeEvent::Referenda(crate::Event::MetadataSet { index, hash })); assert!(Preimage::is_requested(&hash)); }); } @@ -571,7 +571,7 @@ fn set_metadata_works() { fn clear_metadata_works() { new_test_ext().execute_with(|| { use sp_std::borrow::Cow; - let preimage_hash = Preimage::note(Cow::from(vec![1, 2])).unwrap(); + let hash = Preimage::note(Cow::from(vec![1, 2])).unwrap(); assert_ok!(Referenda::submit( RuntimeOrigin::signed(1), Box::new(RawOrigin::Root.into()), @@ -580,14 +580,14 @@ fn clear_metadata_works() { )); let index = ReferendumCount::::get() - 1; assert_ok!( - Referenda::set_metadata(RuntimeOrigin::signed(1), index, preimage_hash.clone(),) + Referenda::set_metadata(RuntimeOrigin::signed(1), index, hash.clone(),) ); - assert!(Preimage::is_requested(&preimage_hash)); + assert!(Preimage::is_requested(&hash)); assert_noop!( Referenda::clear_metadata(RuntimeOrigin::signed(2), index,), Error::::NoPermission, ); assert_ok!(Referenda::clear_metadata(RuntimeOrigin::signed(1), index,),); - System::assert_last_event(RuntimeEvent::Referenda(crate::Event::MetadataCleared { index })); + System::assert_last_event(RuntimeEvent::Referenda(crate::Event::MetadataCleared { index, hash })); }); } diff --git a/frame/referenda/src/weights.rs b/frame/referenda/src/weights.rs index 50f8aa41b30aa..0e34afadaec10 100644 --- a/frame/referenda/src/weights.rs +++ b/frame/referenda/src/weights.rs @@ -1,39 +1,24 @@ -// This file is part of Substrate. - -// Copyright (C) 2022 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// 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. //! Autogenerated weights for pallet_referenda //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-05-23, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 +//! DATE: 2022-10-28, STEPS: `100`, REPEAT: 200, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `cob`, CPU: `` +//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: -// ./target/production/substrate +// ./target/release/substrate // benchmark // pallet // --chain=dev -// --steps=50 -// --repeat=20 -// --pallet=pallet_referenda +// --steps=100 +// --repeat=200 +// --pallet=pallet-referenda // --extrinsic=* -// --execution=wasm // --wasm-execution=compiled -// --template=./.maintain/frame-weight-template.hbs +// --heap-pages=4096 // --output=./frame/referenda/src/weights.rs +// --template=./.maintain/frame-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -71,6 +56,8 @@ pub trait WeightInfo { fn nudge_referendum_continue_confirming() -> Weight; fn nudge_referendum_approved() -> Weight; fn nudge_referendum_rejected() -> Weight; + fn set_metadata() -> Weight; + fn clear_metadata() -> Weight; } /// Weights for pallet_referenda using the Substrate node and recommended hardware. @@ -80,14 +67,16 @@ impl WeightInfo for SubstrateWeight { // Storage: Scheduler Agenda (r:1 w:1) // Storage: Referenda ReferendumInfoFor (r:0 w:1) fn submit() -> Weight { - Weight::from_ref_time(34_640_000 as u64) + // Minimum execution time: 26_000 nanoseconds. + Weight::from_ref_time(27_000_000 as u64) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn place_decision_deposit_preparing() -> Weight { - Weight::from_ref_time(44_290_000 as u64) + // Minimum execution time: 32_000 nanoseconds. + Weight::from_ref_time(34_000_000 as u64) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -95,7 +84,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Referenda DecidingCount (r:1 w:0) // Storage: Referenda TrackQueue (r:1 w:1) fn place_decision_deposit_queued() -> Weight { - Weight::from_ref_time(49_428_000 as u64) + // Minimum execution time: 37_000 nanoseconds. + Weight::from_ref_time(38_000_000 as u64) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } @@ -103,7 +93,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Referenda DecidingCount (r:1 w:0) // Storage: Referenda TrackQueue (r:1 w:1) fn place_decision_deposit_not_queued() -> Weight { - Weight::from_ref_time(50_076_000 as u64) + // Minimum execution time: 36_000 nanoseconds. + Weight::from_ref_time(38_000_000 as u64) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } @@ -111,7 +102,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Referenda DecidingCount (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn place_decision_deposit_passing() -> Weight { - Weight::from_ref_time(55_935_000 as u64) + // Minimum execution time: 42_000 nanoseconds. + Weight::from_ref_time(44_000_000 as u64) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().writes(4 as u64)) } @@ -119,34 +111,40 @@ impl WeightInfo for SubstrateWeight { // Storage: Referenda DecidingCount (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn place_decision_deposit_failing() -> Weight { - Weight::from_ref_time(52_921_000 as u64) + // Minimum execution time: 38_000 nanoseconds. + Weight::from_ref_time(41_000_000 as u64) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) fn refund_decision_deposit() -> Weight { - Weight::from_ref_time(29_160_000 as u64) + // Minimum execution time: 23_000 nanoseconds. + Weight::from_ref_time(25_000_000 as u64) .saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn cancel() -> Weight { - Weight::from_ref_time(34_972_000 as u64) + // Minimum execution time: 25_000 nanoseconds. + Weight::from_ref_time(27_000_000 as u64) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) + // Storage: Referenda MetadataOf (r:1 w:0) fn kill() -> Weight { - Weight::from_ref_time(60_620_000 as u64) - .saturating_add(T::DbWeight::get().reads(3 as u64)) + // Minimum execution time: 48_000 nanoseconds. + Weight::from_ref_time(51_000_000 as u64) + .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Referenda TrackQueue (r:1 w:0) // Storage: Referenda DecidingCount (r:1 w:1) fn one_fewer_deciding_queue_empty() -> Weight { - Weight::from_ref_time(9_615_000 as u64) + // Minimum execution time: 7_000 nanoseconds. + Weight::from_ref_time(8_000_000 as u64) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } @@ -154,7 +152,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn one_fewer_deciding_failing() -> Weight { - Weight::from_ref_time(113_077_000 as u64) + // Minimum execution time: 58_000 nanoseconds. + Weight::from_ref_time(62_000_000 as u64) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().writes(4 as u64)) } @@ -162,7 +161,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn one_fewer_deciding_passing() -> Weight { - Weight::from_ref_time(114_376_000 as u64) + // Minimum execution time: 59_000 nanoseconds. + Weight::from_ref_time(63_000_000 as u64) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().writes(4 as u64)) } @@ -170,7 +170,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Referenda TrackQueue (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_requeued_insertion() -> Weight { - Weight::from_ref_time(43_901_000 as u64) + // Minimum execution time: 50_000 nanoseconds. + Weight::from_ref_time(53_000_000 as u64) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -178,7 +179,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Referenda TrackQueue (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_requeued_slide() -> Weight { - Weight::from_ref_time(43_279_000 as u64) + // Minimum execution time: 52_000 nanoseconds. + Weight::from_ref_time(57_000_000 as u64) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -187,7 +189,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Referenda TrackQueue (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_queued() -> Weight { - Weight::from_ref_time(45_564_000 as u64) + // Minimum execution time: 51_000 nanoseconds. + Weight::from_ref_time(60_000_000 as u64) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -196,27 +199,31 @@ impl WeightInfo for SubstrateWeight { // Storage: Referenda TrackQueue (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_not_queued() -> Weight { - Weight::from_ref_time(45_061_000 as u64) + // Minimum execution time: 51_000 nanoseconds. + Weight::from_ref_time(56_000_000 as u64) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_no_deposit() -> Weight { - Weight::from_ref_time(23_757_000 as u64) + // Minimum execution time: 20_000 nanoseconds. + Weight::from_ref_time(21_000_000 as u64) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_preparing() -> Weight { - Weight::from_ref_time(24_781_000 as u64) + // Minimum execution time: 21_000 nanoseconds. + Weight::from_ref_time(22_000_000 as u64) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) fn nudge_referendum_timed_out() -> Weight { - Weight::from_ref_time(18_344_000 as u64) + // Minimum execution time: 16_000 nanoseconds. + Weight::from_ref_time(17_000_000 as u64) .saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } @@ -224,7 +231,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Referenda DecidingCount (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_begin_deciding_failing() -> Weight { - Weight::from_ref_time(34_752_000 as u64) + // Minimum execution time: 27_000 nanoseconds. + Weight::from_ref_time(29_000_000 as u64) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -232,54 +240,78 @@ impl WeightInfo for SubstrateWeight { // Storage: Referenda DecidingCount (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_begin_deciding_passing() -> Weight { - Weight::from_ref_time(37_055_000 as u64) + // Minimum execution time: 29_000 nanoseconds. + Weight::from_ref_time(31_000_000 as u64) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_begin_confirming() -> Weight { - Weight::from_ref_time(31_442_000 as u64) + // Minimum execution time: 27_000 nanoseconds. + Weight::from_ref_time(30_000_000 as u64) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_end_confirming() -> Weight { - Weight::from_ref_time(33_201_000 as u64) + // Minimum execution time: 28_000 nanoseconds. + Weight::from_ref_time(30_000_000 as u64) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_continue_not_confirming() -> Weight { - Weight::from_ref_time(30_047_000 as u64) + // Minimum execution time: 27_000 nanoseconds. + Weight::from_ref_time(28_000_000 as u64) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_continue_confirming() -> Weight { - Weight::from_ref_time(29_195_000 as u64) + // Minimum execution time: 28_000 nanoseconds. + Weight::from_ref_time(29_000_000 as u64) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) // Storage: Scheduler Lookup (r:1 w:1) - // Storage: Preimage StatusFor (r:1 w:1) fn nudge_referendum_approved() -> Weight { - Weight::from_ref_time(50_119_000 as u64) - .saturating_add(T::DbWeight::get().reads(5 as u64)) - .saturating_add(T::DbWeight::get().writes(5 as u64)) + // Minimum execution time: 33_000 nanoseconds. + Weight::from_ref_time(35_000_000 as u64) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_rejected() -> Weight { - Weight::from_ref_time(32_203_000 as u64) + // Minimum execution time: 29_000 nanoseconds. + Weight::from_ref_time(30_000_000 as u64) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } + // Storage: Referenda ReferendumInfoFor (r:1 w:0) + // Storage: Preimage StatusFor (r:1 w:1) + // Storage: Referenda MetadataOf (r:0 w:1) + fn set_metadata() -> Weight { + // Minimum execution time: 20_000 nanoseconds. + Weight::from_ref_time(21_000_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Referenda ReferendumInfoFor (r:1 w:0) + // Storage: Referenda MetadataOf (r:1 w:1) + // Storage: Preimage StatusFor (r:1 w:1) + fn clear_metadata() -> Weight { + // Minimum execution time: 23_000 nanoseconds. + Weight::from_ref_time(24_000_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } } // For backwards compatibility and tests @@ -288,14 +320,16 @@ impl WeightInfo for () { // Storage: Scheduler Agenda (r:1 w:1) // Storage: Referenda ReferendumInfoFor (r:0 w:1) fn submit() -> Weight { - Weight::from_ref_time(34_640_000 as u64) + // Minimum execution time: 26_000 nanoseconds. + Weight::from_ref_time(27_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn place_decision_deposit_preparing() -> Weight { - Weight::from_ref_time(44_290_000 as u64) + // Minimum execution time: 32_000 nanoseconds. + Weight::from_ref_time(34_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } @@ -303,7 +337,8 @@ impl WeightInfo for () { // Storage: Referenda DecidingCount (r:1 w:0) // Storage: Referenda TrackQueue (r:1 w:1) fn place_decision_deposit_queued() -> Weight { - Weight::from_ref_time(49_428_000 as u64) + // Minimum execution time: 37_000 nanoseconds. + Weight::from_ref_time(38_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } @@ -311,7 +346,8 @@ impl WeightInfo for () { // Storage: Referenda DecidingCount (r:1 w:0) // Storage: Referenda TrackQueue (r:1 w:1) fn place_decision_deposit_not_queued() -> Weight { - Weight::from_ref_time(50_076_000 as u64) + // Minimum execution time: 36_000 nanoseconds. + Weight::from_ref_time(38_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } @@ -319,7 +355,8 @@ impl WeightInfo for () { // Storage: Referenda DecidingCount (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn place_decision_deposit_passing() -> Weight { - Weight::from_ref_time(55_935_000 as u64) + // Minimum execution time: 42_000 nanoseconds. + Weight::from_ref_time(44_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) } @@ -327,34 +364,40 @@ impl WeightInfo for () { // Storage: Referenda DecidingCount (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn place_decision_deposit_failing() -> Weight { - Weight::from_ref_time(52_921_000 as u64) + // Minimum execution time: 38_000 nanoseconds. + Weight::from_ref_time(41_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) fn refund_decision_deposit() -> Weight { - Weight::from_ref_time(29_160_000 as u64) + // Minimum execution time: 23_000 nanoseconds. + Weight::from_ref_time(25_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(1 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn cancel() -> Weight { - Weight::from_ref_time(34_972_000 as u64) + // Minimum execution time: 25_000 nanoseconds. + Weight::from_ref_time(27_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) + // Storage: Referenda MetadataOf (r:1 w:0) fn kill() -> Weight { - Weight::from_ref_time(60_620_000 as u64) - .saturating_add(RocksDbWeight::get().reads(3 as u64)) + // Minimum execution time: 48_000 nanoseconds. + Weight::from_ref_time(51_000_000 as u64) + .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } // Storage: Referenda TrackQueue (r:1 w:0) // Storage: Referenda DecidingCount (r:1 w:1) fn one_fewer_deciding_queue_empty() -> Weight { - Weight::from_ref_time(9_615_000 as u64) + // Minimum execution time: 7_000 nanoseconds. + Weight::from_ref_time(8_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } @@ -362,7 +405,8 @@ impl WeightInfo for () { // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn one_fewer_deciding_failing() -> Weight { - Weight::from_ref_time(113_077_000 as u64) + // Minimum execution time: 58_000 nanoseconds. + Weight::from_ref_time(62_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) } @@ -370,7 +414,8 @@ impl WeightInfo for () { // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn one_fewer_deciding_passing() -> Weight { - Weight::from_ref_time(114_376_000 as u64) + // Minimum execution time: 59_000 nanoseconds. + Weight::from_ref_time(63_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) } @@ -378,7 +423,8 @@ impl WeightInfo for () { // Storage: Referenda TrackQueue (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_requeued_insertion() -> Weight { - Weight::from_ref_time(43_901_000 as u64) + // Minimum execution time: 50_000 nanoseconds. + Weight::from_ref_time(53_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } @@ -386,7 +432,8 @@ impl WeightInfo for () { // Storage: Referenda TrackQueue (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_requeued_slide() -> Weight { - Weight::from_ref_time(43_279_000 as u64) + // Minimum execution time: 52_000 nanoseconds. + Weight::from_ref_time(57_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } @@ -395,7 +442,8 @@ impl WeightInfo for () { // Storage: Referenda TrackQueue (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_queued() -> Weight { - Weight::from_ref_time(45_564_000 as u64) + // Minimum execution time: 51_000 nanoseconds. + Weight::from_ref_time(60_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } @@ -404,27 +452,31 @@ impl WeightInfo for () { // Storage: Referenda TrackQueue (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_not_queued() -> Weight { - Weight::from_ref_time(45_061_000 as u64) + // Minimum execution time: 51_000 nanoseconds. + Weight::from_ref_time(56_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_no_deposit() -> Weight { - Weight::from_ref_time(23_757_000 as u64) + // Minimum execution time: 20_000 nanoseconds. + Weight::from_ref_time(21_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_preparing() -> Weight { - Weight::from_ref_time(24_781_000 as u64) + // Minimum execution time: 21_000 nanoseconds. + Weight::from_ref_time(22_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) fn nudge_referendum_timed_out() -> Weight { - Weight::from_ref_time(18_344_000 as u64) + // Minimum execution time: 16_000 nanoseconds. + Weight::from_ref_time(17_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(1 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } @@ -432,7 +484,8 @@ impl WeightInfo for () { // Storage: Referenda DecidingCount (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_begin_deciding_failing() -> Weight { - Weight::from_ref_time(34_752_000 as u64) + // Minimum execution time: 27_000 nanoseconds. + Weight::from_ref_time(29_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } @@ -440,52 +493,76 @@ impl WeightInfo for () { // Storage: Referenda DecidingCount (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_begin_deciding_passing() -> Weight { - Weight::from_ref_time(37_055_000 as u64) + // Minimum execution time: 29_000 nanoseconds. + Weight::from_ref_time(31_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_begin_confirming() -> Weight { - Weight::from_ref_time(31_442_000 as u64) + // Minimum execution time: 27_000 nanoseconds. + Weight::from_ref_time(30_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_end_confirming() -> Weight { - Weight::from_ref_time(33_201_000 as u64) + // Minimum execution time: 28_000 nanoseconds. + Weight::from_ref_time(30_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_continue_not_confirming() -> Weight { - Weight::from_ref_time(30_047_000 as u64) + // Minimum execution time: 27_000 nanoseconds. + Weight::from_ref_time(28_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_continue_confirming() -> Weight { - Weight::from_ref_time(29_195_000 as u64) + // Minimum execution time: 28_000 nanoseconds. + Weight::from_ref_time(29_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) // Storage: Scheduler Lookup (r:1 w:1) - // Storage: Preimage StatusFor (r:1 w:1) fn nudge_referendum_approved() -> Weight { - Weight::from_ref_time(50_119_000 as u64) - .saturating_add(RocksDbWeight::get().reads(5 as u64)) - .saturating_add(RocksDbWeight::get().writes(5 as u64)) + // Minimum execution time: 33_000 nanoseconds. + Weight::from_ref_time(35_000_000 as u64) + .saturating_add(RocksDbWeight::get().reads(4 as u64)) + .saturating_add(RocksDbWeight::get().writes(4 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_rejected() -> Weight { - Weight::from_ref_time(32_203_000 as u64) + // Minimum execution time: 29_000 nanoseconds. + Weight::from_ref_time(30_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } + // Storage: Referenda ReferendumInfoFor (r:1 w:0) + // Storage: Preimage StatusFor (r:1 w:1) + // Storage: Referenda MetadataOf (r:0 w:1) + fn set_metadata() -> Weight { + // Minimum execution time: 20_000 nanoseconds. + Weight::from_ref_time(21_000_000 as u64) + .saturating_add(RocksDbWeight::get().reads(2 as u64)) + .saturating_add(RocksDbWeight::get().writes(2 as u64)) + } + // Storage: Referenda ReferendumInfoFor (r:1 w:0) + // Storage: Referenda MetadataOf (r:1 w:1) + // Storage: Preimage StatusFor (r:1 w:1) + fn clear_metadata() -> Weight { + // Minimum execution time: 23_000 nanoseconds. + Weight::from_ref_time(24_000_000 as u64) + .saturating_add(RocksDbWeight::get().reads(3 as u64)) + .saturating_add(RocksDbWeight::get().writes(2 as u64)) + } } From 9025acece4b2934a7e7d2390cfa649d313be8bdd Mon Sep 17 00:00:00 2001 From: muharem Date: Fri, 28 Oct 2022 11:34:13 +0200 Subject: [PATCH 09/29] note different preimages --- frame/referenda/src/benchmarking.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frame/referenda/src/benchmarking.rs b/frame/referenda/src/benchmarking.rs index fab96bc9f739d..dd0a35f8aac91 100644 --- a/frame/referenda/src/benchmarking.rs +++ b/frame/referenda/src/benchmarking.rs @@ -538,7 +538,7 @@ benchmarks_instance_pallet! { set_metadata { use sp_std::borrow::Cow; let (origin, index) = create_referendum::(); - let hash = T::Preimages::note(Cow::from(vec![1, 2])).unwrap(); + let hash = T::Preimages::note(Cow::from(vec![5, 6])).unwrap(); }: _(origin, index, hash) verify { assert_last_event::(Event::MetadataSet { index, hash }.into()); @@ -547,7 +547,7 @@ benchmarks_instance_pallet! { clear_metadata { use sp_std::borrow::Cow; let (origin, index) = create_referendum::(); - let hash = T::Preimages::note(Cow::from(vec![1, 2])).unwrap(); + let hash = T::Preimages::note(Cow::from(vec![6, 7, 8])).unwrap(); assert_ok!( Referenda::::set_metadata(origin.clone(), index, hash.clone(),) ); From d1cff03f8711a8f420feea34395dd3f06b2213c8 Mon Sep 17 00:00:00 2001 From: muharem Date: Fri, 28 Oct 2022 18:58:32 +0200 Subject: [PATCH 10/29] metadata for democracy pallet --- Cargo.lock | 1 + frame/democracy/Cargo.toml | 1 + frame/democracy/src/lib.rs | 176 ++++++++++++++++-- frame/democracy/src/tests.rs | 14 +- .../democracy/src/tests/external_proposing.rs | 57 ++++++ frame/democracy/src/tests/fast_tracking.rs | 7 + frame/democracy/src/tests/public_proposals.rs | 68 +++++++ frame/democracy/src/types.rs | 17 ++ frame/referenda/src/lib.rs | 8 +- frame/referenda/src/tests.rs | 16 +- 10 files changed, 341 insertions(+), 24 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 397846693e907..808ed346e57d6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5373,6 +5373,7 @@ dependencies = [ "pallet-preimage", "pallet-scheduler", "parity-scale-codec", + "rand 0.8.5", "scale-info", "serde", "sp-core", diff --git a/frame/democracy/Cargo.toml b/frame/democracy/Cargo.toml index e50d39ff76902..99a5401155acb 100644 --- a/frame/democracy/Cargo.toml +++ b/frame/democracy/Cargo.toml @@ -28,6 +28,7 @@ sp-core = { version = "6.0.0", default-features = false, path = "../../primitive log = { version = "0.4.17", default-features = false } [dev-dependencies] +rand = "0.8.4" pallet-balances = { version = "4.0.0-dev", path = "../balances" } pallet-scheduler = { version = "4.0.0-dev", path = "../scheduler" } pallet-preimage = { version = "4.0.0-dev", path = "../preimage" } diff --git a/frame/democracy/src/lib.rs b/frame/democracy/src/lib.rs index cf954d4800eee..d3c1ab525b714 100644 --- a/frame/democracy/src/lib.rs +++ b/frame/democracy/src/lib.rs @@ -158,8 +158,8 @@ use frame_support::{ traits::{ defensive_prelude::*, schedule::{v3::Named as ScheduleNamed, DispatchTime}, - Bounded, Currency, Get, LockIdentifier, LockableCurrency, OnUnbalanced, QueryPreimage, - ReservableCurrency, StorePreimage, WithdrawReasons, + Bounded, Currency, Get, Hash as PreimageHash, LockIdentifier, LockableCurrency, + OnUnbalanced, QueryPreimage, ReservableCurrency, StorePreimage, WithdrawReasons, }, weights::Weight, }; @@ -176,7 +176,10 @@ mod vote_threshold; pub mod weights; pub use conviction::Conviction; pub use pallet::*; -pub use types::{Delegations, ReferendumInfo, ReferendumStatus, Tally, UnvoteScope}; +pub use types::{ + Delegations, MetadataOwner, PropIndex, ReferendumIndex, ReferendumInfo, ReferendumStatus, + Tally, UnvoteScope, +}; pub use vote::{AccountVote, Vote, Voting}; pub use vote_threshold::{Approved, VoteThreshold}; pub use weights::WeightInfo; @@ -191,12 +194,6 @@ pub mod migrations; const DEMOCRACY_ID: LockIdentifier = *b"democrac"; -/// A proposal index. -pub type PropIndex = u32; - -/// A referendum index. -pub type ReferendumIndex = u32; - type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; type NegativeImbalanceOf = <::Currency as Currency< @@ -425,6 +422,15 @@ pub mod pallet { #[pallet::storage] pub type Cancellations = StorageMap<_, Identity, H256, bool, ValueQuery>; + /// General information concerning any proposal or referendum. + /// The `PreimageHash` refers to the preimage of the `Preimages` provider which can be a JSON + /// dump or IPFS hash of a JSON file. + /// + /// Consider a garbage collection for a metadata of finished referendums to `unrequest` (remove) + /// large preimages. + #[pallet::storage] + pub type MetadataOf = StorageMap<_, Blake2_128Concat, MetadataOwner, PreimageHash>; + #[pallet::genesis_config] pub struct GenesisConfig { _phantom: sp_std::marker::PhantomData, @@ -477,6 +483,29 @@ pub mod pallet { Seconded { seconder: T::AccountId, prop_index: PropIndex }, /// A proposal got canceled. ProposalCanceled { prop_index: PropIndex }, + /// Metadata for a proposal or a referendum has been set. + MetadataSet { + /// Metadata owner. + owner: MetadataOwner, + /// Preimage hash. + hash: PreimageHash, + }, + /// Metadata for a proposal or a referendum has been cleared. + MetadataCleared { + /// Metadata owner. + owner: MetadataOwner, + /// Preimage hash. + hash: PreimageHash, + }, + /// Metadata has been reset to new referendum. + MetadataReset { + /// Previous metadata owner. + prev_owner: MetadataOwner, + /// New metadata owner. + owner: MetadataOwner, + /// Preimage hash. + hash: PreimageHash, + }, } #[pallet::error] @@ -528,6 +557,8 @@ pub mod pallet { TooMany, /// Voting period too low VotingPeriodLow, + /// The metadata preimage for a given hash does not exist. + BadMetadata, } #[pallet::hooks] @@ -647,6 +678,7 @@ pub mod pallet { >::insert(h, true); Self::internal_cancel_referendum(ref_index); + Self::clear_metadata(MetadataOwner::Referendum(ref_index)); Ok(()) } @@ -765,12 +797,13 @@ pub mod pallet { >::kill(); let now = >::block_number(); - Self::inject_referendum( + let ref_index = Self::inject_referendum( now.saturating_add(voting_period), ext_proposal, threshold, delay, ); + Self::reset_metadata(MetadataOwner::External, MetadataOwner::Referendum(ref_index)); Ok(()) } @@ -807,6 +840,7 @@ pub mod pallet { Self::deposit_event(Event::::Vetoed { who, proposal_hash, until }); >::kill(); + Self::clear_metadata(MetadataOwner::External); Ok(()) } @@ -824,6 +858,7 @@ pub mod pallet { ) -> DispatchResult { ensure_root(origin)?; Self::internal_cancel_referendum(ref_index); + Self::clear_metadata(MetadataOwner::Referendum(ref_index)); Ok(()) } @@ -1008,12 +1043,14 @@ pub mod pallet { T::Slash::on_unbalanced(T::Currency::slash_reserved(&who, amount).0); } } + Self::clear_metadata(MetadataOwner::Proposal(prop_index)); } }); // Remove the external queued referendum, if it's there. if matches!(NextExternal::::get(), Some((p, ..)) if p.hash() == proposal_hash) { NextExternal::::kill(); + Self::clear_metadata(MetadataOwner::External); } // Remove the referendum, if it's there. @@ -1021,6 +1058,7 @@ pub mod pallet { if let Ok(status) = Self::referendum_status(ref_index) { if status.proposal.hash() == proposal_hash { Self::internal_cancel_referendum(ref_index); + Self::clear_metadata(MetadataOwner::Referendum(ref_index)); } } } @@ -1049,10 +1087,89 @@ pub mod pallet { T::Slash::on_unbalanced(T::Currency::slash_reserved(&who, amount).0); } } + Self::clear_metadata(MetadataOwner::Proposal(prop_index)); Self::deposit_event(Event::::ProposalCanceled { prop_index }); Ok(()) } + + /// Set the metadata to the external proposal. + /// + /// - `origin`: Must be `ExternalOrigin`. + /// - `hash`: The preimage hash of an on-chain stored preimage. + // TODO replace the weight function + #[pallet::weight(1)] + pub fn set_external_metadata(origin: OriginFor, hash: PreimageHash) -> DispatchResult { + T::ExternalOrigin::ensure_origin(origin)?; + ensure!(>::exists(), Error::::NoProposal); + ensure!(T::Preimages::len(&hash).is_some(), Error::::BadMetadata); + T::Preimages::request(&hash); + MetadataOf::::insert(MetadataOwner::External, hash); + Self::deposit_event(Event::::MetadataSet { owner: MetadataOwner::External, hash }); + Ok(()) + } + + /// Set the metadata to the public proposal. + /// + /// - `origin`: Must be `Signed`, and the creator of the referendum. + /// - `index`: The index of the proposal. + /// - `hash`: The preimage hash of an on-chain stored preimage. + // TODO replace the weight function + #[pallet::weight(1)] + pub fn set_proposal_metadata( + origin: OriginFor, + index: PropIndex, + hash: PreimageHash, + ) -> DispatchResult { + let who = ensure_signed(origin)?; + let (_, _, proposer) = Self::proposal(index)?; + ensure!(proposer == who, Error::::NoPermission); + ensure!(T::Preimages::len(&hash).is_some(), Error::::BadMetadata); + T::Preimages::request(&hash); + let owner = MetadataOwner::Proposal(index); + MetadataOf::::insert(owner.clone(), hash); + Self::deposit_event(Event::::MetadataSet { owner, hash }); + Ok(()) + } + + /// Clear the external proposal metadata. + /// + /// - `origin`: Must be `ExternalOrigin`. + // TODO replace the weight function + #[pallet::weight(1)] + pub fn clear_external_metadata(origin: OriginFor) -> DispatchResult { + T::ExternalOrigin::ensure_origin(origin)?; + Self::clear_metadata(MetadataOwner::External); + Ok(()) + } + + /// Clear the public proposal metadata. + /// + /// - `origin`: Must be `Signed`, and the creator of the referendum. + /// - `index`: The index of the proposal. + // TODO replace the weight function + #[pallet::weight(1)] + pub fn clear_proposal_metadata(origin: OriginFor, index: PropIndex) -> DispatchResult { + let who = ensure_signed(origin)?; + let (_, _, proposer) = Self::proposal(index)?; + ensure!(proposer == who, Error::::NoPermission); + Self::clear_metadata(MetadataOwner::Proposal(index)); + Ok(()) + } + + /// Clear the referendum metadata. + /// + /// - `origin`: Must be `Root`. + /// - `index`: The index of the referendum. + #[pallet::weight(1)] + pub fn clear_referendum_metadata( + origin: OriginFor, + index: ReferendumIndex, + ) -> DispatchResult { + ensure_root(origin)?; + Self::clear_metadata(MetadataOwner::Referendum(index)); + Ok(()) + } } } @@ -1414,12 +1531,13 @@ impl Pallet { if let Some((proposal, threshold)) = >::take() { LastTabledWasExternal::::put(true); Self::deposit_event(Event::::ExternalTabled); - Self::inject_referendum( + let ref_index = Self::inject_referendum( now.saturating_add(T::VotingPeriod::get()), proposal, threshold, T::EnactmentPeriod::get(), ); + Self::reset_metadata(MetadataOwner::External, MetadataOwner::Referendum(ref_index)); Ok(()) } else { return Err(Error::::NoneWaiting.into()) @@ -1442,12 +1560,16 @@ impl Pallet { T::Currency::unreserve(d, deposit); } Self::deposit_event(Event::::Tabled { proposal_index: prop_index, deposit }); - Self::inject_referendum( + let ref_index = Self::inject_referendum( now.saturating_add(T::VotingPeriod::get()), proposal, VoteThreshold::SuperMajorityApprove, T::EnactmentPeriod::get(), ); + Self::reset_metadata( + MetadataOwner::Proposal(prop_index), + MetadataOwner::Referendum(ref_index), + ) } Ok(()) } else { @@ -1560,6 +1682,36 @@ impl Pallet { // `Compact`. decode_compact_u32_at(&>::hashed_key_for(proposal)) } + + // Return a proposal of an index. + fn proposal(index: PropIndex) -> Result<(PropIndex, BoundedCallOf, T::AccountId), Error> { + PublicProps::::get() + .into_iter() + .find(|(prop_index, _, _)| prop_index == &index) + .ok_or(Error::::ProposalMissing) + } + + /// Clear metadata, if `Some` and unrequest associated preimage. + fn clear_metadata(owner: MetadataOwner) { + if let Some(hash) = MetadataOf::::take(owner.clone()) { + if T::Preimages::is_requested(&hash) { + T::Preimages::unrequest(&hash); + } + Self::deposit_event(Event::::MetadataCleared { owner, hash }); + } + } + + /// Reset the metadata of an `owner` to a `new_owner`. + fn reset_metadata(owner: MetadataOwner, new_owner: MetadataOwner) { + if let Some(hash) = MetadataOf::::take(owner.clone()) { + MetadataOf::::insert(new_owner.clone(), hash); + Self::deposit_event(Event::::MetadataReset { + prev_owner: owner, + owner: new_owner, + hash, + }); + } + } } /// Decode `Compact` from the trie at given key. diff --git a/frame/democracy/src/tests.rs b/frame/democracy/src/tests.rs index eceb1a3400bba..a22adf659ed59 100644 --- a/frame/democracy/src/tests.rs +++ b/frame/democracy/src/tests.rs @@ -32,7 +32,7 @@ use pallet_balances::{BalanceLock, Error as BalancesError}; use sp_core::H256; use sp_runtime::{ testing::Header, - traits::{BadOrigin, BlakeTwo256, IdentityLookup}, + traits::{BadOrigin, BlakeTwo256, IdentityLookup, Hash}, Perbill, }; mod cancellation; @@ -274,3 +274,15 @@ fn big_nay(who: u64) -> AccountVote { fn tally(r: ReferendumIndex) -> Tally { Democracy::referendum_status(r).unwrap().tally } + +/// note preimage without registering. +/// randomize the data to make sure the preimage was not noted/registered before. +fn note_random_preimage(who: u64) -> PreimageHash { + use rand::Rng; + let mut rng = rand::thread_rng(); + let data: Vec = (0..100).map(|_| rng.gen_range(0..20)).collect(); + assert_ok!(Preimage::note_preimage(RuntimeOrigin::signed(who), data.clone())); + let hash = BlakeTwo256::hash(&data); + assert!(!Preimage::is_requested(&hash)); + hash +} \ No newline at end of file diff --git a/frame/democracy/src/tests/external_proposing.rs b/frame/democracy/src/tests/external_proposing.rs index 4cfdd2aa74a3d..32380024730a3 100644 --- a/frame/democracy/src/tests/external_proposing.rs +++ b/frame/democracy/src/tests/external_proposing.rs @@ -274,3 +274,60 @@ fn external_and_public_interleaving_works() { ); }); } + +#[test] +fn set_external_metadata_works() { + new_test_ext().execute_with(|| { + use frame_support::traits::Hash as PreimageHash; + // invalid preimage hash. + let invalid_hash: PreimageHash = [1u8; 32].into(); + // fails to set metadata with non external origin. + assert_noop!( + Democracy::set_external_metadata(RuntimeOrigin::signed(1), invalid_hash.clone(),), + BadOrigin, + ); + // fails to set metadata if an external proposal does not exist. + assert_noop!( + Democracy::set_external_metadata(RuntimeOrigin::signed(2), invalid_hash.clone(),), + Error::::NoProposal, + ); + // create an external proposal. + assert_ok!(Democracy::external_propose(RuntimeOrigin::signed(2), set_balance_proposal(2),)); + assert!(>::exists()); + // fails to set non-existing preimage. + assert_noop!( + Democracy::set_external_metadata(RuntimeOrigin::signed(2), invalid_hash.clone(),), + Error::::BadMetadata, + ); + // set metadata successful. + let hash = note_random_preimage(1); + assert_ok!(Democracy::set_external_metadata(RuntimeOrigin::signed(2), hash.clone(),),); + System::assert_last_event(RuntimeEvent::Democracy(crate::Event::MetadataSet { + owner: MetadataOwner::External, + hash, + })); + assert!(Preimage::is_requested(&hash)); + }); +} + +#[test] +fn clear_metadata_works() { + new_test_ext().execute_with(|| { + // create an external proposal. + assert_ok!(Democracy::external_propose(RuntimeOrigin::signed(2), set_balance_proposal(2),)); + assert!(>::exists()); + // set metadata. + let hash = note_random_preimage(1); + assert_ok!(Democracy::set_external_metadata(RuntimeOrigin::signed(2), hash.clone(),)); + assert!(Preimage::is_requested(&hash)); + // fails to clear metadata with a wrong origin. + assert_noop!(Democracy::clear_external_metadata(RuntimeOrigin::signed(1)), BadOrigin,); + // clear metadata successful. + assert_ok!(Democracy::clear_external_metadata(RuntimeOrigin::signed(2))); + System::assert_last_event(RuntimeEvent::Democracy(crate::Event::MetadataCleared { + owner: MetadataOwner::External, + hash, + })); + assert!(!Preimage::is_requested(&hash)); + }); +} diff --git a/frame/democracy/src/tests/fast_tracking.rs b/frame/democracy/src/tests/fast_tracking.rs index 97bb7a63908ab..8d5ae406092c3 100644 --- a/frame/democracy/src/tests/fast_tracking.rs +++ b/frame/democracy/src/tests/fast_tracking.rs @@ -32,6 +32,10 @@ fn fast_track_referendum_works() { RuntimeOrigin::signed(3), set_balance_proposal(2) )); + let hash = note_random_preimage(1); + assert!(>::get(MetadataOwner::External).is_none()); + assert_ok!(Democracy::set_external_metadata(RuntimeOrigin::signed(2), hash.clone(),),); + assert!(>::get(MetadataOwner::External).is_some()); assert_noop!(Democracy::fast_track(RuntimeOrigin::signed(1), h, 3, 2), BadOrigin); assert_ok!(Democracy::fast_track(RuntimeOrigin::signed(5), h, 2, 0)); assert_eq!( @@ -44,6 +48,9 @@ fn fast_track_referendum_works() { tally: Tally { ayes: 0, nays: 0, turnout: 0 }, }) ); + // metadata reset from the external proposal to the referendum. + assert!(>::get(MetadataOwner::External).is_none()); + assert!(>::get(MetadataOwner::Referendum(0)).is_some()); }); } diff --git a/frame/democracy/src/tests/public_proposals.rs b/frame/democracy/src/tests/public_proposals.rs index f48824dc95c5d..1fc64344f8bb0 100644 --- a/frame/democracy/src/tests/public_proposals.rs +++ b/frame/democracy/src/tests/public_proposals.rs @@ -91,7 +91,14 @@ fn cancel_proposal_should_work() { assert_ok!(propose_set_balance(1, 2, 2)); assert_ok!(propose_set_balance(1, 4, 4)); assert_noop!(Democracy::cancel_proposal(RuntimeOrigin::signed(1), 0), BadOrigin); + let hash = note_random_preimage(1); + assert_ok!(Democracy::set_proposal_metadata(RuntimeOrigin::signed(1), 0, hash.clone())); + assert!(>::get(MetadataOwner::Proposal(0)).is_some()); + assert!(Preimage::is_requested(&hash)); assert_ok!(Democracy::cancel_proposal(RuntimeOrigin::root(), 0)); + // metadata cleared, preimage unrequested. + assert!(>::get(MetadataOwner::Proposal(0)).is_none()); + assert!(!Preimage::is_requested(&hash)); System::assert_last_event(crate::Event::ProposalCanceled { prop_index: 0 }.into()); assert_eq!(Democracy::backing_for(0), None); assert_eq!(Democracy::backing_for(1), Some(4)); @@ -139,3 +146,64 @@ fn runners_up_should_come_after() { assert_ok!(Democracy::vote(RuntimeOrigin::signed(1), 2, aye(1))); }); } + +#[test] +fn set_external_metadata_works() { + new_test_ext().execute_with(|| { + use frame_support::traits::Hash as PreimageHash; + // invalid preimage hash. + let invalid_hash: PreimageHash = [1u8; 32].into(); + // create an external proposal. + assert_ok!(propose_set_balance(1, 2, 5)); + let index = Democracy::public_prop_count() - 1; + // fails to set non-existing preimage. + assert_noop!( + Democracy::set_proposal_metadata(RuntimeOrigin::signed(1), index, invalid_hash.clone(),), + Error::::BadMetadata, + ); + // note preimage. + let hash = note_random_preimage(1); + // fails to set non-existing preimage. + assert_noop!( + Democracy::set_proposal_metadata(RuntimeOrigin::signed(3), index, hash.clone(),), + Error::::NoPermission, + ); + // set metadata successful. + assert_ok!( + Democracy::set_proposal_metadata(RuntimeOrigin::signed(1), index, hash.clone(),), + ); + System::assert_last_event(RuntimeEvent::Democracy(crate::Event::MetadataSet { + owner: MetadataOwner::Proposal(index), + hash, + })); + assert!(Preimage::is_requested(&hash)); + }); +} + +#[test] +fn clear_metadata_works() { + new_test_ext().execute_with(|| { + // create an external proposal. + assert_ok!(propose_set_balance(1, 2, 5)); + let index = Democracy::public_prop_count() - 1; + // set metadata. + let hash = note_random_preimage(1); + assert!(!Preimage::is_requested(&hash)); + assert_ok!( + Democracy::set_proposal_metadata(RuntimeOrigin::signed(1), index, hash.clone(),) + ); + assert!(Preimage::is_requested(&hash)); + // fails to clear metadata with a wrong origin. + assert_noop!( + Democracy::clear_proposal_metadata(RuntimeOrigin::signed(3), index), + Error::::NoPermission, + ); + // clear metadata successful. + assert_ok!(Democracy::clear_proposal_metadata(RuntimeOrigin::signed(1), index)); + System::assert_last_event(RuntimeEvent::Democracy(crate::Event::MetadataCleared { + owner: MetadataOwner::Proposal(index), + hash, + })); + assert!(!Preimage::is_requested(&hash)); + }); +} diff --git a/frame/democracy/src/types.rs b/frame/democracy/src/types.rs index 4b7f1a0fac45c..25954e05498a6 100644 --- a/frame/democracy/src/types.rs +++ b/frame/democracy/src/types.rs @@ -25,6 +25,12 @@ use sp_runtime::{ RuntimeDebug, }; +/// A proposal index. +pub type PropIndex = u32; + +/// A referendum index. +pub type ReferendumIndex = u32; + /// Info regarding an ongoing referendum. #[derive(Encode, MaxEncodedLen, Decode, Default, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo)] pub struct Tally { @@ -206,3 +212,14 @@ pub enum UnvoteScope { /// Permitted to do only the changes that do not need the owner's permission. OnlyExpired, } + +/// Identifies an owner of a metadata. +#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo, MaxEncodedLen)] +pub enum MetadataOwner { + /// External proposal. + External, + /// Public proposal of the index. + Proposal(PropIndex), + /// Referendum of the index. + Referendum(ReferendumIndex), +} diff --git a/frame/referenda/src/lib.rs b/frame/referenda/src/lib.rs index 991eb0a2adb46..8546e0d4c7a9d 100644 --- a/frame/referenda/src/lib.rs +++ b/frame/referenda/src/lib.rs @@ -611,9 +611,8 @@ pub mod pallet { /// /// - `origin`: Must be `Signed`, and the creator of the referendum. /// - `index`: The index of the referendum to add metadata for. - /// - `hash`: The preimage hash of an existing preimage. - // TODO replace the weight function - #[pallet::weight(1)] + /// - `hash`: The preimage hash of an on-chain stored preimage. + #[pallet::weight(T::WeightInfo::set_metadata())] pub fn set_metadata( origin: OriginFor, index: ReferendumIndex, @@ -634,8 +633,7 @@ pub mod pallet { /// - `origin`: Must be `Signed` or `Root`. If the referendum is ongoing, it must also be /// the creator of the referendum. /// - `index`: The index of the ongoing referendum to clear metadata for. - // TODO replace the weight function - #[pallet::weight(1)] + #[pallet::weight(T::WeightInfo::clear_metadata())] pub fn clear_metadata(origin: OriginFor, index: ReferendumIndex) -> DispatchResult { let maybe_who = ensure_signed_or_root(origin)?; if let Some(who) = maybe_who { diff --git a/frame/referenda/src/tests.rs b/frame/referenda/src/tests.rs index 7d699c66c9a36..c7ed36a630237 100644 --- a/frame/referenda/src/tests.rs +++ b/frame/referenda/src/tests.rs @@ -523,8 +523,8 @@ fn curve_handles_all_inputs() { #[test] fn set_metadata_works() { new_test_ext().execute_with(|| { - use sp_std::borrow::Cow; use frame_support::traits::Hash as PreimageHash; + use sp_std::borrow::Cow; // invalid preimage hash. let invalid_hash: PreimageHash = [1u8; 32].into(); // fails to set metadata for a finished referendum. @@ -562,7 +562,10 @@ fn set_metadata_works() { let index = ReferendumCount::::get() - 1; let hash = Preimage::note(Cow::from(vec![1])).unwrap(); assert_ok!(Referenda::set_metadata(RuntimeOrigin::signed(1), index, hash.clone(),)); - System::assert_last_event(RuntimeEvent::Referenda(crate::Event::MetadataSet { index, hash })); + System::assert_last_event(RuntimeEvent::Referenda(crate::Event::MetadataSet { + index, + hash, + })); assert!(Preimage::is_requested(&hash)); }); } @@ -579,15 +582,16 @@ fn clear_metadata_works() { DispatchTime::At(1), )); let index = ReferendumCount::::get() - 1; - assert_ok!( - Referenda::set_metadata(RuntimeOrigin::signed(1), index, hash.clone(),) - ); + assert_ok!(Referenda::set_metadata(RuntimeOrigin::signed(1), index, hash.clone(),)); assert!(Preimage::is_requested(&hash)); assert_noop!( Referenda::clear_metadata(RuntimeOrigin::signed(2), index,), Error::::NoPermission, ); assert_ok!(Referenda::clear_metadata(RuntimeOrigin::signed(1), index,),); - System::assert_last_event(RuntimeEvent::Referenda(crate::Event::MetadataCleared { index, hash })); + System::assert_last_event(RuntimeEvent::Referenda(crate::Event::MetadataCleared { + index, + hash, + })); }); } From afa1b2412d9bdad5b4d360aee488f8fa142bf15c Mon Sep 17 00:00:00 2001 From: muharem Date: Sun, 30 Oct 2022 19:33:54 +0100 Subject: [PATCH 11/29] metadata democracy pallet tests and benches --- Cargo.lock | 1 - frame/democracy/Cargo.toml | 1 - frame/democracy/src/benchmarking.rs | 170 +++++++- frame/democracy/src/lib.rs | 51 ++- frame/democracy/src/tests.rs | 16 +- .../democracy/src/tests/external_proposing.rs | 14 +- frame/democracy/src/tests/fast_tracking.rs | 4 +- frame/democracy/src/tests/public_proposals.rs | 11 +- frame/democracy/src/weights.rs | 412 ++++++++++++------ frame/referenda/src/mock.rs | 14 +- frame/referenda/src/tests.rs | 7 +- 11 files changed, 509 insertions(+), 192 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 808ed346e57d6..397846693e907 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5373,7 +5373,6 @@ dependencies = [ "pallet-preimage", "pallet-scheduler", "parity-scale-codec", - "rand 0.8.5", "scale-info", "serde", "sp-core", diff --git a/frame/democracy/Cargo.toml b/frame/democracy/Cargo.toml index 99a5401155acb..e50d39ff76902 100644 --- a/frame/democracy/Cargo.toml +++ b/frame/democracy/Cargo.toml @@ -28,7 +28,6 @@ sp-core = { version = "6.0.0", default-features = false, path = "../../primitive log = { version = "0.4.17", default-features = false } [dev-dependencies] -rand = "0.8.4" pallet-balances = { version = "4.0.0-dev", path = "../balances" } pallet-scheduler = { version = "4.0.0-dev", path = "../scheduler" } pallet-preimage = { version = "4.0.0-dev", path = "../preimage" } diff --git a/frame/democracy/src/benchmarking.rs b/frame/democracy/src/benchmarking.rs index 424192e2521da..fb5f9cbda69b1 100644 --- a/frame/democracy/src/benchmarking.rs +++ b/frame/democracy/src/benchmarking.rs @@ -54,19 +54,20 @@ fn add_proposal(n: u32) -> Result { Ok(proposal.hash()) } -fn add_referendum(n: u32) -> (ReferendumIndex, H256) { +// add a referendum and a metadata. +fn add_referendum(n: u32) -> (ReferendumIndex, H256, PreimageHash) { let vote_threshold = VoteThreshold::SimpleMajority; let proposal = make_proposal::(n); let hash = proposal.hash(); - ( - Democracy::::inject_referendum( - T::LaunchPeriod::get(), - proposal, - vote_threshold, - 0u32.into(), - ), - hash, - ) + let index = Democracy::::inject_referendum( + T::LaunchPeriod::get(), + proposal, + vote_threshold, + 0u32.into(), + ); + let preimage_hash = note_preimage::(); + MetadataOf::::insert(crate::MetadataOwner::Referendum(index), preimage_hash.clone()); + (index, hash, preimage_hash) } fn account_vote(b: BalanceOf) -> AccountVote> { @@ -75,6 +76,25 @@ fn account_vote(b: BalanceOf) -> AccountVote> { AccountVote::Standard { vote: v, balance: b } } +fn assert_last_event(generic_event: ::RuntimeEvent) { + frame_system::Pallet::::assert_last_event(generic_event.into()); +} + +fn assert_has_event(generic_event: ::RuntimeEvent) { + frame_system::Pallet::::assert_has_event(generic_event.into()); +} + +// note a new preimage. +fn note_preimage() -> PreimageHash { + use core::sync::atomic::{AtomicU8, Ordering}; + use sp_std::borrow::Cow; + // note a new preimage on every function invoke. + static COUNTER: AtomicU8 = AtomicU8::new(0); + let data = Cow::from(vec![COUNTER.fetch_add(1, Ordering::Relaxed)]); + let hash = ::Preimages::note(data.clone()).unwrap(); + hash +} + benchmarks! { propose { let p = T::MaxProposals::get(); @@ -178,7 +198,7 @@ benchmarks! { emergency_cancel { let origin = T::CancellationOrigin::successful_origin(); - let ref_index = add_referendum::(0).0; + let (ref_index, _, preimage_hash) = add_referendum::(0); assert_ok!(Democracy::::referendum_status(ref_index)); }: _(origin, ref_index) verify { @@ -187,6 +207,10 @@ benchmarks! { Democracy::::referendum_status(ref_index), Error::::ReferendumInvalid, ); + assert_last_event::(crate::Event::MetadataCleared { + owner: MetadataOwner::Referendum(ref_index), + hash: preimage_hash, + }.into()); } blacklist { @@ -197,7 +221,7 @@ benchmarks! { // We should really add a lot of seconds here, but we're not doing it elsewhere. // Add a referendum of our proposal. - let (ref_index, hash) = add_referendum::(0); + let (ref_index, hash, preimage_hash) = add_referendum::(0); assert_ok!(Democracy::::referendum_status(ref_index)); // Place our proposal in the external queue, too. assert_ok!( @@ -211,6 +235,10 @@ benchmarks! { Democracy::::referendum_status(ref_index), Error::::ReferendumInvalid ); + assert_has_event::(crate::Event::MetadataCleared { + owner: MetadataOwner::Referendum(ref_index), + hash: preimage_hash, + }.into()); } // Worst case scenario, we external propose a previously blacklisted proposal @@ -254,15 +282,24 @@ benchmarks! { let origin_propose = T::ExternalDefaultOrigin::successful_origin(); let proposal = make_proposal::(0); let proposal_hash = proposal.hash(); - Democracy::::external_propose_default(origin_propose, proposal)?; - + Democracy::::external_propose_default(origin_propose.clone(), proposal)?; + // Set metadata to the external proposal. + let preimage_hash = note_preimage::(); + assert_ok!(Democracy::::set_external_metadata( + origin_propose, + preimage_hash.clone())); // NOTE: Instant origin may invoke a little bit more logic, but may not always succeed. let origin_fast_track = T::FastTrackOrigin::successful_origin(); let voting_period = T::FastTrackVotingPeriod::get(); let delay = 0u32; }: _(origin_fast_track, proposal_hash, voting_period, delay.into()) verify { - assert_eq!(Democracy::::referendum_count(), 1, "referendum not created") + assert_eq!(Democracy::::referendum_count(), 1, "referendum not created"); + assert_last_event::(crate::Event::MetadataReset { + prev_owner: MetadataOwner::External, + owner: MetadataOwner::Referendum(0), + hash: preimage_hash, + }.into()); } veto_external { @@ -270,7 +307,13 @@ benchmarks! { let proposal_hash = proposal.hash(); let origin_propose = T::ExternalDefaultOrigin::successful_origin(); - Democracy::::external_propose_default(origin_propose, proposal)?; + Democracy::::external_propose_default(origin_propose.clone(), proposal)?; + + let preimage_hash = note_preimage::(); + assert_ok!(Democracy::::set_external_metadata( + origin_propose, + preimage_hash.clone()) + ); let mut vetoers: BoundedVec = Default::default(); for i in 0 .. (T::MaxBlacklisted::get() - 1) { @@ -293,12 +336,31 @@ benchmarks! { for i in 0 .. T::MaxProposals::get() { add_proposal::(i)?; } + // Add metadata to the first proposal. + let proposer = funded_account::("proposer", 0); + let preimage_hash = note_preimage::(); + assert_ok!(Democracy::::set_proposal_metadata( + RawOrigin::Signed(proposer).into(), + 0, + preimage_hash.clone())); let cancel_origin = T::CancelProposalOrigin::successful_origin(); }: _(cancel_origin, 0) + verify { + assert_last_event::(crate::Event::MetadataCleared { + owner: MetadataOwner::Proposal(0), + hash: preimage_hash, + }.into()); + } cancel_referendum { - let ref_index = add_referendum::(0).0; + let (ref_index, _, preimage_hash) = add_referendum::(0); }: _(RawOrigin::Root, ref_index) + verify { + assert_last_event::(crate::Event::MetadataCleared { + owner: MetadataOwner::Referendum(0), + hash: preimage_hash, + }.into()); + } #[extra] on_initialize_external { @@ -666,6 +728,80 @@ benchmarks! { assert_eq!(votes.len(), (r - 1) as usize, "Vote was not removed"); } + set_external_metadata { + let origin = T::ExternalOrigin::successful_origin(); + assert_ok!( + Democracy::::external_propose(origin.clone(), make_proposal::(0)) + ); + let preimage_hash = note_preimage::(); + }: _(origin, preimage_hash) + verify { + assert_last_event::(crate::Event::MetadataSet { + owner: MetadataOwner::External, + hash: preimage_hash, + }.into()); + } + + clear_external_metadata { + let origin = T::ExternalOrigin::successful_origin(); + assert_ok!( + Democracy::::external_propose(origin.clone(), make_proposal::(0)) + ); + let proposer = funded_account::("proposer", 0); + let preimage_hash = note_preimage::(); + assert_ok!(Democracy::::set_external_metadata(origin.clone(), preimage_hash.clone())); + }: _(origin) + verify { + assert_last_event::(crate::Event::MetadataCleared { + owner: MetadataOwner::External, + hash: preimage_hash, + }.into()); + } + + set_proposal_metadata { + // Place our proposal at the end to make sure it's worst case. + for i in 0 .. T::MaxProposals::get() { + add_proposal::(i)?; + } + let proposer = funded_account::("proposer", 0); + let preimage_hash = note_preimage::(); + }: _(RawOrigin::Signed(proposer).into(), 0, preimage_hash) + verify { + assert_last_event::(crate::Event::MetadataSet { + owner: MetadataOwner::Proposal(0), + hash: preimage_hash, + }.into()); + } + + clear_proposal_metadata { + // Place our proposal at the end to make sure it's worst case. + for i in 0 .. T::MaxProposals::get() { + add_proposal::(i)?; + } + let proposer = funded_account::("proposer", 0); + let preimage_hash = note_preimage::(); + assert_ok!(Democracy::::set_proposal_metadata( + RawOrigin::Signed(proposer.clone()).into(), + 0, + preimage_hash.clone())); + }: _(RawOrigin::Signed(proposer).into(), 0) + verify { + assert_last_event::(crate::Event::MetadataCleared { + owner: MetadataOwner::Proposal(0), + hash: preimage_hash, + }.into()); + } + + clear_referendum_metadata { + let (ref_index, _, preimage_hash) = add_referendum::(0); + }: _(RawOrigin::Root, ref_index) + verify { + assert_last_event::(crate::Event::MetadataCleared { + owner: MetadataOwner::Referendum(ref_index), + hash: preimage_hash, + }.into()); + } + impl_benchmark_test_suite!( Democracy, crate::tests::new_test_ext(), diff --git a/frame/democracy/src/lib.rs b/frame/democracy/src/lib.rs index d3c1ab525b714..1a6c879f49177 100644 --- a/frame/democracy/src/lib.rs +++ b/frame/democracy/src/lib.rs @@ -158,8 +158,9 @@ use frame_support::{ traits::{ defensive_prelude::*, schedule::{v3::Named as ScheduleNamed, DispatchTime}, - Bounded, Currency, Get, Hash as PreimageHash, LockIdentifier, LockableCurrency, - OnUnbalanced, QueryPreimage, ReservableCurrency, StorePreimage, WithdrawReasons, + Bounded, Currency, EnsureOrigin, Get, Hash as PreimageHash, LockIdentifier, + LockableCurrency, OnUnbalanced, QueryPreimage, ReservableCurrency, StorePreimage, + WithdrawReasons, }, weights::Weight, }; @@ -497,7 +498,7 @@ pub mod pallet { /// Preimage hash. hash: PreimageHash, }, - /// Metadata has been reset to new referendum. + /// Metadata has been reset to new owner. MetadataReset { /// Previous metadata owner. prev_owner: MetadataOwner, @@ -1087,9 +1088,8 @@ pub mod pallet { T::Slash::on_unbalanced(T::Currency::slash_reserved(&who, amount).0); } } - Self::clear_metadata(MetadataOwner::Proposal(prop_index)); - Self::deposit_event(Event::::ProposalCanceled { prop_index }); + Self::clear_metadata(MetadataOwner::Proposal(prop_index)); Ok(()) } @@ -1097,11 +1097,20 @@ pub mod pallet { /// /// - `origin`: Must be `ExternalOrigin`. /// - `hash`: The preimage hash of an on-chain stored preimage. - // TODO replace the weight function - #[pallet::weight(1)] + #[pallet::weight(T::WeightInfo::set_external_metadata())] pub fn set_external_metadata(origin: OriginFor, hash: PreimageHash) -> DispatchResult { - T::ExternalOrigin::ensure_origin(origin)?; - ensure!(>::exists(), Error::::NoProposal); + let (_, threshold) = >::get().ok_or(Error::::NoProposal)?; + match threshold { + VoteThreshold::SuperMajorityApprove => { + let _ = T::ExternalOrigin::ensure_origin(origin)?; + }, + VoteThreshold::SuperMajorityAgainst => { + let _ = T::ExternalDefaultOrigin::ensure_origin(origin)?; + }, + VoteThreshold::SimpleMajority => { + let _ = T::ExternalMajorityOrigin::ensure_origin(origin)?; + }, + }; ensure!(T::Preimages::len(&hash).is_some(), Error::::BadMetadata); T::Preimages::request(&hash); MetadataOf::::insert(MetadataOwner::External, hash); @@ -1114,8 +1123,7 @@ pub mod pallet { /// - `origin`: Must be `Signed`, and the creator of the referendum. /// - `index`: The index of the proposal. /// - `hash`: The preimage hash of an on-chain stored preimage. - // TODO replace the weight function - #[pallet::weight(1)] + #[pallet::weight(T::WeightInfo::set_proposal_metadata())] pub fn set_proposal_metadata( origin: OriginFor, index: PropIndex, @@ -1135,10 +1143,20 @@ pub mod pallet { /// Clear the external proposal metadata. /// /// - `origin`: Must be `ExternalOrigin`. - // TODO replace the weight function - #[pallet::weight(1)] + #[pallet::weight(T::WeightInfo::clear_external_metadata())] pub fn clear_external_metadata(origin: OriginFor) -> DispatchResult { - T::ExternalOrigin::ensure_origin(origin)?; + let (_, threshold) = >::get().ok_or(Error::::NoProposal)?; + match threshold { + VoteThreshold::SuperMajorityApprove => { + let _ = T::ExternalOrigin::ensure_origin(origin)?; + }, + VoteThreshold::SuperMajorityAgainst => { + let _ = T::ExternalDefaultOrigin::ensure_origin(origin)?; + }, + VoteThreshold::SimpleMajority => { + let _ = T::ExternalMajorityOrigin::ensure_origin(origin)?; + }, + }; Self::clear_metadata(MetadataOwner::External); Ok(()) } @@ -1147,8 +1165,7 @@ pub mod pallet { /// /// - `origin`: Must be `Signed`, and the creator of the referendum. /// - `index`: The index of the proposal. - // TODO replace the weight function - #[pallet::weight(1)] + #[pallet::weight(T::WeightInfo::clear_proposal_metadata())] pub fn clear_proposal_metadata(origin: OriginFor, index: PropIndex) -> DispatchResult { let who = ensure_signed(origin)?; let (_, _, proposer) = Self::proposal(index)?; @@ -1161,7 +1178,7 @@ pub mod pallet { /// /// - `origin`: Must be `Root`. /// - `index`: The index of the referendum. - #[pallet::weight(1)] + #[pallet::weight(T::WeightInfo::clear_referendum_metadata())] pub fn clear_referendum_metadata( origin: OriginFor, index: ReferendumIndex, diff --git a/frame/democracy/src/tests.rs b/frame/democracy/src/tests.rs index a22adf659ed59..ea30b2feb4d0f 100644 --- a/frame/democracy/src/tests.rs +++ b/frame/democracy/src/tests.rs @@ -32,7 +32,7 @@ use pallet_balances::{BalanceLock, Error as BalancesError}; use sp_core::H256; use sp_runtime::{ testing::Header, - traits::{BadOrigin, BlakeTwo256, IdentityLookup, Hash}, + traits::{BadOrigin, BlakeTwo256, Hash, IdentityLookup}, Perbill, }; mod cancellation; @@ -275,14 +275,14 @@ fn tally(r: ReferendumIndex) -> Tally { Democracy::referendum_status(r).unwrap().tally } -/// note preimage without registering. -/// randomize the data to make sure the preimage was not noted/registered before. -fn note_random_preimage(who: u64) -> PreimageHash { - use rand::Rng; - let mut rng = rand::thread_rng(); - let data: Vec = (0..100).map(|_| rng.gen_range(0..20)).collect(); +/// note a new preimage without registering. +fn note_preimage(who: u64) -> PreimageHash { + use std::sync::atomic::{AtomicU8, Ordering}; + // note a new preimage on every function invoke. + static COUNTER: AtomicU8 = AtomicU8::new(0); + let data = vec![COUNTER.fetch_add(1, Ordering::Relaxed)]; assert_ok!(Preimage::note_preimage(RuntimeOrigin::signed(who), data.clone())); let hash = BlakeTwo256::hash(&data); assert!(!Preimage::is_requested(&hash)); hash -} \ No newline at end of file +} diff --git a/frame/democracy/src/tests/external_proposing.rs b/frame/democracy/src/tests/external_proposing.rs index 32380024730a3..51634505f22ed 100644 --- a/frame/democracy/src/tests/external_proposing.rs +++ b/frame/democracy/src/tests/external_proposing.rs @@ -281,11 +281,6 @@ fn set_external_metadata_works() { use frame_support::traits::Hash as PreimageHash; // invalid preimage hash. let invalid_hash: PreimageHash = [1u8; 32].into(); - // fails to set metadata with non external origin. - assert_noop!( - Democracy::set_external_metadata(RuntimeOrigin::signed(1), invalid_hash.clone(),), - BadOrigin, - ); // fails to set metadata if an external proposal does not exist. assert_noop!( Democracy::set_external_metadata(RuntimeOrigin::signed(2), invalid_hash.clone(),), @@ -294,13 +289,18 @@ fn set_external_metadata_works() { // create an external proposal. assert_ok!(Democracy::external_propose(RuntimeOrigin::signed(2), set_balance_proposal(2),)); assert!(>::exists()); + // fails to set metadata with non external origin. + assert_noop!( + Democracy::set_external_metadata(RuntimeOrigin::signed(1), invalid_hash.clone(),), + BadOrigin, + ); // fails to set non-existing preimage. assert_noop!( Democracy::set_external_metadata(RuntimeOrigin::signed(2), invalid_hash.clone(),), Error::::BadMetadata, ); // set metadata successful. - let hash = note_random_preimage(1); + let hash = note_preimage(1); assert_ok!(Democracy::set_external_metadata(RuntimeOrigin::signed(2), hash.clone(),),); System::assert_last_event(RuntimeEvent::Democracy(crate::Event::MetadataSet { owner: MetadataOwner::External, @@ -317,7 +317,7 @@ fn clear_metadata_works() { assert_ok!(Democracy::external_propose(RuntimeOrigin::signed(2), set_balance_proposal(2),)); assert!(>::exists()); // set metadata. - let hash = note_random_preimage(1); + let hash = note_preimage(1); assert_ok!(Democracy::set_external_metadata(RuntimeOrigin::signed(2), hash.clone(),)); assert!(Preimage::is_requested(&hash)); // fails to clear metadata with a wrong origin. diff --git a/frame/democracy/src/tests/fast_tracking.rs b/frame/democracy/src/tests/fast_tracking.rs index 8d5ae406092c3..3c798a044e8d1 100644 --- a/frame/democracy/src/tests/fast_tracking.rs +++ b/frame/democracy/src/tests/fast_tracking.rs @@ -32,9 +32,9 @@ fn fast_track_referendum_works() { RuntimeOrigin::signed(3), set_balance_proposal(2) )); - let hash = note_random_preimage(1); + let hash = note_preimage(1); assert!(>::get(MetadataOwner::External).is_none()); - assert_ok!(Democracy::set_external_metadata(RuntimeOrigin::signed(2), hash.clone(),),); + assert_ok!(Democracy::set_external_metadata(RuntimeOrigin::signed(3), hash.clone(),),); assert!(>::get(MetadataOwner::External).is_some()); assert_noop!(Democracy::fast_track(RuntimeOrigin::signed(1), h, 3, 2), BadOrigin); assert_ok!(Democracy::fast_track(RuntimeOrigin::signed(5), h, 2, 0)); diff --git a/frame/democracy/src/tests/public_proposals.rs b/frame/democracy/src/tests/public_proposals.rs index 1fc64344f8bb0..6d498567beb3e 100644 --- a/frame/democracy/src/tests/public_proposals.rs +++ b/frame/democracy/src/tests/public_proposals.rs @@ -91,7 +91,7 @@ fn cancel_proposal_should_work() { assert_ok!(propose_set_balance(1, 2, 2)); assert_ok!(propose_set_balance(1, 4, 4)); assert_noop!(Democracy::cancel_proposal(RuntimeOrigin::signed(1), 0), BadOrigin); - let hash = note_random_preimage(1); + let hash = note_preimage(1); assert_ok!(Democracy::set_proposal_metadata(RuntimeOrigin::signed(1), 0, hash.clone())); assert!(>::get(MetadataOwner::Proposal(0)).is_some()); assert!(Preimage::is_requested(&hash)); @@ -99,7 +99,10 @@ fn cancel_proposal_should_work() { // metadata cleared, preimage unrequested. assert!(>::get(MetadataOwner::Proposal(0)).is_none()); assert!(!Preimage::is_requested(&hash)); - System::assert_last_event(crate::Event::ProposalCanceled { prop_index: 0 }.into()); + System::assert_has_event(crate::Event::ProposalCanceled { prop_index: 0 }.into()); + System::assert_last_event( + crate::Event::MetadataCleared { owner: MetadataOwner::Proposal(0), hash }.into(), + ); assert_eq!(Democracy::backing_for(0), None); assert_eq!(Democracy::backing_for(1), Some(4)); }); @@ -162,7 +165,7 @@ fn set_external_metadata_works() { Error::::BadMetadata, ); // note preimage. - let hash = note_random_preimage(1); + let hash = note_preimage(1); // fails to set non-existing preimage. assert_noop!( Democracy::set_proposal_metadata(RuntimeOrigin::signed(3), index, hash.clone(),), @@ -187,7 +190,7 @@ fn clear_metadata_works() { assert_ok!(propose_set_balance(1, 2, 5)); let index = Democracy::public_prop_count() - 1; // set metadata. - let hash = note_random_preimage(1); + let hash = note_preimage(1); assert!(!Preimage::is_requested(&hash)); assert_ok!( Democracy::set_proposal_metadata(RuntimeOrigin::signed(1), index, hash.clone(),) diff --git a/frame/democracy/src/weights.rs b/frame/democracy/src/weights.rs index 0a3b717938022..3ace5d727078c 100644 --- a/frame/democracy/src/weights.rs +++ b/frame/democracy/src/weights.rs @@ -1,39 +1,22 @@ -// This file is part of Substrate. - -// Copyright (C) 2022 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// 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. //! Autogenerated weights for pallet_democracy //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-10-03, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 +//! DATE: 2022-10-30, STEPS: `100`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `cob`, CPU: `` +//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: -// /home/benchbot/cargo_target_dir/production/substrate +// ./target/release/substrate // benchmark // pallet -// --steps=50 +// --chain=dev +// --steps=100 // --repeat=20 +// --pallet=pallet-democracy // --extrinsic=* -// --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --pallet=pallet_democracy -// --chain=dev // --output=./frame/democracy/src/weights.rs // --template=./.maintain/frame-weight-template.hbs @@ -68,6 +51,11 @@ pub trait WeightInfo { fn unlock_set(r: u32, ) -> Weight; fn remove_vote(r: u32, ) -> Weight; fn remove_other_vote(r: u32, ) -> Weight; + fn set_external_metadata() -> Weight; + fn clear_external_metadata() -> Weight; + fn set_proposal_metadata() -> Weight; + fn clear_proposal_metadata() -> Weight; + fn clear_referendum_metadata() -> Weight; } /// Weights for pallet_democracy using the Substrate node and recommended hardware. @@ -78,13 +66,15 @@ impl WeightInfo for SubstrateWeight { // Storage: Democracy Blacklist (r:1 w:0) // Storage: Democracy DepositOf (r:0 w:1) fn propose() -> Weight { - Weight::from_ref_time(57_410_000 as u64) + // Minimum execution time: 31_000 nanoseconds. + Weight::from_ref_time(32_000_000 as u64) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Democracy DepositOf (r:1 w:1) fn second() -> Weight { - Weight::from_ref_time(49_224_000 as u64) + // Minimum execution time: 29_000 nanoseconds. + Weight::from_ref_time(30_000_000 as u64) .saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } @@ -92,7 +82,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Democracy VotingOf (r:1 w:1) // Storage: Balances Locks (r:1 w:1) fn vote_new() -> Weight { - Weight::from_ref_time(60_933_000 as u64) + // Minimum execution time: 40_000 nanoseconds. + Weight::from_ref_time(43_000_000 as u64) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -100,81 +91,107 @@ impl WeightInfo for SubstrateWeight { // Storage: Democracy VotingOf (r:1 w:1) // Storage: Balances Locks (r:1 w:1) fn vote_existing() -> Weight { - Weight::from_ref_time(60_393_000 as u64) + // Minimum execution time: 40_000 nanoseconds. + Weight::from_ref_time(42_000_000 as u64) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Democracy ReferendumInfoOf (r:1 w:1) // Storage: Democracy Cancellations (r:1 w:1) + // Storage: Democracy MetadataOf (r:1 w:1) + // Storage: Preimage StatusFor (r:1 w:1) + // Storage: Preimage PreimageFor (r:0 w:1) fn emergency_cancel() -> Weight { - Weight::from_ref_time(24_588_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Minimum execution time: 30_000 nanoseconds. + Weight::from_ref_time(31_000_000 as u64) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(5 as u64)) } // Storage: Democracy PublicProps (r:1 w:1) // Storage: Democracy DepositOf (r:1 w:1) // Storage: System Account (r:1 w:1) + // Storage: Democracy MetadataOf (r:3 w:1) TODO // Storage: Democracy NextExternal (r:1 w:1) // Storage: Democracy ReferendumInfoOf (r:1 w:1) + // Storage: Preimage StatusFor (r:1 w:1) + // Storage: Preimage PreimageFor (r:0 w:1) TODO // Storage: Democracy Blacklist (r:0 w:1) fn blacklist() -> Weight { - Weight::from_ref_time(91_226_000 as u64) - .saturating_add(T::DbWeight::get().reads(5 as u64)) - .saturating_add(T::DbWeight::get().writes(6 as u64)) + // Minimum execution time: 74_000 nanoseconds. + Weight::from_ref_time(75_000_000 as u64) + .saturating_add(T::DbWeight::get().reads(9 as u64)) + .saturating_add(T::DbWeight::get().writes(9 as u64)) } // Storage: Democracy NextExternal (r:1 w:1) // Storage: Democracy Blacklist (r:1 w:0) fn external_propose() -> Weight { - Weight::from_ref_time(18_898_000 as u64) + // Minimum execution time: 15_000 nanoseconds. + Weight::from_ref_time(16_000_000 as u64) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Democracy NextExternal (r:0 w:1) fn external_propose_majority() -> Weight { - Weight::from_ref_time(5_136_000 as u64) + // Minimum execution time: 3_000 nanoseconds. + Weight::from_ref_time(4_000_000 as u64) .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Democracy NextExternal (r:0 w:1) fn external_propose_default() -> Weight { - Weight::from_ref_time(5_243_000 as u64) + // Minimum execution time: 3_000 nanoseconds. + Weight::from_ref_time(3_000_000 as u64) .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Democracy NextExternal (r:1 w:1) // Storage: Democracy ReferendumCount (r:1 w:1) + // Storage: Democracy MetadataOf (r:1 w:2) // Storage: Democracy ReferendumInfoOf (r:0 w:1) fn fast_track() -> Weight { - Weight::from_ref_time(24_275_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) + // Minimum execution time: 24_000 nanoseconds. + Weight::from_ref_time(25_000_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(5 as u64)) } // Storage: Democracy NextExternal (r:1 w:1) // Storage: Democracy Blacklist (r:1 w:1) + // Storage: Democracy MetadataOf (r:1 w:1) + // Storage: Preimage StatusFor (r:1 w:1) fn veto_external() -> Weight { - Weight::from_ref_time(30_988_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Minimum execution time: 32_000 nanoseconds. + Weight::from_ref_time(33_000_000 as u64) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: Democracy PublicProps (r:1 w:1) // Storage: Democracy DepositOf (r:1 w:1) // Storage: System Account (r:1 w:1) + // Storage: Democracy MetadataOf (r:1 w:1) + // Storage: Preimage StatusFor (r:1 w:1) fn cancel_proposal() -> Weight { - Weight::from_ref_time(78_515_000 as u64) - .saturating_add(T::DbWeight::get().reads(3 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) + // Minimum execution time: 62_000 nanoseconds. + Weight::from_ref_time(64_000_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(5 as u64)) } + // Storage: Democracy MetadataOf (r:1 w:1) + // Storage: Preimage StatusFor (r:1 w:1) + // Storage: Preimage PreimageFor (r:0 w:1) // Storage: Democracy ReferendumInfoOf (r:0 w:1) fn cancel_referendum() -> Weight { - Weight::from_ref_time(16_155_000 as u64) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Minimum execution time: 26_000 nanoseconds. + Weight::from_ref_time(27_000_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: Democracy LowestUnbaked (r:1 w:1) // Storage: Democracy ReferendumCount (r:1 w:0) - // Storage: Democracy ReferendumInfoOf (r:2 w:0) + // Storage: Democracy ReferendumInfoOf (r:1 w:0) /// The range of component `r` is `[0, 99]`. fn on_initialize_base(r: u32, ) -> Weight { - Weight::from_ref_time(7_007_000 as u64) - // Standard Error: 2_686 - .saturating_add(Weight::from_ref_time(2_288_781 as u64).saturating_mul(r as u64)) + // Minimum execution time: 5_000 nanoseconds. + Weight::from_ref_time(6_798_554 as u64) + // Standard Error: 6_545 + .saturating_add(Weight::from_ref_time(2_094_736 as u64).saturating_mul(r as u64)) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(r as u64))) .saturating_add(T::DbWeight::get().writes(1 as u64)) @@ -184,36 +201,39 @@ impl WeightInfo for SubstrateWeight { // Storage: Democracy LastTabledWasExternal (r:1 w:0) // Storage: Democracy NextExternal (r:1 w:0) // Storage: Democracy PublicProps (r:1 w:0) - // Storage: Democracy ReferendumInfoOf (r:2 w:0) + // Storage: Democracy ReferendumInfoOf (r:1 w:0) /// The range of component `r` is `[0, 99]`. fn on_initialize_base_with_launch_period(r: u32, ) -> Weight { - Weight::from_ref_time(9_528_000 as u64) - // Standard Error: 2_521 - .saturating_add(Weight::from_ref_time(2_291_780 as u64).saturating_mul(r as u64)) + // Minimum execution time: 6_000 nanoseconds. + Weight::from_ref_time(8_955_683 as u64) + // Standard Error: 6_329 + .saturating_add(Weight::from_ref_time(2_077_016 as u64).saturating_mul(r as u64)) .saturating_add(T::DbWeight::get().reads(5 as u64)) .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(r as u64))) .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Democracy VotingOf (r:3 w:3) // Storage: Balances Locks (r:1 w:1) - // Storage: Democracy ReferendumInfoOf (r:2 w:2) + // Storage: Democracy ReferendumInfoOf (r:1 w:1) /// The range of component `r` is `[0, 99]`. fn delegate(r: u32, ) -> Weight { - Weight::from_ref_time(46_787_000 as u64) - // Standard Error: 2_943 - .saturating_add(Weight::from_ref_time(3_460_194 as u64).saturating_mul(r as u64)) + // Minimum execution time: 37_000 nanoseconds. + Weight::from_ref_time(40_658_475 as u64) + // Standard Error: 6_103 + .saturating_add(Weight::from_ref_time(3_177_141 as u64).saturating_mul(r as u64)) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(r as u64))) .saturating_add(T::DbWeight::get().writes(4 as u64)) .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(r as u64))) } // Storage: Democracy VotingOf (r:2 w:2) - // Storage: Democracy ReferendumInfoOf (r:2 w:2) + // Storage: Democracy ReferendumInfoOf (r:1 w:1) /// The range of component `r` is `[0, 99]`. fn undelegate(r: u32, ) -> Weight { - Weight::from_ref_time(29_789_000 as u64) - // Standard Error: 2_324 - .saturating_add(Weight::from_ref_time(3_360_918 as u64).saturating_mul(r as u64)) + // Minimum execution time: 23_000 nanoseconds. + Weight::from_ref_time(21_737_425 as u64) + // Standard Error: 5_868 + .saturating_add(Weight::from_ref_time(3_172_334 as u64).saturating_mul(r as u64)) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(r as u64))) .saturating_add(T::DbWeight::get().writes(2 as u64)) @@ -221,7 +241,8 @@ impl WeightInfo for SubstrateWeight { } // Storage: Democracy PublicProps (r:0 w:1) fn clear_public_proposals() -> Weight { - Weight::from_ref_time(6_519_000 as u64) + // Minimum execution time: 3_000 nanoseconds. + Weight::from_ref_time(4_000_000 as u64) .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Democracy VotingOf (r:1 w:1) @@ -229,9 +250,10 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:1) /// The range of component `r` is `[0, 99]`. fn unlock_remove(r: u32, ) -> Weight { - Weight::from_ref_time(28_884_000 as u64) - // Standard Error: 2_631 - .saturating_add(Weight::from_ref_time(163_516 as u64).saturating_mul(r as u64)) + // Minimum execution time: 22_000 nanoseconds. + Weight::from_ref_time(27_756_178 as u64) + // Standard Error: 860 + .saturating_add(Weight::from_ref_time(19_693 as u64).saturating_mul(r as u64)) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -240,9 +262,10 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:1) /// The range of component `r` is `[0, 99]`. fn unlock_set(r: u32, ) -> Weight { - Weight::from_ref_time(33_498_000 as u64) - // Standard Error: 622 - .saturating_add(Weight::from_ref_time(133_421 as u64).saturating_mul(r as u64)) + // Minimum execution time: 25_000 nanoseconds. + Weight::from_ref_time(27_614_554 as u64) + // Standard Error: 829 + .saturating_add(Weight::from_ref_time(46_251 as u64).saturating_mul(r as u64)) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -250,9 +273,10 @@ impl WeightInfo for SubstrateWeight { // Storage: Democracy VotingOf (r:1 w:1) /// The range of component `r` is `[1, 100]`. fn remove_vote(r: u32, ) -> Weight { - Weight::from_ref_time(18_201_000 as u64) - // Standard Error: 1_007 - .saturating_add(Weight::from_ref_time(152_699 as u64).saturating_mul(r as u64)) + // Minimum execution time: 13_000 nanoseconds. + Weight::from_ref_time(15_102_121 as u64) + // Standard Error: 708 + .saturating_add(Weight::from_ref_time(54_453 as u64).saturating_mul(r as u64)) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } @@ -260,12 +284,58 @@ impl WeightInfo for SubstrateWeight { // Storage: Democracy VotingOf (r:1 w:1) /// The range of component `r` is `[1, 100]`. fn remove_other_vote(r: u32, ) -> Weight { - Weight::from_ref_time(18_455_000 as u64) - // Standard Error: 951 - .saturating_add(Weight::from_ref_time(150_907 as u64).saturating_mul(r as u64)) + // Minimum execution time: 13_000 nanoseconds. + Weight::from_ref_time(15_093_151 as u64) + // Standard Error: 829 + .saturating_add(Weight::from_ref_time(58_373 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Democracy NextExternal (r:1 w:0) + // Storage: Preimage StatusFor (r:1 w:1) + // Storage: Democracy MetadataOf (r:0 w:1) + fn set_external_metadata() -> Weight { + // Minimum execution time: 21_000 nanoseconds. + Weight::from_ref_time(22_000_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Democracy NextExternal (r:1 w:0) + // Storage: Democracy MetadataOf (r:1 w:1) + // Storage: Preimage StatusFor (r:1 w:1) + fn clear_external_metadata() -> Weight { + // Minimum execution time: 23_000 nanoseconds. + Weight::from_ref_time(25_000_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Democracy PublicProps (r:1 w:0) + // Storage: Preimage StatusFor (r:1 w:1) + // Storage: Democracy MetadataOf (r:0 w:1) + fn set_proposal_metadata() -> Weight { + // Minimum execution time: 35_000 nanoseconds. + Weight::from_ref_time(37_000_000 as u64) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } + // Storage: Democracy PublicProps (r:1 w:0) + // Storage: Democracy MetadataOf (r:1 w:1) + // Storage: Preimage StatusFor (r:1 w:1) + fn clear_proposal_metadata() -> Weight { + // Minimum execution time: 37_000 nanoseconds. + Weight::from_ref_time(38_000_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Democracy MetadataOf (r:1 w:1) + // Storage: Preimage StatusFor (r:1 w:1) + // Storage: Preimage PreimageFor (r:0 w:1) + fn clear_referendum_metadata() -> Weight { + // Minimum execution time: 23_000 nanoseconds. + Weight::from_ref_time(23_000_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } } // For backwards compatibility and tests @@ -275,13 +345,15 @@ impl WeightInfo for () { // Storage: Democracy Blacklist (r:1 w:0) // Storage: Democracy DepositOf (r:0 w:1) fn propose() -> Weight { - Weight::from_ref_time(57_410_000 as u64) + // Minimum execution time: 31_000 nanoseconds. + Weight::from_ref_time(32_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } // Storage: Democracy DepositOf (r:1 w:1) fn second() -> Weight { - Weight::from_ref_time(49_224_000 as u64) + // Minimum execution time: 29_000 nanoseconds. + Weight::from_ref_time(30_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(1 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } @@ -289,7 +361,8 @@ impl WeightInfo for () { // Storage: Democracy VotingOf (r:1 w:1) // Storage: Balances Locks (r:1 w:1) fn vote_new() -> Weight { - Weight::from_ref_time(60_933_000 as u64) + // Minimum execution time: 40_000 nanoseconds. + Weight::from_ref_time(43_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } @@ -297,81 +370,107 @@ impl WeightInfo for () { // Storage: Democracy VotingOf (r:1 w:1) // Storage: Balances Locks (r:1 w:1) fn vote_existing() -> Weight { - Weight::from_ref_time(60_393_000 as u64) + // Minimum execution time: 40_000 nanoseconds. + Weight::from_ref_time(42_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } // Storage: Democracy ReferendumInfoOf (r:1 w:1) // Storage: Democracy Cancellations (r:1 w:1) + // Storage: Democracy MetadataOf (r:1 w:1) + // Storage: Preimage StatusFor (r:1 w:1) + // Storage: Preimage PreimageFor (r:0 w:1) fn emergency_cancel() -> Weight { - Weight::from_ref_time(24_588_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + // Minimum execution time: 30_000 nanoseconds. + Weight::from_ref_time(31_000_000 as u64) + .saturating_add(RocksDbWeight::get().reads(4 as u64)) + .saturating_add(RocksDbWeight::get().writes(5 as u64)) } // Storage: Democracy PublicProps (r:1 w:1) // Storage: Democracy DepositOf (r:1 w:1) // Storage: System Account (r:1 w:1) + // Storage: Democracy MetadataOf (r:3 w:1) // Storage: Democracy NextExternal (r:1 w:1) // Storage: Democracy ReferendumInfoOf (r:1 w:1) + // Storage: Preimage StatusFor (r:1 w:1) + // Storage: Preimage PreimageFor (r:0 w:1) // Storage: Democracy Blacklist (r:0 w:1) fn blacklist() -> Weight { - Weight::from_ref_time(91_226_000 as u64) - .saturating_add(RocksDbWeight::get().reads(5 as u64)) - .saturating_add(RocksDbWeight::get().writes(6 as u64)) + // Minimum execution time: 74_000 nanoseconds. + Weight::from_ref_time(75_000_000 as u64) + .saturating_add(RocksDbWeight::get().reads(9 as u64)) + .saturating_add(RocksDbWeight::get().writes(9 as u64)) } // Storage: Democracy NextExternal (r:1 w:1) // Storage: Democracy Blacklist (r:1 w:0) fn external_propose() -> Weight { - Weight::from_ref_time(18_898_000 as u64) + // Minimum execution time: 15_000 nanoseconds. + Weight::from_ref_time(16_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } // Storage: Democracy NextExternal (r:0 w:1) fn external_propose_majority() -> Weight { - Weight::from_ref_time(5_136_000 as u64) + // Minimum execution time: 3_000 nanoseconds. + Weight::from_ref_time(4_000_000 as u64) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } // Storage: Democracy NextExternal (r:0 w:1) fn external_propose_default() -> Weight { - Weight::from_ref_time(5_243_000 as u64) + // Minimum execution time: 3_000 nanoseconds. + Weight::from_ref_time(3_000_000 as u64) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } // Storage: Democracy NextExternal (r:1 w:1) // Storage: Democracy ReferendumCount (r:1 w:1) + // Storage: Democracy MetadataOf (r:1 w:2) // Storage: Democracy ReferendumInfoOf (r:0 w:1) fn fast_track() -> Weight { - Weight::from_ref_time(24_275_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(3 as u64)) + // Minimum execution time: 24_000 nanoseconds. + Weight::from_ref_time(25_000_000 as u64) + .saturating_add(RocksDbWeight::get().reads(3 as u64)) + .saturating_add(RocksDbWeight::get().writes(5 as u64)) } // Storage: Democracy NextExternal (r:1 w:1) // Storage: Democracy Blacklist (r:1 w:1) + // Storage: Democracy MetadataOf (r:1 w:1) + // Storage: Preimage StatusFor (r:1 w:1) fn veto_external() -> Weight { - Weight::from_ref_time(30_988_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + // Minimum execution time: 32_000 nanoseconds. + Weight::from_ref_time(33_000_000 as u64) + .saturating_add(RocksDbWeight::get().reads(4 as u64)) + .saturating_add(RocksDbWeight::get().writes(4 as u64)) } // Storage: Democracy PublicProps (r:1 w:1) // Storage: Democracy DepositOf (r:1 w:1) // Storage: System Account (r:1 w:1) + // Storage: Democracy MetadataOf (r:1 w:1) + // Storage: Preimage StatusFor (r:1 w:1) fn cancel_proposal() -> Weight { - Weight::from_ref_time(78_515_000 as u64) - .saturating_add(RocksDbWeight::get().reads(3 as u64)) - .saturating_add(RocksDbWeight::get().writes(3 as u64)) + // Minimum execution time: 62_000 nanoseconds. + Weight::from_ref_time(64_000_000 as u64) + .saturating_add(RocksDbWeight::get().reads(5 as u64)) + .saturating_add(RocksDbWeight::get().writes(5 as u64)) } + // Storage: Democracy MetadataOf (r:1 w:1) + // Storage: Preimage StatusFor (r:1 w:1) + // Storage: Preimage PreimageFor (r:0 w:1) // Storage: Democracy ReferendumInfoOf (r:0 w:1) fn cancel_referendum() -> Weight { - Weight::from_ref_time(16_155_000 as u64) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Minimum execution time: 26_000 nanoseconds. + Weight::from_ref_time(27_000_000 as u64) + .saturating_add(RocksDbWeight::get().reads(2 as u64)) + .saturating_add(RocksDbWeight::get().writes(4 as u64)) } // Storage: Democracy LowestUnbaked (r:1 w:1) // Storage: Democracy ReferendumCount (r:1 w:0) - // Storage: Democracy ReferendumInfoOf (r:2 w:0) + // Storage: Democracy ReferendumInfoOf (r:1 w:0) /// The range of component `r` is `[0, 99]`. fn on_initialize_base(r: u32, ) -> Weight { - Weight::from_ref_time(7_007_000 as u64) - // Standard Error: 2_686 - .saturating_add(Weight::from_ref_time(2_288_781 as u64).saturating_mul(r as u64)) + // Minimum execution time: 5_000 nanoseconds. + Weight::from_ref_time(6_798_554 as u64) + // Standard Error: 6_545 + .saturating_add(Weight::from_ref_time(2_094_736 as u64).saturating_mul(r as u64)) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(r as u64))) .saturating_add(RocksDbWeight::get().writes(1 as u64)) @@ -381,36 +480,39 @@ impl WeightInfo for () { // Storage: Democracy LastTabledWasExternal (r:1 w:0) // Storage: Democracy NextExternal (r:1 w:0) // Storage: Democracy PublicProps (r:1 w:0) - // Storage: Democracy ReferendumInfoOf (r:2 w:0) + // Storage: Democracy ReferendumInfoOf (r:1 w:0) /// The range of component `r` is `[0, 99]`. fn on_initialize_base_with_launch_period(r: u32, ) -> Weight { - Weight::from_ref_time(9_528_000 as u64) - // Standard Error: 2_521 - .saturating_add(Weight::from_ref_time(2_291_780 as u64).saturating_mul(r as u64)) + // Minimum execution time: 6_000 nanoseconds. + Weight::from_ref_time(8_955_683 as u64) + // Standard Error: 6_329 + .saturating_add(Weight::from_ref_time(2_077_016 as u64).saturating_mul(r as u64)) .saturating_add(RocksDbWeight::get().reads(5 as u64)) .saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(r as u64))) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } // Storage: Democracy VotingOf (r:3 w:3) // Storage: Balances Locks (r:1 w:1) - // Storage: Democracy ReferendumInfoOf (r:2 w:2) + // Storage: Democracy ReferendumInfoOf (r:1 w:1) /// The range of component `r` is `[0, 99]`. fn delegate(r: u32, ) -> Weight { - Weight::from_ref_time(46_787_000 as u64) - // Standard Error: 2_943 - .saturating_add(Weight::from_ref_time(3_460_194 as u64).saturating_mul(r as u64)) + // Minimum execution time: 37_000 nanoseconds. + Weight::from_ref_time(40_658_475 as u64) + // Standard Error: 6_103 + .saturating_add(Weight::from_ref_time(3_177_141 as u64).saturating_mul(r as u64)) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(r as u64))) .saturating_add(RocksDbWeight::get().writes(4 as u64)) .saturating_add(RocksDbWeight::get().writes((1 as u64).saturating_mul(r as u64))) } // Storage: Democracy VotingOf (r:2 w:2) - // Storage: Democracy ReferendumInfoOf (r:2 w:2) + // Storage: Democracy ReferendumInfoOf (r:1 w:1) /// The range of component `r` is `[0, 99]`. fn undelegate(r: u32, ) -> Weight { - Weight::from_ref_time(29_789_000 as u64) - // Standard Error: 2_324 - .saturating_add(Weight::from_ref_time(3_360_918 as u64).saturating_mul(r as u64)) + // Minimum execution time: 23_000 nanoseconds. + Weight::from_ref_time(21_737_425 as u64) + // Standard Error: 5_868 + .saturating_add(Weight::from_ref_time(3_172_334 as u64).saturating_mul(r as u64)) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(r as u64))) .saturating_add(RocksDbWeight::get().writes(2 as u64)) @@ -418,7 +520,8 @@ impl WeightInfo for () { } // Storage: Democracy PublicProps (r:0 w:1) fn clear_public_proposals() -> Weight { - Weight::from_ref_time(6_519_000 as u64) + // Minimum execution time: 3_000 nanoseconds. + Weight::from_ref_time(4_000_000 as u64) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } // Storage: Democracy VotingOf (r:1 w:1) @@ -426,9 +529,10 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:1) /// The range of component `r` is `[0, 99]`. fn unlock_remove(r: u32, ) -> Weight { - Weight::from_ref_time(28_884_000 as u64) - // Standard Error: 2_631 - .saturating_add(Weight::from_ref_time(163_516 as u64).saturating_mul(r as u64)) + // Minimum execution time: 22_000 nanoseconds. + Weight::from_ref_time(27_756_178 as u64) + // Standard Error: 860 + .saturating_add(Weight::from_ref_time(19_693 as u64).saturating_mul(r as u64)) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } @@ -437,9 +541,10 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:1) /// The range of component `r` is `[0, 99]`. fn unlock_set(r: u32, ) -> Weight { - Weight::from_ref_time(33_498_000 as u64) - // Standard Error: 622 - .saturating_add(Weight::from_ref_time(133_421 as u64).saturating_mul(r as u64)) + // Minimum execution time: 25_000 nanoseconds. + Weight::from_ref_time(27_614_554 as u64) + // Standard Error: 829 + .saturating_add(Weight::from_ref_time(46_251 as u64).saturating_mul(r as u64)) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } @@ -447,9 +552,10 @@ impl WeightInfo for () { // Storage: Democracy VotingOf (r:1 w:1) /// The range of component `r` is `[1, 100]`. fn remove_vote(r: u32, ) -> Weight { - Weight::from_ref_time(18_201_000 as u64) - // Standard Error: 1_007 - .saturating_add(Weight::from_ref_time(152_699 as u64).saturating_mul(r as u64)) + // Minimum execution time: 13_000 nanoseconds. + Weight::from_ref_time(15_102_121 as u64) + // Standard Error: 708 + .saturating_add(Weight::from_ref_time(54_453 as u64).saturating_mul(r as u64)) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } @@ -457,10 +563,56 @@ impl WeightInfo for () { // Storage: Democracy VotingOf (r:1 w:1) /// The range of component `r` is `[1, 100]`. fn remove_other_vote(r: u32, ) -> Weight { - Weight::from_ref_time(18_455_000 as u64) - // Standard Error: 951 - .saturating_add(Weight::from_ref_time(150_907 as u64).saturating_mul(r as u64)) + // Minimum execution time: 13_000 nanoseconds. + Weight::from_ref_time(15_093_151 as u64) + // Standard Error: 829 + .saturating_add(Weight::from_ref_time(58_373 as u64).saturating_mul(r as u64)) + .saturating_add(RocksDbWeight::get().reads(2 as u64)) + .saturating_add(RocksDbWeight::get().writes(2 as u64)) + } + // Storage: Democracy NextExternal (r:1 w:0) + // Storage: Preimage StatusFor (r:1 w:1) + // Storage: Democracy MetadataOf (r:0 w:1) + fn set_external_metadata() -> Weight { + // Minimum execution time: 21_000 nanoseconds. + Weight::from_ref_time(22_000_000 as u64) + .saturating_add(RocksDbWeight::get().reads(2 as u64)) + .saturating_add(RocksDbWeight::get().writes(2 as u64)) + } + // Storage: Democracy NextExternal (r:1 w:0) + // Storage: Democracy MetadataOf (r:1 w:1) + // Storage: Preimage StatusFor (r:1 w:1) + fn clear_external_metadata() -> Weight { + // Minimum execution time: 23_000 nanoseconds. + Weight::from_ref_time(25_000_000 as u64) + .saturating_add(RocksDbWeight::get().reads(3 as u64)) + .saturating_add(RocksDbWeight::get().writes(2 as u64)) + } + // Storage: Democracy PublicProps (r:1 w:0) + // Storage: Preimage StatusFor (r:1 w:1) + // Storage: Democracy MetadataOf (r:0 w:1) + fn set_proposal_metadata() -> Weight { + // Minimum execution time: 35_000 nanoseconds. + Weight::from_ref_time(37_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } + // Storage: Democracy PublicProps (r:1 w:0) + // Storage: Democracy MetadataOf (r:1 w:1) + // Storage: Preimage StatusFor (r:1 w:1) + fn clear_proposal_metadata() -> Weight { + // Minimum execution time: 37_000 nanoseconds. + Weight::from_ref_time(38_000_000 as u64) + .saturating_add(RocksDbWeight::get().reads(3 as u64)) + .saturating_add(RocksDbWeight::get().writes(2 as u64)) + } + // Storage: Democracy MetadataOf (r:1 w:1) + // Storage: Preimage StatusFor (r:1 w:1) + // Storage: Preimage PreimageFor (r:0 w:1) + fn clear_referendum_metadata() -> Weight { + // Minimum execution time: 23_000 nanoseconds. + Weight::from_ref_time(23_000_000 as u64) + .saturating_add(RocksDbWeight::get().reads(2 as u64)) + .saturating_add(RocksDbWeight::get().writes(3 as u64)) + } } diff --git a/frame/referenda/src/mock.rs b/frame/referenda/src/mock.rs index c98fbf9a676b1..929473b8a2b09 100644 --- a/frame/referenda/src/mock.rs +++ b/frame/referenda/src/mock.rs @@ -32,7 +32,7 @@ use frame_system::{EnsureRoot, EnsureSignedBy}; use sp_core::H256; use sp_runtime::{ testing::Header, - traits::{BlakeTwo256, IdentityLookup}, + traits::{BlakeTwo256, Hash, IdentityLookup}, DispatchResult, Perbill, }; @@ -472,3 +472,15 @@ impl RefState { index } } + +/// note a new preimage without registering. +pub fn note_preimage(who: u64) -> PreimageHash { + use std::sync::atomic::{AtomicU8, Ordering}; + // note a new preimage on every function invoke. + static COUNTER: AtomicU8 = AtomicU8::new(0); + let data = vec![COUNTER.fetch_add(1, Ordering::Relaxed)]; + assert_ok!(Preimage::note_preimage(RuntimeOrigin::signed(who), data.clone())); + let hash = BlakeTwo256::hash(&data); + assert!(!Preimage::is_requested(&hash)); + hash +} diff --git a/frame/referenda/src/tests.rs b/frame/referenda/src/tests.rs index c7ed36a630237..d18318abcda4c 100644 --- a/frame/referenda/src/tests.rs +++ b/frame/referenda/src/tests.rs @@ -524,7 +524,6 @@ fn curve_handles_all_inputs() { fn set_metadata_works() { new_test_ext().execute_with(|| { use frame_support::traits::Hash as PreimageHash; - use sp_std::borrow::Cow; // invalid preimage hash. let invalid_hash: PreimageHash = [1u8; 32].into(); // fails to set metadata for a finished referendum. @@ -560,7 +559,7 @@ fn set_metadata_works() { ); // metadata set. let index = ReferendumCount::::get() - 1; - let hash = Preimage::note(Cow::from(vec![1])).unwrap(); + let hash = note_preimage(1); assert_ok!(Referenda::set_metadata(RuntimeOrigin::signed(1), index, hash.clone(),)); System::assert_last_event(RuntimeEvent::Referenda(crate::Event::MetadataSet { index, @@ -573,8 +572,7 @@ fn set_metadata_works() { #[test] fn clear_metadata_works() { new_test_ext().execute_with(|| { - use sp_std::borrow::Cow; - let hash = Preimage::note(Cow::from(vec![1, 2])).unwrap(); + let hash = note_preimage(1); assert_ok!(Referenda::submit( RuntimeOrigin::signed(1), Box::new(RawOrigin::Root.into()), @@ -593,5 +591,6 @@ fn clear_metadata_works() { index, hash, })); + assert!(!Preimage::is_requested(&hash)); }); } From 7ffe4c8acf6e005b03da201bd83df85ec626f46d Mon Sep 17 00:00:00 2001 From: muharem Date: Sun, 30 Oct 2022 19:53:14 +0100 Subject: [PATCH 12/29] fix cargo clippy --- frame/democracy/src/tests/external_proposing.rs | 10 +++++----- frame/democracy/src/tests/fast_tracking.rs | 2 +- frame/democracy/src/tests/public_proposals.rs | 14 +++++--------- frame/referenda/src/tests.rs | 8 ++++---- 4 files changed, 15 insertions(+), 19 deletions(-) diff --git a/frame/democracy/src/tests/external_proposing.rs b/frame/democracy/src/tests/external_proposing.rs index 51634505f22ed..2cd12e087843b 100644 --- a/frame/democracy/src/tests/external_proposing.rs +++ b/frame/democracy/src/tests/external_proposing.rs @@ -283,7 +283,7 @@ fn set_external_metadata_works() { let invalid_hash: PreimageHash = [1u8; 32].into(); // fails to set metadata if an external proposal does not exist. assert_noop!( - Democracy::set_external_metadata(RuntimeOrigin::signed(2), invalid_hash.clone(),), + Democracy::set_external_metadata(RuntimeOrigin::signed(2), invalid_hash), Error::::NoProposal, ); // create an external proposal. @@ -291,17 +291,17 @@ fn set_external_metadata_works() { assert!(>::exists()); // fails to set metadata with non external origin. assert_noop!( - Democracy::set_external_metadata(RuntimeOrigin::signed(1), invalid_hash.clone(),), + Democracy::set_external_metadata(RuntimeOrigin::signed(1), invalid_hash), BadOrigin, ); // fails to set non-existing preimage. assert_noop!( - Democracy::set_external_metadata(RuntimeOrigin::signed(2), invalid_hash.clone(),), + Democracy::set_external_metadata(RuntimeOrigin::signed(2), invalid_hash), Error::::BadMetadata, ); // set metadata successful. let hash = note_preimage(1); - assert_ok!(Democracy::set_external_metadata(RuntimeOrigin::signed(2), hash.clone(),),); + assert_ok!(Democracy::set_external_metadata(RuntimeOrigin::signed(2), hash,),); System::assert_last_event(RuntimeEvent::Democracy(crate::Event::MetadataSet { owner: MetadataOwner::External, hash, @@ -318,7 +318,7 @@ fn clear_metadata_works() { assert!(>::exists()); // set metadata. let hash = note_preimage(1); - assert_ok!(Democracy::set_external_metadata(RuntimeOrigin::signed(2), hash.clone(),)); + assert_ok!(Democracy::set_external_metadata(RuntimeOrigin::signed(2), hash,)); assert!(Preimage::is_requested(&hash)); // fails to clear metadata with a wrong origin. assert_noop!(Democracy::clear_external_metadata(RuntimeOrigin::signed(1)), BadOrigin,); diff --git a/frame/democracy/src/tests/fast_tracking.rs b/frame/democracy/src/tests/fast_tracking.rs index 3c798a044e8d1..34350a494dc6f 100644 --- a/frame/democracy/src/tests/fast_tracking.rs +++ b/frame/democracy/src/tests/fast_tracking.rs @@ -34,7 +34,7 @@ fn fast_track_referendum_works() { )); let hash = note_preimage(1); assert!(>::get(MetadataOwner::External).is_none()); - assert_ok!(Democracy::set_external_metadata(RuntimeOrigin::signed(3), hash.clone(),),); + assert_ok!(Democracy::set_external_metadata(RuntimeOrigin::signed(3), hash,),); assert!(>::get(MetadataOwner::External).is_some()); assert_noop!(Democracy::fast_track(RuntimeOrigin::signed(1), h, 3, 2), BadOrigin); assert_ok!(Democracy::fast_track(RuntimeOrigin::signed(5), h, 2, 0)); diff --git a/frame/democracy/src/tests/public_proposals.rs b/frame/democracy/src/tests/public_proposals.rs index 6d498567beb3e..e05df6d7319bd 100644 --- a/frame/democracy/src/tests/public_proposals.rs +++ b/frame/democracy/src/tests/public_proposals.rs @@ -92,7 +92,7 @@ fn cancel_proposal_should_work() { assert_ok!(propose_set_balance(1, 4, 4)); assert_noop!(Democracy::cancel_proposal(RuntimeOrigin::signed(1), 0), BadOrigin); let hash = note_preimage(1); - assert_ok!(Democracy::set_proposal_metadata(RuntimeOrigin::signed(1), 0, hash.clone())); + assert_ok!(Democracy::set_proposal_metadata(RuntimeOrigin::signed(1), 0, hash)); assert!(>::get(MetadataOwner::Proposal(0)).is_some()); assert!(Preimage::is_requested(&hash)); assert_ok!(Democracy::cancel_proposal(RuntimeOrigin::root(), 0)); @@ -161,20 +161,18 @@ fn set_external_metadata_works() { let index = Democracy::public_prop_count() - 1; // fails to set non-existing preimage. assert_noop!( - Democracy::set_proposal_metadata(RuntimeOrigin::signed(1), index, invalid_hash.clone(),), + Democracy::set_proposal_metadata(RuntimeOrigin::signed(1), index, invalid_hash,), Error::::BadMetadata, ); // note preimage. let hash = note_preimage(1); // fails to set non-existing preimage. assert_noop!( - Democracy::set_proposal_metadata(RuntimeOrigin::signed(3), index, hash.clone(),), + Democracy::set_proposal_metadata(RuntimeOrigin::signed(3), index, hash,), Error::::NoPermission, ); // set metadata successful. - assert_ok!( - Democracy::set_proposal_metadata(RuntimeOrigin::signed(1), index, hash.clone(),), - ); + assert_ok!(Democracy::set_proposal_metadata(RuntimeOrigin::signed(1), index, hash,),); System::assert_last_event(RuntimeEvent::Democracy(crate::Event::MetadataSet { owner: MetadataOwner::Proposal(index), hash, @@ -192,9 +190,7 @@ fn clear_metadata_works() { // set metadata. let hash = note_preimage(1); assert!(!Preimage::is_requested(&hash)); - assert_ok!( - Democracy::set_proposal_metadata(RuntimeOrigin::signed(1), index, hash.clone(),) - ); + assert_ok!(Democracy::set_proposal_metadata(RuntimeOrigin::signed(1), index, hash,)); assert!(Preimage::is_requested(&hash)); // fails to clear metadata with a wrong origin. assert_noop!( diff --git a/frame/referenda/src/tests.rs b/frame/referenda/src/tests.rs index d18318abcda4c..feaf21afdef95 100644 --- a/frame/referenda/src/tests.rs +++ b/frame/referenda/src/tests.rs @@ -536,7 +536,7 @@ fn set_metadata_works() { let index = ReferendumCount::::get() - 1; assert_ok!(Referenda::kill(RuntimeOrigin::root(), index)); assert_noop!( - Referenda::set_metadata(RuntimeOrigin::signed(1), index, invalid_hash.clone(),), + Referenda::set_metadata(RuntimeOrigin::signed(1), index, invalid_hash), Error::::NotOngoing, ); // no permission to set metadata. @@ -548,7 +548,7 @@ fn set_metadata_works() { )); let index = ReferendumCount::::get() - 1; assert_noop!( - Referenda::set_metadata(RuntimeOrigin::signed(2), index, invalid_hash.clone(),), + Referenda::set_metadata(RuntimeOrigin::signed(2), index, invalid_hash), Error::::NoPermission, ); // preimage does not exist. @@ -560,7 +560,7 @@ fn set_metadata_works() { // metadata set. let index = ReferendumCount::::get() - 1; let hash = note_preimage(1); - assert_ok!(Referenda::set_metadata(RuntimeOrigin::signed(1), index, hash.clone(),)); + assert_ok!(Referenda::set_metadata(RuntimeOrigin::signed(1), index, hash)); System::assert_last_event(RuntimeEvent::Referenda(crate::Event::MetadataSet { index, hash, @@ -580,7 +580,7 @@ fn clear_metadata_works() { DispatchTime::At(1), )); let index = ReferendumCount::::get() - 1; - assert_ok!(Referenda::set_metadata(RuntimeOrigin::signed(1), index, hash.clone(),)); + assert_ok!(Referenda::set_metadata(RuntimeOrigin::signed(1), index, hash)); assert!(Preimage::is_requested(&hash)); assert_noop!( Referenda::clear_metadata(RuntimeOrigin::signed(2), index,), From 418262d2a343df11ae59299f24c2f9db1c71782a Mon Sep 17 00:00:00 2001 From: muharem Date: Mon, 31 Oct 2022 12:53:51 +0100 Subject: [PATCH 13/29] update docs --- frame/democracy/src/benchmarking.rs | 2 +- frame/democracy/src/lib.rs | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/frame/democracy/src/benchmarking.rs b/frame/democracy/src/benchmarking.rs index fb5f9cbda69b1..1bcd16ce9cc19 100644 --- a/frame/democracy/src/benchmarking.rs +++ b/frame/democracy/src/benchmarking.rs @@ -54,7 +54,7 @@ fn add_proposal(n: u32) -> Result { Ok(proposal.hash()) } -// add a referendum and a metadata. +// add a referendum with a metadata. fn add_referendum(n: u32) -> (ReferendumIndex, H256, PreimageHash) { let vote_threshold = VoteThreshold::SimpleMajority; let proposal = make_proposal::(n); diff --git a/frame/democracy/src/lib.rs b/frame/democracy/src/lib.rs index 1a6c879f49177..185926ec6d3f4 100644 --- a/frame/democracy/src/lib.rs +++ b/frame/democracy/src/lib.rs @@ -1095,7 +1095,9 @@ pub mod pallet { /// Set the metadata to the external proposal. /// - /// - `origin`: Must be `ExternalOrigin`. + /// - `origin`: Must be an external origin and correspond to the proposal vote threshold, + /// `ExternalOrigin` for `SuperMajorityApprove`, `ExternalDefaultOrigin` for + /// `SuperMajorityAgainst` and `ExternalMajorityOrigin` for `SimpleMajority`. /// - `hash`: The preimage hash of an on-chain stored preimage. #[pallet::weight(T::WeightInfo::set_external_metadata())] pub fn set_external_metadata(origin: OriginFor, hash: PreimageHash) -> DispatchResult { @@ -1120,7 +1122,7 @@ pub mod pallet { /// Set the metadata to the public proposal. /// - /// - `origin`: Must be `Signed`, and the creator of the referendum. + /// - `origin`: Must be `Signed`, and the creator of the proposal. /// - `index`: The index of the proposal. /// - `hash`: The preimage hash of an on-chain stored preimage. #[pallet::weight(T::WeightInfo::set_proposal_metadata())] @@ -1142,7 +1144,9 @@ pub mod pallet { /// Clear the external proposal metadata. /// - /// - `origin`: Must be `ExternalOrigin`. + /// - `origin`: Must be an external origin and correspond to the proposal vote threshold, + /// `ExternalOrigin` for `SuperMajorityApprove`, `ExternalDefaultOrigin` for + /// `SuperMajorityAgainst` and `ExternalMajorityOrigin` for `SimpleMajority`. #[pallet::weight(T::WeightInfo::clear_external_metadata())] pub fn clear_external_metadata(origin: OriginFor) -> DispatchResult { let (_, threshold) = >::get().ok_or(Error::::NoProposal)?; @@ -1163,7 +1167,7 @@ pub mod pallet { /// Clear the public proposal metadata. /// - /// - `origin`: Must be `Signed`, and the creator of the referendum. + /// - `origin`: Must be `Signed`, and the creator of the proposal. /// - `index`: The index of the proposal. #[pallet::weight(T::WeightInfo::clear_proposal_metadata())] pub fn clear_proposal_metadata(origin: OriginFor, index: PropIndex) -> DispatchResult { From ef4e0cb2fe087ea77817c05faa2cb1617f97ae6a Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Mon, 31 Oct 2022 12:22:02 +0000 Subject: [PATCH 14/29] ".git/.scripts/bench-bot.sh" pallet dev pallet_democracy --- frame/democracy/src/weights.rs | 333 +++++++++++++++++---------------- 1 file changed, 176 insertions(+), 157 deletions(-) diff --git a/frame/democracy/src/weights.rs b/frame/democracy/src/weights.rs index 3ace5d727078c..2176dfb48d873 100644 --- a/frame/democracy/src/weights.rs +++ b/frame/democracy/src/weights.rs @@ -1,22 +1,41 @@ +// This file is part of Substrate. + +// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// 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. //! Autogenerated weights for pallet_democracy //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-10-30, STEPS: `100`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `cob`, CPU: `` -//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 +//! DATE: 2022-10-31, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: -// ./target/release/substrate +// /home/benchbot/cargo_target_dir/production/substrate // benchmark // pallet -// --chain=dev -// --steps=100 +// --steps=50 // --repeat=20 -// --pallet=pallet-democracy // --extrinsic=* +// --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 +// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/substrate/.git/.artifacts/bench.json +// --pallet=pallet_democracy +// --chain=dev +// --header=./HEADER-APACHE2 // --output=./frame/democracy/src/weights.rs // --template=./.maintain/frame-weight-template.hbs @@ -66,15 +85,15 @@ impl WeightInfo for SubstrateWeight { // Storage: Democracy Blacklist (r:1 w:0) // Storage: Democracy DepositOf (r:0 w:1) fn propose() -> Weight { - // Minimum execution time: 31_000 nanoseconds. - Weight::from_ref_time(32_000_000 as u64) + // Minimum execution time: 56_190 nanoseconds. + Weight::from_ref_time(57_022_000 as u64) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Democracy DepositOf (r:1 w:1) fn second() -> Weight { - // Minimum execution time: 29_000 nanoseconds. - Weight::from_ref_time(30_000_000 as u64) + // Minimum execution time: 48_192 nanoseconds. + Weight::from_ref_time(48_719_000 as u64) .saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } @@ -82,8 +101,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Democracy VotingOf (r:1 w:1) // Storage: Balances Locks (r:1 w:1) fn vote_new() -> Weight { - // Minimum execution time: 40_000 nanoseconds. - Weight::from_ref_time(43_000_000 as u64) + // Minimum execution time: 71_575 nanoseconds. + Weight::from_ref_time(72_584_000 as u64) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -91,8 +110,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Democracy VotingOf (r:1 w:1) // Storage: Balances Locks (r:1 w:1) fn vote_existing() -> Weight { - // Minimum execution time: 40_000 nanoseconds. - Weight::from_ref_time(42_000_000 as u64) + // Minimum execution time: 72_634 nanoseconds. + Weight::from_ref_time(74_350_000 as u64) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -102,44 +121,44 @@ impl WeightInfo for SubstrateWeight { // Storage: Preimage StatusFor (r:1 w:1) // Storage: Preimage PreimageFor (r:0 w:1) fn emergency_cancel() -> Weight { - // Minimum execution time: 30_000 nanoseconds. - Weight::from_ref_time(31_000_000 as u64) + // Minimum execution time: 44_016 nanoseconds. + Weight::from_ref_time(44_755_000 as u64) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().writes(5 as u64)) } // Storage: Democracy PublicProps (r:1 w:1) // Storage: Democracy DepositOf (r:1 w:1) // Storage: System Account (r:1 w:1) - // Storage: Democracy MetadataOf (r:3 w:1) TODO + // Storage: Democracy MetadataOf (r:3 w:1) // Storage: Democracy NextExternal (r:1 w:1) // Storage: Democracy ReferendumInfoOf (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:1) - // Storage: Preimage PreimageFor (r:0 w:1) TODO + // Storage: Preimage PreimageFor (r:0 w:1) // Storage: Democracy Blacklist (r:0 w:1) fn blacklist() -> Weight { - // Minimum execution time: 74_000 nanoseconds. - Weight::from_ref_time(75_000_000 as u64) + // Minimum execution time: 109_317 nanoseconds. + Weight::from_ref_time(110_489_000 as u64) .saturating_add(T::DbWeight::get().reads(9 as u64)) .saturating_add(T::DbWeight::get().writes(9 as u64)) } // Storage: Democracy NextExternal (r:1 w:1) // Storage: Democracy Blacklist (r:1 w:0) fn external_propose() -> Weight { - // Minimum execution time: 15_000 nanoseconds. - Weight::from_ref_time(16_000_000 as u64) + // Minimum execution time: 18_768 nanoseconds. + Weight::from_ref_time(19_256_000 as u64) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Democracy NextExternal (r:0 w:1) fn external_propose_majority() -> Weight { - // Minimum execution time: 3_000 nanoseconds. - Weight::from_ref_time(4_000_000 as u64) + // Minimum execution time: 4_887 nanoseconds. + Weight::from_ref_time(5_071_000 as u64) .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Democracy NextExternal (r:0 w:1) fn external_propose_default() -> Weight { - // Minimum execution time: 3_000 nanoseconds. - Weight::from_ref_time(3_000_000 as u64) + // Minimum execution time: 4_966 nanoseconds. + Weight::from_ref_time(5_174_000 as u64) .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Democracy NextExternal (r:1 w:1) @@ -147,8 +166,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Democracy MetadataOf (r:1 w:2) // Storage: Democracy ReferendumInfoOf (r:0 w:1) fn fast_track() -> Weight { - // Minimum execution time: 24_000 nanoseconds. - Weight::from_ref_time(25_000_000 as u64) + // Minimum execution time: 34_839 nanoseconds. + Weight::from_ref_time(35_514_000 as u64) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(5 as u64)) } @@ -157,8 +176,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Democracy MetadataOf (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:1) fn veto_external() -> Weight { - // Minimum execution time: 32_000 nanoseconds. - Weight::from_ref_time(33_000_000 as u64) + // Minimum execution time: 46_388 nanoseconds. + Weight::from_ref_time(46_837_000 as u64) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().writes(4 as u64)) } @@ -168,8 +187,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Democracy MetadataOf (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:1) fn cancel_proposal() -> Weight { - // Minimum execution time: 62_000 nanoseconds. - Weight::from_ref_time(64_000_000 as u64) + // Minimum execution time: 88_273 nanoseconds. + Weight::from_ref_time(89_910_000 as u64) .saturating_add(T::DbWeight::get().reads(5 as u64)) .saturating_add(T::DbWeight::get().writes(5 as u64)) } @@ -178,20 +197,20 @@ impl WeightInfo for SubstrateWeight { // Storage: Preimage PreimageFor (r:0 w:1) // Storage: Democracy ReferendumInfoOf (r:0 w:1) fn cancel_referendum() -> Weight { - // Minimum execution time: 26_000 nanoseconds. - Weight::from_ref_time(27_000_000 as u64) + // Minimum execution time: 36_626 nanoseconds. + Weight::from_ref_time(37_221_000 as u64) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: Democracy LowestUnbaked (r:1 w:1) // Storage: Democracy ReferendumCount (r:1 w:0) - // Storage: Democracy ReferendumInfoOf (r:1 w:0) + // Storage: Democracy ReferendumInfoOf (r:2 w:0) /// The range of component `r` is `[0, 99]`. fn on_initialize_base(r: u32, ) -> Weight { - // Minimum execution time: 5_000 nanoseconds. - Weight::from_ref_time(6_798_554 as u64) - // Standard Error: 6_545 - .saturating_add(Weight::from_ref_time(2_094_736 as u64).saturating_mul(r as u64)) + // Minimum execution time: 6_738 nanoseconds. + Weight::from_ref_time(12_684_834 as u64) + // Standard Error: 5_168 + .saturating_add(Weight::from_ref_time(2_402_248 as u64).saturating_mul(r as u64)) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(r as u64))) .saturating_add(T::DbWeight::get().writes(1 as u64)) @@ -201,39 +220,39 @@ impl WeightInfo for SubstrateWeight { // Storage: Democracy LastTabledWasExternal (r:1 w:0) // Storage: Democracy NextExternal (r:1 w:0) // Storage: Democracy PublicProps (r:1 w:0) - // Storage: Democracy ReferendumInfoOf (r:1 w:0) + // Storage: Democracy ReferendumInfoOf (r:2 w:0) /// The range of component `r` is `[0, 99]`. fn on_initialize_base_with_launch_period(r: u32, ) -> Weight { - // Minimum execution time: 6_000 nanoseconds. - Weight::from_ref_time(8_955_683 as u64) - // Standard Error: 6_329 - .saturating_add(Weight::from_ref_time(2_077_016 as u64).saturating_mul(r as u64)) + // Minimum execution time: 9_188 nanoseconds. + Weight::from_ref_time(16_333_541 as u64) + // Standard Error: 4_393 + .saturating_add(Weight::from_ref_time(2_379_560 as u64).saturating_mul(r as u64)) .saturating_add(T::DbWeight::get().reads(5 as u64)) .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(r as u64))) .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Democracy VotingOf (r:3 w:3) // Storage: Balances Locks (r:1 w:1) - // Storage: Democracy ReferendumInfoOf (r:1 w:1) + // Storage: Democracy ReferendumInfoOf (r:2 w:2) /// The range of component `r` is `[0, 99]`. fn delegate(r: u32, ) -> Weight { - // Minimum execution time: 37_000 nanoseconds. - Weight::from_ref_time(40_658_475 as u64) - // Standard Error: 6_103 - .saturating_add(Weight::from_ref_time(3_177_141 as u64).saturating_mul(r as u64)) + // Minimum execution time: 47_322 nanoseconds. + Weight::from_ref_time(52_103_092 as u64) + // Standard Error: 5_569 + .saturating_add(Weight::from_ref_time(3_600_758 as u64).saturating_mul(r as u64)) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(r as u64))) .saturating_add(T::DbWeight::get().writes(4 as u64)) .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(r as u64))) } // Storage: Democracy VotingOf (r:2 w:2) - // Storage: Democracy ReferendumInfoOf (r:1 w:1) + // Storage: Democracy ReferendumInfoOf (r:2 w:2) /// The range of component `r` is `[0, 99]`. fn undelegate(r: u32, ) -> Weight { - // Minimum execution time: 23_000 nanoseconds. - Weight::from_ref_time(21_737_425 as u64) - // Standard Error: 5_868 - .saturating_add(Weight::from_ref_time(3_172_334 as u64).saturating_mul(r as u64)) + // Minimum execution time: 29_730 nanoseconds. + Weight::from_ref_time(32_215_196 as u64) + // Standard Error: 5_365 + .saturating_add(Weight::from_ref_time(3_570_430 as u64).saturating_mul(r as u64)) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(r as u64))) .saturating_add(T::DbWeight::get().writes(2 as u64)) @@ -241,8 +260,8 @@ impl WeightInfo for SubstrateWeight { } // Storage: Democracy PublicProps (r:0 w:1) fn clear_public_proposals() -> Weight { - // Minimum execution time: 3_000 nanoseconds. - Weight::from_ref_time(4_000_000 as u64) + // Minimum execution time: 6_443 nanoseconds. + Weight::from_ref_time(6_548_000 as u64) .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Democracy VotingOf (r:1 w:1) @@ -250,10 +269,10 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:1) /// The range of component `r` is `[0, 99]`. fn unlock_remove(r: u32, ) -> Weight { - // Minimum execution time: 22_000 nanoseconds. - Weight::from_ref_time(27_756_178 as u64) - // Standard Error: 860 - .saturating_add(Weight::from_ref_time(19_693 as u64).saturating_mul(r as u64)) + // Minimum execution time: 28_747 nanoseconds. + Weight::from_ref_time(37_459_555 as u64) + // Standard Error: 3_898 + .saturating_add(Weight::from_ref_time(152_180 as u64).saturating_mul(r as u64)) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -262,10 +281,10 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:1) /// The range of component `r` is `[0, 99]`. fn unlock_set(r: u32, ) -> Weight { - // Minimum execution time: 25_000 nanoseconds. - Weight::from_ref_time(27_614_554 as u64) - // Standard Error: 829 - .saturating_add(Weight::from_ref_time(46_251 as u64).saturating_mul(r as u64)) + // Minimum execution time: 34_624 nanoseconds. + Weight::from_ref_time(35_432_999 as u64) + // Standard Error: 3_069 + .saturating_add(Weight::from_ref_time(227_652 as u64).saturating_mul(r as u64)) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -273,10 +292,10 @@ impl WeightInfo for SubstrateWeight { // Storage: Democracy VotingOf (r:1 w:1) /// The range of component `r` is `[1, 100]`. fn remove_vote(r: u32, ) -> Weight { - // Minimum execution time: 13_000 nanoseconds. - Weight::from_ref_time(15_102_121 as u64) - // Standard Error: 708 - .saturating_add(Weight::from_ref_time(54_453 as u64).saturating_mul(r as u64)) + // Minimum execution time: 18_142 nanoseconds. + Weight::from_ref_time(20_388_863 as u64) + // Standard Error: 1_654 + .saturating_add(Weight::from_ref_time(265_937 as u64).saturating_mul(r as u64)) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } @@ -284,10 +303,10 @@ impl WeightInfo for SubstrateWeight { // Storage: Democracy VotingOf (r:1 w:1) /// The range of component `r` is `[1, 100]`. fn remove_other_vote(r: u32, ) -> Weight { - // Minimum execution time: 13_000 nanoseconds. - Weight::from_ref_time(15_093_151 as u64) - // Standard Error: 829 - .saturating_add(Weight::from_ref_time(58_373 as u64).saturating_mul(r as u64)) + // Minimum execution time: 18_375 nanoseconds. + Weight::from_ref_time(20_522_580 as u64) + // Standard Error: 1_295 + .saturating_add(Weight::from_ref_time(262_384 as u64).saturating_mul(r as u64)) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } @@ -295,8 +314,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Preimage StatusFor (r:1 w:1) // Storage: Democracy MetadataOf (r:0 w:1) fn set_external_metadata() -> Weight { - // Minimum execution time: 21_000 nanoseconds. - Weight::from_ref_time(22_000_000 as u64) + // Minimum execution time: 26_968 nanoseconds. + Weight::from_ref_time(27_371_000 as u64) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } @@ -304,8 +323,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Democracy MetadataOf (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:1) fn clear_external_metadata() -> Weight { - // Minimum execution time: 23_000 nanoseconds. - Weight::from_ref_time(25_000_000 as u64) + // Minimum execution time: 31_538 nanoseconds. + Weight::from_ref_time(31_988_000 as u64) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } @@ -313,8 +332,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Preimage StatusFor (r:1 w:1) // Storage: Democracy MetadataOf (r:0 w:1) fn set_proposal_metadata() -> Weight { - // Minimum execution time: 35_000 nanoseconds. - Weight::from_ref_time(37_000_000 as u64) + // Minimum execution time: 52_544 nanoseconds. + Weight::from_ref_time(53_569_000 as u64) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } @@ -322,8 +341,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Democracy MetadataOf (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:1) fn clear_proposal_metadata() -> Weight { - // Minimum execution time: 37_000 nanoseconds. - Weight::from_ref_time(38_000_000 as u64) + // Minimum execution time: 51_457 nanoseconds. + Weight::from_ref_time(56_328_000 as u64) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } @@ -331,8 +350,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Preimage StatusFor (r:1 w:1) // Storage: Preimage PreimageFor (r:0 w:1) fn clear_referendum_metadata() -> Weight { - // Minimum execution time: 23_000 nanoseconds. - Weight::from_ref_time(23_000_000 as u64) + // Minimum execution time: 32_189 nanoseconds. + Weight::from_ref_time(32_756_000 as u64) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -345,15 +364,15 @@ impl WeightInfo for () { // Storage: Democracy Blacklist (r:1 w:0) // Storage: Democracy DepositOf (r:0 w:1) fn propose() -> Weight { - // Minimum execution time: 31_000 nanoseconds. - Weight::from_ref_time(32_000_000 as u64) + // Minimum execution time: 56_190 nanoseconds. + Weight::from_ref_time(57_022_000 as u64) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } // Storage: Democracy DepositOf (r:1 w:1) fn second() -> Weight { - // Minimum execution time: 29_000 nanoseconds. - Weight::from_ref_time(30_000_000 as u64) + // Minimum execution time: 48_192 nanoseconds. + Weight::from_ref_time(48_719_000 as u64) .saturating_add(RocksDbWeight::get().reads(1 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } @@ -361,8 +380,8 @@ impl WeightInfo for () { // Storage: Democracy VotingOf (r:1 w:1) // Storage: Balances Locks (r:1 w:1) fn vote_new() -> Weight { - // Minimum execution time: 40_000 nanoseconds. - Weight::from_ref_time(43_000_000 as u64) + // Minimum execution time: 71_575 nanoseconds. + Weight::from_ref_time(72_584_000 as u64) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } @@ -370,8 +389,8 @@ impl WeightInfo for () { // Storage: Democracy VotingOf (r:1 w:1) // Storage: Balances Locks (r:1 w:1) fn vote_existing() -> Weight { - // Minimum execution time: 40_000 nanoseconds. - Weight::from_ref_time(42_000_000 as u64) + // Minimum execution time: 72_634 nanoseconds. + Weight::from_ref_time(74_350_000 as u64) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } @@ -381,8 +400,8 @@ impl WeightInfo for () { // Storage: Preimage StatusFor (r:1 w:1) // Storage: Preimage PreimageFor (r:0 w:1) fn emergency_cancel() -> Weight { - // Minimum execution time: 30_000 nanoseconds. - Weight::from_ref_time(31_000_000 as u64) + // Minimum execution time: 44_016 nanoseconds. + Weight::from_ref_time(44_755_000 as u64) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(5 as u64)) } @@ -396,29 +415,29 @@ impl WeightInfo for () { // Storage: Preimage PreimageFor (r:0 w:1) // Storage: Democracy Blacklist (r:0 w:1) fn blacklist() -> Weight { - // Minimum execution time: 74_000 nanoseconds. - Weight::from_ref_time(75_000_000 as u64) + // Minimum execution time: 109_317 nanoseconds. + Weight::from_ref_time(110_489_000 as u64) .saturating_add(RocksDbWeight::get().reads(9 as u64)) .saturating_add(RocksDbWeight::get().writes(9 as u64)) } // Storage: Democracy NextExternal (r:1 w:1) // Storage: Democracy Blacklist (r:1 w:0) fn external_propose() -> Weight { - // Minimum execution time: 15_000 nanoseconds. - Weight::from_ref_time(16_000_000 as u64) + // Minimum execution time: 18_768 nanoseconds. + Weight::from_ref_time(19_256_000 as u64) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } // Storage: Democracy NextExternal (r:0 w:1) fn external_propose_majority() -> Weight { - // Minimum execution time: 3_000 nanoseconds. - Weight::from_ref_time(4_000_000 as u64) + // Minimum execution time: 4_887 nanoseconds. + Weight::from_ref_time(5_071_000 as u64) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } // Storage: Democracy NextExternal (r:0 w:1) fn external_propose_default() -> Weight { - // Minimum execution time: 3_000 nanoseconds. - Weight::from_ref_time(3_000_000 as u64) + // Minimum execution time: 4_966 nanoseconds. + Weight::from_ref_time(5_174_000 as u64) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } // Storage: Democracy NextExternal (r:1 w:1) @@ -426,8 +445,8 @@ impl WeightInfo for () { // Storage: Democracy MetadataOf (r:1 w:2) // Storage: Democracy ReferendumInfoOf (r:0 w:1) fn fast_track() -> Weight { - // Minimum execution time: 24_000 nanoseconds. - Weight::from_ref_time(25_000_000 as u64) + // Minimum execution time: 34_839 nanoseconds. + Weight::from_ref_time(35_514_000 as u64) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(5 as u64)) } @@ -436,8 +455,8 @@ impl WeightInfo for () { // Storage: Democracy MetadataOf (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:1) fn veto_external() -> Weight { - // Minimum execution time: 32_000 nanoseconds. - Weight::from_ref_time(33_000_000 as u64) + // Minimum execution time: 46_388 nanoseconds. + Weight::from_ref_time(46_837_000 as u64) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) } @@ -447,8 +466,8 @@ impl WeightInfo for () { // Storage: Democracy MetadataOf (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:1) fn cancel_proposal() -> Weight { - // Minimum execution time: 62_000 nanoseconds. - Weight::from_ref_time(64_000_000 as u64) + // Minimum execution time: 88_273 nanoseconds. + Weight::from_ref_time(89_910_000 as u64) .saturating_add(RocksDbWeight::get().reads(5 as u64)) .saturating_add(RocksDbWeight::get().writes(5 as u64)) } @@ -457,20 +476,20 @@ impl WeightInfo for () { // Storage: Preimage PreimageFor (r:0 w:1) // Storage: Democracy ReferendumInfoOf (r:0 w:1) fn cancel_referendum() -> Weight { - // Minimum execution time: 26_000 nanoseconds. - Weight::from_ref_time(27_000_000 as u64) + // Minimum execution time: 36_626 nanoseconds. + Weight::from_ref_time(37_221_000 as u64) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) } // Storage: Democracy LowestUnbaked (r:1 w:1) // Storage: Democracy ReferendumCount (r:1 w:0) - // Storage: Democracy ReferendumInfoOf (r:1 w:0) + // Storage: Democracy ReferendumInfoOf (r:2 w:0) /// The range of component `r` is `[0, 99]`. fn on_initialize_base(r: u32, ) -> Weight { - // Minimum execution time: 5_000 nanoseconds. - Weight::from_ref_time(6_798_554 as u64) - // Standard Error: 6_545 - .saturating_add(Weight::from_ref_time(2_094_736 as u64).saturating_mul(r as u64)) + // Minimum execution time: 6_738 nanoseconds. + Weight::from_ref_time(12_684_834 as u64) + // Standard Error: 5_168 + .saturating_add(Weight::from_ref_time(2_402_248 as u64).saturating_mul(r as u64)) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(r as u64))) .saturating_add(RocksDbWeight::get().writes(1 as u64)) @@ -480,39 +499,39 @@ impl WeightInfo for () { // Storage: Democracy LastTabledWasExternal (r:1 w:0) // Storage: Democracy NextExternal (r:1 w:0) // Storage: Democracy PublicProps (r:1 w:0) - // Storage: Democracy ReferendumInfoOf (r:1 w:0) + // Storage: Democracy ReferendumInfoOf (r:2 w:0) /// The range of component `r` is `[0, 99]`. fn on_initialize_base_with_launch_period(r: u32, ) -> Weight { - // Minimum execution time: 6_000 nanoseconds. - Weight::from_ref_time(8_955_683 as u64) - // Standard Error: 6_329 - .saturating_add(Weight::from_ref_time(2_077_016 as u64).saturating_mul(r as u64)) + // Minimum execution time: 9_188 nanoseconds. + Weight::from_ref_time(16_333_541 as u64) + // Standard Error: 4_393 + .saturating_add(Weight::from_ref_time(2_379_560 as u64).saturating_mul(r as u64)) .saturating_add(RocksDbWeight::get().reads(5 as u64)) .saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(r as u64))) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } // Storage: Democracy VotingOf (r:3 w:3) // Storage: Balances Locks (r:1 w:1) - // Storage: Democracy ReferendumInfoOf (r:1 w:1) + // Storage: Democracy ReferendumInfoOf (r:2 w:2) /// The range of component `r` is `[0, 99]`. fn delegate(r: u32, ) -> Weight { - // Minimum execution time: 37_000 nanoseconds. - Weight::from_ref_time(40_658_475 as u64) - // Standard Error: 6_103 - .saturating_add(Weight::from_ref_time(3_177_141 as u64).saturating_mul(r as u64)) + // Minimum execution time: 47_322 nanoseconds. + Weight::from_ref_time(52_103_092 as u64) + // Standard Error: 5_569 + .saturating_add(Weight::from_ref_time(3_600_758 as u64).saturating_mul(r as u64)) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(r as u64))) .saturating_add(RocksDbWeight::get().writes(4 as u64)) .saturating_add(RocksDbWeight::get().writes((1 as u64).saturating_mul(r as u64))) } // Storage: Democracy VotingOf (r:2 w:2) - // Storage: Democracy ReferendumInfoOf (r:1 w:1) + // Storage: Democracy ReferendumInfoOf (r:2 w:2) /// The range of component `r` is `[0, 99]`. fn undelegate(r: u32, ) -> Weight { - // Minimum execution time: 23_000 nanoseconds. - Weight::from_ref_time(21_737_425 as u64) - // Standard Error: 5_868 - .saturating_add(Weight::from_ref_time(3_172_334 as u64).saturating_mul(r as u64)) + // Minimum execution time: 29_730 nanoseconds. + Weight::from_ref_time(32_215_196 as u64) + // Standard Error: 5_365 + .saturating_add(Weight::from_ref_time(3_570_430 as u64).saturating_mul(r as u64)) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(r as u64))) .saturating_add(RocksDbWeight::get().writes(2 as u64)) @@ -520,8 +539,8 @@ impl WeightInfo for () { } // Storage: Democracy PublicProps (r:0 w:1) fn clear_public_proposals() -> Weight { - // Minimum execution time: 3_000 nanoseconds. - Weight::from_ref_time(4_000_000 as u64) + // Minimum execution time: 6_443 nanoseconds. + Weight::from_ref_time(6_548_000 as u64) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } // Storage: Democracy VotingOf (r:1 w:1) @@ -529,10 +548,10 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:1) /// The range of component `r` is `[0, 99]`. fn unlock_remove(r: u32, ) -> Weight { - // Minimum execution time: 22_000 nanoseconds. - Weight::from_ref_time(27_756_178 as u64) - // Standard Error: 860 - .saturating_add(Weight::from_ref_time(19_693 as u64).saturating_mul(r as u64)) + // Minimum execution time: 28_747 nanoseconds. + Weight::from_ref_time(37_459_555 as u64) + // Standard Error: 3_898 + .saturating_add(Weight::from_ref_time(152_180 as u64).saturating_mul(r as u64)) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } @@ -541,10 +560,10 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:1) /// The range of component `r` is `[0, 99]`. fn unlock_set(r: u32, ) -> Weight { - // Minimum execution time: 25_000 nanoseconds. - Weight::from_ref_time(27_614_554 as u64) - // Standard Error: 829 - .saturating_add(Weight::from_ref_time(46_251 as u64).saturating_mul(r as u64)) + // Minimum execution time: 34_624 nanoseconds. + Weight::from_ref_time(35_432_999 as u64) + // Standard Error: 3_069 + .saturating_add(Weight::from_ref_time(227_652 as u64).saturating_mul(r as u64)) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } @@ -552,10 +571,10 @@ impl WeightInfo for () { // Storage: Democracy VotingOf (r:1 w:1) /// The range of component `r` is `[1, 100]`. fn remove_vote(r: u32, ) -> Weight { - // Minimum execution time: 13_000 nanoseconds. - Weight::from_ref_time(15_102_121 as u64) - // Standard Error: 708 - .saturating_add(Weight::from_ref_time(54_453 as u64).saturating_mul(r as u64)) + // Minimum execution time: 18_142 nanoseconds. + Weight::from_ref_time(20_388_863 as u64) + // Standard Error: 1_654 + .saturating_add(Weight::from_ref_time(265_937 as u64).saturating_mul(r as u64)) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } @@ -563,10 +582,10 @@ impl WeightInfo for () { // Storage: Democracy VotingOf (r:1 w:1) /// The range of component `r` is `[1, 100]`. fn remove_other_vote(r: u32, ) -> Weight { - // Minimum execution time: 13_000 nanoseconds. - Weight::from_ref_time(15_093_151 as u64) - // Standard Error: 829 - .saturating_add(Weight::from_ref_time(58_373 as u64).saturating_mul(r as u64)) + // Minimum execution time: 18_375 nanoseconds. + Weight::from_ref_time(20_522_580 as u64) + // Standard Error: 1_295 + .saturating_add(Weight::from_ref_time(262_384 as u64).saturating_mul(r as u64)) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } @@ -574,8 +593,8 @@ impl WeightInfo for () { // Storage: Preimage StatusFor (r:1 w:1) // Storage: Democracy MetadataOf (r:0 w:1) fn set_external_metadata() -> Weight { - // Minimum execution time: 21_000 nanoseconds. - Weight::from_ref_time(22_000_000 as u64) + // Minimum execution time: 26_968 nanoseconds. + Weight::from_ref_time(27_371_000 as u64) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } @@ -583,8 +602,8 @@ impl WeightInfo for () { // Storage: Democracy MetadataOf (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:1) fn clear_external_metadata() -> Weight { - // Minimum execution time: 23_000 nanoseconds. - Weight::from_ref_time(25_000_000 as u64) + // Minimum execution time: 31_538 nanoseconds. + Weight::from_ref_time(31_988_000 as u64) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } @@ -592,8 +611,8 @@ impl WeightInfo for () { // Storage: Preimage StatusFor (r:1 w:1) // Storage: Democracy MetadataOf (r:0 w:1) fn set_proposal_metadata() -> Weight { - // Minimum execution time: 35_000 nanoseconds. - Weight::from_ref_time(37_000_000 as u64) + // Minimum execution time: 52_544 nanoseconds. + Weight::from_ref_time(53_569_000 as u64) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } @@ -601,8 +620,8 @@ impl WeightInfo for () { // Storage: Democracy MetadataOf (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:1) fn clear_proposal_metadata() -> Weight { - // Minimum execution time: 37_000 nanoseconds. - Weight::from_ref_time(38_000_000 as u64) + // Minimum execution time: 51_457 nanoseconds. + Weight::from_ref_time(56_328_000 as u64) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } @@ -610,8 +629,8 @@ impl WeightInfo for () { // Storage: Preimage StatusFor (r:1 w:1) // Storage: Preimage PreimageFor (r:0 w:1) fn clear_referendum_metadata() -> Weight { - // Minimum execution time: 23_000 nanoseconds. - Weight::from_ref_time(23_000_000 as u64) + // Minimum execution time: 32_189 nanoseconds. + Weight::from_ref_time(32_756_000 as u64) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } From 4211b34b56530c86597e9b546eda7bdfa0731319 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Mon, 31 Oct 2022 12:38:47 +0000 Subject: [PATCH 15/29] ".git/.scripts/bench-bot.sh" pallet dev pallet_referenda --- frame/referenda/src/weights.rs | 267 ++++++++++++++++++--------------- 1 file changed, 143 insertions(+), 124 deletions(-) diff --git a/frame/referenda/src/weights.rs b/frame/referenda/src/weights.rs index 0e34afadaec10..f2d0cc1dbfd82 100644 --- a/frame/referenda/src/weights.rs +++ b/frame/referenda/src/weights.rs @@ -1,22 +1,41 @@ +// This file is part of Substrate. + +// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// 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. //! Autogenerated weights for pallet_referenda //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-10-28, STEPS: `100`, REPEAT: 200, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `cob`, CPU: `` -//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 +//! DATE: 2022-10-31, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: -// ./target/release/substrate +// /home/benchbot/cargo_target_dir/production/substrate // benchmark // pallet -// --chain=dev -// --steps=100 -// --repeat=200 -// --pallet=pallet-referenda +// --steps=50 +// --repeat=20 // --extrinsic=* +// --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 +// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/substrate/.git/.artifacts/bench.json +// --pallet=pallet_referenda +// --chain=dev +// --header=./HEADER-APACHE2 // --output=./frame/referenda/src/weights.rs // --template=./.maintain/frame-weight-template.hbs @@ -67,16 +86,16 @@ impl WeightInfo for SubstrateWeight { // Storage: Scheduler Agenda (r:1 w:1) // Storage: Referenda ReferendumInfoFor (r:0 w:1) fn submit() -> Weight { - // Minimum execution time: 26_000 nanoseconds. - Weight::from_ref_time(27_000_000 as u64) + // Minimum execution time: 40_050 nanoseconds. + Weight::from_ref_time(40_550_000 as u64) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn place_decision_deposit_preparing() -> Weight { - // Minimum execution time: 32_000 nanoseconds. - Weight::from_ref_time(34_000_000 as u64) + // Minimum execution time: 50_115 nanoseconds. + Weight::from_ref_time(50_867_000 as u64) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -84,8 +103,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Referenda DecidingCount (r:1 w:0) // Storage: Referenda TrackQueue (r:1 w:1) fn place_decision_deposit_queued() -> Weight { - // Minimum execution time: 37_000 nanoseconds. - Weight::from_ref_time(38_000_000 as u64) + // Minimum execution time: 56_164 nanoseconds. + Weight::from_ref_time(57_189_000 as u64) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } @@ -93,8 +112,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Referenda DecidingCount (r:1 w:0) // Storage: Referenda TrackQueue (r:1 w:1) fn place_decision_deposit_not_queued() -> Weight { - // Minimum execution time: 36_000 nanoseconds. - Weight::from_ref_time(38_000_000 as u64) + // Minimum execution time: 54_378 nanoseconds. + Weight::from_ref_time(55_313_000 as u64) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } @@ -102,8 +121,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Referenda DecidingCount (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn place_decision_deposit_passing() -> Weight { - // Minimum execution time: 42_000 nanoseconds. - Weight::from_ref_time(44_000_000 as u64) + // Minimum execution time: 64_917 nanoseconds. + Weight::from_ref_time(65_530_000 as u64) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().writes(4 as u64)) } @@ -111,23 +130,23 @@ impl WeightInfo for SubstrateWeight { // Storage: Referenda DecidingCount (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn place_decision_deposit_failing() -> Weight { - // Minimum execution time: 38_000 nanoseconds. - Weight::from_ref_time(41_000_000 as u64) + // Minimum execution time: 60_579 nanoseconds. + Weight::from_ref_time(61_756_000 as u64) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) fn refund_decision_deposit() -> Weight { - // Minimum execution time: 23_000 nanoseconds. - Weight::from_ref_time(25_000_000 as u64) + // Minimum execution time: 35_168 nanoseconds. + Weight::from_ref_time(36_131_000 as u64) .saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn cancel() -> Weight { - // Minimum execution time: 25_000 nanoseconds. - Weight::from_ref_time(27_000_000 as u64) + // Minimum execution time: 40_311 nanoseconds. + Weight::from_ref_time(40_833_000 as u64) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -135,16 +154,16 @@ impl WeightInfo for SubstrateWeight { // Storage: Scheduler Agenda (r:2 w:2) // Storage: Referenda MetadataOf (r:1 w:0) fn kill() -> Weight { - // Minimum execution time: 48_000 nanoseconds. - Weight::from_ref_time(51_000_000 as u64) + // Minimum execution time: 73_602 nanoseconds. + Weight::from_ref_time(75_492_000 as u64) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Referenda TrackQueue (r:1 w:0) // Storage: Referenda DecidingCount (r:1 w:1) fn one_fewer_deciding_queue_empty() -> Weight { - // Minimum execution time: 7_000 nanoseconds. - Weight::from_ref_time(8_000_000 as u64) + // Minimum execution time: 14_016 nanoseconds. + Weight::from_ref_time(14_869_000 as u64) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } @@ -152,8 +171,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn one_fewer_deciding_failing() -> Weight { - // Minimum execution time: 58_000 nanoseconds. - Weight::from_ref_time(62_000_000 as u64) + // Minimum execution time: 86_026 nanoseconds. + Weight::from_ref_time(87_034_000 as u64) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().writes(4 as u64)) } @@ -161,8 +180,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn one_fewer_deciding_passing() -> Weight { - // Minimum execution time: 59_000 nanoseconds. - Weight::from_ref_time(63_000_000 as u64) + // Minimum execution time: 87_319 nanoseconds. + Weight::from_ref_time(87_885_000 as u64) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().writes(4 as u64)) } @@ -170,8 +189,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Referenda TrackQueue (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_requeued_insertion() -> Weight { - // Minimum execution time: 50_000 nanoseconds. - Weight::from_ref_time(53_000_000 as u64) + // Minimum execution time: 70_278 nanoseconds. + Weight::from_ref_time(71_234_000 as u64) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -179,8 +198,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Referenda TrackQueue (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_requeued_slide() -> Weight { - // Minimum execution time: 52_000 nanoseconds. - Weight::from_ref_time(57_000_000 as u64) + // Minimum execution time: 70_592 nanoseconds. + Weight::from_ref_time(71_089_000 as u64) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -189,8 +208,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Referenda TrackQueue (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_queued() -> Weight { - // Minimum execution time: 51_000 nanoseconds. - Weight::from_ref_time(60_000_000 as u64) + // Minimum execution time: 72_336 nanoseconds. + Weight::from_ref_time(73_450_000 as u64) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -199,31 +218,31 @@ impl WeightInfo for SubstrateWeight { // Storage: Referenda TrackQueue (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_not_queued() -> Weight { - // Minimum execution time: 51_000 nanoseconds. - Weight::from_ref_time(56_000_000 as u64) + // Minimum execution time: 71_854 nanoseconds. + Weight::from_ref_time(72_790_000 as u64) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_no_deposit() -> Weight { - // Minimum execution time: 20_000 nanoseconds. - Weight::from_ref_time(21_000_000 as u64) + // Minimum execution time: 30_069 nanoseconds. + Weight::from_ref_time(31_002_000 as u64) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_preparing() -> Weight { - // Minimum execution time: 21_000 nanoseconds. - Weight::from_ref_time(22_000_000 as u64) + // Minimum execution time: 31_454 nanoseconds. + Weight::from_ref_time(31_894_000 as u64) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) fn nudge_referendum_timed_out() -> Weight { - // Minimum execution time: 16_000 nanoseconds. - Weight::from_ref_time(17_000_000 as u64) + // Minimum execution time: 23_962 nanoseconds. + Weight::from_ref_time(24_084_000 as u64) .saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } @@ -231,8 +250,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Referenda DecidingCount (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_begin_deciding_failing() -> Weight { - // Minimum execution time: 27_000 nanoseconds. - Weight::from_ref_time(29_000_000 as u64) + // Minimum execution time: 44_266 nanoseconds. + Weight::from_ref_time(45_060_000 as u64) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -240,40 +259,40 @@ impl WeightInfo for SubstrateWeight { // Storage: Referenda DecidingCount (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_begin_deciding_passing() -> Weight { - // Minimum execution time: 29_000 nanoseconds. - Weight::from_ref_time(31_000_000 as u64) + // Minimum execution time: 45_862 nanoseconds. + Weight::from_ref_time(46_553_000 as u64) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_begin_confirming() -> Weight { - // Minimum execution time: 27_000 nanoseconds. - Weight::from_ref_time(30_000_000 as u64) + // Minimum execution time: 42_134 nanoseconds. + Weight::from_ref_time(42_662_000 as u64) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_end_confirming() -> Weight { - // Minimum execution time: 28_000 nanoseconds. - Weight::from_ref_time(30_000_000 as u64) + // Minimum execution time: 43_133 nanoseconds. + Weight::from_ref_time(43_964_000 as u64) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_continue_not_confirming() -> Weight { - // Minimum execution time: 27_000 nanoseconds. - Weight::from_ref_time(28_000_000 as u64) + // Minimum execution time: 40_001 nanoseconds. + Weight::from_ref_time(40_626_000 as u64) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_continue_confirming() -> Weight { - // Minimum execution time: 28_000 nanoseconds. - Weight::from_ref_time(29_000_000 as u64) + // Minimum execution time: 39_214 nanoseconds. + Weight::from_ref_time(39_831_000 as u64) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } @@ -281,16 +300,16 @@ impl WeightInfo for SubstrateWeight { // Storage: Scheduler Agenda (r:2 w:2) // Storage: Scheduler Lookup (r:1 w:1) fn nudge_referendum_approved() -> Weight { - // Minimum execution time: 33_000 nanoseconds. - Weight::from_ref_time(35_000_000 as u64) + // Minimum execution time: 52_266 nanoseconds. + Weight::from_ref_time(52_726_000 as u64) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_rejected() -> Weight { - // Minimum execution time: 29_000 nanoseconds. - Weight::from_ref_time(30_000_000 as u64) + // Minimum execution time: 42_472 nanoseconds. + Weight::from_ref_time(43_031_000 as u64) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } @@ -298,8 +317,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Preimage StatusFor (r:1 w:1) // Storage: Referenda MetadataOf (r:0 w:1) fn set_metadata() -> Weight { - // Minimum execution time: 20_000 nanoseconds. - Weight::from_ref_time(21_000_000 as u64) + // Minimum execution time: 29_621 nanoseconds. + Weight::from_ref_time(30_799_000 as u64) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } @@ -307,8 +326,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Referenda MetadataOf (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:1) fn clear_metadata() -> Weight { - // Minimum execution time: 23_000 nanoseconds. - Weight::from_ref_time(24_000_000 as u64) + // Minimum execution time: 32_124 nanoseconds. + Weight::from_ref_time(33_107_000 as u64) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } @@ -320,16 +339,16 @@ impl WeightInfo for () { // Storage: Scheduler Agenda (r:1 w:1) // Storage: Referenda ReferendumInfoFor (r:0 w:1) fn submit() -> Weight { - // Minimum execution time: 26_000 nanoseconds. - Weight::from_ref_time(27_000_000 as u64) + // Minimum execution time: 40_050 nanoseconds. + Weight::from_ref_time(40_550_000 as u64) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn place_decision_deposit_preparing() -> Weight { - // Minimum execution time: 32_000 nanoseconds. - Weight::from_ref_time(34_000_000 as u64) + // Minimum execution time: 50_115 nanoseconds. + Weight::from_ref_time(50_867_000 as u64) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } @@ -337,8 +356,8 @@ impl WeightInfo for () { // Storage: Referenda DecidingCount (r:1 w:0) // Storage: Referenda TrackQueue (r:1 w:1) fn place_decision_deposit_queued() -> Weight { - // Minimum execution time: 37_000 nanoseconds. - Weight::from_ref_time(38_000_000 as u64) + // Minimum execution time: 56_164 nanoseconds. + Weight::from_ref_time(57_189_000 as u64) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } @@ -346,8 +365,8 @@ impl WeightInfo for () { // Storage: Referenda DecidingCount (r:1 w:0) // Storage: Referenda TrackQueue (r:1 w:1) fn place_decision_deposit_not_queued() -> Weight { - // Minimum execution time: 36_000 nanoseconds. - Weight::from_ref_time(38_000_000 as u64) + // Minimum execution time: 54_378 nanoseconds. + Weight::from_ref_time(55_313_000 as u64) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } @@ -355,8 +374,8 @@ impl WeightInfo for () { // Storage: Referenda DecidingCount (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn place_decision_deposit_passing() -> Weight { - // Minimum execution time: 42_000 nanoseconds. - Weight::from_ref_time(44_000_000 as u64) + // Minimum execution time: 64_917 nanoseconds. + Weight::from_ref_time(65_530_000 as u64) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) } @@ -364,23 +383,23 @@ impl WeightInfo for () { // Storage: Referenda DecidingCount (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn place_decision_deposit_failing() -> Weight { - // Minimum execution time: 38_000 nanoseconds. - Weight::from_ref_time(41_000_000 as u64) + // Minimum execution time: 60_579 nanoseconds. + Weight::from_ref_time(61_756_000 as u64) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) fn refund_decision_deposit() -> Weight { - // Minimum execution time: 23_000 nanoseconds. - Weight::from_ref_time(25_000_000 as u64) + // Minimum execution time: 35_168 nanoseconds. + Weight::from_ref_time(36_131_000 as u64) .saturating_add(RocksDbWeight::get().reads(1 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn cancel() -> Weight { - // Minimum execution time: 25_000 nanoseconds. - Weight::from_ref_time(27_000_000 as u64) + // Minimum execution time: 40_311 nanoseconds. + Weight::from_ref_time(40_833_000 as u64) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } @@ -388,16 +407,16 @@ impl WeightInfo for () { // Storage: Scheduler Agenda (r:2 w:2) // Storage: Referenda MetadataOf (r:1 w:0) fn kill() -> Weight { - // Minimum execution time: 48_000 nanoseconds. - Weight::from_ref_time(51_000_000 as u64) + // Minimum execution time: 73_602 nanoseconds. + Weight::from_ref_time(75_492_000 as u64) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } // Storage: Referenda TrackQueue (r:1 w:0) // Storage: Referenda DecidingCount (r:1 w:1) fn one_fewer_deciding_queue_empty() -> Weight { - // Minimum execution time: 7_000 nanoseconds. - Weight::from_ref_time(8_000_000 as u64) + // Minimum execution time: 14_016 nanoseconds. + Weight::from_ref_time(14_869_000 as u64) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } @@ -405,8 +424,8 @@ impl WeightInfo for () { // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn one_fewer_deciding_failing() -> Weight { - // Minimum execution time: 58_000 nanoseconds. - Weight::from_ref_time(62_000_000 as u64) + // Minimum execution time: 86_026 nanoseconds. + Weight::from_ref_time(87_034_000 as u64) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) } @@ -414,8 +433,8 @@ impl WeightInfo for () { // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn one_fewer_deciding_passing() -> Weight { - // Minimum execution time: 59_000 nanoseconds. - Weight::from_ref_time(63_000_000 as u64) + // Minimum execution time: 87_319 nanoseconds. + Weight::from_ref_time(87_885_000 as u64) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) } @@ -423,8 +442,8 @@ impl WeightInfo for () { // Storage: Referenda TrackQueue (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_requeued_insertion() -> Weight { - // Minimum execution time: 50_000 nanoseconds. - Weight::from_ref_time(53_000_000 as u64) + // Minimum execution time: 70_278 nanoseconds. + Weight::from_ref_time(71_234_000 as u64) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } @@ -432,8 +451,8 @@ impl WeightInfo for () { // Storage: Referenda TrackQueue (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_requeued_slide() -> Weight { - // Minimum execution time: 52_000 nanoseconds. - Weight::from_ref_time(57_000_000 as u64) + // Minimum execution time: 70_592 nanoseconds. + Weight::from_ref_time(71_089_000 as u64) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } @@ -442,8 +461,8 @@ impl WeightInfo for () { // Storage: Referenda TrackQueue (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_queued() -> Weight { - // Minimum execution time: 51_000 nanoseconds. - Weight::from_ref_time(60_000_000 as u64) + // Minimum execution time: 72_336 nanoseconds. + Weight::from_ref_time(73_450_000 as u64) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } @@ -452,31 +471,31 @@ impl WeightInfo for () { // Storage: Referenda TrackQueue (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_not_queued() -> Weight { - // Minimum execution time: 51_000 nanoseconds. - Weight::from_ref_time(56_000_000 as u64) + // Minimum execution time: 71_854 nanoseconds. + Weight::from_ref_time(72_790_000 as u64) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_no_deposit() -> Weight { - // Minimum execution time: 20_000 nanoseconds. - Weight::from_ref_time(21_000_000 as u64) + // Minimum execution time: 30_069 nanoseconds. + Weight::from_ref_time(31_002_000 as u64) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_preparing() -> Weight { - // Minimum execution time: 21_000 nanoseconds. - Weight::from_ref_time(22_000_000 as u64) + // Minimum execution time: 31_454 nanoseconds. + Weight::from_ref_time(31_894_000 as u64) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) fn nudge_referendum_timed_out() -> Weight { - // Minimum execution time: 16_000 nanoseconds. - Weight::from_ref_time(17_000_000 as u64) + // Minimum execution time: 23_962 nanoseconds. + Weight::from_ref_time(24_084_000 as u64) .saturating_add(RocksDbWeight::get().reads(1 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } @@ -484,8 +503,8 @@ impl WeightInfo for () { // Storage: Referenda DecidingCount (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_begin_deciding_failing() -> Weight { - // Minimum execution time: 27_000 nanoseconds. - Weight::from_ref_time(29_000_000 as u64) + // Minimum execution time: 44_266 nanoseconds. + Weight::from_ref_time(45_060_000 as u64) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } @@ -493,40 +512,40 @@ impl WeightInfo for () { // Storage: Referenda DecidingCount (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_begin_deciding_passing() -> Weight { - // Minimum execution time: 29_000 nanoseconds. - Weight::from_ref_time(31_000_000 as u64) + // Minimum execution time: 45_862 nanoseconds. + Weight::from_ref_time(46_553_000 as u64) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_begin_confirming() -> Weight { - // Minimum execution time: 27_000 nanoseconds. - Weight::from_ref_time(30_000_000 as u64) + // Minimum execution time: 42_134 nanoseconds. + Weight::from_ref_time(42_662_000 as u64) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_end_confirming() -> Weight { - // Minimum execution time: 28_000 nanoseconds. - Weight::from_ref_time(30_000_000 as u64) + // Minimum execution time: 43_133 nanoseconds. + Weight::from_ref_time(43_964_000 as u64) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_continue_not_confirming() -> Weight { - // Minimum execution time: 27_000 nanoseconds. - Weight::from_ref_time(28_000_000 as u64) + // Minimum execution time: 40_001 nanoseconds. + Weight::from_ref_time(40_626_000 as u64) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_continue_confirming() -> Weight { - // Minimum execution time: 28_000 nanoseconds. - Weight::from_ref_time(29_000_000 as u64) + // Minimum execution time: 39_214 nanoseconds. + Weight::from_ref_time(39_831_000 as u64) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } @@ -534,16 +553,16 @@ impl WeightInfo for () { // Storage: Scheduler Agenda (r:2 w:2) // Storage: Scheduler Lookup (r:1 w:1) fn nudge_referendum_approved() -> Weight { - // Minimum execution time: 33_000 nanoseconds. - Weight::from_ref_time(35_000_000 as u64) + // Minimum execution time: 52_266 nanoseconds. + Weight::from_ref_time(52_726_000 as u64) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_rejected() -> Weight { - // Minimum execution time: 29_000 nanoseconds. - Weight::from_ref_time(30_000_000 as u64) + // Minimum execution time: 42_472 nanoseconds. + Weight::from_ref_time(43_031_000 as u64) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } @@ -551,8 +570,8 @@ impl WeightInfo for () { // Storage: Preimage StatusFor (r:1 w:1) // Storage: Referenda MetadataOf (r:0 w:1) fn set_metadata() -> Weight { - // Minimum execution time: 20_000 nanoseconds. - Weight::from_ref_time(21_000_000 as u64) + // Minimum execution time: 29_621 nanoseconds. + Weight::from_ref_time(30_799_000 as u64) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } @@ -560,8 +579,8 @@ impl WeightInfo for () { // Storage: Referenda MetadataOf (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:1) fn clear_metadata() -> Weight { - // Minimum execution time: 23_000 nanoseconds. - Weight::from_ref_time(24_000_000 as u64) + // Minimum execution time: 32_124 nanoseconds. + Weight::from_ref_time(33_107_000 as u64) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } From 83ee3f4ab39bab70ea4967d6db6404527ac7301d Mon Sep 17 00:00:00 2001 From: Muharem Ismailov Date: Mon, 14 Nov 2022 11:07:26 +0100 Subject: [PATCH 16/29] Update the doc frame/democracy/src/lib.rs Co-authored-by: Roman Useinov --- frame/democracy/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/democracy/src/lib.rs b/frame/democracy/src/lib.rs index 185926ec6d3f4..7d9761348cf67 100644 --- a/frame/democracy/src/lib.rs +++ b/frame/democracy/src/lib.rs @@ -1120,7 +1120,7 @@ pub mod pallet { Ok(()) } - /// Set the metadata to the public proposal. + /// Set the metadata of the public proposal. /// /// - `origin`: Must be `Signed`, and the creator of the proposal. /// - `index`: The index of the proposal. From 32ec398aac3fe08802ea0a2debf499dcac5b9fc1 Mon Sep 17 00:00:00 2001 From: Muharem Ismailov Date: Mon, 14 Nov 2022 12:43:42 +0100 Subject: [PATCH 17/29] Update the doc frame/democracy/src/lib.rs Co-authored-by: Anthony Alaribe --- frame/democracy/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/democracy/src/lib.rs b/frame/democracy/src/lib.rs index 7d9761348cf67..404f5f6a524f6 100644 --- a/frame/democracy/src/lib.rs +++ b/frame/democracy/src/lib.rs @@ -1098,7 +1098,7 @@ pub mod pallet { /// - `origin`: Must be an external origin and correspond to the proposal vote threshold, /// `ExternalOrigin` for `SuperMajorityApprove`, `ExternalDefaultOrigin` for /// `SuperMajorityAgainst` and `ExternalMajorityOrigin` for `SimpleMajority`. - /// - `hash`: The preimage hash of an on-chain stored preimage. + /// - `hash`: The hash of an on-chain stored preimage. #[pallet::weight(T::WeightInfo::set_external_metadata())] pub fn set_external_metadata(origin: OriginFor, hash: PreimageHash) -> DispatchResult { let (_, threshold) = >::get().ok_or(Error::::NoProposal)?; From 49c9453b21d1a3e6296dd6cb3743df1012b66cb7 Mon Sep 17 00:00:00 2001 From: Muharem Ismailov Date: Mon, 14 Nov 2022 12:54:39 +0100 Subject: [PATCH 18/29] reference instead clone for take Co-authored-by: Anthony Alaribe --- frame/democracy/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frame/democracy/src/lib.rs b/frame/democracy/src/lib.rs index 404f5f6a524f6..03d1033a0e826 100644 --- a/frame/democracy/src/lib.rs +++ b/frame/democracy/src/lib.rs @@ -1714,7 +1714,7 @@ impl Pallet { /// Clear metadata, if `Some` and unrequest associated preimage. fn clear_metadata(owner: MetadataOwner) { - if let Some(hash) = MetadataOf::::take(owner.clone()) { + if let Some(hash) = MetadataOf::::take(&owner) { if T::Preimages::is_requested(&hash) { T::Preimages::unrequest(&hash); } @@ -1724,8 +1724,8 @@ impl Pallet { /// Reset the metadata of an `owner` to a `new_owner`. fn reset_metadata(owner: MetadataOwner, new_owner: MetadataOwner) { - if let Some(hash) = MetadataOf::::take(owner.clone()) { - MetadataOf::::insert(new_owner.clone(), hash); + if let Some(hash) = MetadataOf::::take(&owner) { + MetadataOf::::insert(&new_owner, hash); Self::deposit_event(Event::::MetadataReset { prev_owner: owner, owner: new_owner, From 0abe070a58bd2186bf7e89701efb0984c2705836 Mon Sep 17 00:00:00 2001 From: muharem Date: Mon, 14 Nov 2022 13:01:33 +0100 Subject: [PATCH 19/29] error rename BadMetadata to PreimageNotExist --- frame/democracy/src/lib.rs | 8 ++++---- frame/democracy/src/tests/external_proposing.rs | 2 +- frame/democracy/src/tests/public_proposals.rs | 2 +- frame/referenda/src/lib.rs | 6 +++--- frame/referenda/src/tests.rs | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/frame/democracy/src/lib.rs b/frame/democracy/src/lib.rs index 03d1033a0e826..df6f16e27b367 100644 --- a/frame/democracy/src/lib.rs +++ b/frame/democracy/src/lib.rs @@ -558,8 +558,8 @@ pub mod pallet { TooMany, /// Voting period too low VotingPeriodLow, - /// The metadata preimage for a given hash does not exist. - BadMetadata, + /// The preimage does not exist. + PreimageNotExist, } #[pallet::hooks] @@ -1113,7 +1113,7 @@ pub mod pallet { let _ = T::ExternalMajorityOrigin::ensure_origin(origin)?; }, }; - ensure!(T::Preimages::len(&hash).is_some(), Error::::BadMetadata); + ensure!(T::Preimages::len(&hash).is_some(), Error::::PreimageNotExist); T::Preimages::request(&hash); MetadataOf::::insert(MetadataOwner::External, hash); Self::deposit_event(Event::::MetadataSet { owner: MetadataOwner::External, hash }); @@ -1134,7 +1134,7 @@ pub mod pallet { let who = ensure_signed(origin)?; let (_, _, proposer) = Self::proposal(index)?; ensure!(proposer == who, Error::::NoPermission); - ensure!(T::Preimages::len(&hash).is_some(), Error::::BadMetadata); + ensure!(T::Preimages::len(&hash).is_some(), Error::::PreimageNotExist); T::Preimages::request(&hash); let owner = MetadataOwner::Proposal(index); MetadataOf::::insert(owner.clone(), hash); diff --git a/frame/democracy/src/tests/external_proposing.rs b/frame/democracy/src/tests/external_proposing.rs index 2cd12e087843b..17cb2baaed3e5 100644 --- a/frame/democracy/src/tests/external_proposing.rs +++ b/frame/democracy/src/tests/external_proposing.rs @@ -297,7 +297,7 @@ fn set_external_metadata_works() { // fails to set non-existing preimage. assert_noop!( Democracy::set_external_metadata(RuntimeOrigin::signed(2), invalid_hash), - Error::::BadMetadata, + Error::::PreimageNotExist, ); // set metadata successful. let hash = note_preimage(1); diff --git a/frame/democracy/src/tests/public_proposals.rs b/frame/democracy/src/tests/public_proposals.rs index e05df6d7319bd..21e642477f23e 100644 --- a/frame/democracy/src/tests/public_proposals.rs +++ b/frame/democracy/src/tests/public_proposals.rs @@ -162,7 +162,7 @@ fn set_external_metadata_works() { // fails to set non-existing preimage. assert_noop!( Democracy::set_proposal_metadata(RuntimeOrigin::signed(1), index, invalid_hash,), - Error::::BadMetadata, + Error::::PreimageNotExist, ); // note preimage. let hash = note_preimage(1); diff --git a/frame/referenda/src/lib.rs b/frame/referenda/src/lib.rs index fe3e4a36eedbf..23c996bfaebb2 100644 --- a/frame/referenda/src/lib.rs +++ b/frame/referenda/src/lib.rs @@ -392,8 +392,8 @@ pub mod pallet { NoPermission, /// The deposit cannot be refunded since none was made. NoDeposit, - /// The metadata preimage for a given hash does not exist. - BadMetadata, + /// The preimage does not exist. + PreimageNotExist, } #[pallet::call] @@ -621,7 +621,7 @@ pub mod pallet { let who = ensure_signed(origin)?; let status = Self::ensure_ongoing(index)?; ensure!(status.submission_deposit.who == who, Error::::NoPermission); - ensure!(T::Preimages::len(&hash).is_some(), Error::::BadMetadata); + ensure!(T::Preimages::len(&hash).is_some(), Error::::PreimageNotExist); T::Preimages::request(&hash); MetadataOf::::insert(index, hash); Self::deposit_event(Event::::MetadataSet { index, hash }); diff --git a/frame/referenda/src/tests.rs b/frame/referenda/src/tests.rs index feaf21afdef95..ec2ff9c02efe0 100644 --- a/frame/referenda/src/tests.rs +++ b/frame/referenda/src/tests.rs @@ -555,7 +555,7 @@ fn set_metadata_works() { let index = ReferendumCount::::get() - 1; assert_noop!( Referenda::set_metadata(RuntimeOrigin::signed(1), index, invalid_hash,), - Error::::BadMetadata, + Error::::PreimageNotExist, ); // metadata set. let index = ReferendumCount::::get() - 1; From 0efce508759a0958df7bb3f5ca97742ef420f1e6 Mon Sep 17 00:00:00 2001 From: muharem Date: Mon, 14 Nov 2022 13:03:51 +0100 Subject: [PATCH 20/29] clear metadata within internal_cancel_referendum fn --- frame/democracy/src/lib.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/frame/democracy/src/lib.rs b/frame/democracy/src/lib.rs index df6f16e27b367..5ad7a6dd43d52 100644 --- a/frame/democracy/src/lib.rs +++ b/frame/democracy/src/lib.rs @@ -679,7 +679,6 @@ pub mod pallet { >::insert(h, true); Self::internal_cancel_referendum(ref_index); - Self::clear_metadata(MetadataOwner::Referendum(ref_index)); Ok(()) } @@ -859,7 +858,6 @@ pub mod pallet { ) -> DispatchResult { ensure_root(origin)?; Self::internal_cancel_referendum(ref_index); - Self::clear_metadata(MetadataOwner::Referendum(ref_index)); Ok(()) } @@ -1059,7 +1057,6 @@ pub mod pallet { if let Ok(status) = Self::referendum_status(ref_index) { if status.proposal.hash() == proposal_hash { Self::internal_cancel_referendum(ref_index); - Self::clear_metadata(MetadataOwner::Referendum(ref_index)); } } } @@ -1266,6 +1263,7 @@ impl Pallet { pub fn internal_cancel_referendum(ref_index: ReferendumIndex) { Self::deposit_event(Event::::Cancelled { ref_index }); ReferendumInfoOf::::remove(ref_index); + Self::clear_metadata(MetadataOwner::Referendum(ref_index)); } // private. From 7f89c1ac6a9395f878b6fae0c2b4ad0696479263 Mon Sep 17 00:00:00 2001 From: muharem Date: Mon, 14 Nov 2022 15:38:35 +0100 Subject: [PATCH 21/29] remove redundant clone --- frame/democracy/src/benchmarking.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/democracy/src/benchmarking.rs b/frame/democracy/src/benchmarking.rs index 1bcd16ce9cc19..c1faa769834c5 100644 --- a/frame/democracy/src/benchmarking.rs +++ b/frame/democracy/src/benchmarking.rs @@ -91,7 +91,7 @@ fn note_preimage() -> PreimageHash { // note a new preimage on every function invoke. static COUNTER: AtomicU8 = AtomicU8::new(0); let data = Cow::from(vec![COUNTER.fetch_add(1, Ordering::Relaxed)]); - let hash = ::Preimages::note(data.clone()).unwrap(); + let hash = ::Preimages::note(data).unwrap(); hash } From c22876fb907412c462a006faef69845b613656d5 Mon Sep 17 00:00:00 2001 From: muharem Date: Thu, 17 Nov 2022 12:02:01 +0100 Subject: [PATCH 22/29] collapse metadata api into one set_metadata method --- frame/democracy/src/benchmarking.rs | 93 +++-- frame/democracy/src/lib.rs | 161 ++++--- frame/democracy/src/tests.rs | 1 + .../democracy/src/tests/external_proposing.rs | 57 --- frame/democracy/src/tests/fast_tracking.rs | 6 +- frame/democracy/src/tests/metadata.rs | 222 ++++++++++ frame/democracy/src/tests/public_proposals.rs | 63 +-- frame/democracy/src/weights.rs | 392 ++++++++---------- frame/referenda/src/benchmarking.rs | 8 +- frame/referenda/src/lib.rs | 48 +-- frame/referenda/src/tests.rs | 14 +- frame/referenda/src/weights.rs | 275 ++++++------ 12 files changed, 700 insertions(+), 640 deletions(-) create mode 100644 frame/democracy/src/tests/metadata.rs diff --git a/frame/democracy/src/benchmarking.rs b/frame/democracy/src/benchmarking.rs index c1faa769834c5..da64682e74207 100644 --- a/frame/democracy/src/benchmarking.rs +++ b/frame/democracy/src/benchmarking.rs @@ -285,9 +285,10 @@ benchmarks! { Democracy::::external_propose_default(origin_propose.clone(), proposal)?; // Set metadata to the external proposal. let preimage_hash = note_preimage::(); - assert_ok!(Democracy::::set_external_metadata( + assert_ok!(Democracy::::set_metadata( origin_propose, - preimage_hash.clone())); + MetadataOwner::External, + Some(preimage_hash))); // NOTE: Instant origin may invoke a little bit more logic, but may not always succeed. let origin_fast_track = T::FastTrackOrigin::successful_origin(); let voting_period = T::FastTrackVotingPeriod::get(); @@ -310,9 +311,10 @@ benchmarks! { Democracy::::external_propose_default(origin_propose.clone(), proposal)?; let preimage_hash = note_preimage::(); - assert_ok!(Democracy::::set_external_metadata( + assert_ok!(Democracy::::set_metadata( origin_propose, - preimage_hash.clone()) + MetadataOwner::External, + Some(preimage_hash)) ); let mut vetoers: BoundedVec = Default::default(); @@ -339,10 +341,10 @@ benchmarks! { // Add metadata to the first proposal. let proposer = funded_account::("proposer", 0); let preimage_hash = note_preimage::(); - assert_ok!(Democracy::::set_proposal_metadata( + assert_ok!(Democracy::::set_metadata( RawOrigin::Signed(proposer).into(), - 0, - preimage_hash.clone())); + MetadataOwner::Proposal(0), + Some(preimage_hash))); let cancel_origin = T::CancelProposalOrigin::successful_origin(); }: _(cancel_origin, 0) verify { @@ -733,12 +735,13 @@ benchmarks! { assert_ok!( Democracy::::external_propose(origin.clone(), make_proposal::(0)) ); - let preimage_hash = note_preimage::(); - }: _(origin, preimage_hash) + let owner = MetadataOwner::External; + let hash = note_preimage::(); + }: set_metadata(origin, owner.clone(), Some(hash)) verify { assert_last_event::(crate::Event::MetadataSet { - owner: MetadataOwner::External, - hash: preimage_hash, + owner, + hash, }.into()); } @@ -747,14 +750,15 @@ benchmarks! { assert_ok!( Democracy::::external_propose(origin.clone(), make_proposal::(0)) ); + let owner = MetadataOwner::External; let proposer = funded_account::("proposer", 0); - let preimage_hash = note_preimage::(); - assert_ok!(Democracy::::set_external_metadata(origin.clone(), preimage_hash.clone())); - }: _(origin) + let hash = note_preimage::(); + assert_ok!(Democracy::::set_metadata(origin.clone(), owner.clone(), Some(hash))); + }: set_metadata(origin, owner.clone(), None) verify { assert_last_event::(crate::Event::MetadataCleared { - owner: MetadataOwner::External, - hash: preimage_hash, + owner, + hash, }.into()); } @@ -763,13 +767,14 @@ benchmarks! { for i in 0 .. T::MaxProposals::get() { add_proposal::(i)?; } + let owner = MetadataOwner::Proposal(0); let proposer = funded_account::("proposer", 0); - let preimage_hash = note_preimage::(); - }: _(RawOrigin::Signed(proposer).into(), 0, preimage_hash) + let hash = note_preimage::(); + }: set_metadata(RawOrigin::Signed(proposer).into(), owner.clone(), Some(hash)) verify { assert_last_event::(crate::Event::MetadataSet { - owner: MetadataOwner::Proposal(0), - hash: preimage_hash, + owner, + hash, }.into()); } @@ -779,26 +784,52 @@ benchmarks! { add_proposal::(i)?; } let proposer = funded_account::("proposer", 0); - let preimage_hash = note_preimage::(); - assert_ok!(Democracy::::set_proposal_metadata( + let owner = MetadataOwner::Proposal(0); + let hash = note_preimage::(); + assert_ok!(Democracy::::set_metadata( RawOrigin::Signed(proposer.clone()).into(), - 0, - preimage_hash.clone())); - }: _(RawOrigin::Signed(proposer).into(), 0) + owner.clone(), + Some(hash))); + }: set_metadata(RawOrigin::Signed(proposer).into(), owner.clone(), None) verify { assert_last_event::(crate::Event::MetadataCleared { - owner: MetadataOwner::Proposal(0), - hash: preimage_hash, + owner, + hash, + }.into()); + } + + set_referendum_metadata { + // create not ongoing referendum. + ReferendumInfoOf::::insert( + 0, + ReferendumInfo::Finished { end: T::BlockNumber::zero(), approved: true }, + ); + let owner = MetadataOwner::Referendum(0); + let caller = funded_account::("caller", 0); + let hash = note_preimage::(); + }: set_metadata(RawOrigin::Root.into(), owner.clone(), Some(hash)) + verify { + assert_last_event::(crate::Event::MetadataSet { + owner, + hash, }.into()); } clear_referendum_metadata { - let (ref_index, _, preimage_hash) = add_referendum::(0); - }: _(RawOrigin::Root, ref_index) + // create not ongoing referendum. + ReferendumInfoOf::::insert( + 0, + ReferendumInfo::Finished { end: T::BlockNumber::zero(), approved: true }, + ); + let owner = MetadataOwner::Referendum(0); + let hash = note_preimage::(); + MetadataOf::::insert(owner.clone(), hash); + let caller = funded_account::("caller", 0); + }: set_metadata(RawOrigin::Signed(caller).into(), owner.clone(), None) verify { assert_last_event::(crate::Event::MetadataCleared { - owner: MetadataOwner::Referendum(ref_index), - hash: preimage_hash, + owner, + hash, }.into()); } diff --git a/frame/democracy/src/lib.rs b/frame/democracy/src/lib.rs index 5ad7a6dd43d52..b1d5de42eea8b 100644 --- a/frame/democracy/src/lib.rs +++ b/frame/democracy/src/lib.rs @@ -155,6 +155,7 @@ use codec::{Decode, Encode}; use frame_support::{ ensure, + error::BadOrigin, traits::{ defensive_prelude::*, schedule::{v3::Named as ScheduleNamed, DispatchTime}, @@ -164,6 +165,7 @@ use frame_support::{ }, weights::Weight, }; +use frame_system::pallet_prelude::OriginFor; use sp_runtime::{ traits::{Bounded as ArithBounded, One, Saturating, StaticLookup, Zero}, ArithmeticError, DispatchError, DispatchResult, @@ -1090,102 +1092,60 @@ pub mod pallet { Ok(()) } - /// Set the metadata to the external proposal. - /// - /// - `origin`: Must be an external origin and correspond to the proposal vote threshold, - /// `ExternalOrigin` for `SuperMajorityApprove`, `ExternalDefaultOrigin` for - /// `SuperMajorityAgainst` and `ExternalMajorityOrigin` for `SimpleMajority`. - /// - `hash`: The hash of an on-chain stored preimage. - #[pallet::weight(T::WeightInfo::set_external_metadata())] - pub fn set_external_metadata(origin: OriginFor, hash: PreimageHash) -> DispatchResult { - let (_, threshold) = >::get().ok_or(Error::::NoProposal)?; - match threshold { - VoteThreshold::SuperMajorityApprove => { - let _ = T::ExternalOrigin::ensure_origin(origin)?; - }, - VoteThreshold::SuperMajorityAgainst => { - let _ = T::ExternalDefaultOrigin::ensure_origin(origin)?; - }, - VoteThreshold::SimpleMajority => { - let _ = T::ExternalMajorityOrigin::ensure_origin(origin)?; - }, - }; - ensure!(T::Preimages::len(&hash).is_some(), Error::::PreimageNotExist); - T::Preimages::request(&hash); - MetadataOf::::insert(MetadataOwner::External, hash); - Self::deposit_event(Event::::MetadataSet { owner: MetadataOwner::External, hash }); - Ok(()) - } - - /// Set the metadata of the public proposal. - /// - /// - `origin`: Must be `Signed`, and the creator of the proposal. - /// - `index`: The index of the proposal. - /// - `hash`: The preimage hash of an on-chain stored preimage. - #[pallet::weight(T::WeightInfo::set_proposal_metadata())] - pub fn set_proposal_metadata( + /// Set or clear a metadata of a proposal or a referendum. + /// + /// Parameters: + /// - `origin`: Must correspond to the `MetadataOwner`. + /// - `ExternalOrigin` for an external proposal with the `SuperMajorityApprove` threshold. + /// - `ExternalDefaultOrigin` for an external proposal with the `SuperMajorityAgainst` threshold. + /// - `ExternalMajorityOrigin` for an external proposal with the `SimpleMajority` threshold. + /// - `Signed` by a creator for a public proposal. + /// - `Signed` to clear a metadata for a finished referendum. + /// - `Root` to set a metadata for an ongoing referendum. + /// - `owner`: an identifier of a metadata owner. + /// - `maybe_hash`: The hash of an on-chain stored preimage. `None` to clear a metadata. + #[pallet::weight( + match (owner, maybe_hash) { + (MetadataOwner::External, Some(_)) => T::WeightInfo::set_external_metadata(), + (MetadataOwner::External, None) => T::WeightInfo::clear_external_metadata(), + (MetadataOwner::Proposal(_), Some(_)) => T::WeightInfo::set_proposal_metadata(), + (MetadataOwner::Proposal(_), None) => T::WeightInfo::clear_proposal_metadata(), + (MetadataOwner::Referendum(_), Some(_)) => T::WeightInfo::set_referendum_metadata(), + (MetadataOwner::Referendum(_), None) => T::WeightInfo::clear_referendum_metadata(), + } + )] + pub fn set_metadata( origin: OriginFor, - index: PropIndex, - hash: PreimageHash, + owner: MetadataOwner, + maybe_hash: Option, ) -> DispatchResult { - let who = ensure_signed(origin)?; - let (_, _, proposer) = Self::proposal(index)?; - ensure!(proposer == who, Error::::NoPermission); - ensure!(T::Preimages::len(&hash).is_some(), Error::::PreimageNotExist); - T::Preimages::request(&hash); - let owner = MetadataOwner::Proposal(index); - MetadataOf::::insert(owner.clone(), hash); - Self::deposit_event(Event::::MetadataSet { owner, hash }); - Ok(()) - } - - /// Clear the external proposal metadata. - /// - /// - `origin`: Must be an external origin and correspond to the proposal vote threshold, - /// `ExternalOrigin` for `SuperMajorityApprove`, `ExternalDefaultOrigin` for - /// `SuperMajorityAgainst` and `ExternalMajorityOrigin` for `SimpleMajority`. - #[pallet::weight(T::WeightInfo::clear_external_metadata())] - pub fn clear_external_metadata(origin: OriginFor) -> DispatchResult { - let (_, threshold) = >::get().ok_or(Error::::NoProposal)?; - match threshold { - VoteThreshold::SuperMajorityApprove => { - let _ = T::ExternalOrigin::ensure_origin(origin)?; + match owner { + MetadataOwner::External => { + let (_, threshold) = >::get().ok_or(Error::::NoProposal)?; + Self::ensure_external_origin(threshold, origin)?; }, - VoteThreshold::SuperMajorityAgainst => { - let _ = T::ExternalDefaultOrigin::ensure_origin(origin)?; + MetadataOwner::Proposal(index) => { + let who = ensure_signed(origin)?; + let (_, _, proposer) = Self::proposal(index)?; + ensure!(proposer == who, Error::::NoPermission); }, - VoteThreshold::SimpleMajority => { - let _ = T::ExternalMajorityOrigin::ensure_origin(origin)?; + MetadataOwner::Referendum(index) => { + let maybe_root = ensure_signed_or_root(origin)?.is_none(); + ensure!(maybe_root || maybe_hash.is_none(), Error::::NoPermission); + ensure!( + maybe_root || Self::referendum_status(index).is_err(), + Error::::NoPermission + ); }, - }; - Self::clear_metadata(MetadataOwner::External); - Ok(()) - } - - /// Clear the public proposal metadata. - /// - /// - `origin`: Must be `Signed`, and the creator of the proposal. - /// - `index`: The index of the proposal. - #[pallet::weight(T::WeightInfo::clear_proposal_metadata())] - pub fn clear_proposal_metadata(origin: OriginFor, index: PropIndex) -> DispatchResult { - let who = ensure_signed(origin)?; - let (_, _, proposer) = Self::proposal(index)?; - ensure!(proposer == who, Error::::NoPermission); - Self::clear_metadata(MetadataOwner::Proposal(index)); - Ok(()) - } - - /// Clear the referendum metadata. - /// - /// - `origin`: Must be `Root`. - /// - `index`: The index of the referendum. - #[pallet::weight(T::WeightInfo::clear_referendum_metadata())] - pub fn clear_referendum_metadata( - origin: OriginFor, - index: ReferendumIndex, - ) -> DispatchResult { - ensure_root(origin)?; - Self::clear_metadata(MetadataOwner::Referendum(index)); + } + if let Some(hash) = maybe_hash { + ensure!(T::Preimages::len(&hash).is_some(), Error::::PreimageNotExist); + T::Preimages::request(&hash); + MetadataOf::::insert(owner.clone(), hash); + Self::deposit_event(Event::::MetadataSet { owner, hash }); + } else { + Self::clear_metadata(owner); + } Ok(()) } } @@ -1731,6 +1691,25 @@ impl Pallet { }); } } + + /// Ensure external origin for corresponding vote threshold. + fn ensure_external_origin( + threshold: VoteThreshold, + origin: OriginFor, + ) -> Result<(), BadOrigin> { + match threshold { + VoteThreshold::SuperMajorityApprove => { + let _ = T::ExternalOrigin::ensure_origin(origin)?; + }, + VoteThreshold::SuperMajorityAgainst => { + let _ = T::ExternalDefaultOrigin::ensure_origin(origin)?; + }, + VoteThreshold::SimpleMajority => { + let _ = T::ExternalMajorityOrigin::ensure_origin(origin)?; + }, + }; + Ok(()) + } } /// Decode `Compact` from the trie at given key. diff --git a/frame/democracy/src/tests.rs b/frame/democracy/src/tests.rs index ea30b2feb4d0f..24aad1b359998 100644 --- a/frame/democracy/src/tests.rs +++ b/frame/democracy/src/tests.rs @@ -44,6 +44,7 @@ mod lock_voting; mod public_proposals; mod scheduling; mod voting; +mod metadata; const AYE: Vote = Vote { aye: true, conviction: Conviction::None }; const NAY: Vote = Vote { aye: false, conviction: Conviction::None }; diff --git a/frame/democracy/src/tests/external_proposing.rs b/frame/democracy/src/tests/external_proposing.rs index 17cb2baaed3e5..4cfdd2aa74a3d 100644 --- a/frame/democracy/src/tests/external_proposing.rs +++ b/frame/democracy/src/tests/external_proposing.rs @@ -274,60 +274,3 @@ fn external_and_public_interleaving_works() { ); }); } - -#[test] -fn set_external_metadata_works() { - new_test_ext().execute_with(|| { - use frame_support::traits::Hash as PreimageHash; - // invalid preimage hash. - let invalid_hash: PreimageHash = [1u8; 32].into(); - // fails to set metadata if an external proposal does not exist. - assert_noop!( - Democracy::set_external_metadata(RuntimeOrigin::signed(2), invalid_hash), - Error::::NoProposal, - ); - // create an external proposal. - assert_ok!(Democracy::external_propose(RuntimeOrigin::signed(2), set_balance_proposal(2),)); - assert!(>::exists()); - // fails to set metadata with non external origin. - assert_noop!( - Democracy::set_external_metadata(RuntimeOrigin::signed(1), invalid_hash), - BadOrigin, - ); - // fails to set non-existing preimage. - assert_noop!( - Democracy::set_external_metadata(RuntimeOrigin::signed(2), invalid_hash), - Error::::PreimageNotExist, - ); - // set metadata successful. - let hash = note_preimage(1); - assert_ok!(Democracy::set_external_metadata(RuntimeOrigin::signed(2), hash,),); - System::assert_last_event(RuntimeEvent::Democracy(crate::Event::MetadataSet { - owner: MetadataOwner::External, - hash, - })); - assert!(Preimage::is_requested(&hash)); - }); -} - -#[test] -fn clear_metadata_works() { - new_test_ext().execute_with(|| { - // create an external proposal. - assert_ok!(Democracy::external_propose(RuntimeOrigin::signed(2), set_balance_proposal(2),)); - assert!(>::exists()); - // set metadata. - let hash = note_preimage(1); - assert_ok!(Democracy::set_external_metadata(RuntimeOrigin::signed(2), hash,)); - assert!(Preimage::is_requested(&hash)); - // fails to clear metadata with a wrong origin. - assert_noop!(Democracy::clear_external_metadata(RuntimeOrigin::signed(1)), BadOrigin,); - // clear metadata successful. - assert_ok!(Democracy::clear_external_metadata(RuntimeOrigin::signed(2))); - System::assert_last_event(RuntimeEvent::Democracy(crate::Event::MetadataCleared { - owner: MetadataOwner::External, - hash, - })); - assert!(!Preimage::is_requested(&hash)); - }); -} diff --git a/frame/democracy/src/tests/fast_tracking.rs b/frame/democracy/src/tests/fast_tracking.rs index 34350a494dc6f..09af3dbf3b5dd 100644 --- a/frame/democracy/src/tests/fast_tracking.rs +++ b/frame/democracy/src/tests/fast_tracking.rs @@ -34,7 +34,11 @@ fn fast_track_referendum_works() { )); let hash = note_preimage(1); assert!(>::get(MetadataOwner::External).is_none()); - assert_ok!(Democracy::set_external_metadata(RuntimeOrigin::signed(3), hash,),); + assert_ok!(Democracy::set_metadata( + RuntimeOrigin::signed(3), + MetadataOwner::External, + Some(hash), + ),); assert!(>::get(MetadataOwner::External).is_some()); assert_noop!(Democracy::fast_track(RuntimeOrigin::signed(1), h, 3, 2), BadOrigin); assert_ok!(Democracy::fast_track(RuntimeOrigin::signed(5), h, 2, 0)); diff --git a/frame/democracy/src/tests/metadata.rs b/frame/democracy/src/tests/metadata.rs new file mode 100644 index 0000000000000..b9bbc471d3fa7 --- /dev/null +++ b/frame/democracy/src/tests/metadata.rs @@ -0,0 +1,222 @@ +// This file is part of Substrate. + +// Copyright (C) 2017-2022 Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// 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. + +//! The tests for functionality concerning the metadata. + +use super::*; + +#[test] +fn set_external_metadata_works() { + new_test_ext().execute_with(|| { + use frame_support::traits::Hash as PreimageHash; + // invalid preimage hash. + let invalid_hash: PreimageHash = [1u8; 32].into(); + // metadata owner is an external proposal. + let owner = MetadataOwner::External; + // fails to set metadata if an external proposal does not exist. + assert_noop!( + Democracy::set_metadata(RuntimeOrigin::signed(2), owner.clone(), Some(invalid_hash)), + Error::::NoProposal, + ); + // create an external proposal. + assert_ok!(Democracy::external_propose(RuntimeOrigin::signed(2), set_balance_proposal(2),)); + assert!(>::exists()); + // fails to set metadata with non external origin. + assert_noop!( + Democracy::set_metadata(RuntimeOrigin::signed(1), owner.clone(), Some(invalid_hash)), + BadOrigin, + ); + // fails to set non-existing preimage. + assert_noop!( + Democracy::set_metadata(RuntimeOrigin::signed(2), owner.clone(), Some(invalid_hash)), + Error::::PreimageNotExist, + ); + // set metadata successful. + let hash = note_preimage(1); + assert_ok!(Democracy::set_metadata(RuntimeOrigin::signed(2), owner.clone(), Some(hash),),); + System::assert_last_event(RuntimeEvent::Democracy(crate::Event::MetadataSet { + owner, + hash, + })); + assert!(Preimage::is_requested(&hash)); + }); +} + +#[test] +fn clear_metadata_works() { + new_test_ext().execute_with(|| { + // metadata owner is an external proposal. + let owner = MetadataOwner::External; + // create an external proposal. + assert_ok!(Democracy::external_propose(RuntimeOrigin::signed(2), set_balance_proposal(2),)); + assert!(>::exists()); + // set metadata. + let hash = note_preimage(1); + assert_ok!(Democracy::set_metadata(RuntimeOrigin::signed(2), owner.clone(), Some(hash),)); + assert!(Preimage::is_requested(&hash)); + // fails to clear metadata with a wrong origin. + assert_noop!( + Democracy::set_metadata(RuntimeOrigin::signed(1), owner.clone(), None), + BadOrigin, + ); + // clear metadata successful. + assert_ok!(Democracy::set_metadata(RuntimeOrigin::signed(2), owner.clone(), None)); + System::assert_last_event(RuntimeEvent::Democracy(crate::Event::MetadataCleared { + owner, + hash, + })); + assert!(!Preimage::is_requested(&hash)); + }); +} + +#[test] +fn set_proposal_metadata_works() { + new_test_ext().execute_with(|| { + use frame_support::traits::Hash as PreimageHash; + // invalid preimage hash. + let invalid_hash: PreimageHash = [1u8; 32].into(); + // create an external proposal. + assert_ok!(propose_set_balance(1, 2, 5)); + // metadata owner is a public proposal. + let owner = MetadataOwner::Proposal(Democracy::public_prop_count() - 1); + // fails to set non-existing preimage. + assert_noop!( + Democracy::set_metadata(RuntimeOrigin::signed(1), owner.clone(), Some(invalid_hash),), + Error::::PreimageNotExist, + ); + // note preimage. + let hash = note_preimage(1); + // fails to set a preimage if an origin is not a proposer. + assert_noop!( + Democracy::set_metadata(RuntimeOrigin::signed(3), owner.clone(), Some(hash),), + Error::::NoPermission, + ); + // set metadata successful. + assert_ok!(Democracy::set_metadata(RuntimeOrigin::signed(1), owner.clone(), Some(hash),),); + System::assert_last_event(RuntimeEvent::Democracy(crate::Event::MetadataSet { + owner, + hash, + })); + assert!(Preimage::is_requested(&hash)); + }); +} + +#[test] +fn clear_proposal_metadata_works() { + new_test_ext().execute_with(|| { + // create an external proposal. + assert_ok!(propose_set_balance(1, 2, 5)); + // metadata owner is a public proposal. + let owner = MetadataOwner::Proposal(Democracy::public_prop_count() - 1); + // set metadata. + let hash = note_preimage(1); + assert!(!Preimage::is_requested(&hash)); + assert_ok!(Democracy::set_metadata(RuntimeOrigin::signed(1), owner.clone(), Some(hash),)); + assert!(Preimage::is_requested(&hash)); + // fails to clear metadata with a wrong origin. + assert_noop!( + Democracy::set_metadata(RuntimeOrigin::signed(3), owner.clone(), None), + Error::::NoPermission, + ); + // clear metadata successful. + assert_ok!(Democracy::set_metadata(RuntimeOrigin::signed(1), owner.clone(), None)); + System::assert_last_event(RuntimeEvent::Democracy(crate::Event::MetadataCleared { + owner, + hash, + })); + assert!(!Preimage::is_requested(&hash)); + }); +} + +#[test] +fn set_referendum_metadata_by_root() { + new_test_ext().execute_with(|| { + let index = Democracy::inject_referendum( + 2, + set_balance_proposal(2), + VoteThreshold::SuperMajorityApprove, + 0, + ); + // metadata owner is a referendum. + let owner = MetadataOwner::Referendum(index); + // note preimage. + let hash = note_preimage(1); + // fails to set if not a root. + assert_noop!( + Democracy::set_metadata(RuntimeOrigin::signed(3), owner.clone(), Some(hash),), + Error::::NoPermission, + ); + // fails to clear if not a root. + assert_noop!( + Democracy::set_metadata(RuntimeOrigin::signed(3), owner.clone(), None,), + Error::::NoPermission, + ); + // succeed to set metadata by a root for an ongoing referendum. + assert!(!Preimage::is_requested(&hash)); + assert_ok!(Democracy::set_metadata(RuntimeOrigin::root(), owner.clone(), Some(hash),)); + assert!(Preimage::is_requested(&hash)); + System::assert_last_event(RuntimeEvent::Democracy(crate::Event::MetadataSet { + owner: owner.clone(), + hash, + })); + // succeed to clear metadata by a root for an ongoing referendum. + assert_ok!(Democracy::set_metadata(RuntimeOrigin::root(), owner.clone(), None)); + System::assert_last_event(RuntimeEvent::Democracy(crate::Event::MetadataCleared { + owner, + hash, + })); + assert!(!Preimage::is_requested(&hash)); + }); +} + +#[test] +fn clear_referendum_metadata_works() { + new_test_ext().execute_with(|| { + // create a referendum. + let index = Democracy::inject_referendum( + 2, + set_balance_proposal(2), + VoteThreshold::SuperMajorityApprove, + 0, + ); + // metadata owner is a referendum. + let owner = MetadataOwner::Referendum(index); + // set metadata. + let hash = note_preimage(1); + // referendum finished. + MetadataOf::::insert(owner.clone(), hash); + Preimage::request(&hash); + assert!(Preimage::is_requested(&hash)); + // no permission to clear metadata of an ongoing referendum. + assert_noop!( + Democracy::set_metadata(RuntimeOrigin::signed(1), owner.clone(), None), + Error::::NoPermission, + ); + // referendum finished. + ReferendumInfoOf::::insert( + index, + ReferendumInfo::Finished { end: 1, approved: true }, + ); + // clear metadata successful. + assert_ok!(Democracy::set_metadata(RuntimeOrigin::signed(1), owner.clone(), None)); + System::assert_last_event(RuntimeEvent::Democracy(crate::Event::MetadataCleared { + owner, + hash, + })); + assert!(!Preimage::is_requested(&hash)); + }); +} diff --git a/frame/democracy/src/tests/public_proposals.rs b/frame/democracy/src/tests/public_proposals.rs index 21e642477f23e..dc7f21daae3da 100644 --- a/frame/democracy/src/tests/public_proposals.rs +++ b/frame/democracy/src/tests/public_proposals.rs @@ -92,7 +92,11 @@ fn cancel_proposal_should_work() { assert_ok!(propose_set_balance(1, 4, 4)); assert_noop!(Democracy::cancel_proposal(RuntimeOrigin::signed(1), 0), BadOrigin); let hash = note_preimage(1); - assert_ok!(Democracy::set_proposal_metadata(RuntimeOrigin::signed(1), 0, hash)); + assert_ok!(Democracy::set_metadata( + RuntimeOrigin::signed(1), + MetadataOwner::Proposal(0), + Some(hash) + )); assert!(>::get(MetadataOwner::Proposal(0)).is_some()); assert!(Preimage::is_requested(&hash)); assert_ok!(Democracy::cancel_proposal(RuntimeOrigin::root(), 0)); @@ -149,60 +153,3 @@ fn runners_up_should_come_after() { assert_ok!(Democracy::vote(RuntimeOrigin::signed(1), 2, aye(1))); }); } - -#[test] -fn set_external_metadata_works() { - new_test_ext().execute_with(|| { - use frame_support::traits::Hash as PreimageHash; - // invalid preimage hash. - let invalid_hash: PreimageHash = [1u8; 32].into(); - // create an external proposal. - assert_ok!(propose_set_balance(1, 2, 5)); - let index = Democracy::public_prop_count() - 1; - // fails to set non-existing preimage. - assert_noop!( - Democracy::set_proposal_metadata(RuntimeOrigin::signed(1), index, invalid_hash,), - Error::::PreimageNotExist, - ); - // note preimage. - let hash = note_preimage(1); - // fails to set non-existing preimage. - assert_noop!( - Democracy::set_proposal_metadata(RuntimeOrigin::signed(3), index, hash,), - Error::::NoPermission, - ); - // set metadata successful. - assert_ok!(Democracy::set_proposal_metadata(RuntimeOrigin::signed(1), index, hash,),); - System::assert_last_event(RuntimeEvent::Democracy(crate::Event::MetadataSet { - owner: MetadataOwner::Proposal(index), - hash, - })); - assert!(Preimage::is_requested(&hash)); - }); -} - -#[test] -fn clear_metadata_works() { - new_test_ext().execute_with(|| { - // create an external proposal. - assert_ok!(propose_set_balance(1, 2, 5)); - let index = Democracy::public_prop_count() - 1; - // set metadata. - let hash = note_preimage(1); - assert!(!Preimage::is_requested(&hash)); - assert_ok!(Democracy::set_proposal_metadata(RuntimeOrigin::signed(1), index, hash,)); - assert!(Preimage::is_requested(&hash)); - // fails to clear metadata with a wrong origin. - assert_noop!( - Democracy::clear_proposal_metadata(RuntimeOrigin::signed(3), index), - Error::::NoPermission, - ); - // clear metadata successful. - assert_ok!(Democracy::clear_proposal_metadata(RuntimeOrigin::signed(1), index)); - System::assert_last_event(RuntimeEvent::Democracy(crate::Event::MetadataCleared { - owner: MetadataOwner::Proposal(index), - hash, - })); - assert!(!Preimage::is_requested(&hash)); - }); -} diff --git a/frame/democracy/src/weights.rs b/frame/democracy/src/weights.rs index 2176dfb48d873..05a5c18a67fdd 100644 --- a/frame/democracy/src/weights.rs +++ b/frame/democracy/src/weights.rs @@ -1,42 +1,23 @@ -// This file is part of Substrate. - -// Copyright (C) 2022 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// 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. //! Autogenerated weights for pallet_democracy //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-10-31, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 +//! DATE: 2022-11-17, STEPS: `2`, REPEAT: 1, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `cob`, CPU: `` +//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: -// /home/benchbot/cargo_target_dir/production/substrate +// ./target/release/substrate // benchmark // pallet -// --steps=50 -// --repeat=20 +// --chain=dev +// --steps=2 +// --repeat=1 +// --pallet=pallet-democracy // --extrinsic=* -// --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/substrate/.git/.artifacts/bench.json -// --pallet=pallet_democracy -// --chain=dev -// --header=./HEADER-APACHE2 -// --output=./frame/democracy/src/weights.rs +// --output=./frame/democracy/src/._weights.rs // --template=./.maintain/frame-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -74,6 +55,7 @@ pub trait WeightInfo { fn clear_external_metadata() -> Weight; fn set_proposal_metadata() -> Weight; fn clear_proposal_metadata() -> Weight; + fn set_referendum_metadata() -> Weight; fn clear_referendum_metadata() -> Weight; } @@ -85,15 +67,15 @@ impl WeightInfo for SubstrateWeight { // Storage: Democracy Blacklist (r:1 w:0) // Storage: Democracy DepositOf (r:0 w:1) fn propose() -> Weight { - // Minimum execution time: 56_190 nanoseconds. - Weight::from_ref_time(57_022_000 as u64) + // Minimum execution time: 33_000 nanoseconds. + Weight::from_ref_time(33_000_000 as u64) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Democracy DepositOf (r:1 w:1) fn second() -> Weight { - // Minimum execution time: 48_192 nanoseconds. - Weight::from_ref_time(48_719_000 as u64) + // Minimum execution time: 33_000 nanoseconds. + Weight::from_ref_time(33_000_000 as u64) .saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } @@ -101,8 +83,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Democracy VotingOf (r:1 w:1) // Storage: Balances Locks (r:1 w:1) fn vote_new() -> Weight { - // Minimum execution time: 71_575 nanoseconds. - Weight::from_ref_time(72_584_000 as u64) + // Minimum execution time: 44_000 nanoseconds. + Weight::from_ref_time(44_000_000 as u64) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -110,8 +92,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Democracy VotingOf (r:1 w:1) // Storage: Balances Locks (r:1 w:1) fn vote_existing() -> Weight { - // Minimum execution time: 72_634 nanoseconds. - Weight::from_ref_time(74_350_000 as u64) + // Minimum execution time: 43_000 nanoseconds. + Weight::from_ref_time(43_000_000 as u64) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -121,8 +103,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Preimage StatusFor (r:1 w:1) // Storage: Preimage PreimageFor (r:0 w:1) fn emergency_cancel() -> Weight { - // Minimum execution time: 44_016 nanoseconds. - Weight::from_ref_time(44_755_000 as u64) + // Minimum execution time: 35_000 nanoseconds. + Weight::from_ref_time(35_000_000 as u64) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().writes(5 as u64)) } @@ -136,29 +118,29 @@ impl WeightInfo for SubstrateWeight { // Storage: Preimage PreimageFor (r:0 w:1) // Storage: Democracy Blacklist (r:0 w:1) fn blacklist() -> Weight { - // Minimum execution time: 109_317 nanoseconds. - Weight::from_ref_time(110_489_000 as u64) + // Minimum execution time: 81_000 nanoseconds. + Weight::from_ref_time(81_000_000 as u64) .saturating_add(T::DbWeight::get().reads(9 as u64)) .saturating_add(T::DbWeight::get().writes(9 as u64)) } // Storage: Democracy NextExternal (r:1 w:1) // Storage: Democracy Blacklist (r:1 w:0) fn external_propose() -> Weight { - // Minimum execution time: 18_768 nanoseconds. - Weight::from_ref_time(19_256_000 as u64) + // Minimum execution time: 18_000 nanoseconds. + Weight::from_ref_time(18_000_000 as u64) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Democracy NextExternal (r:0 w:1) fn external_propose_majority() -> Weight { - // Minimum execution time: 4_887 nanoseconds. - Weight::from_ref_time(5_071_000 as u64) + // Minimum execution time: 6_000 nanoseconds. + Weight::from_ref_time(6_000_000 as u64) .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Democracy NextExternal (r:0 w:1) fn external_propose_default() -> Weight { - // Minimum execution time: 4_966 nanoseconds. - Weight::from_ref_time(5_174_000 as u64) + // Minimum execution time: 5_000 nanoseconds. + Weight::from_ref_time(5_000_000 as u64) .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Democracy NextExternal (r:1 w:1) @@ -166,8 +148,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Democracy MetadataOf (r:1 w:2) // Storage: Democracy ReferendumInfoOf (r:0 w:1) fn fast_track() -> Weight { - // Minimum execution time: 34_839 nanoseconds. - Weight::from_ref_time(35_514_000 as u64) + // Minimum execution time: 26_000 nanoseconds. + Weight::from_ref_time(26_000_000 as u64) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(5 as u64)) } @@ -176,8 +158,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Democracy MetadataOf (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:1) fn veto_external() -> Weight { - // Minimum execution time: 46_388 nanoseconds. - Weight::from_ref_time(46_837_000 as u64) + // Minimum execution time: 35_000 nanoseconds. + Weight::from_ref_time(35_000_000 as u64) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().writes(4 as u64)) } @@ -187,8 +169,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Democracy MetadataOf (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:1) fn cancel_proposal() -> Weight { - // Minimum execution time: 88_273 nanoseconds. - Weight::from_ref_time(89_910_000 as u64) + // Minimum execution time: 65_000 nanoseconds. + Weight::from_ref_time(65_000_000 as u64) .saturating_add(T::DbWeight::get().reads(5 as u64)) .saturating_add(T::DbWeight::get().writes(5 as u64)) } @@ -197,22 +179,19 @@ impl WeightInfo for SubstrateWeight { // Storage: Preimage PreimageFor (r:0 w:1) // Storage: Democracy ReferendumInfoOf (r:0 w:1) fn cancel_referendum() -> Weight { - // Minimum execution time: 36_626 nanoseconds. - Weight::from_ref_time(37_221_000 as u64) + // Minimum execution time: 29_000 nanoseconds. + Weight::from_ref_time(29_000_000 as u64) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: Democracy LowestUnbaked (r:1 w:1) // Storage: Democracy ReferendumCount (r:1 w:0) - // Storage: Democracy ReferendumInfoOf (r:2 w:0) + // Storage: Democracy ReferendumInfoOf (r:99 w:0) /// The range of component `r` is `[0, 99]`. - fn on_initialize_base(r: u32, ) -> Weight { - // Minimum execution time: 6_738 nanoseconds. - Weight::from_ref_time(12_684_834 as u64) - // Standard Error: 5_168 - .saturating_add(Weight::from_ref_time(2_402_248 as u64).saturating_mul(r as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(r as u64))) + fn on_initialize_base(_r: u32, ) -> Weight { + // Minimum execution time: 7_000 nanoseconds. + Weight::from_ref_time(302_000_000 as u64) + .saturating_add(T::DbWeight::get().reads(101 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Democracy LowestUnbaked (r:1 w:1) @@ -220,59 +199,46 @@ impl WeightInfo for SubstrateWeight { // Storage: Democracy LastTabledWasExternal (r:1 w:0) // Storage: Democracy NextExternal (r:1 w:0) // Storage: Democracy PublicProps (r:1 w:0) - // Storage: Democracy ReferendumInfoOf (r:2 w:0) + // Storage: Democracy ReferendumInfoOf (r:99 w:0) /// The range of component `r` is `[0, 99]`. - fn on_initialize_base_with_launch_period(r: u32, ) -> Weight { - // Minimum execution time: 9_188 nanoseconds. - Weight::from_ref_time(16_333_541 as u64) - // Standard Error: 4_393 - .saturating_add(Weight::from_ref_time(2_379_560 as u64).saturating_mul(r as u64)) - .saturating_add(T::DbWeight::get().reads(5 as u64)) - .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(r as u64))) + fn on_initialize_base_with_launch_period(_r: u32, ) -> Weight { + // Minimum execution time: 8_000 nanoseconds. + Weight::from_ref_time(239_000_000 as u64) + .saturating_add(T::DbWeight::get().reads(104 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Democracy VotingOf (r:3 w:3) // Storage: Balances Locks (r:1 w:1) - // Storage: Democracy ReferendumInfoOf (r:2 w:2) + // Storage: Democracy ReferendumInfoOf (r:99 w:99) /// The range of component `r` is `[0, 99]`. - fn delegate(r: u32, ) -> Weight { - // Minimum execution time: 47_322 nanoseconds. - Weight::from_ref_time(52_103_092 as u64) - // Standard Error: 5_569 - .saturating_add(Weight::from_ref_time(3_600_758 as u64).saturating_mul(r as u64)) - .saturating_add(T::DbWeight::get().reads(4 as u64)) - .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(r as u64))) - .saturating_add(T::DbWeight::get().writes(4 as u64)) - .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(r as u64))) + fn delegate(_r: u32, ) -> Weight { + // Minimum execution time: 40_000 nanoseconds. + Weight::from_ref_time(375_000_000 as u64) + .saturating_add(T::DbWeight::get().reads(103 as u64)) + .saturating_add(T::DbWeight::get().writes(103 as u64)) } // Storage: Democracy VotingOf (r:2 w:2) - // Storage: Democracy ReferendumInfoOf (r:2 w:2) + // Storage: Democracy ReferendumInfoOf (r:99 w:99) /// The range of component `r` is `[0, 99]`. - fn undelegate(r: u32, ) -> Weight { - // Minimum execution time: 29_730 nanoseconds. - Weight::from_ref_time(32_215_196 as u64) - // Standard Error: 5_365 - .saturating_add(Weight::from_ref_time(3_570_430 as u64).saturating_mul(r as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(r as u64))) - .saturating_add(T::DbWeight::get().writes(2 as u64)) - .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(r as u64))) + fn undelegate(_r: u32, ) -> Weight { + // Minimum execution time: 25_000 nanoseconds. + Weight::from_ref_time(334_000_000 as u64) + .saturating_add(T::DbWeight::get().reads(101 as u64)) + .saturating_add(T::DbWeight::get().writes(101 as u64)) } // Storage: Democracy PublicProps (r:0 w:1) fn clear_public_proposals() -> Weight { - // Minimum execution time: 6_443 nanoseconds. - Weight::from_ref_time(6_548_000 as u64) + // Minimum execution time: 5_000 nanoseconds. + Weight::from_ref_time(5_000_000 as u64) .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Democracy VotingOf (r:1 w:1) // Storage: Balances Locks (r:1 w:1) // Storage: System Account (r:1 w:1) /// The range of component `r` is `[0, 99]`. - fn unlock_remove(r: u32, ) -> Weight { - // Minimum execution time: 28_747 nanoseconds. - Weight::from_ref_time(37_459_555 as u64) - // Standard Error: 3_898 - .saturating_add(Weight::from_ref_time(152_180 as u64).saturating_mul(r as u64)) + fn unlock_remove(_r: u32, ) -> Weight { + // Minimum execution time: 29_000 nanoseconds. + Weight::from_ref_time(31_000_000 as u64) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -280,33 +246,27 @@ impl WeightInfo for SubstrateWeight { // Storage: Balances Locks (r:1 w:1) // Storage: System Account (r:1 w:1) /// The range of component `r` is `[0, 99]`. - fn unlock_set(r: u32, ) -> Weight { - // Minimum execution time: 34_624 nanoseconds. - Weight::from_ref_time(35_432_999 as u64) - // Standard Error: 3_069 - .saturating_add(Weight::from_ref_time(227_652 as u64).saturating_mul(r as u64)) + fn unlock_set(_r: u32, ) -> Weight { + // Minimum execution time: 29_000 nanoseconds. + Weight::from_ref_time(33_000_000 as u64) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Democracy ReferendumInfoOf (r:1 w:1) // Storage: Democracy VotingOf (r:1 w:1) /// The range of component `r` is `[1, 100]`. - fn remove_vote(r: u32, ) -> Weight { - // Minimum execution time: 18_142 nanoseconds. - Weight::from_ref_time(20_388_863 as u64) - // Standard Error: 1_654 - .saturating_add(Weight::from_ref_time(265_937 as u64).saturating_mul(r as u64)) + fn remove_vote(_r: u32, ) -> Weight { + // Minimum execution time: 15_000 nanoseconds. + Weight::from_ref_time(21_000_000 as u64) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Democracy ReferendumInfoOf (r:1 w:1) // Storage: Democracy VotingOf (r:1 w:1) /// The range of component `r` is `[1, 100]`. - fn remove_other_vote(r: u32, ) -> Weight { - // Minimum execution time: 18_375 nanoseconds. - Weight::from_ref_time(20_522_580 as u64) - // Standard Error: 1_295 - .saturating_add(Weight::from_ref_time(262_384 as u64).saturating_mul(r as u64)) + fn remove_other_vote(_r: u32, ) -> Weight { + // Minimum execution time: 15_000 nanoseconds. + Weight::from_ref_time(24_000_000 as u64) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } @@ -314,8 +274,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Preimage StatusFor (r:1 w:1) // Storage: Democracy MetadataOf (r:0 w:1) fn set_external_metadata() -> Weight { - // Minimum execution time: 26_968 nanoseconds. - Weight::from_ref_time(27_371_000 as u64) + // Minimum execution time: 23_000 nanoseconds. + Weight::from_ref_time(23_000_000 as u64) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } @@ -323,8 +283,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Democracy MetadataOf (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:1) fn clear_external_metadata() -> Weight { - // Minimum execution time: 31_538 nanoseconds. - Weight::from_ref_time(31_988_000 as u64) + // Minimum execution time: 27_000 nanoseconds. + Weight::from_ref_time(27_000_000 as u64) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } @@ -332,8 +292,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Preimage StatusFor (r:1 w:1) // Storage: Democracy MetadataOf (r:0 w:1) fn set_proposal_metadata() -> Weight { - // Minimum execution time: 52_544 nanoseconds. - Weight::from_ref_time(53_569_000 as u64) + // Minimum execution time: 42_000 nanoseconds. + Weight::from_ref_time(42_000_000 as u64) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } @@ -341,18 +301,27 @@ impl WeightInfo for SubstrateWeight { // Storage: Democracy MetadataOf (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:1) fn clear_proposal_metadata() -> Weight { - // Minimum execution time: 51_457 nanoseconds. - Weight::from_ref_time(56_328_000 as u64) + // Minimum execution time: 39_000 nanoseconds. + Weight::from_ref_time(39_000_000 as u64) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } + // Storage: Preimage StatusFor (r:1 w:1) + // Storage: Democracy MetadataOf (r:0 w:1) + fn set_referendum_metadata() -> Weight { + // Minimum execution time: 21_000 nanoseconds. + Weight::from_ref_time(21_000_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Democracy ReferendumInfoOf (r:1 w:0) // Storage: Democracy MetadataOf (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:1) // Storage: Preimage PreimageFor (r:0 w:1) fn clear_referendum_metadata() -> Weight { - // Minimum execution time: 32_189 nanoseconds. - Weight::from_ref_time(32_756_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) + // Minimum execution time: 33_000 nanoseconds. + Weight::from_ref_time(33_000_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } } @@ -364,15 +333,15 @@ impl WeightInfo for () { // Storage: Democracy Blacklist (r:1 w:0) // Storage: Democracy DepositOf (r:0 w:1) fn propose() -> Weight { - // Minimum execution time: 56_190 nanoseconds. - Weight::from_ref_time(57_022_000 as u64) + // Minimum execution time: 33_000 nanoseconds. + Weight::from_ref_time(33_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } // Storage: Democracy DepositOf (r:1 w:1) fn second() -> Weight { - // Minimum execution time: 48_192 nanoseconds. - Weight::from_ref_time(48_719_000 as u64) + // Minimum execution time: 33_000 nanoseconds. + Weight::from_ref_time(33_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(1 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } @@ -380,8 +349,8 @@ impl WeightInfo for () { // Storage: Democracy VotingOf (r:1 w:1) // Storage: Balances Locks (r:1 w:1) fn vote_new() -> Weight { - // Minimum execution time: 71_575 nanoseconds. - Weight::from_ref_time(72_584_000 as u64) + // Minimum execution time: 44_000 nanoseconds. + Weight::from_ref_time(44_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } @@ -389,8 +358,8 @@ impl WeightInfo for () { // Storage: Democracy VotingOf (r:1 w:1) // Storage: Balances Locks (r:1 w:1) fn vote_existing() -> Weight { - // Minimum execution time: 72_634 nanoseconds. - Weight::from_ref_time(74_350_000 as u64) + // Minimum execution time: 43_000 nanoseconds. + Weight::from_ref_time(43_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } @@ -400,8 +369,8 @@ impl WeightInfo for () { // Storage: Preimage StatusFor (r:1 w:1) // Storage: Preimage PreimageFor (r:0 w:1) fn emergency_cancel() -> Weight { - // Minimum execution time: 44_016 nanoseconds. - Weight::from_ref_time(44_755_000 as u64) + // Minimum execution time: 35_000 nanoseconds. + Weight::from_ref_time(35_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(5 as u64)) } @@ -415,29 +384,29 @@ impl WeightInfo for () { // Storage: Preimage PreimageFor (r:0 w:1) // Storage: Democracy Blacklist (r:0 w:1) fn blacklist() -> Weight { - // Minimum execution time: 109_317 nanoseconds. - Weight::from_ref_time(110_489_000 as u64) + // Minimum execution time: 81_000 nanoseconds. + Weight::from_ref_time(81_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(9 as u64)) .saturating_add(RocksDbWeight::get().writes(9 as u64)) } // Storage: Democracy NextExternal (r:1 w:1) // Storage: Democracy Blacklist (r:1 w:0) fn external_propose() -> Weight { - // Minimum execution time: 18_768 nanoseconds. - Weight::from_ref_time(19_256_000 as u64) + // Minimum execution time: 18_000 nanoseconds. + Weight::from_ref_time(18_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } // Storage: Democracy NextExternal (r:0 w:1) fn external_propose_majority() -> Weight { - // Minimum execution time: 4_887 nanoseconds. - Weight::from_ref_time(5_071_000 as u64) + // Minimum execution time: 6_000 nanoseconds. + Weight::from_ref_time(6_000_000 as u64) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } // Storage: Democracy NextExternal (r:0 w:1) fn external_propose_default() -> Weight { - // Minimum execution time: 4_966 nanoseconds. - Weight::from_ref_time(5_174_000 as u64) + // Minimum execution time: 5_000 nanoseconds. + Weight::from_ref_time(5_000_000 as u64) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } // Storage: Democracy NextExternal (r:1 w:1) @@ -445,8 +414,8 @@ impl WeightInfo for () { // Storage: Democracy MetadataOf (r:1 w:2) // Storage: Democracy ReferendumInfoOf (r:0 w:1) fn fast_track() -> Weight { - // Minimum execution time: 34_839 nanoseconds. - Weight::from_ref_time(35_514_000 as u64) + // Minimum execution time: 26_000 nanoseconds. + Weight::from_ref_time(26_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(5 as u64)) } @@ -455,8 +424,8 @@ impl WeightInfo for () { // Storage: Democracy MetadataOf (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:1) fn veto_external() -> Weight { - // Minimum execution time: 46_388 nanoseconds. - Weight::from_ref_time(46_837_000 as u64) + // Minimum execution time: 35_000 nanoseconds. + Weight::from_ref_time(35_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) } @@ -466,8 +435,8 @@ impl WeightInfo for () { // Storage: Democracy MetadataOf (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:1) fn cancel_proposal() -> Weight { - // Minimum execution time: 88_273 nanoseconds. - Weight::from_ref_time(89_910_000 as u64) + // Minimum execution time: 65_000 nanoseconds. + Weight::from_ref_time(65_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(5 as u64)) .saturating_add(RocksDbWeight::get().writes(5 as u64)) } @@ -476,22 +445,19 @@ impl WeightInfo for () { // Storage: Preimage PreimageFor (r:0 w:1) // Storage: Democracy ReferendumInfoOf (r:0 w:1) fn cancel_referendum() -> Weight { - // Minimum execution time: 36_626 nanoseconds. - Weight::from_ref_time(37_221_000 as u64) + // Minimum execution time: 29_000 nanoseconds. + Weight::from_ref_time(29_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) } // Storage: Democracy LowestUnbaked (r:1 w:1) // Storage: Democracy ReferendumCount (r:1 w:0) - // Storage: Democracy ReferendumInfoOf (r:2 w:0) + // Storage: Democracy ReferendumInfoOf (r:99 w:0) /// The range of component `r` is `[0, 99]`. - fn on_initialize_base(r: u32, ) -> Weight { - // Minimum execution time: 6_738 nanoseconds. - Weight::from_ref_time(12_684_834 as u64) - // Standard Error: 5_168 - .saturating_add(Weight::from_ref_time(2_402_248 as u64).saturating_mul(r as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(r as u64))) + fn on_initialize_base(_r: u32, ) -> Weight { + // Minimum execution time: 7_000 nanoseconds. + Weight::from_ref_time(302_000_000 as u64) + .saturating_add(RocksDbWeight::get().reads(101 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } // Storage: Democracy LowestUnbaked (r:1 w:1) @@ -499,59 +465,46 @@ impl WeightInfo for () { // Storage: Democracy LastTabledWasExternal (r:1 w:0) // Storage: Democracy NextExternal (r:1 w:0) // Storage: Democracy PublicProps (r:1 w:0) - // Storage: Democracy ReferendumInfoOf (r:2 w:0) + // Storage: Democracy ReferendumInfoOf (r:99 w:0) /// The range of component `r` is `[0, 99]`. - fn on_initialize_base_with_launch_period(r: u32, ) -> Weight { - // Minimum execution time: 9_188 nanoseconds. - Weight::from_ref_time(16_333_541 as u64) - // Standard Error: 4_393 - .saturating_add(Weight::from_ref_time(2_379_560 as u64).saturating_mul(r as u64)) - .saturating_add(RocksDbWeight::get().reads(5 as u64)) - .saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(r as u64))) + fn on_initialize_base_with_launch_period(_r: u32, ) -> Weight { + // Minimum execution time: 8_000 nanoseconds. + Weight::from_ref_time(239_000_000 as u64) + .saturating_add(RocksDbWeight::get().reads(104 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } // Storage: Democracy VotingOf (r:3 w:3) // Storage: Balances Locks (r:1 w:1) - // Storage: Democracy ReferendumInfoOf (r:2 w:2) + // Storage: Democracy ReferendumInfoOf (r:99 w:99) /// The range of component `r` is `[0, 99]`. - fn delegate(r: u32, ) -> Weight { - // Minimum execution time: 47_322 nanoseconds. - Weight::from_ref_time(52_103_092 as u64) - // Standard Error: 5_569 - .saturating_add(Weight::from_ref_time(3_600_758 as u64).saturating_mul(r as u64)) - .saturating_add(RocksDbWeight::get().reads(4 as u64)) - .saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(r as u64))) - .saturating_add(RocksDbWeight::get().writes(4 as u64)) - .saturating_add(RocksDbWeight::get().writes((1 as u64).saturating_mul(r as u64))) + fn delegate(_r: u32, ) -> Weight { + // Minimum execution time: 40_000 nanoseconds. + Weight::from_ref_time(375_000_000 as u64) + .saturating_add(RocksDbWeight::get().reads(103 as u64)) + .saturating_add(RocksDbWeight::get().writes(103 as u64)) } // Storage: Democracy VotingOf (r:2 w:2) - // Storage: Democracy ReferendumInfoOf (r:2 w:2) + // Storage: Democracy ReferendumInfoOf (r:99 w:99) /// The range of component `r` is `[0, 99]`. - fn undelegate(r: u32, ) -> Weight { - // Minimum execution time: 29_730 nanoseconds. - Weight::from_ref_time(32_215_196 as u64) - // Standard Error: 5_365 - .saturating_add(Weight::from_ref_time(3_570_430 as u64).saturating_mul(r as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(r as u64))) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) - .saturating_add(RocksDbWeight::get().writes((1 as u64).saturating_mul(r as u64))) + fn undelegate(_r: u32, ) -> Weight { + // Minimum execution time: 25_000 nanoseconds. + Weight::from_ref_time(334_000_000 as u64) + .saturating_add(RocksDbWeight::get().reads(101 as u64)) + .saturating_add(RocksDbWeight::get().writes(101 as u64)) } // Storage: Democracy PublicProps (r:0 w:1) fn clear_public_proposals() -> Weight { - // Minimum execution time: 6_443 nanoseconds. - Weight::from_ref_time(6_548_000 as u64) + // Minimum execution time: 5_000 nanoseconds. + Weight::from_ref_time(5_000_000 as u64) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } // Storage: Democracy VotingOf (r:1 w:1) // Storage: Balances Locks (r:1 w:1) // Storage: System Account (r:1 w:1) /// The range of component `r` is `[0, 99]`. - fn unlock_remove(r: u32, ) -> Weight { - // Minimum execution time: 28_747 nanoseconds. - Weight::from_ref_time(37_459_555 as u64) - // Standard Error: 3_898 - .saturating_add(Weight::from_ref_time(152_180 as u64).saturating_mul(r as u64)) + fn unlock_remove(_r: u32, ) -> Weight { + // Minimum execution time: 29_000 nanoseconds. + Weight::from_ref_time(31_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } @@ -559,33 +512,27 @@ impl WeightInfo for () { // Storage: Balances Locks (r:1 w:1) // Storage: System Account (r:1 w:1) /// The range of component `r` is `[0, 99]`. - fn unlock_set(r: u32, ) -> Weight { - // Minimum execution time: 34_624 nanoseconds. - Weight::from_ref_time(35_432_999 as u64) - // Standard Error: 3_069 - .saturating_add(Weight::from_ref_time(227_652 as u64).saturating_mul(r as u64)) + fn unlock_set(_r: u32, ) -> Weight { + // Minimum execution time: 29_000 nanoseconds. + Weight::from_ref_time(33_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } // Storage: Democracy ReferendumInfoOf (r:1 w:1) // Storage: Democracy VotingOf (r:1 w:1) /// The range of component `r` is `[1, 100]`. - fn remove_vote(r: u32, ) -> Weight { - // Minimum execution time: 18_142 nanoseconds. - Weight::from_ref_time(20_388_863 as u64) - // Standard Error: 1_654 - .saturating_add(Weight::from_ref_time(265_937 as u64).saturating_mul(r as u64)) + fn remove_vote(_r: u32, ) -> Weight { + // Minimum execution time: 15_000 nanoseconds. + Weight::from_ref_time(21_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } // Storage: Democracy ReferendumInfoOf (r:1 w:1) // Storage: Democracy VotingOf (r:1 w:1) /// The range of component `r` is `[1, 100]`. - fn remove_other_vote(r: u32, ) -> Weight { - // Minimum execution time: 18_375 nanoseconds. - Weight::from_ref_time(20_522_580 as u64) - // Standard Error: 1_295 - .saturating_add(Weight::from_ref_time(262_384 as u64).saturating_mul(r as u64)) + fn remove_other_vote(_r: u32, ) -> Weight { + // Minimum execution time: 15_000 nanoseconds. + Weight::from_ref_time(24_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } @@ -593,8 +540,8 @@ impl WeightInfo for () { // Storage: Preimage StatusFor (r:1 w:1) // Storage: Democracy MetadataOf (r:0 w:1) fn set_external_metadata() -> Weight { - // Minimum execution time: 26_968 nanoseconds. - Weight::from_ref_time(27_371_000 as u64) + // Minimum execution time: 23_000 nanoseconds. + Weight::from_ref_time(23_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } @@ -602,8 +549,8 @@ impl WeightInfo for () { // Storage: Democracy MetadataOf (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:1) fn clear_external_metadata() -> Weight { - // Minimum execution time: 31_538 nanoseconds. - Weight::from_ref_time(31_988_000 as u64) + // Minimum execution time: 27_000 nanoseconds. + Weight::from_ref_time(27_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } @@ -611,8 +558,8 @@ impl WeightInfo for () { // Storage: Preimage StatusFor (r:1 w:1) // Storage: Democracy MetadataOf (r:0 w:1) fn set_proposal_metadata() -> Weight { - // Minimum execution time: 52_544 nanoseconds. - Weight::from_ref_time(53_569_000 as u64) + // Minimum execution time: 42_000 nanoseconds. + Weight::from_ref_time(42_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } @@ -620,18 +567,27 @@ impl WeightInfo for () { // Storage: Democracy MetadataOf (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:1) fn clear_proposal_metadata() -> Weight { - // Minimum execution time: 51_457 nanoseconds. - Weight::from_ref_time(56_328_000 as u64) + // Minimum execution time: 39_000 nanoseconds. + Weight::from_ref_time(39_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } + // Storage: Preimage StatusFor (r:1 w:1) + // Storage: Democracy MetadataOf (r:0 w:1) + fn set_referendum_metadata() -> Weight { + // Minimum execution time: 21_000 nanoseconds. + Weight::from_ref_time(21_000_000 as u64) + .saturating_add(RocksDbWeight::get().reads(1 as u64)) + .saturating_add(RocksDbWeight::get().writes(2 as u64)) + } + // Storage: Democracy ReferendumInfoOf (r:1 w:0) // Storage: Democracy MetadataOf (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:1) // Storage: Preimage PreimageFor (r:0 w:1) fn clear_referendum_metadata() -> Weight { - // Minimum execution time: 32_189 nanoseconds. - Weight::from_ref_time(32_756_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) + // Minimum execution time: 33_000 nanoseconds. + Weight::from_ref_time(33_000_000 as u64) + .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } } diff --git a/frame/referenda/src/benchmarking.rs b/frame/referenda/src/benchmarking.rs index dd0a35f8aac91..bdd0ca0edbeb3 100644 --- a/frame/referenda/src/benchmarking.rs +++ b/frame/referenda/src/benchmarking.rs @@ -535,11 +535,11 @@ benchmarks_instance_pallet! { assert_matches!(info, ReferendumInfo::Rejected(..)); } - set_metadata { + set_some_metadata { use sp_std::borrow::Cow; let (origin, index) = create_referendum::(); let hash = T::Preimages::note(Cow::from(vec![5, 6])).unwrap(); - }: _(origin, index, hash) + }: set_metadata(origin, index, Some(hash)) verify { assert_last_event::(Event::MetadataSet { index, hash }.into()); } @@ -549,10 +549,10 @@ benchmarks_instance_pallet! { let (origin, index) = create_referendum::(); let hash = T::Preimages::note(Cow::from(vec![6, 7, 8])).unwrap(); assert_ok!( - Referenda::::set_metadata(origin.clone(), index, hash.clone(),) + Referenda::::set_metadata(origin.clone(), index, Some(hash)) ); assert!(T::Preimages::is_requested(&hash)); - }: _(origin, index) + }: set_metadata(origin, index, None) verify { assert_last_event::(Event::MetadataCleared { index, hash }.into()); } diff --git a/frame/referenda/src/lib.rs b/frame/referenda/src/lib.rs index 23c996bfaebb2..3b84fa24bd71b 100644 --- a/frame/referenda/src/lib.rs +++ b/frame/referenda/src/lib.rs @@ -607,42 +607,38 @@ pub mod pallet { Ok(Some(branch.weight::()).into()) } - /// Set the metadata to an ongoing referendum. + /// Set or clear metadata of a referendum. /// - /// - `origin`: Must be `Signed`, and the creator of the referendum. - /// - `index`: The index of the referendum to add metadata for. - /// - `hash`: The preimage hash of an on-chain stored preimage. - #[pallet::weight(T::WeightInfo::set_metadata())] + /// Parameters: + /// - `origin`: Must be `Signed` by a creator of a referendum or by anyone to clear a + /// metadata of a finished referendum. + /// - `index`: The index of a referendum to set or clear metadata for. + /// - `maybe_hash`: The hash of an on-chain stored preimage. `None` to clear a metadata. + #[pallet::weight( + maybe_hash.map_or( + T::WeightInfo::clear_metadata(), |_| T::WeightInfo::set_some_metadata()) + )] pub fn set_metadata( origin: OriginFor, index: ReferendumIndex, - hash: PreimageHash, + maybe_hash: Option, ) -> DispatchResult { let who = ensure_signed(origin)?; - let status = Self::ensure_ongoing(index)?; - ensure!(status.submission_deposit.who == who, Error::::NoPermission); - ensure!(T::Preimages::len(&hash).is_some(), Error::::PreimageNotExist); - T::Preimages::request(&hash); - MetadataOf::::insert(index, hash); - Self::deposit_event(Event::::MetadataSet { index, hash }); - Ok(()) - } - - /// Clear the referendum metadata. - /// - /// - `origin`: Must be `Signed` or `Root`. If the referendum is ongoing, it must also be - /// the creator of the referendum. - /// - `index`: The index of the ongoing referendum to clear metadata for. - #[pallet::weight(T::WeightInfo::clear_metadata())] - pub fn clear_metadata(origin: OriginFor, index: ReferendumIndex) -> DispatchResult { - let maybe_who = ensure_signed_or_root(origin)?; - if let Some(who) = maybe_who { + if let Some(hash) = maybe_hash { + let status = Self::ensure_ongoing(index)?; + ensure!(status.submission_deposit.who == who, Error::::NoPermission); + ensure!(T::Preimages::len(&hash).is_some(), Error::::PreimageNotExist); + T::Preimages::request(&hash); + MetadataOf::::insert(index, hash); + Self::deposit_event(Event::::MetadataSet { index, hash }); + Ok(()) + } else { if let Some(status) = Self::ensure_ongoing(index).ok() { ensure!(status.submission_deposit.who == who, Error::::NoPermission); } + Self::do_clear_metadata(index); + Ok(()) } - Self::do_clear_metadata(index); - Ok(()) } } } diff --git a/frame/referenda/src/tests.rs b/frame/referenda/src/tests.rs index ec2ff9c02efe0..d16150b5013bd 100644 --- a/frame/referenda/src/tests.rs +++ b/frame/referenda/src/tests.rs @@ -536,7 +536,7 @@ fn set_metadata_works() { let index = ReferendumCount::::get() - 1; assert_ok!(Referenda::kill(RuntimeOrigin::root(), index)); assert_noop!( - Referenda::set_metadata(RuntimeOrigin::signed(1), index, invalid_hash), + Referenda::set_metadata(RuntimeOrigin::signed(1), index, Some(invalid_hash)), Error::::NotOngoing, ); // no permission to set metadata. @@ -548,19 +548,19 @@ fn set_metadata_works() { )); let index = ReferendumCount::::get() - 1; assert_noop!( - Referenda::set_metadata(RuntimeOrigin::signed(2), index, invalid_hash), + Referenda::set_metadata(RuntimeOrigin::signed(2), index, Some(invalid_hash)), Error::::NoPermission, ); // preimage does not exist. let index = ReferendumCount::::get() - 1; assert_noop!( - Referenda::set_metadata(RuntimeOrigin::signed(1), index, invalid_hash,), + Referenda::set_metadata(RuntimeOrigin::signed(1), index, Some(invalid_hash)), Error::::PreimageNotExist, ); // metadata set. let index = ReferendumCount::::get() - 1; let hash = note_preimage(1); - assert_ok!(Referenda::set_metadata(RuntimeOrigin::signed(1), index, hash)); + assert_ok!(Referenda::set_metadata(RuntimeOrigin::signed(1), index, Some(hash))); System::assert_last_event(RuntimeEvent::Referenda(crate::Event::MetadataSet { index, hash, @@ -580,13 +580,13 @@ fn clear_metadata_works() { DispatchTime::At(1), )); let index = ReferendumCount::::get() - 1; - assert_ok!(Referenda::set_metadata(RuntimeOrigin::signed(1), index, hash)); + assert_ok!(Referenda::set_metadata(RuntimeOrigin::signed(1), index, Some(hash))); assert!(Preimage::is_requested(&hash)); assert_noop!( - Referenda::clear_metadata(RuntimeOrigin::signed(2), index,), + Referenda::set_metadata(RuntimeOrigin::signed(2), index, None), Error::::NoPermission, ); - assert_ok!(Referenda::clear_metadata(RuntimeOrigin::signed(1), index,),); + assert_ok!(Referenda::set_metadata(RuntimeOrigin::signed(1), index, None),); System::assert_last_event(RuntimeEvent::Referenda(crate::Event::MetadataCleared { index, hash, diff --git a/frame/referenda/src/weights.rs b/frame/referenda/src/weights.rs index f2d0cc1dbfd82..1a7bdd6af2c87 100644 --- a/frame/referenda/src/weights.rs +++ b/frame/referenda/src/weights.rs @@ -1,42 +1,23 @@ -// This file is part of Substrate. - -// Copyright (C) 2022 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// 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. //! Autogenerated weights for pallet_referenda //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-10-31, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 +//! DATE: 2022-11-16, STEPS: `2`, REPEAT: 1, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `cob`, CPU: `` +//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: -// /home/benchbot/cargo_target_dir/production/substrate +// ./target/release/substrate // benchmark // pallet -// --steps=50 -// --repeat=20 +// --chain=dev +// --steps=2 +// --repeat=1 +// --pallet=pallet-referenda // --extrinsic=* -// --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/substrate/.git/.artifacts/bench.json -// --pallet=pallet_referenda -// --chain=dev -// --header=./HEADER-APACHE2 -// --output=./frame/referenda/src/weights.rs +// --output=./frame/referenda/src/._weights.rs // --template=./.maintain/frame-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -75,7 +56,7 @@ pub trait WeightInfo { fn nudge_referendum_continue_confirming() -> Weight; fn nudge_referendum_approved() -> Weight; fn nudge_referendum_rejected() -> Weight; - fn set_metadata() -> Weight; + fn set_some_metadata() -> Weight; fn clear_metadata() -> Weight; } @@ -86,16 +67,16 @@ impl WeightInfo for SubstrateWeight { // Storage: Scheduler Agenda (r:1 w:1) // Storage: Referenda ReferendumInfoFor (r:0 w:1) fn submit() -> Weight { - // Minimum execution time: 40_050 nanoseconds. - Weight::from_ref_time(40_550_000 as u64) + // Minimum execution time: 30_000 nanoseconds. + Weight::from_ref_time(30_000_000 as u64) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn place_decision_deposit_preparing() -> Weight { - // Minimum execution time: 50_115 nanoseconds. - Weight::from_ref_time(50_867_000 as u64) + // Minimum execution time: 38_000 nanoseconds. + Weight::from_ref_time(38_000_000 as u64) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -103,8 +84,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Referenda DecidingCount (r:1 w:0) // Storage: Referenda TrackQueue (r:1 w:1) fn place_decision_deposit_queued() -> Weight { - // Minimum execution time: 56_164 nanoseconds. - Weight::from_ref_time(57_189_000 as u64) + // Minimum execution time: 41_000 nanoseconds. + Weight::from_ref_time(41_000_000 as u64) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } @@ -112,8 +93,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Referenda DecidingCount (r:1 w:0) // Storage: Referenda TrackQueue (r:1 w:1) fn place_decision_deposit_not_queued() -> Weight { - // Minimum execution time: 54_378 nanoseconds. - Weight::from_ref_time(55_313_000 as u64) + // Minimum execution time: 42_000 nanoseconds. + Weight::from_ref_time(42_000_000 as u64) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } @@ -121,8 +102,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Referenda DecidingCount (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn place_decision_deposit_passing() -> Weight { - // Minimum execution time: 64_917 nanoseconds. - Weight::from_ref_time(65_530_000 as u64) + // Minimum execution time: 73_000 nanoseconds. + Weight::from_ref_time(73_000_000 as u64) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().writes(4 as u64)) } @@ -130,23 +111,23 @@ impl WeightInfo for SubstrateWeight { // Storage: Referenda DecidingCount (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn place_decision_deposit_failing() -> Weight { - // Minimum execution time: 60_579 nanoseconds. - Weight::from_ref_time(61_756_000 as u64) + // Minimum execution time: 44_000 nanoseconds. + Weight::from_ref_time(44_000_000 as u64) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) fn refund_decision_deposit() -> Weight { - // Minimum execution time: 35_168 nanoseconds. - Weight::from_ref_time(36_131_000 as u64) + // Minimum execution time: 28_000 nanoseconds. + Weight::from_ref_time(28_000_000 as u64) .saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn cancel() -> Weight { - // Minimum execution time: 40_311 nanoseconds. - Weight::from_ref_time(40_833_000 as u64) + // Minimum execution time: 30_000 nanoseconds. + Weight::from_ref_time(30_000_000 as u64) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -154,16 +135,16 @@ impl WeightInfo for SubstrateWeight { // Storage: Scheduler Agenda (r:2 w:2) // Storage: Referenda MetadataOf (r:1 w:0) fn kill() -> Weight { - // Minimum execution time: 73_602 nanoseconds. - Weight::from_ref_time(75_492_000 as u64) + // Minimum execution time: 52_000 nanoseconds. + Weight::from_ref_time(52_000_000 as u64) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Referenda TrackQueue (r:1 w:0) // Storage: Referenda DecidingCount (r:1 w:1) fn one_fewer_deciding_queue_empty() -> Weight { - // Minimum execution time: 14_016 nanoseconds. - Weight::from_ref_time(14_869_000 as u64) + // Minimum execution time: 12_000 nanoseconds. + Weight::from_ref_time(12_000_000 as u64) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } @@ -171,8 +152,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn one_fewer_deciding_failing() -> Weight { - // Minimum execution time: 86_026 nanoseconds. - Weight::from_ref_time(87_034_000 as u64) + // Minimum execution time: 66_000 nanoseconds. + Weight::from_ref_time(66_000_000 as u64) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().writes(4 as u64)) } @@ -180,8 +161,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn one_fewer_deciding_passing() -> Weight { - // Minimum execution time: 87_319 nanoseconds. - Weight::from_ref_time(87_885_000 as u64) + // Minimum execution time: 110_000 nanoseconds. + Weight::from_ref_time(110_000_000 as u64) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().writes(4 as u64)) } @@ -189,8 +170,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Referenda TrackQueue (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_requeued_insertion() -> Weight { - // Minimum execution time: 70_278 nanoseconds. - Weight::from_ref_time(71_234_000 as u64) + // Minimum execution time: 106_000 nanoseconds. + Weight::from_ref_time(106_000_000 as u64) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -198,8 +179,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Referenda TrackQueue (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_requeued_slide() -> Weight { - // Minimum execution time: 70_592 nanoseconds. - Weight::from_ref_time(71_089_000 as u64) + // Minimum execution time: 55_000 nanoseconds. + Weight::from_ref_time(55_000_000 as u64) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -208,8 +189,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Referenda TrackQueue (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_queued() -> Weight { - // Minimum execution time: 72_336 nanoseconds. - Weight::from_ref_time(73_450_000 as u64) + // Minimum execution time: 60_000 nanoseconds. + Weight::from_ref_time(60_000_000 as u64) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -218,31 +199,31 @@ impl WeightInfo for SubstrateWeight { // Storage: Referenda TrackQueue (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_not_queued() -> Weight { - // Minimum execution time: 71_854 nanoseconds. - Weight::from_ref_time(72_790_000 as u64) + // Minimum execution time: 58_000 nanoseconds. + Weight::from_ref_time(58_000_000 as u64) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_no_deposit() -> Weight { - // Minimum execution time: 30_069 nanoseconds. - Weight::from_ref_time(31_002_000 as u64) + // Minimum execution time: 23_000 nanoseconds. + Weight::from_ref_time(23_000_000 as u64) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_preparing() -> Weight { - // Minimum execution time: 31_454 nanoseconds. - Weight::from_ref_time(31_894_000 as u64) + // Minimum execution time: 25_000 nanoseconds. + Weight::from_ref_time(25_000_000 as u64) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) fn nudge_referendum_timed_out() -> Weight { - // Minimum execution time: 23_962 nanoseconds. - Weight::from_ref_time(24_084_000 as u64) + // Minimum execution time: 18_000 nanoseconds. + Weight::from_ref_time(18_000_000 as u64) .saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } @@ -250,8 +231,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Referenda DecidingCount (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_begin_deciding_failing() -> Weight { - // Minimum execution time: 44_266 nanoseconds. - Weight::from_ref_time(45_060_000 as u64) + // Minimum execution time: 31_000 nanoseconds. + Weight::from_ref_time(31_000_000 as u64) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -259,40 +240,40 @@ impl WeightInfo for SubstrateWeight { // Storage: Referenda DecidingCount (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_begin_deciding_passing() -> Weight { - // Minimum execution time: 45_862 nanoseconds. - Weight::from_ref_time(46_553_000 as u64) + // Minimum execution time: 32_000 nanoseconds. + Weight::from_ref_time(32_000_000 as u64) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_begin_confirming() -> Weight { - // Minimum execution time: 42_134 nanoseconds. - Weight::from_ref_time(42_662_000 as u64) + // Minimum execution time: 30_000 nanoseconds. + Weight::from_ref_time(30_000_000 as u64) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_end_confirming() -> Weight { - // Minimum execution time: 43_133 nanoseconds. - Weight::from_ref_time(43_964_000 as u64) + // Minimum execution time: 30_000 nanoseconds. + Weight::from_ref_time(30_000_000 as u64) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_continue_not_confirming() -> Weight { - // Minimum execution time: 40_001 nanoseconds. - Weight::from_ref_time(40_626_000 as u64) + // Minimum execution time: 29_000 nanoseconds. + Weight::from_ref_time(29_000_000 as u64) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_continue_confirming() -> Weight { - // Minimum execution time: 39_214 nanoseconds. - Weight::from_ref_time(39_831_000 as u64) + // Minimum execution time: 31_000 nanoseconds. + Weight::from_ref_time(31_000_000 as u64) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } @@ -300,25 +281,25 @@ impl WeightInfo for SubstrateWeight { // Storage: Scheduler Agenda (r:2 w:2) // Storage: Scheduler Lookup (r:1 w:1) fn nudge_referendum_approved() -> Weight { - // Minimum execution time: 52_266 nanoseconds. - Weight::from_ref_time(52_726_000 as u64) + // Minimum execution time: 37_000 nanoseconds. + Weight::from_ref_time(37_000_000 as u64) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_rejected() -> Weight { - // Minimum execution time: 42_472 nanoseconds. - Weight::from_ref_time(43_031_000 as u64) + // Minimum execution time: 35_000 nanoseconds. + Weight::from_ref_time(35_000_000 as u64) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:0) // Storage: Preimage StatusFor (r:1 w:1) // Storage: Referenda MetadataOf (r:0 w:1) - fn set_metadata() -> Weight { - // Minimum execution time: 29_621 nanoseconds. - Weight::from_ref_time(30_799_000 as u64) + fn set_some_metadata() -> Weight { + // Minimum execution time: 25_000 nanoseconds. + Weight::from_ref_time(25_000_000 as u64) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } @@ -326,8 +307,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Referenda MetadataOf (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:1) fn clear_metadata() -> Weight { - // Minimum execution time: 32_124 nanoseconds. - Weight::from_ref_time(33_107_000 as u64) + // Minimum execution time: 26_000 nanoseconds. + Weight::from_ref_time(26_000_000 as u64) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } @@ -339,16 +320,16 @@ impl WeightInfo for () { // Storage: Scheduler Agenda (r:1 w:1) // Storage: Referenda ReferendumInfoFor (r:0 w:1) fn submit() -> Weight { - // Minimum execution time: 40_050 nanoseconds. - Weight::from_ref_time(40_550_000 as u64) + // Minimum execution time: 30_000 nanoseconds. + Weight::from_ref_time(30_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn place_decision_deposit_preparing() -> Weight { - // Minimum execution time: 50_115 nanoseconds. - Weight::from_ref_time(50_867_000 as u64) + // Minimum execution time: 38_000 nanoseconds. + Weight::from_ref_time(38_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } @@ -356,8 +337,8 @@ impl WeightInfo for () { // Storage: Referenda DecidingCount (r:1 w:0) // Storage: Referenda TrackQueue (r:1 w:1) fn place_decision_deposit_queued() -> Weight { - // Minimum execution time: 56_164 nanoseconds. - Weight::from_ref_time(57_189_000 as u64) + // Minimum execution time: 41_000 nanoseconds. + Weight::from_ref_time(41_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } @@ -365,8 +346,8 @@ impl WeightInfo for () { // Storage: Referenda DecidingCount (r:1 w:0) // Storage: Referenda TrackQueue (r:1 w:1) fn place_decision_deposit_not_queued() -> Weight { - // Minimum execution time: 54_378 nanoseconds. - Weight::from_ref_time(55_313_000 as u64) + // Minimum execution time: 42_000 nanoseconds. + Weight::from_ref_time(42_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } @@ -374,8 +355,8 @@ impl WeightInfo for () { // Storage: Referenda DecidingCount (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn place_decision_deposit_passing() -> Weight { - // Minimum execution time: 64_917 nanoseconds. - Weight::from_ref_time(65_530_000 as u64) + // Minimum execution time: 73_000 nanoseconds. + Weight::from_ref_time(73_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) } @@ -383,23 +364,23 @@ impl WeightInfo for () { // Storage: Referenda DecidingCount (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn place_decision_deposit_failing() -> Weight { - // Minimum execution time: 60_579 nanoseconds. - Weight::from_ref_time(61_756_000 as u64) + // Minimum execution time: 44_000 nanoseconds. + Weight::from_ref_time(44_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) fn refund_decision_deposit() -> Weight { - // Minimum execution time: 35_168 nanoseconds. - Weight::from_ref_time(36_131_000 as u64) + // Minimum execution time: 28_000 nanoseconds. + Weight::from_ref_time(28_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(1 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn cancel() -> Weight { - // Minimum execution time: 40_311 nanoseconds. - Weight::from_ref_time(40_833_000 as u64) + // Minimum execution time: 30_000 nanoseconds. + Weight::from_ref_time(30_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } @@ -407,16 +388,16 @@ impl WeightInfo for () { // Storage: Scheduler Agenda (r:2 w:2) // Storage: Referenda MetadataOf (r:1 w:0) fn kill() -> Weight { - // Minimum execution time: 73_602 nanoseconds. - Weight::from_ref_time(75_492_000 as u64) + // Minimum execution time: 52_000 nanoseconds. + Weight::from_ref_time(52_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } // Storage: Referenda TrackQueue (r:1 w:0) // Storage: Referenda DecidingCount (r:1 w:1) fn one_fewer_deciding_queue_empty() -> Weight { - // Minimum execution time: 14_016 nanoseconds. - Weight::from_ref_time(14_869_000 as u64) + // Minimum execution time: 12_000 nanoseconds. + Weight::from_ref_time(12_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } @@ -424,8 +405,8 @@ impl WeightInfo for () { // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn one_fewer_deciding_failing() -> Weight { - // Minimum execution time: 86_026 nanoseconds. - Weight::from_ref_time(87_034_000 as u64) + // Minimum execution time: 66_000 nanoseconds. + Weight::from_ref_time(66_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) } @@ -433,8 +414,8 @@ impl WeightInfo for () { // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:2 w:2) fn one_fewer_deciding_passing() -> Weight { - // Minimum execution time: 87_319 nanoseconds. - Weight::from_ref_time(87_885_000 as u64) + // Minimum execution time: 110_000 nanoseconds. + Weight::from_ref_time(110_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) } @@ -442,8 +423,8 @@ impl WeightInfo for () { // Storage: Referenda TrackQueue (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_requeued_insertion() -> Weight { - // Minimum execution time: 70_278 nanoseconds. - Weight::from_ref_time(71_234_000 as u64) + // Minimum execution time: 106_000 nanoseconds. + Weight::from_ref_time(106_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } @@ -451,8 +432,8 @@ impl WeightInfo for () { // Storage: Referenda TrackQueue (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_requeued_slide() -> Weight { - // Minimum execution time: 70_592 nanoseconds. - Weight::from_ref_time(71_089_000 as u64) + // Minimum execution time: 55_000 nanoseconds. + Weight::from_ref_time(55_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } @@ -461,8 +442,8 @@ impl WeightInfo for () { // Storage: Referenda TrackQueue (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_queued() -> Weight { - // Minimum execution time: 72_336 nanoseconds. - Weight::from_ref_time(73_450_000 as u64) + // Minimum execution time: 60_000 nanoseconds. + Weight::from_ref_time(60_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } @@ -471,31 +452,31 @@ impl WeightInfo for () { // Storage: Referenda TrackQueue (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_not_queued() -> Weight { - // Minimum execution time: 71_854 nanoseconds. - Weight::from_ref_time(72_790_000 as u64) + // Minimum execution time: 58_000 nanoseconds. + Weight::from_ref_time(58_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_no_deposit() -> Weight { - // Minimum execution time: 30_069 nanoseconds. - Weight::from_ref_time(31_002_000 as u64) + // Minimum execution time: 23_000 nanoseconds. + Weight::from_ref_time(23_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_preparing() -> Weight { - // Minimum execution time: 31_454 nanoseconds. - Weight::from_ref_time(31_894_000 as u64) + // Minimum execution time: 25_000 nanoseconds. + Weight::from_ref_time(25_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) fn nudge_referendum_timed_out() -> Weight { - // Minimum execution time: 23_962 nanoseconds. - Weight::from_ref_time(24_084_000 as u64) + // Minimum execution time: 18_000 nanoseconds. + Weight::from_ref_time(18_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(1 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } @@ -503,8 +484,8 @@ impl WeightInfo for () { // Storage: Referenda DecidingCount (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_begin_deciding_failing() -> Weight { - // Minimum execution time: 44_266 nanoseconds. - Weight::from_ref_time(45_060_000 as u64) + // Minimum execution time: 31_000 nanoseconds. + Weight::from_ref_time(31_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } @@ -512,40 +493,40 @@ impl WeightInfo for () { // Storage: Referenda DecidingCount (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_begin_deciding_passing() -> Weight { - // Minimum execution time: 45_862 nanoseconds. - Weight::from_ref_time(46_553_000 as u64) + // Minimum execution time: 32_000 nanoseconds. + Weight::from_ref_time(32_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_begin_confirming() -> Weight { - // Minimum execution time: 42_134 nanoseconds. - Weight::from_ref_time(42_662_000 as u64) + // Minimum execution time: 30_000 nanoseconds. + Weight::from_ref_time(30_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_end_confirming() -> Weight { - // Minimum execution time: 43_133 nanoseconds. - Weight::from_ref_time(43_964_000 as u64) + // Minimum execution time: 30_000 nanoseconds. + Weight::from_ref_time(30_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_continue_not_confirming() -> Weight { - // Minimum execution time: 40_001 nanoseconds. - Weight::from_ref_time(40_626_000 as u64) + // Minimum execution time: 29_000 nanoseconds. + Weight::from_ref_time(29_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_continue_confirming() -> Weight { - // Minimum execution time: 39_214 nanoseconds. - Weight::from_ref_time(39_831_000 as u64) + // Minimum execution time: 31_000 nanoseconds. + Weight::from_ref_time(31_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } @@ -553,25 +534,25 @@ impl WeightInfo for () { // Storage: Scheduler Agenda (r:2 w:2) // Storage: Scheduler Lookup (r:1 w:1) fn nudge_referendum_approved() -> Weight { - // Minimum execution time: 52_266 nanoseconds. - Weight::from_ref_time(52_726_000 as u64) + // Minimum execution time: 37_000 nanoseconds. + Weight::from_ref_time(37_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) fn nudge_referendum_rejected() -> Weight { - // Minimum execution time: 42_472 nanoseconds. - Weight::from_ref_time(43_031_000 as u64) + // Minimum execution time: 35_000 nanoseconds. + Weight::from_ref_time(35_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } // Storage: Referenda ReferendumInfoFor (r:1 w:0) // Storage: Preimage StatusFor (r:1 w:1) // Storage: Referenda MetadataOf (r:0 w:1) - fn set_metadata() -> Weight { - // Minimum execution time: 29_621 nanoseconds. - Weight::from_ref_time(30_799_000 as u64) + fn set_some_metadata() -> Weight { + // Minimum execution time: 25_000 nanoseconds. + Weight::from_ref_time(25_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } @@ -579,8 +560,8 @@ impl WeightInfo for () { // Storage: Referenda MetadataOf (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:1) fn clear_metadata() -> Weight { - // Minimum execution time: 32_124 nanoseconds. - Weight::from_ref_time(33_107_000 as u64) + // Minimum execution time: 26_000 nanoseconds. + Weight::from_ref_time(26_000_000 as u64) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } From fe9636c3d85222d5224066c5648e5e37d89b7a3c Mon Sep 17 00:00:00 2001 From: muharem Date: Thu, 17 Nov 2022 12:17:51 +0100 Subject: [PATCH 23/29] fmt --- frame/democracy/src/lib.rs | 9 ++++++--- frame/democracy/src/tests.rs | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/frame/democracy/src/lib.rs b/frame/democracy/src/lib.rs index b1d5de42eea8b..3cb00888405b2 100644 --- a/frame/democracy/src/lib.rs +++ b/frame/democracy/src/lib.rs @@ -1096,9 +1096,12 @@ pub mod pallet { /// /// Parameters: /// - `origin`: Must correspond to the `MetadataOwner`. - /// - `ExternalOrigin` for an external proposal with the `SuperMajorityApprove` threshold. - /// - `ExternalDefaultOrigin` for an external proposal with the `SuperMajorityAgainst` threshold. - /// - `ExternalMajorityOrigin` for an external proposal with the `SimpleMajority` threshold. + /// - `ExternalOrigin` for an external proposal with the `SuperMajorityApprove` + /// threshold. + /// - `ExternalDefaultOrigin` for an external proposal with the `SuperMajorityAgainst` + /// threshold. + /// - `ExternalMajorityOrigin` for an external proposal with the `SimpleMajority` + /// threshold. /// - `Signed` by a creator for a public proposal. /// - `Signed` to clear a metadata for a finished referendum. /// - `Root` to set a metadata for an ongoing referendum. diff --git a/frame/democracy/src/tests.rs b/frame/democracy/src/tests.rs index 24aad1b359998..94eff9959a449 100644 --- a/frame/democracy/src/tests.rs +++ b/frame/democracy/src/tests.rs @@ -41,10 +41,10 @@ mod delegation; mod external_proposing; mod fast_tracking; mod lock_voting; +mod metadata; mod public_proposals; mod scheduling; mod voting; -mod metadata; const AYE: Vote = Vote { aye: true, conviction: Conviction::None }; const NAY: Vote = Vote { aye: false, conviction: Conviction::None }; From e6a1edb197112ca41cfa4aad710e72f94ea7ea6f Mon Sep 17 00:00:00 2001 From: muharem Date: Mon, 23 Jan 2023 18:01:14 +0100 Subject: [PATCH 24/29] review fixes --- frame/democracy/src/lib.rs | 8 ++++---- frame/referenda/src/lib.rs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/frame/democracy/src/lib.rs b/frame/democracy/src/lib.rs index ce1174f2eb7ec..02b571ec9b86f 100644 --- a/frame/democracy/src/lib.rs +++ b/frame/democracy/src/lib.rs @@ -1152,10 +1152,10 @@ pub mod pallet { ensure!(proposer == who, Error::::NoPermission); }, MetadataOwner::Referendum(index) => { - let maybe_root = ensure_signed_or_root(origin)?.is_none(); - ensure!(maybe_root || maybe_hash.is_none(), Error::::NoPermission); + let is_root = ensure_signed_or_root(origin)?.is_none(); + ensure!(is_root || maybe_hash.is_none(), Error::::NoPermission); ensure!( - maybe_root || Self::referendum_status(index).is_err(), + is_root || Self::referendum_status(index).is_err(), Error::::NoPermission ); }, @@ -1684,7 +1684,7 @@ impl Pallet { decode_compact_u32_at(&>::hashed_key_for(proposal)) } - // Return a proposal of an index. + /// Return a proposal of an index. fn proposal(index: PropIndex) -> Result<(PropIndex, BoundedCallOf, T::AccountId), Error> { PublicProps::::get() .into_iter() diff --git a/frame/referenda/src/lib.rs b/frame/referenda/src/lib.rs index aa041f55dc436..ad42eacffe759 100644 --- a/frame/referenda/src/lib.rs +++ b/frame/referenda/src/lib.rs @@ -379,7 +379,7 @@ pub mod pallet { index: ReferendumIndex, /// Preimage hash. hash: PreimageHash, - } + }, } #[pallet::error] From 48ebf6d0fd49483691caaef93e4c57f9df7586a3 Mon Sep 17 00:00:00 2001 From: muharem Date: Mon, 23 Jan 2023 19:04:33 +0100 Subject: [PATCH 25/29] not request preimage on set_metadata --- frame/democracy/src/lib.rs | 4 ---- frame/democracy/src/tests/metadata.rs | 13 ------------- frame/democracy/src/tests/public_proposals.rs | 2 -- frame/referenda/src/benchmarking.rs | 1 - frame/referenda/src/lib.rs | 4 ---- frame/referenda/src/tests.rs | 3 --- 6 files changed, 27 deletions(-) diff --git a/frame/democracy/src/lib.rs b/frame/democracy/src/lib.rs index 02b571ec9b86f..0630a81952522 100644 --- a/frame/democracy/src/lib.rs +++ b/frame/democracy/src/lib.rs @@ -1162,7 +1162,6 @@ pub mod pallet { } if let Some(hash) = maybe_hash { ensure!(T::Preimages::len(&hash).is_some(), Error::::PreimageNotExist); - T::Preimages::request(&hash); MetadataOf::::insert(owner.clone(), hash); Self::deposit_event(Event::::MetadataSet { owner, hash }); } else { @@ -1695,9 +1694,6 @@ impl Pallet { /// Clear metadata, if `Some` and unrequest associated preimage. fn clear_metadata(owner: MetadataOwner) { if let Some(hash) = MetadataOf::::take(&owner) { - if T::Preimages::is_requested(&hash) { - T::Preimages::unrequest(&hash); - } Self::deposit_event(Event::::MetadataCleared { owner, hash }); } } diff --git a/frame/democracy/src/tests/metadata.rs b/frame/democracy/src/tests/metadata.rs index b9bbc471d3fa7..95b617e37b199 100644 --- a/frame/democracy/src/tests/metadata.rs +++ b/frame/democracy/src/tests/metadata.rs @@ -52,7 +52,6 @@ fn set_external_metadata_works() { owner, hash, })); - assert!(Preimage::is_requested(&hash)); }); } @@ -67,7 +66,6 @@ fn clear_metadata_works() { // set metadata. let hash = note_preimage(1); assert_ok!(Democracy::set_metadata(RuntimeOrigin::signed(2), owner.clone(), Some(hash),)); - assert!(Preimage::is_requested(&hash)); // fails to clear metadata with a wrong origin. assert_noop!( Democracy::set_metadata(RuntimeOrigin::signed(1), owner.clone(), None), @@ -79,7 +77,6 @@ fn clear_metadata_works() { owner, hash, })); - assert!(!Preimage::is_requested(&hash)); }); } @@ -111,7 +108,6 @@ fn set_proposal_metadata_works() { owner, hash, })); - assert!(Preimage::is_requested(&hash)); }); } @@ -124,9 +120,7 @@ fn clear_proposal_metadata_works() { let owner = MetadataOwner::Proposal(Democracy::public_prop_count() - 1); // set metadata. let hash = note_preimage(1); - assert!(!Preimage::is_requested(&hash)); assert_ok!(Democracy::set_metadata(RuntimeOrigin::signed(1), owner.clone(), Some(hash),)); - assert!(Preimage::is_requested(&hash)); // fails to clear metadata with a wrong origin. assert_noop!( Democracy::set_metadata(RuntimeOrigin::signed(3), owner.clone(), None), @@ -138,7 +132,6 @@ fn clear_proposal_metadata_works() { owner, hash, })); - assert!(!Preimage::is_requested(&hash)); }); } @@ -166,9 +159,7 @@ fn set_referendum_metadata_by_root() { Error::::NoPermission, ); // succeed to set metadata by a root for an ongoing referendum. - assert!(!Preimage::is_requested(&hash)); assert_ok!(Democracy::set_metadata(RuntimeOrigin::root(), owner.clone(), Some(hash),)); - assert!(Preimage::is_requested(&hash)); System::assert_last_event(RuntimeEvent::Democracy(crate::Event::MetadataSet { owner: owner.clone(), hash, @@ -179,7 +170,6 @@ fn set_referendum_metadata_by_root() { owner, hash, })); - assert!(!Preimage::is_requested(&hash)); }); } @@ -199,8 +189,6 @@ fn clear_referendum_metadata_works() { let hash = note_preimage(1); // referendum finished. MetadataOf::::insert(owner.clone(), hash); - Preimage::request(&hash); - assert!(Preimage::is_requested(&hash)); // no permission to clear metadata of an ongoing referendum. assert_noop!( Democracy::set_metadata(RuntimeOrigin::signed(1), owner.clone(), None), @@ -217,6 +205,5 @@ fn clear_referendum_metadata_works() { owner, hash, })); - assert!(!Preimage::is_requested(&hash)); }); } diff --git a/frame/democracy/src/tests/public_proposals.rs b/frame/democracy/src/tests/public_proposals.rs index dc7f21daae3da..f9471442c6336 100644 --- a/frame/democracy/src/tests/public_proposals.rs +++ b/frame/democracy/src/tests/public_proposals.rs @@ -98,11 +98,9 @@ fn cancel_proposal_should_work() { Some(hash) )); assert!(>::get(MetadataOwner::Proposal(0)).is_some()); - assert!(Preimage::is_requested(&hash)); assert_ok!(Democracy::cancel_proposal(RuntimeOrigin::root(), 0)); // metadata cleared, preimage unrequested. assert!(>::get(MetadataOwner::Proposal(0)).is_none()); - assert!(!Preimage::is_requested(&hash)); System::assert_has_event(crate::Event::ProposalCanceled { prop_index: 0 }.into()); System::assert_last_event( crate::Event::MetadataCleared { owner: MetadataOwner::Proposal(0), hash }.into(), diff --git a/frame/referenda/src/benchmarking.rs b/frame/referenda/src/benchmarking.rs index 1bd6d5f24b5eb..115baca1fb348 100644 --- a/frame/referenda/src/benchmarking.rs +++ b/frame/referenda/src/benchmarking.rs @@ -565,7 +565,6 @@ benchmarks_instance_pallet! { assert_ok!( Referenda::::set_metadata(origin.clone(), index, Some(hash)) ); - assert!(T::Preimages::is_requested(&hash)); }: set_metadata(origin, index, None) verify { assert_last_event::(Event::MetadataCleared { index, hash }.into()); diff --git a/frame/referenda/src/lib.rs b/frame/referenda/src/lib.rs index ad42eacffe759..b36d4b1b4b67b 100644 --- a/frame/referenda/src/lib.rs +++ b/frame/referenda/src/lib.rs @@ -683,7 +683,6 @@ pub mod pallet { let status = Self::ensure_ongoing(index)?; ensure!(status.submission_deposit.who == who, Error::::NoPermission); ensure!(T::Preimages::len(&hash).is_some(), Error::::PreimageNotExist); - T::Preimages::request(&hash); MetadataOf::::insert(index, hash); Self::deposit_event(Event::::MetadataSet { index, hash }); Ok(()) @@ -1270,9 +1269,6 @@ impl, I: 'static> Pallet { /// Clear metadata, if `Some` and unrequest associated preimage. fn do_clear_metadata(index: ReferendumIndex) { if let Some(hash) = MetadataOf::::take(index) { - if T::Preimages::is_requested(&hash) { - T::Preimages::unrequest(&hash); - } Self::deposit_event(Event::::MetadataCleared { index, hash }); } } diff --git a/frame/referenda/src/tests.rs b/frame/referenda/src/tests.rs index 5a5732153a423..034454cfcc265 100644 --- a/frame/referenda/src/tests.rs +++ b/frame/referenda/src/tests.rs @@ -624,7 +624,6 @@ fn set_metadata_works() { index, hash, })); - assert!(Preimage::is_requested(&hash)); }); } @@ -640,7 +639,6 @@ fn clear_metadata_works() { )); let index = ReferendumCount::::get() - 1; assert_ok!(Referenda::set_metadata(RuntimeOrigin::signed(1), index, Some(hash))); - assert!(Preimage::is_requested(&hash)); assert_noop!( Referenda::set_metadata(RuntimeOrigin::signed(2), index, None), Error::::NoPermission, @@ -650,6 +648,5 @@ fn clear_metadata_works() { index, hash, })); - assert!(!Preimage::is_requested(&hash)); }); } From 850a931e22f9d50740e47af4db4e246fa8837173 Mon Sep 17 00:00:00 2001 From: muharem Date: Fri, 27 Jan 2023 16:51:07 +0100 Subject: [PATCH 26/29] rename events and update docs --- frame/democracy/src/benchmarking.rs | 2 +- frame/democracy/src/lib.rs | 8 ++++---- frame/referenda/src/lib.rs | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/frame/democracy/src/benchmarking.rs b/frame/democracy/src/benchmarking.rs index da64682e74207..33fa049b13d3e 100644 --- a/frame/democracy/src/benchmarking.rs +++ b/frame/democracy/src/benchmarking.rs @@ -296,7 +296,7 @@ benchmarks! { }: _(origin_fast_track, proposal_hash, voting_period, delay.into()) verify { assert_eq!(Democracy::::referendum_count(), 1, "referendum not created"); - assert_last_event::(crate::Event::MetadataReset { + assert_last_event::(crate::Event::MetadataTransferred { prev_owner: MetadataOwner::External, owner: MetadataOwner::Referendum(0), hash: preimage_hash, diff --git a/frame/democracy/src/lib.rs b/frame/democracy/src/lib.rs index 0630a81952522..c00ba403c93c8 100644 --- a/frame/democracy/src/lib.rs +++ b/frame/democracy/src/lib.rs @@ -500,8 +500,8 @@ pub mod pallet { /// Preimage hash. hash: PreimageHash, }, - /// Metadata has been reset to new owner. - MetadataReset { + /// Metadata has been transferred to new owner. + MetadataTransferred { /// Previous metadata owner. prev_owner: MetadataOwner, /// New metadata owner. @@ -1691,7 +1691,7 @@ impl Pallet { .ok_or(Error::::ProposalMissing) } - /// Clear metadata, if `Some` and unrequest associated preimage. + /// Clear metadata if exist for a given owner. fn clear_metadata(owner: MetadataOwner) { if let Some(hash) = MetadataOf::::take(&owner) { Self::deposit_event(Event::::MetadataCleared { owner, hash }); @@ -1702,7 +1702,7 @@ impl Pallet { fn reset_metadata(owner: MetadataOwner, new_owner: MetadataOwner) { if let Some(hash) = MetadataOf::::take(&owner) { MetadataOf::::insert(&new_owner, hash); - Self::deposit_event(Event::::MetadataReset { + Self::deposit_event(Event::::MetadataTransferred { prev_owner: owner, owner: new_owner, hash, diff --git a/frame/referenda/src/lib.rs b/frame/referenda/src/lib.rs index b36d4b1b4b67b..4491c1b40d197 100644 --- a/frame/referenda/src/lib.rs +++ b/frame/referenda/src/lib.rs @@ -1266,7 +1266,7 @@ impl, I: 'static> Pallet { approval_needed.passing(x, tally.approval(id)) } - /// Clear metadata, if `Some` and unrequest associated preimage. + /// Clear metadata if exist for a given referendum index. fn do_clear_metadata(index: ReferendumIndex) { if let Some(hash) = MetadataOf::::take(index) { Self::deposit_event(Event::::MetadataCleared { index, hash }); From 04dede2bf4447ef062f1c2e38ff41662abc1972f Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Fri, 27 Jan 2023 16:57:08 +0000 Subject: [PATCH 27/29] ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_democracy --- frame/democracy/src/weights.rs | 651 +++++++++++++++++++-------------- 1 file changed, 367 insertions(+), 284 deletions(-) diff --git a/frame/democracy/src/weights.rs b/frame/democracy/src/weights.rs index e33d8e42d7e2b..10d0744eac029 100644 --- a/frame/democracy/src/weights.rs +++ b/frame/democracy/src/weights.rs @@ -18,25 +18,26 @@ //! Autogenerated weights for pallet_democracy //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-01-27, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `runner-b3zmxxc-project-145-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: -// ./target/production/substrate +// target/production/substrate // benchmark // pallet -// --chain=dev // --steps=50 // --repeat=20 -// --pallet=pallet_democracy // --extrinsic=* // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --output=./frame/democracy/src/weights.rs +// --json-file=/builds/parity/mirrors/substrate/.git/.artifacts/bench.json +// --pallet=pallet_democracy +// --chain=dev // --header=./HEADER-APACHE2 +// --output=./frame/democracy/src/weights.rs // --template=./.maintain/frame-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -93,8 +94,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `4864` // Estimated: `23409` - // Minimum execution time: 34_509 nanoseconds. - Weight::from_parts(34_781_000, 23409) + // Minimum execution time: 42_939 nanoseconds. + Weight::from_parts(43_543_000, 23409) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -104,8 +105,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `3620` // Estimated: `5705` - // Minimum execution time: 31_151 nanoseconds. - Weight::from_parts(31_566_000, 5705) + // Minimum execution time: 36_475 nanoseconds. + Weight::from_parts(37_863_000, 5705) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -117,10 +118,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) fn vote_new() -> Weight { // Proof Size summary in bytes: - // Measured: `3555` + // Measured: `3565` // Estimated: `12720` - // Minimum execution time: 42_618 nanoseconds. - Weight::from_parts(43_231_000, 12720) + // Minimum execution time: 56_372 nanoseconds. + Weight::from_parts(57_483_000, 12720) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -132,10 +133,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) fn vote_existing() -> Weight { // Proof Size summary in bytes: - // Measured: `3577` + // Measured: `3587` // Estimated: `12720` - // Minimum execution time: 42_875 nanoseconds. - Weight::from_parts(43_338_000, 12720) + // Minimum execution time: 56_789 nanoseconds. + Weight::from_parts(57_737_000, 12720) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -143,14 +144,16 @@ impl WeightInfo for SubstrateWeight { /// Proof: Democracy ReferendumInfoOf (max_values: None, max_size: Some(201), added: 2676, mode: MaxEncodedLen) /// Storage: Democracy Cancellations (r:1 w:1) /// Proof: Democracy Cancellations (max_values: None, max_size: Some(33), added: 2508, mode: MaxEncodedLen) + /// Storage: Democracy MetadataOf (r:1 w:1) + /// Proof: Democracy MetadataOf (max_values: None, max_size: Some(53), added: 2528, mode: MaxEncodedLen) fn emergency_cancel() -> Weight { // Proof Size summary in bytes: - // Measured: `320` - // Estimated: `5184` - // Minimum execution time: 16_543 nanoseconds. - Weight::from_parts(16_762_000, 5184) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) + // Measured: `398` + // Estimated: `7712` + // Minimum execution time: 24_379 nanoseconds. + Weight::from_parts(25_302_000, 7712) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) } /// Storage: Democracy PublicProps (r:1 w:1) /// Proof: Democracy PublicProps (max_values: Some(1), max_size: Some(16702), added: 17197, mode: MaxEncodedLen) @@ -158,6 +161,8 @@ impl WeightInfo for SubstrateWeight { /// Proof: Democracy DepositOf (max_values: None, max_size: Some(3230), added: 5705, mode: MaxEncodedLen) /// Storage: System Account (r:1 w:1) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Democracy MetadataOf (r:3 w:1) + /// Proof: Democracy MetadataOf (max_values: None, max_size: Some(53), added: 2528, mode: MaxEncodedLen) /// Storage: Democracy NextExternal (r:1 w:1) /// Proof: Democracy NextExternal (max_values: Some(1), max_size: Some(132), added: 627, mode: MaxEncodedLen) /// Storage: Democracy ReferendumInfoOf (r:1 w:1) @@ -166,12 +171,12 @@ impl WeightInfo for SubstrateWeight { /// Proof: Democracy Blacklist (max_values: None, max_size: Some(3238), added: 5713, mode: MaxEncodedLen) fn blacklist() -> Weight { // Proof Size summary in bytes: - // Measured: `5958` - // Estimated: `28808` - // Minimum execution time: 70_135 nanoseconds. - Weight::from_parts(70_616_000, 28808) - .saturating_add(T::DbWeight::get().reads(5_u64)) - .saturating_add(T::DbWeight::get().writes(6_u64)) + // Measured: `6036` + // Estimated: `36392` + // Minimum execution time: 100_345 nanoseconds. + Weight::from_parts(102_233_000, 36392) + .saturating_add(T::DbWeight::get().reads(8_u64)) + .saturating_add(T::DbWeight::get().writes(7_u64)) } /// Storage: Democracy NextExternal (r:1 w:1) /// Proof: Democracy NextExternal (max_values: Some(1), max_size: Some(132), added: 627, mode: MaxEncodedLen) @@ -181,8 +186,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `3448` // Estimated: `6340` - // Minimum execution time: 12_580 nanoseconds. - Weight::from_parts(12_987_000, 6340) + // Minimum execution time: 13_155 nanoseconds. + Weight::from_parts(14_158_000, 6340) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -192,8 +197,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_320 nanoseconds. - Weight::from_ref_time(3_513_000) + // Minimum execution time: 2_961 nanoseconds. + Weight::from_ref_time(3_139_000) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: Democracy NextExternal (r:0 w:1) @@ -202,37 +207,41 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_407 nanoseconds. - Weight::from_ref_time(3_565_000) + // Minimum execution time: 3_040 nanoseconds. + Weight::from_ref_time(3_261_000) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: Democracy NextExternal (r:1 w:1) /// Proof: Democracy NextExternal (max_values: Some(1), max_size: Some(132), added: 627, mode: MaxEncodedLen) /// Storage: Democracy ReferendumCount (r:1 w:1) /// Proof: Democracy ReferendumCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Democracy MetadataOf (r:1 w:2) + /// Proof: Democracy MetadataOf (max_values: None, max_size: Some(53), added: 2528, mode: MaxEncodedLen) /// Storage: Democracy ReferendumInfoOf (r:0 w:1) /// Proof: Democracy ReferendumInfoOf (max_values: None, max_size: Some(201), added: 2676, mode: MaxEncodedLen) fn fast_track() -> Weight { // Proof Size summary in bytes: - // Measured: `212` - // Estimated: `1126` - // Minimum execution time: 16_831 nanoseconds. - Weight::from_parts(17_155_000, 1126) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Measured: `286` + // Estimated: `3654` + // Minimum execution time: 26_666 nanoseconds. + Weight::from_parts(28_014_000, 3654) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(5_u64)) } /// Storage: Democracy NextExternal (r:1 w:1) /// Proof: Democracy NextExternal (max_values: Some(1), max_size: Some(132), added: 627, mode: MaxEncodedLen) /// Storage: Democracy Blacklist (r:1 w:1) /// Proof: Democracy Blacklist (max_values: None, max_size: Some(3238), added: 5713, mode: MaxEncodedLen) + /// Storage: Democracy MetadataOf (r:1 w:1) + /// Proof: Democracy MetadataOf (max_values: None, max_size: Some(53), added: 2528, mode: MaxEncodedLen) fn veto_external() -> Weight { // Proof Size summary in bytes: - // Measured: `3477` - // Estimated: `6340` - // Minimum execution time: 22_072 nanoseconds. - Weight::from_parts(22_517_000, 6340) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) + // Measured: `3551` + // Estimated: `8868` + // Minimum execution time: 30_180 nanoseconds. + Weight::from_parts(31_593_000, 8868) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) } /// Storage: Democracy PublicProps (r:1 w:1) /// Proof: Democracy PublicProps (max_values: Some(1), max_size: Some(16702), added: 17197, mode: MaxEncodedLen) @@ -240,24 +249,29 @@ impl WeightInfo for SubstrateWeight { /// Proof: Democracy DepositOf (max_values: None, max_size: Some(3230), added: 5705, mode: MaxEncodedLen) /// Storage: System Account (r:1 w:1) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Democracy MetadataOf (r:1 w:1) + /// Proof: Democracy MetadataOf (max_values: None, max_size: Some(53), added: 2528, mode: MaxEncodedLen) fn cancel_proposal() -> Weight { // Proof Size summary in bytes: - // Measured: `5837` - // Estimated: `25505` - // Minimum execution time: 56_925 nanoseconds. - Weight::from_parts(57_253_000, 25505) - .saturating_add(T::DbWeight::get().reads(3_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Measured: `5915` + // Estimated: `28033` + // Minimum execution time: 80_780 nanoseconds. + Weight::from_parts(82_070_000, 28033) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) } + /// Storage: Democracy MetadataOf (r:1 w:1) + /// Proof: Democracy MetadataOf (max_values: None, max_size: Some(53), added: 2528, mode: MaxEncodedLen) /// Storage: Democracy ReferendumInfoOf (r:0 w:1) /// Proof: Democracy ReferendumInfoOf (max_values: None, max_size: Some(201), added: 2676, mode: MaxEncodedLen) fn cancel_referendum() -> Weight { // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 8_582 nanoseconds. - Weight::from_ref_time(8_754_000) - .saturating_add(T::DbWeight::get().writes(1_u64)) + // Measured: `271` + // Estimated: `2528` + // Minimum execution time: 18_117 nanoseconds. + Weight::from_parts(19_027_000, 2528) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } /// Storage: Democracy LowestUnbaked (r:1 w:1) /// Proof: Democracy LowestUnbaked (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) @@ -268,12 +282,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 99]`. fn on_initialize_base(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `207 + r * (117 ±0)` + // Measured: `244 + r * (117 ±0)` // Estimated: `998 + r * (2676 ±0)` - // Minimum execution time: 6_665 nanoseconds. - Weight::from_parts(9_219_932, 998) - // Standard Error: 4_236 - .saturating_add(Weight::from_ref_time(2_194_623).saturating_mul(r.into())) + // Minimum execution time: 7_093 nanoseconds. + Weight::from_parts(8_792_955, 998) + // Standard Error: 6_630 + .saturating_add(Weight::from_ref_time(3_091_565).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(1_u64)) @@ -294,12 +308,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 99]`. fn on_initialize_base_with_launch_period(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `207 + r * (117 ±0)` + // Measured: `244 + r * (117 ±0)` // Estimated: `19318 + r * (2676 ±0)` - // Minimum execution time: 9_842 nanoseconds. - Weight::from_parts(11_932_535, 19318) - // Standard Error: 4_413 - .saturating_add(Weight::from_ref_time(2_199_644).saturating_mul(r.into())) + // Minimum execution time: 10_372 nanoseconds. + Weight::from_parts(10_961_165, 19318) + // Standard Error: 7_284 + .saturating_add(Weight::from_ref_time(3_112_573).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(1_u64)) @@ -314,12 +328,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 99]`. fn delegate(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `948 + r * (139 ±0)` + // Measured: `958 + r * (139 ±0)` // Estimated: `22584 + r * (2676 ±0)` - // Minimum execution time: 34_740 nanoseconds. - Weight::from_parts(38_366_374, 22584) - // Standard Error: 4_868 - .saturating_add(Weight::from_ref_time(3_286_516).saturating_mul(r.into())) + // Minimum execution time: 36_618 nanoseconds. + Weight::from_parts(42_803_184, 22584) + // Standard Error: 7_268 + .saturating_add(Weight::from_ref_time(4_537_902).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(4_u64)) @@ -333,12 +347,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 99]`. fn undelegate(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `547 + r * (139 ±0)` + // Measured: `557 + r * (139 ±0)` // Estimated: `12540 + r * (2676 ±0)` - // Minimum execution time: 19_516 nanoseconds. - Weight::from_parts(21_629_605, 12540) - // Standard Error: 4_401 - .saturating_add(Weight::from_ref_time(3_238_187).saturating_mul(r.into())) + // Minimum execution time: 19_758 nanoseconds. + Weight::from_parts(21_641_793, 12540) + // Standard Error: 6_889 + .saturating_add(Weight::from_ref_time(4_478_884).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(2_u64)) @@ -351,8 +365,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_291 nanoseconds. - Weight::from_ref_time(3_485_000) + // Minimum execution time: 2_844 nanoseconds. + Weight::from_ref_time(3_017_000) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: Democracy VotingOf (r:1 w:1) @@ -364,12 +378,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 99]`. fn unlock_remove(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `617` + // Measured: `627` // Estimated: `12647` - // Minimum execution time: 19_357 nanoseconds. - Weight::from_parts(24_014_517, 12647) - // Standard Error: 994 - .saturating_add(Weight::from_ref_time(17_096).saturating_mul(r.into())) + // Minimum execution time: 20_380 nanoseconds. + Weight::from_parts(28_295_875, 12647) + // Standard Error: 2_331 + .saturating_add(Weight::from_ref_time(67_348).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -382,12 +396,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 99]`. fn unlock_set(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `618 + r * (22 ±0)` + // Measured: `628 + r * (22 ±0)` // Estimated: `12647` - // Minimum execution time: 22_340 nanoseconds. - Weight::from_parts(23_355_734, 12647) - // Standard Error: 548 - .saturating_add(Weight::from_ref_time(64_308).saturating_mul(r.into())) + // Minimum execution time: 24_475 nanoseconds. + Weight::from_parts(27_102_576, 12647) + // Standard Error: 1_464 + .saturating_add(Weight::from_ref_time(128_921).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -398,12 +412,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[1, 100]`. fn remove_vote(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `781 + r * (26 ±0)` + // Measured: `791 + r * (26 ±0)` // Estimated: `8946` - // Minimum execution time: 14_542 nanoseconds. - Weight::from_parts(16_411_916, 8946) - // Standard Error: 839 - .saturating_add(Weight::from_ref_time(73_268).saturating_mul(r.into())) + // Minimum execution time: 15_039 nanoseconds. + Weight::from_parts(19_252_498, 8946) + // Standard Error: 1_798 + .saturating_add(Weight::from_ref_time(131_855).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -414,68 +428,96 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[1, 100]`. fn remove_other_vote(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `781 + r * (26 ±0)` + // Measured: `791 + r * (26 ±0)` // Estimated: `8946` - // Minimum execution time: 14_463 nanoseconds. - Weight::from_parts(16_302_901, 8946) - // Standard Error: 809 - .saturating_add(Weight::from_ref_time(73_692).saturating_mul(r.into())) + // Minimum execution time: 14_837 nanoseconds. + Weight::from_parts(19_144_929, 8946) + // Standard Error: 1_875 + .saturating_add(Weight::from_ref_time(136_819).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } - // Storage: Democracy NextExternal (r:1 w:0) - // Storage: Preimage StatusFor (r:1 w:1) - // Storage: Democracy MetadataOf (r:0 w:1) + /// Storage: Democracy NextExternal (r:1 w:0) + /// Proof: Democracy NextExternal (max_values: Some(1), max_size: Some(132), added: 627, mode: MaxEncodedLen) + /// Storage: Preimage StatusFor (r:1 w:0) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) + /// Storage: Democracy MetadataOf (r:0 w:1) + /// Proof: Democracy MetadataOf (max_values: None, max_size: Some(53), added: 2528, mode: MaxEncodedLen) fn set_external_metadata() -> Weight { - // Minimum execution time: 303_000 nanoseconds. - Weight::from_ref_time(304_000_000) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(2)) - } - // Storage: Democracy NextExternal (r:1 w:0) - // Storage: Democracy MetadataOf (r:1 w:1) - // Storage: Preimage StatusFor (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `356` + // Estimated: `3193` + // Minimum execution time: 17_338 nanoseconds. + Weight::from_parts(17_946_000, 3193) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Democracy NextExternal (r:1 w:0) + /// Proof: Democracy NextExternal (max_values: Some(1), max_size: Some(132), added: 627, mode: MaxEncodedLen) + /// Storage: Democracy MetadataOf (r:1 w:1) + /// Proof: Democracy MetadataOf (max_values: None, max_size: Some(53), added: 2528, mode: MaxEncodedLen) fn clear_external_metadata() -> Weight { - // Minimum execution time: 333_000 nanoseconds. - Weight::from_ref_time(337_000_000) - .saturating_add(RocksDbWeight::get().reads(3)) - .saturating_add(RocksDbWeight::get().writes(2)) - } - // Storage: Democracy PublicProps (r:1 w:0) - // Storage: Preimage StatusFor (r:1 w:1) - // Storage: Democracy MetadataOf (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `286` + // Estimated: `3155` + // Minimum execution time: 15_364 nanoseconds. + Weight::from_parts(15_990_000, 3155) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Democracy PublicProps (r:1 w:0) + /// Proof: Democracy PublicProps (max_values: Some(1), max_size: Some(16702), added: 17197, mode: MaxEncodedLen) + /// Storage: Preimage StatusFor (r:1 w:0) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) + /// Storage: Democracy MetadataOf (r:0 w:1) + /// Proof: Democracy MetadataOf (max_values: None, max_size: Some(53), added: 2528, mode: MaxEncodedLen) fn set_proposal_metadata() -> Weight { - // Minimum execution time: 377_000 nanoseconds. - Weight::from_ref_time(379_000_000) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(2)) - } - // Storage: Democracy PublicProps (r:1 w:0) - // Storage: Democracy MetadataOf (r:1 w:1) - // Storage: Preimage StatusFor (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `4919` + // Estimated: `19763` + // Minimum execution time: 37_147 nanoseconds. + Weight::from_parts(37_778_000, 19763) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Democracy PublicProps (r:1 w:0) + /// Proof: Democracy PublicProps (max_values: Some(1), max_size: Some(16702), added: 17197, mode: MaxEncodedLen) + /// Storage: Democracy MetadataOf (r:1 w:1) + /// Proof: Democracy MetadataOf (max_values: None, max_size: Some(53), added: 2528, mode: MaxEncodedLen) fn clear_proposal_metadata() -> Weight { - // Minimum execution time: 407_000 nanoseconds. - Weight::from_ref_time(415_000_000) - .saturating_add(RocksDbWeight::get().reads(3)) - .saturating_add(RocksDbWeight::get().writes(2)) + // Proof Size summary in bytes: + // Measured: `4853` + // Estimated: `19725` + // Minimum execution time: 34_118 nanoseconds. + Weight::from_parts(34_737_000, 19725) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: Preimage StatusFor (r:1 w:1) - // Storage: Democracy MetadataOf (r:0 w:1) + /// Storage: Preimage StatusFor (r:1 w:0) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) + /// Storage: Democracy MetadataOf (r:0 w:1) + /// Proof: Democracy MetadataOf (max_values: None, max_size: Some(53), added: 2528, mode: MaxEncodedLen) fn set_referendum_metadata() -> Weight { - // Minimum execution time: 234_000 nanoseconds. - Weight::from_ref_time(234_000_000) - .saturating_add(RocksDbWeight::get().reads(1)) - .saturating_add(RocksDbWeight::get().writes(2)) - } - // Storage: Democracy ReferendumInfoOf (r:1 w:0) - // Storage: Democracy MetadataOf (r:1 w:1) - // Storage: Preimage StatusFor (r:1 w:1) - // Storage: Preimage PreimageFor (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `144` + // Estimated: `2566` + // Minimum execution time: 12_787 nanoseconds. + Weight::from_parts(13_463_000, 2566) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Democracy ReferendumInfoOf (r:1 w:0) + /// Proof: Democracy ReferendumInfoOf (max_values: None, max_size: Some(201), added: 2676, mode: MaxEncodedLen) + /// Storage: Democracy MetadataOf (r:1 w:1) + /// Proof: Democracy MetadataOf (max_values: None, max_size: Some(53), added: 2528, mode: MaxEncodedLen) fn clear_referendum_metadata() -> Weight { - // Minimum execution time: 384_000 nanoseconds. - Weight::from_ref_time(386_000_000) - .saturating_add(RocksDbWeight::get().reads(3)) - .saturating_add(RocksDbWeight::get().writes(3)) + // Proof Size summary in bytes: + // Measured: `302` + // Estimated: `5204` + // Minimum execution time: 17_636 nanoseconds. + Weight::from_parts(18_399_000, 5204) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } } @@ -493,8 +535,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `4864` // Estimated: `23409` - // Minimum execution time: 34_509 nanoseconds. - Weight::from_parts(34_781_000, 23409) + // Minimum execution time: 42_939 nanoseconds. + Weight::from_parts(43_543_000, 23409) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -504,8 +546,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `3620` // Estimated: `5705` - // Minimum execution time: 31_151 nanoseconds. - Weight::from_parts(31_566_000, 5705) + // Minimum execution time: 36_475 nanoseconds. + Weight::from_parts(37_863_000, 5705) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -517,10 +559,10 @@ impl WeightInfo for () { /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) fn vote_new() -> Weight { // Proof Size summary in bytes: - // Measured: `3555` + // Measured: `3565` // Estimated: `12720` - // Minimum execution time: 42_618 nanoseconds. - Weight::from_parts(43_231_000, 12720) + // Minimum execution time: 56_372 nanoseconds. + Weight::from_parts(57_483_000, 12720) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -532,10 +574,10 @@ impl WeightInfo for () { /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) fn vote_existing() -> Weight { // Proof Size summary in bytes: - // Measured: `3577` + // Measured: `3587` // Estimated: `12720` - // Minimum execution time: 42_875 nanoseconds. - Weight::from_parts(43_338_000, 12720) + // Minimum execution time: 56_789 nanoseconds. + Weight::from_parts(57_737_000, 12720) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -543,14 +585,16 @@ impl WeightInfo for () { /// Proof: Democracy ReferendumInfoOf (max_values: None, max_size: Some(201), added: 2676, mode: MaxEncodedLen) /// Storage: Democracy Cancellations (r:1 w:1) /// Proof: Democracy Cancellations (max_values: None, max_size: Some(33), added: 2508, mode: MaxEncodedLen) + /// Storage: Democracy MetadataOf (r:1 w:1) + /// Proof: Democracy MetadataOf (max_values: None, max_size: Some(53), added: 2528, mode: MaxEncodedLen) fn emergency_cancel() -> Weight { // Proof Size summary in bytes: - // Measured: `320` - // Estimated: `5184` - // Minimum execution time: 16_543 nanoseconds. - Weight::from_parts(16_762_000, 5184) - .saturating_add(RocksDbWeight::get().reads(2_u64)) - .saturating_add(RocksDbWeight::get().writes(2_u64)) + // Measured: `398` + // Estimated: `7712` + // Minimum execution time: 24_379 nanoseconds. + Weight::from_parts(25_302_000, 7712) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) } /// Storage: Democracy PublicProps (r:1 w:1) /// Proof: Democracy PublicProps (max_values: Some(1), max_size: Some(16702), added: 17197, mode: MaxEncodedLen) @@ -558,6 +602,8 @@ impl WeightInfo for () { /// Proof: Democracy DepositOf (max_values: None, max_size: Some(3230), added: 5705, mode: MaxEncodedLen) /// Storage: System Account (r:1 w:1) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Democracy MetadataOf (r:3 w:1) + /// Proof: Democracy MetadataOf (max_values: None, max_size: Some(53), added: 2528, mode: MaxEncodedLen) /// Storage: Democracy NextExternal (r:1 w:1) /// Proof: Democracy NextExternal (max_values: Some(1), max_size: Some(132), added: 627, mode: MaxEncodedLen) /// Storage: Democracy ReferendumInfoOf (r:1 w:1) @@ -566,12 +612,12 @@ impl WeightInfo for () { /// Proof: Democracy Blacklist (max_values: None, max_size: Some(3238), added: 5713, mode: MaxEncodedLen) fn blacklist() -> Weight { // Proof Size summary in bytes: - // Measured: `5958` - // Estimated: `28808` - // Minimum execution time: 70_135 nanoseconds. - Weight::from_parts(70_616_000, 28808) - .saturating_add(RocksDbWeight::get().reads(5_u64)) - .saturating_add(RocksDbWeight::get().writes(6_u64)) + // Measured: `6036` + // Estimated: `36392` + // Minimum execution time: 100_345 nanoseconds. + Weight::from_parts(102_233_000, 36392) + .saturating_add(RocksDbWeight::get().reads(8_u64)) + .saturating_add(RocksDbWeight::get().writes(7_u64)) } /// Storage: Democracy NextExternal (r:1 w:1) /// Proof: Democracy NextExternal (max_values: Some(1), max_size: Some(132), added: 627, mode: MaxEncodedLen) @@ -581,8 +627,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `3448` // Estimated: `6340` - // Minimum execution time: 12_580 nanoseconds. - Weight::from_parts(12_987_000, 6340) + // Minimum execution time: 13_155 nanoseconds. + Weight::from_parts(14_158_000, 6340) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -592,8 +638,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_320 nanoseconds. - Weight::from_ref_time(3_513_000) + // Minimum execution time: 2_961 nanoseconds. + Weight::from_ref_time(3_139_000) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: Democracy NextExternal (r:0 w:1) @@ -602,37 +648,41 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_407 nanoseconds. - Weight::from_ref_time(3_565_000) + // Minimum execution time: 3_040 nanoseconds. + Weight::from_ref_time(3_261_000) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: Democracy NextExternal (r:1 w:1) /// Proof: Democracy NextExternal (max_values: Some(1), max_size: Some(132), added: 627, mode: MaxEncodedLen) /// Storage: Democracy ReferendumCount (r:1 w:1) /// Proof: Democracy ReferendumCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Democracy MetadataOf (r:1 w:2) + /// Proof: Democracy MetadataOf (max_values: None, max_size: Some(53), added: 2528, mode: MaxEncodedLen) /// Storage: Democracy ReferendumInfoOf (r:0 w:1) /// Proof: Democracy ReferendumInfoOf (max_values: None, max_size: Some(201), added: 2676, mode: MaxEncodedLen) fn fast_track() -> Weight { // Proof Size summary in bytes: - // Measured: `212` - // Estimated: `1126` - // Minimum execution time: 16_831 nanoseconds. - Weight::from_parts(17_155_000, 1126) - .saturating_add(RocksDbWeight::get().reads(2_u64)) - .saturating_add(RocksDbWeight::get().writes(3_u64)) + // Measured: `286` + // Estimated: `3654` + // Minimum execution time: 26_666 nanoseconds. + Weight::from_parts(28_014_000, 3654) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(5_u64)) } /// Storage: Democracy NextExternal (r:1 w:1) /// Proof: Democracy NextExternal (max_values: Some(1), max_size: Some(132), added: 627, mode: MaxEncodedLen) /// Storage: Democracy Blacklist (r:1 w:1) /// Proof: Democracy Blacklist (max_values: None, max_size: Some(3238), added: 5713, mode: MaxEncodedLen) + /// Storage: Democracy MetadataOf (r:1 w:1) + /// Proof: Democracy MetadataOf (max_values: None, max_size: Some(53), added: 2528, mode: MaxEncodedLen) fn veto_external() -> Weight { // Proof Size summary in bytes: - // Measured: `3477` - // Estimated: `6340` - // Minimum execution time: 22_072 nanoseconds. - Weight::from_parts(22_517_000, 6340) - .saturating_add(RocksDbWeight::get().reads(2_u64)) - .saturating_add(RocksDbWeight::get().writes(2_u64)) + // Measured: `3551` + // Estimated: `8868` + // Minimum execution time: 30_180 nanoseconds. + Weight::from_parts(31_593_000, 8868) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) } /// Storage: Democracy PublicProps (r:1 w:1) /// Proof: Democracy PublicProps (max_values: Some(1), max_size: Some(16702), added: 17197, mode: MaxEncodedLen) @@ -640,24 +690,29 @@ impl WeightInfo for () { /// Proof: Democracy DepositOf (max_values: None, max_size: Some(3230), added: 5705, mode: MaxEncodedLen) /// Storage: System Account (r:1 w:1) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Democracy MetadataOf (r:1 w:1) + /// Proof: Democracy MetadataOf (max_values: None, max_size: Some(53), added: 2528, mode: MaxEncodedLen) fn cancel_proposal() -> Weight { // Proof Size summary in bytes: - // Measured: `5837` - // Estimated: `25505` - // Minimum execution time: 56_925 nanoseconds. - Weight::from_parts(57_253_000, 25505) - .saturating_add(RocksDbWeight::get().reads(3_u64)) - .saturating_add(RocksDbWeight::get().writes(3_u64)) + // Measured: `5915` + // Estimated: `28033` + // Minimum execution time: 80_780 nanoseconds. + Weight::from_parts(82_070_000, 28033) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) } + /// Storage: Democracy MetadataOf (r:1 w:1) + /// Proof: Democracy MetadataOf (max_values: None, max_size: Some(53), added: 2528, mode: MaxEncodedLen) /// Storage: Democracy ReferendumInfoOf (r:0 w:1) /// Proof: Democracy ReferendumInfoOf (max_values: None, max_size: Some(201), added: 2676, mode: MaxEncodedLen) fn cancel_referendum() -> Weight { // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 8_582 nanoseconds. - Weight::from_ref_time(8_754_000) - .saturating_add(RocksDbWeight::get().writes(1_u64)) + // Measured: `271` + // Estimated: `2528` + // Minimum execution time: 18_117 nanoseconds. + Weight::from_parts(19_027_000, 2528) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } /// Storage: Democracy LowestUnbaked (r:1 w:1) /// Proof: Democracy LowestUnbaked (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) @@ -668,12 +723,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 99]`. fn on_initialize_base(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `207 + r * (117 ±0)` + // Measured: `244 + r * (117 ±0)` // Estimated: `998 + r * (2676 ±0)` - // Minimum execution time: 6_665 nanoseconds. - Weight::from_parts(9_219_932, 998) - // Standard Error: 4_236 - .saturating_add(Weight::from_ref_time(2_194_623).saturating_mul(r.into())) + // Minimum execution time: 7_093 nanoseconds. + Weight::from_parts(8_792_955, 998) + // Standard Error: 6_630 + .saturating_add(Weight::from_ref_time(3_091_565).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(1_u64)) @@ -694,12 +749,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 99]`. fn on_initialize_base_with_launch_period(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `207 + r * (117 ±0)` + // Measured: `244 + r * (117 ±0)` // Estimated: `19318 + r * (2676 ±0)` - // Minimum execution time: 9_842 nanoseconds. - Weight::from_parts(11_932_535, 19318) - // Standard Error: 4_413 - .saturating_add(Weight::from_ref_time(2_199_644).saturating_mul(r.into())) + // Minimum execution time: 10_372 nanoseconds. + Weight::from_parts(10_961_165, 19318) + // Standard Error: 7_284 + .saturating_add(Weight::from_ref_time(3_112_573).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(1_u64)) @@ -714,12 +769,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 99]`. fn delegate(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `948 + r * (139 ±0)` + // Measured: `958 + r * (139 ±0)` // Estimated: `22584 + r * (2676 ±0)` - // Minimum execution time: 34_740 nanoseconds. - Weight::from_parts(38_366_374, 22584) - // Standard Error: 4_868 - .saturating_add(Weight::from_ref_time(3_286_516).saturating_mul(r.into())) + // Minimum execution time: 36_618 nanoseconds. + Weight::from_parts(42_803_184, 22584) + // Standard Error: 7_268 + .saturating_add(Weight::from_ref_time(4_537_902).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(4_u64)) @@ -733,12 +788,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 99]`. fn undelegate(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `547 + r * (139 ±0)` + // Measured: `557 + r * (139 ±0)` // Estimated: `12540 + r * (2676 ±0)` - // Minimum execution time: 19_516 nanoseconds. - Weight::from_parts(21_629_605, 12540) - // Standard Error: 4_401 - .saturating_add(Weight::from_ref_time(3_238_187).saturating_mul(r.into())) + // Minimum execution time: 19_758 nanoseconds. + Weight::from_parts(21_641_793, 12540) + // Standard Error: 6_889 + .saturating_add(Weight::from_ref_time(4_478_884).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(2_u64)) @@ -751,8 +806,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_291 nanoseconds. - Weight::from_ref_time(3_485_000) + // Minimum execution time: 2_844 nanoseconds. + Weight::from_ref_time(3_017_000) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: Democracy VotingOf (r:1 w:1) @@ -764,12 +819,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 99]`. fn unlock_remove(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `617` + // Measured: `627` // Estimated: `12647` - // Minimum execution time: 19_357 nanoseconds. - Weight::from_parts(24_014_517, 12647) - // Standard Error: 994 - .saturating_add(Weight::from_ref_time(17_096).saturating_mul(r.into())) + // Minimum execution time: 20_380 nanoseconds. + Weight::from_parts(28_295_875, 12647) + // Standard Error: 2_331 + .saturating_add(Weight::from_ref_time(67_348).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -782,12 +837,12 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 99]`. fn unlock_set(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `618 + r * (22 ±0)` + // Measured: `628 + r * (22 ±0)` // Estimated: `12647` - // Minimum execution time: 22_340 nanoseconds. - Weight::from_parts(23_355_734, 12647) - // Standard Error: 548 - .saturating_add(Weight::from_ref_time(64_308).saturating_mul(r.into())) + // Minimum execution time: 24_475 nanoseconds. + Weight::from_parts(27_102_576, 12647) + // Standard Error: 1_464 + .saturating_add(Weight::from_ref_time(128_921).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -798,12 +853,12 @@ impl WeightInfo for () { /// The range of component `r` is `[1, 100]`. fn remove_vote(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `781 + r * (26 ±0)` + // Measured: `791 + r * (26 ±0)` // Estimated: `8946` - // Minimum execution time: 14_542 nanoseconds. - Weight::from_parts(16_411_916, 8946) - // Standard Error: 839 - .saturating_add(Weight::from_ref_time(73_268).saturating_mul(r.into())) + // Minimum execution time: 15_039 nanoseconds. + Weight::from_parts(19_252_498, 8946) + // Standard Error: 1_798 + .saturating_add(Weight::from_ref_time(131_855).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -814,67 +869,95 @@ impl WeightInfo for () { /// The range of component `r` is `[1, 100]`. fn remove_other_vote(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `781 + r * (26 ±0)` + // Measured: `791 + r * (26 ±0)` // Estimated: `8946` - // Minimum execution time: 14_463 nanoseconds. - Weight::from_parts(16_302_901, 8946) - // Standard Error: 809 - .saturating_add(Weight::from_ref_time(73_692).saturating_mul(r.into())) + // Minimum execution time: 14_837 nanoseconds. + Weight::from_parts(19_144_929, 8946) + // Standard Error: 1_875 + .saturating_add(Weight::from_ref_time(136_819).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } - // Storage: Democracy NextExternal (r:1 w:0) - // Storage: Preimage StatusFor (r:1 w:1) - // Storage: Democracy MetadataOf (r:0 w:1) + /// Storage: Democracy NextExternal (r:1 w:0) + /// Proof: Democracy NextExternal (max_values: Some(1), max_size: Some(132), added: 627, mode: MaxEncodedLen) + /// Storage: Preimage StatusFor (r:1 w:0) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) + /// Storage: Democracy MetadataOf (r:0 w:1) + /// Proof: Democracy MetadataOf (max_values: None, max_size: Some(53), added: 2528, mode: MaxEncodedLen) fn set_external_metadata() -> Weight { - // Minimum execution time: 303_000 nanoseconds. - Weight::from_ref_time(304_000_000) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(2)) - } - // Storage: Democracy NextExternal (r:1 w:0) - // Storage: Democracy MetadataOf (r:1 w:1) - // Storage: Preimage StatusFor (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `356` + // Estimated: `3193` + // Minimum execution time: 17_338 nanoseconds. + Weight::from_parts(17_946_000, 3193) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Democracy NextExternal (r:1 w:0) + /// Proof: Democracy NextExternal (max_values: Some(1), max_size: Some(132), added: 627, mode: MaxEncodedLen) + /// Storage: Democracy MetadataOf (r:1 w:1) + /// Proof: Democracy MetadataOf (max_values: None, max_size: Some(53), added: 2528, mode: MaxEncodedLen) fn clear_external_metadata() -> Weight { - // Minimum execution time: 333_000 nanoseconds. - Weight::from_ref_time(337_000_000) - .saturating_add(RocksDbWeight::get().reads(3)) - .saturating_add(RocksDbWeight::get().writes(2)) - } - // Storage: Democracy PublicProps (r:1 w:0) - // Storage: Preimage StatusFor (r:1 w:1) - // Storage: Democracy MetadataOf (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `286` + // Estimated: `3155` + // Minimum execution time: 15_364 nanoseconds. + Weight::from_parts(15_990_000, 3155) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Democracy PublicProps (r:1 w:0) + /// Proof: Democracy PublicProps (max_values: Some(1), max_size: Some(16702), added: 17197, mode: MaxEncodedLen) + /// Storage: Preimage StatusFor (r:1 w:0) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) + /// Storage: Democracy MetadataOf (r:0 w:1) + /// Proof: Democracy MetadataOf (max_values: None, max_size: Some(53), added: 2528, mode: MaxEncodedLen) fn set_proposal_metadata() -> Weight { - // Minimum execution time: 377_000 nanoseconds. - Weight::from_ref_time(379_000_000) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(2)) - } - // Storage: Democracy PublicProps (r:1 w:0) - // Storage: Democracy MetadataOf (r:1 w:1) - // Storage: Preimage StatusFor (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `4919` + // Estimated: `19763` + // Minimum execution time: 37_147 nanoseconds. + Weight::from_parts(37_778_000, 19763) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Democracy PublicProps (r:1 w:0) + /// Proof: Democracy PublicProps (max_values: Some(1), max_size: Some(16702), added: 17197, mode: MaxEncodedLen) + /// Storage: Democracy MetadataOf (r:1 w:1) + /// Proof: Democracy MetadataOf (max_values: None, max_size: Some(53), added: 2528, mode: MaxEncodedLen) fn clear_proposal_metadata() -> Weight { - // Minimum execution time: 407_000 nanoseconds. - Weight::from_ref_time(415_000_000) - .saturating_add(RocksDbWeight::get().reads(3)) - .saturating_add(RocksDbWeight::get().writes(2)) + // Proof Size summary in bytes: + // Measured: `4853` + // Estimated: `19725` + // Minimum execution time: 34_118 nanoseconds. + Weight::from_parts(34_737_000, 19725) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: Preimage StatusFor (r:1 w:1) - // Storage: Democracy MetadataOf (r:0 w:1) + /// Storage: Preimage StatusFor (r:1 w:0) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) + /// Storage: Democracy MetadataOf (r:0 w:1) + /// Proof: Democracy MetadataOf (max_values: None, max_size: Some(53), added: 2528, mode: MaxEncodedLen) fn set_referendum_metadata() -> Weight { - // Minimum execution time: 234_000 nanoseconds. - Weight::from_ref_time(234_000_000) - .saturating_add(RocksDbWeight::get().reads(1)) - .saturating_add(RocksDbWeight::get().writes(2)) - } - // Storage: Democracy ReferendumInfoOf (r:1 w:0) - // Storage: Democracy MetadataOf (r:1 w:1) - // Storage: Preimage StatusFor (r:1 w:1) - // Storage: Preimage PreimageFor (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `144` + // Estimated: `2566` + // Minimum execution time: 12_787 nanoseconds. + Weight::from_parts(13_463_000, 2566) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Democracy ReferendumInfoOf (r:1 w:0) + /// Proof: Democracy ReferendumInfoOf (max_values: None, max_size: Some(201), added: 2676, mode: MaxEncodedLen) + /// Storage: Democracy MetadataOf (r:1 w:1) + /// Proof: Democracy MetadataOf (max_values: None, max_size: Some(53), added: 2528, mode: MaxEncodedLen) fn clear_referendum_metadata() -> Weight { - // Minimum execution time: 384_000 nanoseconds. - Weight::from_ref_time(386_000_000) - .saturating_add(RocksDbWeight::get().reads(3)) - .saturating_add(RocksDbWeight::get().writes(3)) + // Proof Size summary in bytes: + // Measured: `302` + // Estimated: `5204` + // Minimum execution time: 17_636 nanoseconds. + Weight::from_parts(18_399_000, 5204) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } } From d3380716dd7606127b1d1abade1e44cafc0262d1 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Fri, 27 Jan 2023 17:32:40 +0000 Subject: [PATCH 28/29] ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_referenda --- frame/referenda/src/weights.rs | 329 ++++++++++++++++++--------------- 1 file changed, 177 insertions(+), 152 deletions(-) diff --git a/frame/referenda/src/weights.rs b/frame/referenda/src/weights.rs index 852830adcc891..ab49759516bd9 100644 --- a/frame/referenda/src/weights.rs +++ b/frame/referenda/src/weights.rs @@ -18,25 +18,26 @@ //! Autogenerated weights for pallet_referenda //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-01-27, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `runner-b3zmxxc-project-145-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: -// ./target/production/substrate +// target/production/substrate // benchmark // pallet -// --chain=dev // --steps=50 // --repeat=20 -// --pallet=pallet_referenda // --extrinsic=* // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --output=./frame/referenda/src/weights.rs +// --json-file=/builds/parity/mirrors/substrate/.git/.artifacts/bench.json +// --pallet=pallet_referenda +// --chain=dev // --header=./HEADER-APACHE2 +// --output=./frame/referenda/src/weights.rs // --template=./.maintain/frame-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -93,8 +94,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `251` // Estimated: `109996` - // Minimum execution time: 32_207 nanoseconds. - Weight::from_parts(32_639_000, 109996) + // Minimum execution time: 34_540 nanoseconds. + Weight::from_parts(36_144_000, 109996) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -106,8 +107,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `536` // Estimated: `221835` - // Minimum execution time: 43_766 nanoseconds. - Weight::from_parts(44_494_000, 221835) + // Minimum execution time: 46_963 nanoseconds. + Weight::from_parts(48_459_000, 221835) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -121,8 +122,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `3203` // Estimated: `9817` - // Minimum execution time: 41_561 nanoseconds. - Weight::from_parts(42_180_000, 9817) + // Minimum execution time: 55_798 nanoseconds. + Weight::from_parts(58_260_000, 9817) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -136,8 +137,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `3223` // Estimated: `9817` - // Minimum execution time: 41_039 nanoseconds. - Weight::from_parts(41_673_000, 9817) + // Minimum execution time: 53_888 nanoseconds. + Weight::from_parts(57_919_000, 9817) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -151,8 +152,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `536` // Estimated: `224324` - // Minimum execution time: 52_922 nanoseconds. - Weight::from_parts(53_395_000, 224324) + // Minimum execution time: 56_121 nanoseconds. + Weight::from_parts(58_301_000, 224324) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -166,8 +167,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `536` // Estimated: `224324` - // Minimum execution time: 51_050 nanoseconds. - Weight::from_parts(51_736_000, 224324) + // Minimum execution time: 54_237 nanoseconds. + Weight::from_parts(55_681_000, 224324) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -177,8 +178,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `415` // Estimated: `2841` - // Minimum execution time: 24_102 nanoseconds. - Weight::from_parts(24_372_000, 2841) + // Minimum execution time: 25_734 nanoseconds. + Weight::from_parts(26_429_000, 2841) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -188,8 +189,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `405` // Estimated: `2841` - // Minimum execution time: 24_162 nanoseconds. - Weight::from_parts(24_547_000, 2841) + // Minimum execution time: 26_000 nanoseconds. + Weight::from_parts(26_786_000, 2841) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -201,8 +202,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `412` // Estimated: `221835` - // Minimum execution time: 32_247 nanoseconds. - Weight::from_parts(32_731_000, 221835) + // Minimum execution time: 34_567 nanoseconds. + Weight::from_parts(35_939_000, 221835) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -210,13 +211,15 @@ impl WeightInfo for SubstrateWeight { /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) /// Storage: Scheduler Agenda (r:2 w:2) /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) + /// Storage: Referenda MetadataOf (r:1 w:0) + /// Proof: Referenda MetadataOf (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) fn kill() -> Weight { // Proof Size summary in bytes: // Measured: `717` - // Estimated: `221835` - // Minimum execution time: 59_900 nanoseconds. - Weight::from_parts(60_659_000, 221835) - .saturating_add(T::DbWeight::get().reads(3_u64)) + // Estimated: `224362` + // Minimum execution time: 67_744 nanoseconds. + Weight::from_parts(70_047_000, 224362) + .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } /// Storage: Referenda TrackQueue (r:1 w:0) @@ -227,8 +230,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `174` // Estimated: `6976` - // Minimum execution time: 9_322 nanoseconds. - Weight::from_parts(9_638_000, 6976) + // Minimum execution time: 9_886 nanoseconds. + Weight::from_parts(10_406_000, 6976) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -242,8 +245,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `4661` // Estimated: `226322` - // Minimum execution time: 76_976 nanoseconds. - Weight::from_parts(77_597_000, 226322) + // Minimum execution time: 100_449 nanoseconds. + Weight::from_parts(101_812_000, 226322) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -257,8 +260,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `4661` // Estimated: `226322` - // Minimum execution time: 78_405 nanoseconds. - Weight::from_parts(78_972_000, 226322) + // Minimum execution time: 101_430 nanoseconds. + Weight::from_parts(103_704_000, 226322) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -272,8 +275,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `4682` // Estimated: `116825` - // Minimum execution time: 51_360 nanoseconds. - Weight::from_parts(51_737_000, 116825) + // Minimum execution time: 67_224 nanoseconds. + Weight::from_parts(70_596_000, 116825) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -287,8 +290,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `4668` // Estimated: `116825` - // Minimum execution time: 50_485 nanoseconds. - Weight::from_parts(51_601_000, 116825) + // Minimum execution time: 65_461 nanoseconds. + Weight::from_parts(69_624_000, 116825) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -304,8 +307,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `4642` // Estimated: `119314` - // Minimum execution time: 53_075 nanoseconds. - Weight::from_parts(54_014_000, 119314) + // Minimum execution time: 69_848 nanoseconds. + Weight::from_parts(74_480_000, 119314) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -321,8 +324,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `4676` // Estimated: `119314` - // Minimum execution time: 52_916 nanoseconds. - Weight::from_parts(53_716_000, 119314) + // Minimum execution time: 70_042 nanoseconds. + Weight::from_parts(72_912_000, 119314) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -334,8 +337,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `364` // Estimated: `112338` - // Minimum execution time: 21_920 nanoseconds. - Weight::from_parts(22_172_000, 112338) + // Minimum execution time: 23_008 nanoseconds. + Weight::from_parts(23_767_000, 112338) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -347,8 +350,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `412` // Estimated: `112338` - // Minimum execution time: 22_094 nanoseconds. - Weight::from_parts(22_314_000, 112338) + // Minimum execution time: 23_550 nanoseconds. + Weight::from_parts(24_081_000, 112338) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -358,8 +361,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `310` // Estimated: `2841` - // Minimum execution time: 15_696 nanoseconds. - Weight::from_parts(15_964_000, 2841) + // Minimum execution time: 15_850 nanoseconds. + Weight::from_parts(16_773_000, 2841) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -373,8 +376,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `412` // Estimated: `114827` - // Minimum execution time: 30_604 nanoseconds. - Weight::from_parts(31_126_000, 114827) + // Minimum execution time: 32_126 nanoseconds. + Weight::from_parts(33_313_000, 114827) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -388,8 +391,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `412` // Estimated: `114827` - // Minimum execution time: 32_961 nanoseconds. - Weight::from_parts(33_295_000, 114827) + // Minimum execution time: 34_698 nanoseconds. + Weight::from_parts(35_802_000, 114827) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -401,8 +404,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `465` // Estimated: `112338` - // Minimum execution time: 27_072 nanoseconds. - Weight::from_parts(27_405_000, 112338) + // Minimum execution time: 28_710 nanoseconds. + Weight::from_parts(29_574_000, 112338) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -414,8 +417,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `448` // Estimated: `112338` - // Minimum execution time: 27_056 nanoseconds. - Weight::from_parts(27_768_000, 112338) + // Minimum execution time: 29_030 nanoseconds. + Weight::from_parts(30_308_000, 112338) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -427,8 +430,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `465` // Estimated: `112338` - // Minimum execution time: 24_599 nanoseconds. - Weight::from_parts(25_170_000, 112338) + // Minimum execution time: 26_382 nanoseconds. + Weight::from_parts(27_219_000, 112338) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -440,8 +443,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `469` // Estimated: `112338` - // Minimum execution time: 23_737 nanoseconds. - Weight::from_parts(24_184_000, 112338) + // Minimum execution time: 25_445 nanoseconds. + Weight::from_parts(26_010_000, 112338) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -455,8 +458,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `469` // Estimated: `224358` - // Minimum execution time: 37_880 nanoseconds. - Weight::from_parts(38_537_000, 224358) + // Minimum execution time: 41_064 nanoseconds. + Weight::from_parts(42_895_000, 224358) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -468,28 +471,38 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `465` // Estimated: `112338` - // Minimum execution time: 26_898 nanoseconds. - Weight::from_parts(27_496_000, 112338) + // Minimum execution time: 29_472 nanoseconds. + Weight::from_parts(30_011_000, 112338) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } - // Storage: Referenda ReferendumInfoFor (r:1 w:0) - // Storage: Preimage StatusFor (r:1 w:1) - // Storage: Referenda MetadataOf (r:0 w:1) + /// Storage: Referenda ReferendumInfoFor (r:1 w:0) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Preimage StatusFor (r:1 w:0) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) + /// Storage: Referenda MetadataOf (r:0 w:1) + /// Proof: Referenda MetadataOf (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) fn set_some_metadata() -> Weight { - // Minimum execution time: 295_000 nanoseconds. - Weight::from_ref_time(298_000_000) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(2)) - } - // Storage: Referenda ReferendumInfoFor (r:1 w:0) - // Storage: Referenda MetadataOf (r:1 w:1) - // Storage: Preimage StatusFor (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `454` + // Estimated: `5407` + // Minimum execution time: 19_389 nanoseconds. + Weight::from_parts(20_490_000, 5407) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:0) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Referenda MetadataOf (r:1 w:1) + /// Proof: Referenda MetadataOf (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) fn clear_metadata() -> Weight { - // Minimum execution time: 330_000 nanoseconds. - Weight::from_ref_time(364_000_000) - .saturating_add(RocksDbWeight::get().reads(3)) - .saturating_add(RocksDbWeight::get().writes(2)) + // Proof Size summary in bytes: + // Measured: `387` + // Estimated: `5368` + // Minimum execution time: 18_195 nanoseconds. + Weight::from_parts(19_917_000, 5368) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } } @@ -505,8 +518,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `251` // Estimated: `109996` - // Minimum execution time: 32_207 nanoseconds. - Weight::from_parts(32_639_000, 109996) + // Minimum execution time: 34_540 nanoseconds. + Weight::from_parts(36_144_000, 109996) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -518,8 +531,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `536` // Estimated: `221835` - // Minimum execution time: 43_766 nanoseconds. - Weight::from_parts(44_494_000, 221835) + // Minimum execution time: 46_963 nanoseconds. + Weight::from_parts(48_459_000, 221835) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -533,8 +546,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `3203` // Estimated: `9817` - // Minimum execution time: 41_561 nanoseconds. - Weight::from_parts(42_180_000, 9817) + // Minimum execution time: 55_798 nanoseconds. + Weight::from_parts(58_260_000, 9817) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -548,8 +561,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `3223` // Estimated: `9817` - // Minimum execution time: 41_039 nanoseconds. - Weight::from_parts(41_673_000, 9817) + // Minimum execution time: 53_888 nanoseconds. + Weight::from_parts(57_919_000, 9817) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -563,8 +576,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `536` // Estimated: `224324` - // Minimum execution time: 52_922 nanoseconds. - Weight::from_parts(53_395_000, 224324) + // Minimum execution time: 56_121 nanoseconds. + Weight::from_parts(58_301_000, 224324) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -578,8 +591,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `536` // Estimated: `224324` - // Minimum execution time: 51_050 nanoseconds. - Weight::from_parts(51_736_000, 224324) + // Minimum execution time: 54_237 nanoseconds. + Weight::from_parts(55_681_000, 224324) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -589,8 +602,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `415` // Estimated: `2841` - // Minimum execution time: 24_102 nanoseconds. - Weight::from_parts(24_372_000, 2841) + // Minimum execution time: 25_734 nanoseconds. + Weight::from_parts(26_429_000, 2841) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -600,8 +613,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `405` // Estimated: `2841` - // Minimum execution time: 24_162 nanoseconds. - Weight::from_parts(24_547_000, 2841) + // Minimum execution time: 26_000 nanoseconds. + Weight::from_parts(26_786_000, 2841) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -613,8 +626,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `412` // Estimated: `221835` - // Minimum execution time: 32_247 nanoseconds. - Weight::from_parts(32_731_000, 221835) + // Minimum execution time: 34_567 nanoseconds. + Weight::from_parts(35_939_000, 221835) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -622,13 +635,15 @@ impl WeightInfo for () { /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) /// Storage: Scheduler Agenda (r:2 w:2) /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) + /// Storage: Referenda MetadataOf (r:1 w:0) + /// Proof: Referenda MetadataOf (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) fn kill() -> Weight { // Proof Size summary in bytes: // Measured: `717` - // Estimated: `221835` - // Minimum execution time: 59_900 nanoseconds. - Weight::from_parts(60_659_000, 221835) - .saturating_add(RocksDbWeight::get().reads(3_u64)) + // Estimated: `224362` + // Minimum execution time: 67_744 nanoseconds. + Weight::from_parts(70_047_000, 224362) + .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } /// Storage: Referenda TrackQueue (r:1 w:0) @@ -639,8 +654,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `174` // Estimated: `6976` - // Minimum execution time: 9_322 nanoseconds. - Weight::from_parts(9_638_000, 6976) + // Minimum execution time: 9_886 nanoseconds. + Weight::from_parts(10_406_000, 6976) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -654,8 +669,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `4661` // Estimated: `226322` - // Minimum execution time: 76_976 nanoseconds. - Weight::from_parts(77_597_000, 226322) + // Minimum execution time: 100_449 nanoseconds. + Weight::from_parts(101_812_000, 226322) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -669,8 +684,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `4661` // Estimated: `226322` - // Minimum execution time: 78_405 nanoseconds. - Weight::from_parts(78_972_000, 226322) + // Minimum execution time: 101_430 nanoseconds. + Weight::from_parts(103_704_000, 226322) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -684,8 +699,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `4682` // Estimated: `116825` - // Minimum execution time: 51_360 nanoseconds. - Weight::from_parts(51_737_000, 116825) + // Minimum execution time: 67_224 nanoseconds. + Weight::from_parts(70_596_000, 116825) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -699,8 +714,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `4668` // Estimated: `116825` - // Minimum execution time: 50_485 nanoseconds. - Weight::from_parts(51_601_000, 116825) + // Minimum execution time: 65_461 nanoseconds. + Weight::from_parts(69_624_000, 116825) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -716,8 +731,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `4642` // Estimated: `119314` - // Minimum execution time: 53_075 nanoseconds. - Weight::from_parts(54_014_000, 119314) + // Minimum execution time: 69_848 nanoseconds. + Weight::from_parts(74_480_000, 119314) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -733,8 +748,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `4676` // Estimated: `119314` - // Minimum execution time: 52_916 nanoseconds. - Weight::from_parts(53_716_000, 119314) + // Minimum execution time: 70_042 nanoseconds. + Weight::from_parts(72_912_000, 119314) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -746,8 +761,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `364` // Estimated: `112338` - // Minimum execution time: 21_920 nanoseconds. - Weight::from_parts(22_172_000, 112338) + // Minimum execution time: 23_008 nanoseconds. + Weight::from_parts(23_767_000, 112338) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -759,8 +774,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `412` // Estimated: `112338` - // Minimum execution time: 22_094 nanoseconds. - Weight::from_parts(22_314_000, 112338) + // Minimum execution time: 23_550 nanoseconds. + Weight::from_parts(24_081_000, 112338) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -770,8 +785,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `310` // Estimated: `2841` - // Minimum execution time: 15_696 nanoseconds. - Weight::from_parts(15_964_000, 2841) + // Minimum execution time: 15_850 nanoseconds. + Weight::from_parts(16_773_000, 2841) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -785,8 +800,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `412` // Estimated: `114827` - // Minimum execution time: 30_604 nanoseconds. - Weight::from_parts(31_126_000, 114827) + // Minimum execution time: 32_126 nanoseconds. + Weight::from_parts(33_313_000, 114827) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -800,8 +815,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `412` // Estimated: `114827` - // Minimum execution time: 32_961 nanoseconds. - Weight::from_parts(33_295_000, 114827) + // Minimum execution time: 34_698 nanoseconds. + Weight::from_parts(35_802_000, 114827) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -813,8 +828,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `465` // Estimated: `112338` - // Minimum execution time: 27_072 nanoseconds. - Weight::from_parts(27_405_000, 112338) + // Minimum execution time: 28_710 nanoseconds. + Weight::from_parts(29_574_000, 112338) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -826,8 +841,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `448` // Estimated: `112338` - // Minimum execution time: 27_056 nanoseconds. - Weight::from_parts(27_768_000, 112338) + // Minimum execution time: 29_030 nanoseconds. + Weight::from_parts(30_308_000, 112338) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -839,8 +854,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `465` // Estimated: `112338` - // Minimum execution time: 24_599 nanoseconds. - Weight::from_parts(25_170_000, 112338) + // Minimum execution time: 26_382 nanoseconds. + Weight::from_parts(27_219_000, 112338) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -852,8 +867,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `469` // Estimated: `112338` - // Minimum execution time: 23_737 nanoseconds. - Weight::from_parts(24_184_000, 112338) + // Minimum execution time: 25_445 nanoseconds. + Weight::from_parts(26_010_000, 112338) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -867,8 +882,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `469` // Estimated: `224358` - // Minimum execution time: 37_880 nanoseconds. - Weight::from_parts(38_537_000, 224358) + // Minimum execution time: 41_064 nanoseconds. + Weight::from_parts(42_895_000, 224358) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -880,27 +895,37 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `465` // Estimated: `112338` - // Minimum execution time: 26_898 nanoseconds. - Weight::from_parts(27_496_000, 112338) + // Minimum execution time: 29_472 nanoseconds. + Weight::from_parts(30_011_000, 112338) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } - // Storage: Referenda ReferendumInfoFor (r:1 w:0) - // Storage: Preimage StatusFor (r:1 w:1) - // Storage: Referenda MetadataOf (r:0 w:1) + /// Storage: Referenda ReferendumInfoFor (r:1 w:0) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Preimage StatusFor (r:1 w:0) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) + /// Storage: Referenda MetadataOf (r:0 w:1) + /// Proof: Referenda MetadataOf (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) fn set_some_metadata() -> Weight { - // Minimum execution time: 295_000 nanoseconds. - Weight::from_ref_time(298_000_000) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(2)) - } - // Storage: Referenda ReferendumInfoFor (r:1 w:0) - // Storage: Referenda MetadataOf (r:1 w:1) - // Storage: Preimage StatusFor (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `454` + // Estimated: `5407` + // Minimum execution time: 19_389 nanoseconds. + Weight::from_parts(20_490_000, 5407) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:0) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Referenda MetadataOf (r:1 w:1) + /// Proof: Referenda MetadataOf (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) fn clear_metadata() -> Weight { - // Minimum execution time: 330_000 nanoseconds. - Weight::from_ref_time(364_000_000) - .saturating_add(RocksDbWeight::get().reads(3)) - .saturating_add(RocksDbWeight::get().writes(2)) + // Proof Size summary in bytes: + // Measured: `387` + // Estimated: `5368` + // Minimum execution time: 18_195 nanoseconds. + Weight::from_parts(19_917_000, 5368) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } } From 5f26d5bcab2a1804694f275f5f76f0df0766d40c Mon Sep 17 00:00:00 2001 From: muharem Date: Wed, 1 Feb 2023 02:23:04 +0100 Subject: [PATCH 29/29] rename reset_metadata to transfer_metadata --- frame/democracy/src/lib.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/frame/democracy/src/lib.rs b/frame/democracy/src/lib.rs index c00ba403c93c8..3aa8bc0015d38 100644 --- a/frame/democracy/src/lib.rs +++ b/frame/democracy/src/lib.rs @@ -813,7 +813,7 @@ pub mod pallet { threshold, delay, ); - Self::reset_metadata(MetadataOwner::External, MetadataOwner::Referendum(ref_index)); + Self::transfer_metadata(MetadataOwner::External, MetadataOwner::Referendum(ref_index)); Ok(()) } @@ -1537,7 +1537,7 @@ impl Pallet { threshold, T::EnactmentPeriod::get(), ); - Self::reset_metadata(MetadataOwner::External, MetadataOwner::Referendum(ref_index)); + Self::transfer_metadata(MetadataOwner::External, MetadataOwner::Referendum(ref_index)); Ok(()) } else { return Err(Error::::NoneWaiting.into()) @@ -1566,7 +1566,7 @@ impl Pallet { VoteThreshold::SuperMajorityApprove, T::EnactmentPeriod::get(), ); - Self::reset_metadata( + Self::transfer_metadata( MetadataOwner::Proposal(prop_index), MetadataOwner::Referendum(ref_index), ) @@ -1698,8 +1698,8 @@ impl Pallet { } } - /// Reset the metadata of an `owner` to a `new_owner`. - fn reset_metadata(owner: MetadataOwner, new_owner: MetadataOwner) { + /// Transfer the metadata of an `owner` to a `new_owner`. + fn transfer_metadata(owner: MetadataOwner, new_owner: MetadataOwner) { if let Some(hash) = MetadataOf::::take(&owner) { MetadataOf::::insert(&new_owner, hash); Self::deposit_event(Event::::MetadataTransferred {