Referendum proposal's metadata (#12568)

* referenda metadata

* todo comment

* remove TODO, update rustdocs

* referenda clear_metadata origin signed or root

* referenda metadata unit tests

* drop schema type for referenda metadata

* remove metadata type

* referenda metadata benches

* note different preimages

* metadata for democracy pallet

* metadata democracy pallet tests and benches

* fix cargo clippy

* update docs

* ".git/.scripts/bench-bot.sh" pallet dev pallet_democracy

* ".git/.scripts/bench-bot.sh" pallet dev pallet_referenda

* Update the doc frame/democracy/src/lib.rs

Co-authored-by: Roman Useinov <roman.useinov@gmail.com>

* Update the doc frame/democracy/src/lib.rs

Co-authored-by: Anthony Alaribe <anthonyalaribe@gmail.com>

* reference instead clone for take

Co-authored-by: Anthony Alaribe <anthonyalaribe@gmail.com>

* error rename BadMetadata to PreimageNotExist

* clear metadata within internal_cancel_referendum fn

* remove redundant clone

* collapse metadata api into one set_metadata method

* fmt

* review fixes

* not request preimage on set_metadata

* rename events and update docs

* ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_democracy

* ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_referenda

* rename reset_metadata to transfer_metadata

---------

Co-authored-by: command-bot <>
Co-authored-by: Roman Useinov <roman.useinov@gmail.com>
Co-authored-by: Anthony Alaribe <anthonyalaribe@gmail.com>
This commit is contained in:
Muharem Ismailov
2023-02-08 09:33:34 +01:00
committed by GitHub
parent 45f7f5b572
commit cc766cc1c5
13 changed files with 1367 additions and 350 deletions
+186 -17
View File
@@ -54,19 +54,20 @@ fn add_proposal<T: Config>(n: u32) -> Result<H256, &'static str> {
Ok(proposal.hash())
}
fn add_referendum<T: Config>(n: u32) -> (ReferendumIndex, H256) {
// add a referendum with a metadata.
fn add_referendum<T: Config>(n: u32) -> (ReferendumIndex, H256, PreimageHash) {
let vote_threshold = VoteThreshold::SimpleMajority;
let proposal = make_proposal::<T>(n);
let hash = proposal.hash();
(
Democracy::<T>::inject_referendum(
T::LaunchPeriod::get(),
proposal,
vote_threshold,
0u32.into(),
),
hash,
)
let index = Democracy::<T>::inject_referendum(
T::LaunchPeriod::get(),
proposal,
vote_threshold,
0u32.into(),
);
let preimage_hash = note_preimage::<T>();
MetadataOf::<T>::insert(crate::MetadataOwner::Referendum(index), preimage_hash.clone());
(index, hash, preimage_hash)
}
fn account_vote<T: Config>(b: BalanceOf<T>) -> AccountVote<BalanceOf<T>> {
@@ -75,6 +76,25 @@ fn account_vote<T: Config>(b: BalanceOf<T>) -> AccountVote<BalanceOf<T>> {
AccountVote::Standard { vote: v, balance: b }
}
fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
frame_system::Pallet::<T>::assert_last_event(generic_event.into());
}
fn assert_has_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
frame_system::Pallet::<T>::assert_has_event(generic_event.into());
}
// note a new preimage.
fn note_preimage<T: Config>() -> 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 = <T as Config>::Preimages::note(data).unwrap();
hash
}
benchmarks! {
propose {
let p = T::MaxProposals::get();
@@ -179,7 +199,7 @@ benchmarks! {
emergency_cancel {
let origin =
T::CancellationOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?;
let ref_index = add_referendum::<T>(0).0;
let (ref_index, _, preimage_hash) = add_referendum::<T>(0);
assert_ok!(Democracy::<T>::referendum_status(ref_index));
}: _<T::RuntimeOrigin>(origin, ref_index)
verify {
@@ -188,6 +208,10 @@ benchmarks! {
Democracy::<T>::referendum_status(ref_index),
Error::<T>::ReferendumInvalid,
);
assert_last_event::<T>(crate::Event::MetadataCleared {
owner: MetadataOwner::Referendum(ref_index),
hash: preimage_hash,
}.into());
}
blacklist {
@@ -198,7 +222,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::<T>(0);
let (ref_index, hash, preimage_hash) = add_referendum::<T>(0);
assert_ok!(Democracy::<T>::referendum_status(ref_index));
// Place our proposal in the external queue, too.
assert_ok!(Democracy::<T>::external_propose(
@@ -215,6 +239,10 @@ benchmarks! {
Democracy::<T>::referendum_status(ref_index),
Error::<T>::ReferendumInvalid
);
assert_has_event::<T>(crate::Event::MetadataCleared {
owner: MetadataOwner::Referendum(ref_index),
hash: preimage_hash,
}.into());
}
// Worst case scenario, we external propose a previously blacklisted proposal
@@ -262,8 +290,13 @@ benchmarks! {
.expect("ExternalDefaultOrigin has no successful origin required for the benchmark");
let proposal = make_proposal::<T>(0);
let proposal_hash = proposal.hash();
Democracy::<T>::external_propose_default(origin_propose, proposal)?;
Democracy::<T>::external_propose_default(origin_propose.clone(), proposal)?;
// Set metadata to the external proposal.
let preimage_hash = note_preimage::<T>();
assert_ok!(Democracy::<T>::set_metadata(
origin_propose,
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::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?;
@@ -271,7 +304,12 @@ benchmarks! {
let delay = 0u32;
}: _<T::RuntimeOrigin>(origin_fast_track, proposal_hash, voting_period, delay.into())
verify {
assert_eq!(Democracy::<T>::referendum_count(), 1, "referendum not created")
assert_eq!(Democracy::<T>::referendum_count(), 1, "referendum not created");
assert_last_event::<T>(crate::Event::MetadataTransferred {
prev_owner: MetadataOwner::External,
owner: MetadataOwner::Referendum(0),
hash: preimage_hash,
}.into());
}
veto_external {
@@ -280,7 +318,14 @@ benchmarks! {
let origin_propose = T::ExternalDefaultOrigin::try_successful_origin()
.expect("ExternalDefaultOrigin has no successful origin required for the benchmark");
Democracy::<T>::external_propose_default(origin_propose, proposal)?;
Democracy::<T>::external_propose_default(origin_propose.clone(), proposal)?;
let preimage_hash = note_preimage::<T>();
assert_ok!(Democracy::<T>::set_metadata(
origin_propose,
MetadataOwner::External,
Some(preimage_hash))
);
let mut vetoers: BoundedVec<T::AccountId, _> = Default::default();
for i in 0 .. (T::MaxBlacklisted::get() - 1) {
@@ -303,13 +348,32 @@ benchmarks! {
for i in 0 .. T::MaxProposals::get() {
add_proposal::<T>(i)?;
}
// Add metadata to the first proposal.
let proposer = funded_account::<T>("proposer", 0);
let preimage_hash = note_preimage::<T>();
assert_ok!(Democracy::<T>::set_metadata(
RawOrigin::Signed(proposer).into(),
MetadataOwner::Proposal(0),
Some(preimage_hash)));
let cancel_origin = T::CancelProposalOrigin::try_successful_origin()
.map_err(|_| BenchmarkError::Weightless)?;
}: _<T::RuntimeOrigin>(cancel_origin, 0)
verify {
assert_last_event::<T>(crate::Event::MetadataCleared {
owner: MetadataOwner::Proposal(0),
hash: preimage_hash,
}.into());
}
cancel_referendum {
let ref_index = add_referendum::<T>(0).0;
let (ref_index, _, preimage_hash) = add_referendum::<T>(0);
}: _(RawOrigin::Root, ref_index)
verify {
assert_last_event::<T>(crate::Event::MetadataCleared {
owner: MetadataOwner::Referendum(0),
hash: preimage_hash,
}.into());
}
#[extra]
on_initialize_external {
@@ -678,6 +742,111 @@ benchmarks! {
assert_eq!(votes.len(), (r - 1) as usize, "Vote was not removed");
}
set_external_metadata {
let origin = T::ExternalOrigin::try_successful_origin()
.expect("ExternalOrigin has no successful origin required for the benchmark");
assert_ok!(
Democracy::<T>::external_propose(origin.clone(), make_proposal::<T>(0))
);
let owner = MetadataOwner::External;
let hash = note_preimage::<T>();
}: set_metadata<T::RuntimeOrigin>(origin, owner.clone(), Some(hash))
verify {
assert_last_event::<T>(crate::Event::MetadataSet {
owner,
hash,
}.into());
}
clear_external_metadata {
let origin = T::ExternalOrigin::try_successful_origin()
.expect("ExternalOrigin has no successful origin required for the benchmark");
assert_ok!(
Democracy::<T>::external_propose(origin.clone(), make_proposal::<T>(0))
);
let owner = MetadataOwner::External;
let proposer = funded_account::<T>("proposer", 0);
let hash = note_preimage::<T>();
assert_ok!(Democracy::<T>::set_metadata(origin.clone(), owner.clone(), Some(hash)));
}: set_metadata<T::RuntimeOrigin>(origin, owner.clone(), None)
verify {
assert_last_event::<T>(crate::Event::MetadataCleared {
owner,
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::<T>(i)?;
}
let owner = MetadataOwner::Proposal(0);
let proposer = funded_account::<T>("proposer", 0);
let hash = note_preimage::<T>();
}: set_metadata<T::RuntimeOrigin>(RawOrigin::Signed(proposer).into(), owner.clone(), Some(hash))
verify {
assert_last_event::<T>(crate::Event::MetadataSet {
owner,
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::<T>(i)?;
}
let proposer = funded_account::<T>("proposer", 0);
let owner = MetadataOwner::Proposal(0);
let hash = note_preimage::<T>();
assert_ok!(Democracy::<T>::set_metadata(
RawOrigin::Signed(proposer.clone()).into(),
owner.clone(),
Some(hash)));
}: set_metadata<T::RuntimeOrigin>(RawOrigin::Signed(proposer).into(), owner.clone(), None)
verify {
assert_last_event::<T>(crate::Event::MetadataCleared {
owner,
hash,
}.into());
}
set_referendum_metadata {
// create not ongoing referendum.
ReferendumInfoOf::<T>::insert(
0,
ReferendumInfo::Finished { end: T::BlockNumber::zero(), approved: true },
);
let owner = MetadataOwner::Referendum(0);
let caller = funded_account::<T>("caller", 0);
let hash = note_preimage::<T>();
}: set_metadata<T::RuntimeOrigin>(RawOrigin::Root.into(), owner.clone(), Some(hash))
verify {
assert_last_event::<T>(crate::Event::MetadataSet {
owner,
hash,
}.into());
}
clear_referendum_metadata {
// create not ongoing referendum.
ReferendumInfoOf::<T>::insert(
0,
ReferendumInfo::Finished { end: T::BlockNumber::zero(), approved: true },
);
let owner = MetadataOwner::Referendum(0);
let hash = note_preimage::<T>();
MetadataOf::<T>::insert(owner.clone(), hash);
let caller = funded_account::<T>("caller", 0);
}: set_metadata<T::RuntimeOrigin>(RawOrigin::Signed(caller).into(), owner.clone(), None)
verify {
assert_last_event::<T>(crate::Event::MetadataCleared {
owner,
hash,
}.into());
}
impl_benchmark_test_suite!(
Democracy,
crate::tests::new_test_ext(),
+163 -13
View File
@@ -155,14 +155,17 @@
use codec::{Decode, Encode};
use frame_support::{
ensure,
error::BadOrigin,
traits::{
defensive_prelude::*,
schedule::{v3::Named as ScheduleNamed, DispatchTime},
Bounded, Currency, Get, LockIdentifier, LockableCurrency, OnUnbalanced, QueryPreimage,
ReservableCurrency, StorePreimage, WithdrawReasons,
Bounded, Currency, EnsureOrigin, Get, Hash as PreimageHash, LockIdentifier,
LockableCurrency, OnUnbalanced, QueryPreimage, ReservableCurrency, StorePreimage,
WithdrawReasons,
},
weights::Weight,
};
use frame_system::pallet_prelude::OriginFor;
use sp_runtime::{
traits::{Bounded as ArithBounded, One, Saturating, StaticLookup, Zero},
ArithmeticError, DispatchError, DispatchResult,
@@ -176,7 +179,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 +197,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<T> =
<<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
type NegativeImbalanceOf<T> = <<T as Config>::Currency as Currency<
@@ -425,6 +425,15 @@ pub mod pallet {
#[pallet::storage]
pub type Cancellations<T: Config> = 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<T: Config> = StorageMap<_, Blake2_128Concat, MetadataOwner, PreimageHash>;
#[pallet::genesis_config]
pub struct GenesisConfig<T: Config> {
_phantom: sp_std::marker::PhantomData<T>,
@@ -477,6 +486,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 transferred to new owner.
MetadataTransferred {
/// Previous metadata owner.
prev_owner: MetadataOwner,
/// New metadata owner.
owner: MetadataOwner,
/// Preimage hash.
hash: PreimageHash,
},
}
#[pallet::error]
@@ -528,6 +560,8 @@ pub mod pallet {
TooMany,
/// Voting period too low
VotingPeriodLow,
/// The preimage does not exist.
PreimageNotExist,
}
#[pallet::hooks]
@@ -773,12 +807,13 @@ pub mod pallet {
<NextExternal<T>>::kill();
let now = <frame_system::Pallet<T>>::block_number();
Self::inject_referendum(
let ref_index = Self::inject_referendum(
now.saturating_add(voting_period),
ext_proposal,
threshold,
delay,
);
Self::transfer_metadata(MetadataOwner::External, MetadataOwner::Referendum(ref_index));
Ok(())
}
@@ -816,6 +851,7 @@ pub mod pallet {
Self::deposit_event(Event::<T>::Vetoed { who, proposal_hash, until });
<NextExternal<T>>::kill();
Self::clear_metadata(MetadataOwner::External);
Ok(())
}
@@ -1025,12 +1061,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::<T>::get(), Some((p, ..)) if p.hash() == proposal_hash) {
NextExternal::<T>::kill();
Self::clear_metadata(MetadataOwner::External);
}
// Remove the referendum, if it's there.
@@ -1067,8 +1105,68 @@ pub mod pallet {
T::Slash::on_unbalanced(T::Currency::slash_reserved(&who, amount).0);
}
}
Self::deposit_event(Event::<T>::ProposalCanceled { prop_index });
Self::clear_metadata(MetadataOwner::Proposal(prop_index));
Ok(())
}
/// 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::call_index(18)]
#[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<T>,
owner: MetadataOwner,
maybe_hash: Option<PreimageHash>,
) -> DispatchResult {
match owner {
MetadataOwner::External => {
let (_, threshold) = <NextExternal<T>>::get().ok_or(Error::<T>::NoProposal)?;
Self::ensure_external_origin(threshold, origin)?;
},
MetadataOwner::Proposal(index) => {
let who = ensure_signed(origin)?;
let (_, _, proposer) = Self::proposal(index)?;
ensure!(proposer == who, Error::<T>::NoPermission);
},
MetadataOwner::Referendum(index) => {
let is_root = ensure_signed_or_root(origin)?.is_none();
ensure!(is_root || maybe_hash.is_none(), Error::<T>::NoPermission);
ensure!(
is_root || Self::referendum_status(index).is_err(),
Error::<T>::NoPermission
);
},
}
if let Some(hash) = maybe_hash {
ensure!(T::Preimages::len(&hash).is_some(), Error::<T>::PreimageNotExist);
MetadataOf::<T>::insert(owner.clone(), hash);
Self::deposit_event(Event::<T>::MetadataSet { owner, hash });
} else {
Self::clear_metadata(owner);
}
Ok(())
}
}
@@ -1146,6 +1244,7 @@ impl<T: Config> Pallet<T> {
pub fn internal_cancel_referendum(ref_index: ReferendumIndex) {
Self::deposit_event(Event::<T>::Cancelled { ref_index });
ReferendumInfoOf::<T>::remove(ref_index);
Self::clear_metadata(MetadataOwner::Referendum(ref_index));
}
// private.
@@ -1432,12 +1531,13 @@ impl<T: Config> Pallet<T> {
if let Some((proposal, threshold)) = <NextExternal<T>>::take() {
LastTabledWasExternal::<T>::put(true);
Self::deposit_event(Event::<T>::ExternalTabled);
Self::inject_referendum(
let ref_index = Self::inject_referendum(
now.saturating_add(T::VotingPeriod::get()),
proposal,
threshold,
T::EnactmentPeriod::get(),
);
Self::transfer_metadata(MetadataOwner::External, MetadataOwner::Referendum(ref_index));
Ok(())
} else {
return Err(Error::<T>::NoneWaiting.into())
@@ -1460,12 +1560,16 @@ impl<T: Config> Pallet<T> {
T::Currency::unreserve(d, deposit);
}
Self::deposit_event(Event::<T>::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::transfer_metadata(
MetadataOwner::Proposal(prop_index),
MetadataOwner::Referendum(ref_index),
)
}
Ok(())
} else {
@@ -1578,6 +1682,52 @@ impl<T: Config> Pallet<T> {
// `Compact<u32>`.
decode_compact_u32_at(&<DepositOf<T>>::hashed_key_for(proposal))
}
/// Return a proposal of an index.
fn proposal(index: PropIndex) -> Result<(PropIndex, BoundedCallOf<T>, T::AccountId), Error<T>> {
PublicProps::<T>::get()
.into_iter()
.find(|(prop_index, _, _)| prop_index == &index)
.ok_or(Error::<T>::ProposalMissing)
}
/// Clear metadata if exist for a given owner.
fn clear_metadata(owner: MetadataOwner) {
if let Some(hash) = MetadataOf::<T>::take(&owner) {
Self::deposit_event(Event::<T>::MetadataCleared { owner, hash });
}
}
/// Transfer the metadata of an `owner` to a `new_owner`.
fn transfer_metadata(owner: MetadataOwner, new_owner: MetadataOwner) {
if let Some(hash) = MetadataOf::<T>::take(&owner) {
MetadataOf::<T>::insert(&new_owner, hash);
Self::deposit_event(Event::<T>::MetadataTransferred {
prev_owner: owner,
owner: new_owner,
hash,
});
}
}
/// Ensure external origin for corresponding vote threshold.
fn ensure_external_origin(
threshold: VoteThreshold,
origin: OriginFor<T>,
) -> 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<u32>` from the trie at given key.
+14 -1
View File
@@ -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, Hash, IdentityLookup},
Perbill,
};
mod cancellation;
@@ -41,6 +41,7 @@ mod delegation;
mod external_proposing;
mod fast_tracking;
mod lock_voting;
mod metadata;
mod public_proposals;
mod scheduling;
mod voting;
@@ -276,3 +277,15 @@ fn big_nay(who: u64) -> AccountVote<u64> {
fn tally(r: ReferendumIndex) -> Tally<u64> {
Democracy::referendum_status(r).unwrap().tally
}
/// 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
}
@@ -32,6 +32,14 @@ fn fast_track_referendum_works() {
RuntimeOrigin::signed(3),
set_balance_proposal(2)
));
let hash = note_preimage(1);
assert!(<MetadataOf<Test>>::get(MetadataOwner::External).is_none());
assert_ok!(Democracy::set_metadata(
RuntimeOrigin::signed(3),
MetadataOwner::External,
Some(hash),
),);
assert!(<MetadataOf<Test>>::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 +52,9 @@ fn fast_track_referendum_works() {
tally: Tally { ayes: 0, nays: 0, turnout: 0 },
})
);
// metadata reset from the external proposal to the referendum.
assert!(<MetadataOf<Test>>::get(MetadataOwner::External).is_none());
assert!(<MetadataOf<Test>>::get(MetadataOwner::Referendum(0)).is_some());
});
}
@@ -0,0 +1,209 @@
// 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::<Test>::NoProposal,
);
// create an external proposal.
assert_ok!(Democracy::external_propose(RuntimeOrigin::signed(2), set_balance_proposal(2),));
assert!(<NextExternal<Test>>::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::<Test>::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,
}));
});
}
#[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!(<NextExternal<Test>>::exists());
// set metadata.
let hash = note_preimage(1);
assert_ok!(Democracy::set_metadata(RuntimeOrigin::signed(2), owner.clone(), Some(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,
}));
});
}
#[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::<Test>::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::<Test>::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,
}));
});
}
#[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_ok!(Democracy::set_metadata(RuntimeOrigin::signed(1), owner.clone(), Some(hash),));
// fails to clear metadata with a wrong origin.
assert_noop!(
Democracy::set_metadata(RuntimeOrigin::signed(3), owner.clone(), None),
Error::<Test>::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,
}));
});
}
#[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::<Test>::NoPermission,
);
// fails to clear if not a root.
assert_noop!(
Democracy::set_metadata(RuntimeOrigin::signed(3), owner.clone(), None,),
Error::<Test>::NoPermission,
);
// succeed to set metadata by a root for an ongoing referendum.
assert_ok!(Democracy::set_metadata(RuntimeOrigin::root(), owner.clone(), Some(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,
}));
});
}
#[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::<Test>::insert(owner.clone(), hash);
// no permission to clear metadata of an ongoing referendum.
assert_noop!(
Democracy::set_metadata(RuntimeOrigin::signed(1), owner.clone(), None),
Error::<Test>::NoPermission,
);
// referendum finished.
ReferendumInfoOf::<Test>::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,
}));
});
}
@@ -91,8 +91,20 @@ 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_preimage(1);
assert_ok!(Democracy::set_metadata(
RuntimeOrigin::signed(1),
MetadataOwner::Proposal(0),
Some(hash)
));
assert!(<MetadataOf<Test>>::get(MetadataOwner::Proposal(0)).is_some());
assert_ok!(Democracy::cancel_proposal(RuntimeOrigin::root(), 0));
System::assert_last_event(crate::Event::ProposalCanceled { prop_index: 0 }.into());
// metadata cleared, preimage unrequested.
assert!(<MetadataOf<Test>>::get(MetadataOwner::Proposal(0)).is_none());
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));
});
+17
View File
@@ -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<Balance> {
@@ -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),
}
+389 -192
View File
@@ -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)]
@@ -70,6 +71,12 @@ 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 set_referendum_metadata() -> Weight;
fn clear_referendum_metadata() -> Weight;
}
/// Weights for pallet_democracy using the Substrate node and recommended hardware.
@@ -87,8 +94,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// 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))
}
@@ -98,8 +105,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// 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))
}
@@ -111,10 +118,10 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
/// 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))
}
@@ -126,10 +133,10 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
/// 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))
}
@@ -137,14 +144,16 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
/// 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)
@@ -152,6 +161,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
/// 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)
@@ -160,12 +171,12 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
/// 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)
@@ -175,8 +186,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// 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))
}
@@ -186,8 +197,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// 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)
@@ -196,37 +207,41 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// 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)
@@ -234,24 +249,29 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
/// 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)
@@ -262,12 +282,12 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
/// 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))
@@ -288,12 +308,12 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
/// 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))
@@ -308,12 +328,12 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
/// 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))
@@ -327,12 +347,12 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
/// 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))
@@ -345,8 +365,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// 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)
@@ -358,12 +378,12 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
/// 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))
}
@@ -376,12 +396,12 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
/// 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))
}
@@ -392,12 +412,12 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
/// 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))
}
@@ -408,15 +428,97 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
/// 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)
/// 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 {
// 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 {
// 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 {
// 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 {
// 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: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 {
// 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 {
// 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))
}
}
// For backwards compatibility and tests
@@ -433,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))
}
@@ -444,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))
}
@@ -457,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))
}
@@ -472,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))
}
@@ -483,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)
@@ -498,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)
@@ -506,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)
@@ -521,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))
}
@@ -532,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)
@@ -542,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)
@@ -580,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)
@@ -608,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))
@@ -634,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))
@@ -654,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))
@@ -673,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))
@@ -691,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)
@@ -704,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))
}
@@ -722,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))
}
@@ -738,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))
}
@@ -754,13 +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)
/// 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 {
// 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 {
// 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 {
// 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 {
// 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: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 {
// 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 {
// 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))
}
}
+25 -1
View File
@@ -33,7 +33,6 @@ use sp_runtime::traits::Bounded as ArithBounded;
const SEED: u32 = 0;
#[allow(dead_code)]
fn assert_last_event<T: Config<I>, I: 'static>(generic_event: <T as Config<I>>::RuntimeEvent) {
frame_system::Pallet::<T>::assert_last_event(generic_event.into());
}
@@ -631,6 +630,31 @@ benchmarks_instance_pallet! {
assert_matches!(info, ReferendumInfo::Rejected(..));
}
set_some_metadata {
use sp_std::borrow::Cow;
let origin = T::SubmitOrigin::try_successful_origin()
.expect("SubmitOrigin has no successful origin required for the benchmark");
let index = create_referendum::<T, I>(origin.clone());
let hash = T::Preimages::note(Cow::from(vec![5, 6])).unwrap();
}: set_metadata<T::RuntimeOrigin>(origin, index, Some(hash))
verify {
assert_last_event::<T, I>(Event::MetadataSet { index, hash }.into());
}
clear_metadata {
use sp_std::borrow::Cow;
let origin = T::SubmitOrigin::try_successful_origin()
.expect("SubmitOrigin has no successful origin required for the benchmark");
let index = create_referendum::<T, I>(origin.clone());
let hash = T::Preimages::note(Cow::from(vec![6, 7, 8])).unwrap();
assert_ok!(
Referenda::<T, I>::set_metadata(origin.clone(), index, Some(hash))
);
}: set_metadata<T::RuntimeOrigin>(origin, index, None)
verify {
assert_last_event::<T, I>(Event::MetadataCleared { index, hash }.into());
}
impl_benchmark_test_suite!(
Referenda,
crate::mock::new_test_ext(),
+70 -2
View File
@@ -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,
};
@@ -251,6 +251,16 @@ pub mod pallet {
pub type DecidingCount<T: Config<I>, I: 'static = ()> =
StorageMap<_, Twox64Concat, TrackIdOf<T, I>, u32, ValueQuery>;
/// 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 MetadataOf<T: Config<I>, I: 'static = ()> =
StorageMap<_, Blake2_128Concat, ReferendumIndex, PreimageHash>;
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config<I>, I: 'static = ()> {
@@ -356,6 +366,20 @@ pub mod pallet {
/// The amount placed by the account.
amount: BalanceOf<T, I>,
},
/// Metadata for a referendum has been set.
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,
},
}
#[pallet::error]
@@ -384,6 +408,8 @@ pub mod pallet {
NoDeposit,
/// The referendum status is invalid for this operation.
BadStatus,
/// The preimage does not exist.
PreimageNotExist,
}
#[pallet::call]
@@ -540,6 +566,7 @@ pub mod pallet {
Self::deposit_event(Event::<T, I>::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::<T>::block_number());
ReferendumInfoFor::<T, I>::insert(index, info);
Ok(())
@@ -633,6 +660,40 @@ pub mod pallet {
Self::deposit_event(e);
Ok(())
}
/// Set or clear metadata of a referendum.
///
/// 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::call_index(8)]
#[pallet::weight(
maybe_hash.map_or(
T::WeightInfo::clear_metadata(), |_| T::WeightInfo::set_some_metadata())
)]
pub fn set_metadata(
origin: OriginFor<T>,
index: ReferendumIndex,
maybe_hash: Option<PreimageHash>,
) -> DispatchResult {
let who = ensure_signed(origin)?;
if let Some(hash) = maybe_hash {
let status = Self::ensure_ongoing(index)?;
ensure!(status.submission_deposit.who == who, Error::<T, I>::NoPermission);
ensure!(T::Preimages::len(&hash).is_some(), Error::<T, I>::PreimageNotExist);
MetadataOf::<T, I>::insert(index, hash);
Self::deposit_event(Event::<T, I>::MetadataSet { index, hash });
Ok(())
} else {
if let Some(status) = Self::ensure_ongoing(index).ok() {
ensure!(status.submission_deposit.who == who, Error::<T, I>::NoPermission);
}
Self::do_clear_metadata(index);
Ok(())
}
}
}
}
@@ -1204,4 +1265,11 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
support_needed.passing(x, tally.support(id)) &&
approval_needed.passing(x, tally.approval(id))
}
/// Clear metadata if exist for a given referendum index.
fn do_clear_metadata(index: ReferendumIndex) {
if let Some(hash) = MetadataOf::<T, I>::take(index) {
Self::deposit_event(Event::<T, I>::MetadataCleared { index, hash });
}
}
}
+13 -1
View File
@@ -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,
};
@@ -470,3 +470,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
}
+72
View File
@@ -578,3 +578,75 @@ 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 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),
Box::new(RawOrigin::Root.into()),
set_balance_proposal_bounded(1),
DispatchTime::At(1),
));
let index = ReferendumCount::<Test>::get() - 1;
assert_ok!(Referenda::kill(RuntimeOrigin::root(), index));
assert_noop!(
Referenda::set_metadata(RuntimeOrigin::signed(1), index, Some(invalid_hash)),
Error::<Test>::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::<Test>::get() - 1;
assert_noop!(
Referenda::set_metadata(RuntimeOrigin::signed(2), index, Some(invalid_hash)),
Error::<Test>::NoPermission,
);
// preimage does not exist.
let index = ReferendumCount::<Test>::get() - 1;
assert_noop!(
Referenda::set_metadata(RuntimeOrigin::signed(1), index, Some(invalid_hash)),
Error::<Test>::PreimageNotExist,
);
// metadata set.
let index = ReferendumCount::<Test>::get() - 1;
let hash = note_preimage(1);
assert_ok!(Referenda::set_metadata(RuntimeOrigin::signed(1), index, Some(hash)));
System::assert_last_event(RuntimeEvent::Referenda(crate::Event::MetadataSet {
index,
hash,
}));
});
}
#[test]
fn clear_metadata_works() {
new_test_ext().execute_with(|| {
let hash = note_preimage(1);
assert_ok!(Referenda::submit(
RuntimeOrigin::signed(1),
Box::new(RawOrigin::Root.into()),
set_balance_proposal_bounded(1),
DispatchTime::At(1),
));
let index = ReferendumCount::<Test>::get() - 1;
assert_ok!(Referenda::set_metadata(RuntimeOrigin::signed(1), index, Some(hash)));
assert_noop!(
Referenda::set_metadata(RuntimeOrigin::signed(2), index, None),
Error::<Test>::NoPermission,
);
assert_ok!(Referenda::set_metadata(RuntimeOrigin::signed(1), index, None),);
System::assert_last_event(RuntimeEvent::Referenda(crate::Event::MetadataCleared {
index,
hash,
}));
});
}
+185 -122
View File
@@ -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)]
@@ -76,6 +77,8 @@ pub trait WeightInfo {
fn nudge_referendum_continue_confirming() -> Weight;
fn nudge_referendum_approved() -> Weight;
fn nudge_referendum_rejected() -> Weight;
fn set_some_metadata() -> Weight;
fn clear_metadata() -> Weight;
}
/// Weights for pallet_referenda using the Substrate node and recommended hardware.
@@ -91,8 +94,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// 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))
}
@@ -104,8 +107,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// 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))
}
@@ -119,8 +122,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// 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))
}
@@ -134,8 +137,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// 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))
}
@@ -149,8 +152,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// 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))
}
@@ -164,8 +167,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// 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))
}
@@ -175,8 +178,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// 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))
}
@@ -186,8 +189,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// 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))
}
@@ -199,8 +202,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// 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))
}
@@ -208,13 +211,15 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
/// 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)
@@ -225,8 +230,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// 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))
}
@@ -240,8 +245,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// 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))
}
@@ -255,8 +260,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// 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))
}
@@ -270,8 +275,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// 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))
}
@@ -285,8 +290,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// 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))
}
@@ -302,8 +307,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// 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))
}
@@ -319,8 +324,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// 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))
}
@@ -332,8 +337,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// 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))
}
@@ -345,8 +350,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// 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))
}
@@ -356,8 +361,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// 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))
}
@@ -371,8 +376,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// 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))
}
@@ -386,8 +391,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// 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))
}
@@ -399,8 +404,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// 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))
}
@@ -412,8 +417,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// 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))
}
@@ -425,8 +430,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// 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))
}
@@ -438,8 +443,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// 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))
}
@@ -453,8 +458,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// 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))
}
@@ -466,11 +471,39 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// 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)
/// 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 {
// 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 {
// 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))
}
}
// For backwards compatibility and tests
@@ -485,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))
}
@@ -498,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))
}
@@ -513,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))
}
@@ -528,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))
}
@@ -543,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))
}
@@ -558,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))
}
@@ -569,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))
}
@@ -580,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))
}
@@ -593,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))
}
@@ -602,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)
@@ -619,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))
}
@@ -634,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))
}
@@ -649,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))
}
@@ -664,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))
}
@@ -679,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))
}
@@ -696,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))
}
@@ -713,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))
}
@@ -726,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))
}
@@ -739,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))
}
@@ -750,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))
}
@@ -765,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))
}
@@ -780,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))
}
@@ -793,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))
}
@@ -806,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))
}
@@ -819,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))
}
@@ -832,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))
}
@@ -847,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))
}
@@ -860,9 +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)
/// 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 {
// 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 {
// 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))
}
}