From 83fa6261f3cc3204eaedde59da77af00690d0ad8 Mon Sep 17 00:00:00 2001 From: muraca Date: Mon, 12 Jun 2023 20:40:23 +0200 Subject: [PATCH 1/8] bounded Voting Signed-off-by: muraca --- frame/collective/src/lib.rs | 53 ++++++++-- frame/collective/src/migrations/mod.rs | 1 + frame/collective/src/migrations/v5.rs | 129 +++++++++++++++++++++++ frame/collective/src/tests.rs | 135 ++++++++++++++++++++++--- 4 files changed, 293 insertions(+), 25 deletions(-) create mode 100644 frame/collective/src/migrations/v5.rs diff --git a/frame/collective/src/lib.rs b/frame/collective/src/lib.rs index 1084091173934..1fa8e8b61efcf 100644 --- a/frame/collective/src/lib.rs +++ b/frame/collective/src/lib.rs @@ -59,6 +59,7 @@ use frame_support::{ InitializeMembers, StorageVersion, }, weights::Weight, + BoundedVec, CloneNoBound, EqNoBound, Parameter, PartialEqNoBound, }; #[cfg(any(feature = "try-runtime", test))] @@ -155,16 +156,24 @@ impl GetBacking for RawOrigin { } /// Info for keeping track of a motion being voted on. -#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, TypeInfo)] -pub struct Votes { +#[derive( + PartialEqNoBound, EqNoBound, CloneNoBound, Encode, Decode, RuntimeDebug, TypeInfo, MaxEncodedLen, +)] +#[scale_info(skip_type_params(MaxMembers))] +pub struct Votes +where + AccountId: PartialEq + Clone, + BlockNumber: PartialEq + Clone, + MaxMembers: Get, +{ /// The proposal's unique index. index: ProposalIndex, /// The number of approval votes that are needed to pass the motion. threshold: MemberCount, /// The current set of voters that approved it. - ayes: Vec, + ayes: BoundedVec, /// The current set of voters that rejected it. - nays: Vec, + nays: BoundedVec, /// The hard end time of this vote. end: BlockNumber, } @@ -273,8 +282,13 @@ pub mod pallet { /// Votes on a given proposal, if it is ongoing. #[pallet::storage] #[pallet::getter(fn voting)] - pub type Voting, I: 'static = ()> = - StorageMap<_, Identity, T::Hash, Votes>, OptionQuery>; + pub type Voting, I: 'static = ()> = StorageMap< + _, + Identity, + T::Hash, + Votes, T::MaxMembers>, + OptionQuery, + >; /// Proposals so far. #[pallet::storage] @@ -725,7 +739,13 @@ impl, I: 'static> Pallet { >::insert(proposal_hash, proposal); let votes = { let end = frame_system::Pallet::::block_number() + T::MotionDuration::get(); - Votes { index, threshold, ayes: vec![], nays: vec![], end } + Votes { + index, + threshold, + ayes: sp_core::bounded_vec![], + nays: sp_core::bounded_vec![], + end, + } }; >::insert(proposal_hash, votes); @@ -757,7 +777,10 @@ impl, I: 'static> Pallet { if approve { if position_yes.is_none() { - voting.ayes.push(who.clone()); + voting + .ayes + .try_push(who.clone()) + .expect("Proposal voting ayes can't overflow; qed"); } else { return Err(Error::::DuplicateVote.into()) } @@ -766,7 +789,10 @@ impl, I: 'static> Pallet { } } else { if position_no.is_none() { - voting.nays.push(who.clone()); + voting + .nays + .try_push(who.clone()) + .expect("Proposal voting nays can't overflow; qed"); } else { return Err(Error::::DuplicateVote.into()) } @@ -1088,12 +1114,17 @@ impl, I: 'static> ChangeMembers for Pallet { .ayes .into_iter() .filter(|i| outgoing.binary_search(i).is_err()) - .collect(); + .collect::>() + .try_into() + .expect("The filtered elements should be at most equal to the original length; qed"); votes.nays = votes .nays .into_iter() .filter(|i| outgoing.binary_search(i).is_err()) - .collect(); + .collect::>() + .try_into() + .expect("The filtered elements should be at most equal to the original length; qed"); + *v = Some(votes); } }); diff --git a/frame/collective/src/migrations/mod.rs b/frame/collective/src/migrations/mod.rs index 2487ed1d5da52..42e417fc385e6 100644 --- a/frame/collective/src/migrations/mod.rs +++ b/frame/collective/src/migrations/mod.rs @@ -17,3 +17,4 @@ /// Version 4. pub mod v4; +pub mod v5; diff --git a/frame/collective/src/migrations/v5.rs b/frame/collective/src/migrations/v5.rs new file mode 100644 index 0000000000000..0f918263aa447 --- /dev/null +++ b/frame/collective/src/migrations/v5.rs @@ -0,0 +1,129 @@ +// This file is part of Substrate. + +// Copyright (C) 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. + +use crate::{Config, Pallet}; +use codec::{Decode, Encode}; +use frame_support::{ + pallet_prelude::{OptionQuery, StorageVersion, TypeInfo, ValueQuery}, + sp_runtime::Saturating, + traits::Get, + weights::Weight, + BoundedVec, Identity, RuntimeDebug, +}; +use frame_system::pallet_prelude::BlockNumberFor; +use sp_std::prelude::*; + +#[frame_support::storage_alias] +pub type Proposals, I: 'static> = StorageValue< + Pallet, + BoundedVec<::Hash, >::MaxProposals>, + ValueQuery, +>; + +#[frame_support::storage_alias] +pub type ProposalOf, I: 'static> = StorageMap< + Pallet, + Identity, + ::Hash, + >::Proposal, + OptionQuery, +>; + +#[frame_support::storage_alias] +pub type Voting, I: 'static> = StorageMap< + Pallet, + Identity, + ::Hash, + OldVotes<::AccountId, BlockNumberFor>, + OptionQuery, +>; + +/// Info for keeping track of a motion being voted on. +#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, TypeInfo)] +pub struct OldVotes { + /// The proposal's unique index. + pub index: crate::ProposalIndex, + /// The number of approval votes that are needed to pass the motion. + pub threshold: crate::MemberCount, + /// The current set of voters that approved it. + pub ayes: Vec, + /// The current set of voters that rejected it. + pub nays: Vec, + /// The hard end time of this vote. + pub end: BlockNumber, +} + +pub fn migrate_proposals, I: 'static>() -> Weight { + // TODO: implement + Weight::zero() +} + +pub fn migrate_votes, I: 'static>() -> Weight { + let mut count = 0u64; + + crate::Voting::::translate::>, _>(|_, vote| { + count.saturating_inc(); + Some(crate::Votes::, >::MaxMembers> { + index: vote.index, + threshold: vote.threshold, + ayes: vote.ayes.try_into().expect( + format!( + "runtime::collective migration failed, ayes for vote {:?} should not overflow", + vote.index + ) + .as_str(), + ), + nays: vote.nays.try_into().expect( + format!( + "runtime::collective migration failed, nays for vote {:?} should not overflow", + vote.index, + ) + .as_str(), + ), + end: vote.end, + }) + }); + + T::DbWeight::get().reads_writes(count, count) +} + +pub fn migrate, I: 'static>() -> Weight { + let storage_version = StorageVersion::get::>(); + log::info!( + target: "runtime::collective", + "Running migration for collective with storage version {:?}", + storage_version, + ); + + if storage_version <= 4 { + let weight = Weight::zero(); + + weight.saturating_add(migrate_votes::()); + weight.saturating_add(migrate_proposals::()); + + StorageVersion::new(5).put::>(); + + weight + } else { + log::warn!( + target: "runtime::collective", + "Attempted to apply migration to V5 but failed because storage version is {:?}", + storage_version, + ); + Weight::zero() + } +} diff --git a/frame/collective/src/tests.rs b/frame/collective/src/tests.rs index 86b85e07a8bd9..920ba9a7acd18 100644 --- a/frame/collective/src/tests.rs +++ b/frame/collective/src/tests.rs @@ -25,7 +25,7 @@ use frame_support::{ Hashable, }; use frame_system::{EnsureRoot, EventRecord, Phase}; -use sp_core::H256; +use sp_core::{bounded_vec, H256}; use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup}, @@ -656,12 +656,24 @@ fn removal_of_old_voters_votes_works() { assert_ok!(Collective::vote(RuntimeOrigin::signed(2), hash, 0, true)); assert_eq!( Collective::voting(&hash), - Some(Votes { index: 0, threshold: 3, ayes: vec![1, 2], nays: vec![], end }) + Some(Votes { + index: 0, + threshold: 3, + ayes: bounded_vec![1, 2], + nays: bounded_vec![], + end + }) ); Collective::change_members_sorted(&[4], &[1], &[2, 3, 4]); assert_eq!( Collective::voting(&hash), - Some(Votes { index: 0, threshold: 3, ayes: vec![2], nays: vec![], end }) + Some(Votes { + index: 0, + threshold: 3, + ayes: bounded_vec![2], + nays: bounded_vec![], + end + }) ); let proposal = make_proposal(69); @@ -677,12 +689,24 @@ fn removal_of_old_voters_votes_works() { assert_ok!(Collective::vote(RuntimeOrigin::signed(3), hash, 1, false)); assert_eq!( Collective::voting(&hash), - Some(Votes { index: 1, threshold: 2, ayes: vec![2], nays: vec![3], end }) + Some(Votes { + index: 1, + threshold: 2, + ayes: bounded_vec![2], + nays: bounded_vec![3], + end + }) ); Collective::change_members_sorted(&[], &[3], &[2, 4]); assert_eq!( Collective::voting(&hash), - Some(Votes { index: 1, threshold: 2, ayes: vec![2], nays: vec![], end }) + Some(Votes { + index: 1, + threshold: 2, + ayes: bounded_vec![2], + nays: bounded_vec![], + end + }) ); }); } @@ -704,7 +728,13 @@ fn removal_of_old_voters_votes_works_with_set_members() { assert_ok!(Collective::vote(RuntimeOrigin::signed(2), hash, 0, true)); assert_eq!( Collective::voting(&hash), - Some(Votes { index: 0, threshold: 3, ayes: vec![1, 2], nays: vec![], end }) + Some(Votes { + index: 0, + threshold: 3, + ayes: bounded_vec![1, 2], + nays: bounded_vec![], + end + }) ); assert_ok!(Collective::set_members( RuntimeOrigin::root(), @@ -714,7 +744,13 @@ fn removal_of_old_voters_votes_works_with_set_members() { )); assert_eq!( Collective::voting(&hash), - Some(Votes { index: 0, threshold: 3, ayes: vec![2], nays: vec![], end }) + Some(Votes { + index: 0, + threshold: 3, + ayes: bounded_vec![2], + nays: bounded_vec![], + end + }) ); let proposal = make_proposal(69); @@ -730,7 +766,13 @@ fn removal_of_old_voters_votes_works_with_set_members() { assert_ok!(Collective::vote(RuntimeOrigin::signed(3), hash, 1, false)); assert_eq!( Collective::voting(&hash), - Some(Votes { index: 1, threshold: 2, ayes: vec![2], nays: vec![3], end }) + Some(Votes { + index: 1, + threshold: 2, + ayes: bounded_vec![2], + nays: bounded_vec![3], + end + }) ); assert_ok!(Collective::set_members( RuntimeOrigin::root(), @@ -740,7 +782,13 @@ fn removal_of_old_voters_votes_works_with_set_members() { )); assert_eq!( Collective::voting(&hash), - Some(Votes { index: 1, threshold: 2, ayes: vec![2], nays: vec![], end }) + Some(Votes { + index: 1, + threshold: 2, + ayes: bounded_vec![2], + nays: bounded_vec![], + end + }) ); }); } @@ -762,7 +810,7 @@ fn propose_works() { assert_eq!(Collective::proposal_of(&hash), Some(proposal)); assert_eq!( Collective::voting(&hash), - Some(Votes { index: 0, threshold: 3, ayes: vec![], nays: vec![], end }) + Some(Votes { index: 0, threshold: 3, ayes: bounded_vec![], nays: bounded_vec![], end }) ); assert_eq!( @@ -922,13 +970,19 @@ fn motions_vote_after_works() { // Initially there a no votes when the motion is proposed. assert_eq!( Collective::voting(&hash), - Some(Votes { index: 0, threshold: 2, ayes: vec![], nays: vec![], end }) + Some(Votes { index: 0, threshold: 2, ayes: bounded_vec![], nays: bounded_vec![], end }) ); // Cast first aye vote. assert_ok!(Collective::vote(RuntimeOrigin::signed(1), hash, 0, true)); assert_eq!( Collective::voting(&hash), - Some(Votes { index: 0, threshold: 2, ayes: vec![1], nays: vec![], end }) + Some(Votes { + index: 0, + threshold: 2, + ayes: bounded_vec![1], + nays: bounded_vec![], + end + }) ); // Try to cast a duplicate aye vote. assert_noop!( @@ -939,7 +993,13 @@ fn motions_vote_after_works() { assert_ok!(Collective::vote(RuntimeOrigin::signed(1), hash, 0, false)); assert_eq!( Collective::voting(&hash), - Some(Votes { index: 0, threshold: 2, ayes: vec![], nays: vec![1], end }) + Some(Votes { + index: 0, + threshold: 2, + ayes: bounded_vec![], + nays: bounded_vec![1], + end + }) ); // Try to cast a duplicate nay vote. assert_noop!( @@ -990,7 +1050,7 @@ fn motions_all_first_vote_free_works() { )); assert_eq!( Collective::voting(&hash), - Some(Votes { index: 0, threshold: 2, ayes: vec![], nays: vec![], end }) + Some(Votes { index: 0, threshold: 2, ayes: bounded_vec![], nays: bounded_vec![], end }) ); // For the motion, acc 2's first vote, expecting Ok with Pays::No. @@ -1522,3 +1582,50 @@ fn migration_v4() { crate::migrations::v4::post_migrate::(old_pallet); }); } + +#[test] +fn migration_v5() { + ExtBuilder::default().build_and_execute(|| { + assert_eq!(StorageVersion::get::>(), 4); + + // Create a proposal. + let proposal = ::RuntimeCall::System( + frame_system::Call::remark_with_event { remark: 42u64.to_be_bytes().to_vec() }, + ); + let proposal_hash = ::Hashing::hash_of(&proposal); + crate::migrations::v5::Proposals::::put::>(bounded_vec![ + proposal_hash + ]); + crate::migrations::v5::ProposalOf::::insert(proposal_hash, proposal); + + // Create some votes. + let ayes: Vec<::AccountId> = + (1..::MaxMembers::get()).map(|i| i.into()).collect(); + + let vote = crate::migrations::v5::OldVotes { + index: 0, + threshold: 1, + ayes: ayes.clone(), + nays: bounded_vec![], + end: 100, + }; + + // Insert the vote + crate::migrations::v5::Voting::::insert(proposal_hash, vote.clone()); + + // Run migration. + crate::migrations::v5::migrate::(); + // Check that the storage version is updated. + assert_eq!(StorageVersion::get::>(), 5); + + // Check that the vote is there and is bounded. + assert_eq!( + crate::Voting::::get(proposal_hash).unwrap().ayes, + Vec::< + ::AccountId, + // ::MaxMembers + >::try_from(ayes) + .unwrap() + ); + }); +} From 2167e1a029812dd42693a2d1c76e3a9ac423d04f Mon Sep 17 00:00:00 2001 From: muraca Date: Wed, 14 Jun 2023 17:11:19 +0200 Subject: [PATCH 2/8] removed Proposals and ProposalOf, use Bounded instead of hash Signed-off-by: muraca --- Cargo.lock | 1 + frame/collective/Cargo.toml | 4 + frame/collective/src/benchmarking.rs | 122 +++---- frame/collective/src/lib.rs | 257 +++++++------- frame/collective/src/migrations/v5.rs | 75 ++--- frame/collective/src/tests.rs | 462 +++++++++++++++----------- 6 files changed, 492 insertions(+), 429 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b975b4c32b034..21f00b2f58ccf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6300,6 +6300,7 @@ dependencies = [ "frame-support", "frame-system", "log", + "pallet-preimage", "parity-scale-codec", "scale-info", "sp-core", diff --git a/frame/collective/Cargo.toml b/frame/collective/Cargo.toml index 7e9f38dc24a0c..70ac480b15ed3 100644 --- a/frame/collective/Cargo.toml +++ b/frame/collective/Cargo.toml @@ -24,6 +24,9 @@ sp-io = { version = "23.0.0", default-features = false, path = "../../primitives sp-runtime = { version = "24.0.0", default-features = false, path = "../../primitives/runtime" } sp-std = { version = "8.0.0", default-features = false, path = "../../primitives/std" } +[dev-dependencies] +pallet-preimage = { version = "4.0.0-dev", path = "../preimage" } + [features] default = ["std"] std = [ @@ -37,6 +40,7 @@ std = [ "sp-io/std", "sp-runtime/std", "sp-std/std", + "pallet-preimage/std", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", diff --git a/frame/collective/src/benchmarking.rs b/frame/collective/src/benchmarking.rs index 503d725105309..44dcc444eede8 100644 --- a/frame/collective/src/benchmarking.rs +++ b/frame/collective/src/benchmarking.rs @@ -20,20 +20,20 @@ use super::*; use crate::Pallet as Collective; -use sp_runtime::traits::Bounded; -use sp_std::mem::size_of; - use frame_benchmarking::v1::{account, benchmarks_instance_pallet, whitelisted_caller}; +use frame_support::bounded_vec; use frame_system::{ pallet_prelude::BlockNumberFor, Call as SystemCall, Pallet as System, RawOrigin as SystemOrigin, }; +use sp_runtime::traits::Bounded; +use sp_std::mem::size_of; const SEED: u32 = 0; const MAX_BYTES: u32 = 1_024; -fn assert_last_event, I: 'static>(generic_event: >::RuntimeEvent) { - frame_system::Pallet::::assert_last_event(generic_event.into()); +fn assert_has_event, I: 'static>(generic_event: >::RuntimeEvent) { + frame_system::Pallet::::assert_has_event(generic_event.into()); } fn id_to_remark_data(id: u32, length: usize) -> Vec { @@ -69,7 +69,7 @@ benchmarks_instance_pallet! { // Length of the proposals should be irrelevant to `set_members`. let length = 100; for i in 0 .. p { - // Proposals should be different so that different proposal hashes are generated + // Proposals should be different let proposal: T::Proposal = SystemCall::::remark { remark: id_to_remark_data(i, length) }.into(); Collective::::propose( SystemOrigin::Signed(old_members.last().unwrap().clone()).into(), @@ -77,7 +77,7 @@ benchmarks_instance_pallet! { Box::new(proposal.clone()), MAX_BYTES, )?; - let hash = T::Hashing::hash_of(&proposal); + let proposal_bounded = T::Preimages::bound(proposal).unwrap(); // Vote on the proposal to increase state relevant for `set_members`. // Not voting for last old member because they proposed and not voting for the first member // to keep the proposal from passing. @@ -86,7 +86,7 @@ benchmarks_instance_pallet! { let approve = true; Collective::::vote( SystemOrigin::Signed(voter.clone()).into(), - hash, + proposal_bounded.clone(), i, approve, )?; @@ -130,10 +130,10 @@ benchmarks_instance_pallet! { }: _(SystemOrigin::Signed(caller), Box::new(proposal.clone()), bytes_in_storage) verify { - let proposal_hash = T::Hashing::hash_of(&proposal); + let proposal_bounded = T::Preimages::bound(proposal).unwrap(); // Note that execution fails due to mis-matched origin - assert_last_event::( - Event::MemberExecuted { proposal_hash, result: Ok(()) }.into() + assert_has_event::( + Event::MemberExecuted { proposal_bounded, result: Ok(()) }.into() ); } @@ -161,10 +161,10 @@ benchmarks_instance_pallet! { }: propose(SystemOrigin::Signed(caller), threshold, Box::new(proposal.clone()), bytes_in_storage) verify { - let proposal_hash = T::Hashing::hash_of(&proposal); + let proposal_bounded = T::Preimages::bound(proposal).unwrap(); // Note that execution fails due to mis-matched origin - assert_last_event::( - Event::Executed { proposal_hash, result: Ok(()) }.into() + assert_has_event::( + Event::Executed { proposal_bounded, result: Ok(()) }.into() ); } @@ -189,7 +189,7 @@ benchmarks_instance_pallet! { let threshold = m; // Add previous proposals. for i in 0 .. p - 1 { - // Proposals should be different so that different proposal hashes are generated + // Proposals should be different let proposal: T::Proposal = SystemCall::::remark { remark: id_to_remark_data(i, b as usize) }.into(); Collective::::propose( SystemOrigin::Signed(caller.clone()).into(), @@ -207,8 +207,10 @@ benchmarks_instance_pallet! { verify { // New proposal is recorded assert_eq!(Collective::::proposals().len(), p as usize); - let proposal_hash = T::Hashing::hash_of(&proposal); - assert_last_event::(Event::Proposed { account: caller, proposal_index: p - 1, proposal_hash, threshold }.into()); + let proposal_bounded = T::Preimages::bound(proposal).unwrap(); + assert_has_event::( + Event::Proposed { account: caller, proposal_index: p - 1, proposal_bounded, threshold }.into() + ); } vote { @@ -235,9 +237,9 @@ benchmarks_instance_pallet! { let threshold = m - 1; // Add previous proposals - let mut last_hash = T::Hash::default(); + let mut last_bound = frame_support::traits::Bounded::Inline(bounded_vec![]); for i in 0 .. p { - // Proposals should be different so that different proposal hashes are generated + // Proposals should be different let proposal: T::Proposal = SystemCall::::remark { remark: id_to_remark_data(i, b as usize) }.into(); Collective::::propose( SystemOrigin::Signed(proposer.clone()).into(), @@ -245,7 +247,7 @@ benchmarks_instance_pallet! { Box::new(proposal.clone()), bytes_in_storage, )?; - last_hash = T::Hashing::hash_of(&proposal); + last_bound = T::Preimages::bound(proposal).unwrap(); } let index = p - 1; @@ -255,7 +257,7 @@ benchmarks_instance_pallet! { let approve = true; Collective::::vote( SystemOrigin::Signed(voter.clone()).into(), - last_hash, + last_bound.clone(), index, approve, )?; @@ -264,7 +266,7 @@ benchmarks_instance_pallet! { let approve = true; Collective::::vote( SystemOrigin::Signed(voter.clone()).into(), - last_hash, + last_bound.clone(), index, approve, )?; @@ -277,11 +279,11 @@ benchmarks_instance_pallet! { // Whitelist voter account from further DB operations. let voter_key = frame_system::Account::::hashed_key_for(&voter); frame_benchmarking::benchmarking::add_to_whitelist(voter_key.into()); - }: _(SystemOrigin::Signed(voter), last_hash, index, approve) + }: _(SystemOrigin::Signed(voter), last_bound.clone(), index, approve) verify { // All proposals exist and the last proposal has just been updated. assert_eq!(Collective::::proposals().len(), p as usize); - let voting = Collective::::voting(&last_hash).ok_or("Proposal Missing")?; + let voting = Collective::::voting(&last_bound).ok_or("Proposal Missing")?; assert_eq!(voting.ayes.len(), (m - 3) as usize); assert_eq!(voting.nays.len(), 1); } @@ -310,9 +312,9 @@ benchmarks_instance_pallet! { let threshold = m; // Add previous proposals - let mut last_hash = T::Hash::default(); + let mut last_bound = frame_support::traits::Bounded::Inline(bounded_vec![]); for i in 0 .. p { - // Proposals should be different so that different proposal hashes are generated + // Proposals should be different let proposal: T::Proposal = SystemCall::::remark { remark: id_to_remark_data(i, bytes as usize) }.into(); Collective::::propose( SystemOrigin::Signed(proposer.clone()).into(), @@ -320,7 +322,7 @@ benchmarks_instance_pallet! { Box::new(proposal.clone()), bytes_in_storage, )?; - last_hash = T::Hashing::hash_of(&proposal); + last_bound = T::Preimages::bound(proposal).unwrap(); } let index = p - 1; @@ -330,7 +332,7 @@ benchmarks_instance_pallet! { let approve = true; Collective::::vote( SystemOrigin::Signed(voter.clone()).into(), - last_hash, + last_bound.clone(), index, approve, )?; @@ -339,7 +341,7 @@ benchmarks_instance_pallet! { let approve = true; Collective::::vote( SystemOrigin::Signed(voter.clone()).into(), - last_hash, + last_bound.clone(), index, approve, )?; @@ -350,7 +352,7 @@ benchmarks_instance_pallet! { let approve = false; Collective::::vote( SystemOrigin::Signed(voter.clone()).into(), - last_hash, + last_bound.clone(), index, approve, )?; @@ -358,11 +360,11 @@ benchmarks_instance_pallet! { // Whitelist voter account from further DB operations. let voter_key = frame_system::Account::::hashed_key_for(&voter); frame_benchmarking::benchmarking::add_to_whitelist(voter_key.into()); - }: close(SystemOrigin::Signed(voter), last_hash, index, Weight::MAX, bytes_in_storage) + }: close(SystemOrigin::Signed(voter), last_bound.clone(), index, Weight::MAX, bytes_in_storage) verify { // The last proposal is removed. assert_eq!(Collective::::proposals().len(), (p - 1) as usize); - assert_last_event::(Event::Disapproved { proposal_hash: last_hash }.into()); + assert_has_event::(Event::Disapproved { proposal_bounded: last_bound }.into()); } close_early_approved { @@ -387,9 +389,9 @@ benchmarks_instance_pallet! { let threshold = 2; // Add previous proposals - let mut last_hash = T::Hash::default(); + let mut last_bound = frame_support::traits::Bounded::Inline(bounded_vec![]); for i in 0 .. p { - // Proposals should be different so that different proposal hashes are generated + // Proposals should be different let proposal: T::Proposal = SystemCall::::remark { remark: id_to_remark_data(i, b as usize) }.into(); Collective::::propose( SystemOrigin::Signed(caller.clone()).into(), @@ -397,13 +399,13 @@ benchmarks_instance_pallet! { Box::new(proposal.clone()), bytes_in_storage, )?; - last_hash = T::Hashing::hash_of(&proposal); + last_bound = T::Preimages::bound(proposal).unwrap(); } // Caller switches vote to nay on their own proposal, allowing them to be the deciding approval vote Collective::::vote( SystemOrigin::Signed(caller.clone()).into(), - last_hash, + last_bound.clone(), p - 1, false, )?; @@ -414,7 +416,7 @@ benchmarks_instance_pallet! { let approve = false; Collective::::vote( SystemOrigin::Signed(voter.clone()).into(), - last_hash, + last_bound.clone(), p - 1, approve, )?; @@ -423,7 +425,7 @@ benchmarks_instance_pallet! { // Member zero is the first aye Collective::::vote( SystemOrigin::Signed(members[0].clone()).into(), - last_hash, + last_bound.clone(), p - 1, true, )?; @@ -435,15 +437,15 @@ benchmarks_instance_pallet! { let approve = true; Collective::::vote( SystemOrigin::Signed(caller.clone()).into(), - last_hash, + last_bound.clone(), index, approve, )?; - }: close(SystemOrigin::Signed(caller), last_hash, index, Weight::MAX, bytes_in_storage) + }: close(SystemOrigin::Signed(caller), last_bound.clone(), index, Weight::MAX, bytes_in_storage) verify { // The last proposal is removed. assert_eq!(Collective::::proposals().len(), (p - 1) as usize); - assert_last_event::(Event::Executed { proposal_hash: last_hash, result: Ok(()) }.into()); + assert_has_event::(Event::Executed { proposal_bounded: last_bound, result: Ok(()) }.into()); } close_disapproved { @@ -473,9 +475,9 @@ benchmarks_instance_pallet! { let threshold = m - 1; // Add proposals - let mut last_hash = T::Hash::default(); + let mut last_bound = frame_support::traits::Bounded::Inline(bounded_vec![]); for i in 0 .. p { - // Proposals should be different so that different proposal hashes are generated + // Proposals should be different let proposal: T::Proposal = SystemCall::::remark { remark: id_to_remark_data(i, bytes as usize) }.into(); Collective::::propose( SystemOrigin::Signed(caller.clone()).into(), @@ -483,7 +485,7 @@ benchmarks_instance_pallet! { Box::new(proposal.clone()), bytes_in_storage, )?; - last_hash = T::Hashing::hash_of(&proposal); + last_bound = T::Preimages::bound(proposal).unwrap(); } let index = p - 1; @@ -504,7 +506,7 @@ benchmarks_instance_pallet! { } Collective::::vote( SystemOrigin::Signed(voter.clone()).into(), - last_hash, + last_bound.clone(), index, approve, )?; @@ -513,7 +515,7 @@ benchmarks_instance_pallet! { // caller is prime, prime votes nay Collective::::vote( SystemOrigin::Signed(caller.clone()).into(), - last_hash, + last_bound.clone(), index, false, )?; @@ -522,10 +524,10 @@ benchmarks_instance_pallet! { assert_eq!(Collective::::proposals().len(), p as usize); // Prime nay will close it as disapproved - }: close(SystemOrigin::Signed(caller), last_hash, index, Weight::MAX, bytes_in_storage) + }: close(SystemOrigin::Signed(caller), last_bound.clone(), index, Weight::MAX, bytes_in_storage) verify { assert_eq!(Collective::::proposals().len(), (p - 1) as usize); - assert_last_event::(Event::Disapproved { proposal_hash: last_hash }.into()); + assert_has_event::(Event::Disapproved { proposal_bounded: last_bound }.into()); } close_approved { @@ -555,9 +557,9 @@ benchmarks_instance_pallet! { let threshold = 2; // Add proposals - let mut last_hash = T::Hash::default(); + let mut last_bound = frame_support::traits::Bounded::Inline(bounded_vec![]); for i in 0 .. p { - // Proposals should be different so that different proposal hashes are generated + // Proposals should be different let proposal: T::Proposal = SystemCall::::remark { remark: id_to_remark_data(i, b as usize) }.into(); Collective::::propose( SystemOrigin::Signed(caller.clone()).into(), @@ -565,13 +567,13 @@ benchmarks_instance_pallet! { Box::new(proposal.clone()), bytes_in_storage, )?; - last_hash = T::Hashing::hash_of(&proposal); + last_bound = T::Preimages::bound(proposal).unwrap(); } // The prime member votes aye, so abstentions default to aye. Collective::::vote( SystemOrigin::Signed(caller.clone()).into(), - last_hash, + last_bound.clone(), p - 1, true // Vote aye. )?; @@ -583,7 +585,7 @@ benchmarks_instance_pallet! { let approve = false; Collective::::vote( SystemOrigin::Signed(voter.clone()).into(), - last_hash, + last_bound.clone(), p - 1, approve )?; @@ -594,10 +596,10 @@ benchmarks_instance_pallet! { assert_eq!(Collective::::proposals().len(), p as usize); // Prime aye will close it as approved - }: close(SystemOrigin::Signed(caller), last_hash, p - 1, Weight::MAX, bytes_in_storage) + }: close(SystemOrigin::Signed(caller), last_bound.clone(), p - 1, Weight::MAX, bytes_in_storage) verify { assert_eq!(Collective::::proposals().len(), (p - 1) as usize); - assert_last_event::(Event::Executed { proposal_hash: last_hash, result: Ok(()) }.into()); + assert_has_event::(Event::Executed { proposal_bounded: last_bound, result: Ok(()) }.into()); } disapprove_proposal { @@ -626,9 +628,9 @@ benchmarks_instance_pallet! { let threshold = m - 1; // Add proposals - let mut last_hash = T::Hash::default(); + let mut last_bound = frame_support::traits::Bounded::Inline(bounded_vec![]); for i in 0 .. p { - // Proposals should be different so that different proposal hashes are generated + // Proposals should be different let proposal: T::Proposal = SystemCall::::remark { remark: id_to_remark_data(i, b as usize) }.into(); Collective::::propose( SystemOrigin::Signed(caller.clone()).into(), @@ -636,16 +638,16 @@ benchmarks_instance_pallet! { Box::new(proposal.clone()), bytes_in_storage, )?; - last_hash = T::Hashing::hash_of(&proposal); + last_bound = T::Preimages::bound(proposal).unwrap(); } System::::set_block_number(BlockNumberFor::::max_value()); assert_eq!(Collective::::proposals().len(), p as usize); - }: _(SystemOrigin::Root, last_hash) + }: _(SystemOrigin::Root, last_bound.clone()) verify { assert_eq!(Collective::::proposals().len(), (p - 1) as usize); - assert_last_event::(Event::Disapproved { proposal_hash: last_hash }.into()); + assert_has_event::(Event::Disapproved { proposal_bounded: last_bound }.into()); } impl_benchmark_test_suite!(Collective, crate::tests::ExtBuilder::default().build(), crate::tests::Test); diff --git a/frame/collective/src/lib.rs b/frame/collective/src/lib.rs index 1fa8e8b61efcf..819f1e981b12a 100644 --- a/frame/collective/src/lib.rs +++ b/frame/collective/src/lib.rs @@ -43,8 +43,7 @@ #![recursion_limit = "128"] use scale_info::TypeInfo; -use sp_io::storage; -use sp_runtime::{traits::Hash, RuntimeDebug}; +use sp_runtime::RuntimeDebug; use sp_std::{marker::PhantomData, prelude::*, result}; use frame_support::{ @@ -55,8 +54,8 @@ use frame_support::{ }, ensure, impl_ensure_origin_with_arg_ignoring_arg, traits::{ - Backing, ChangeMembers, EnsureOrigin, EnsureOriginWithArg, Get, GetBacking, - InitializeMembers, StorageVersion, + Backing, Bounded, ChangeMembers, EnsureOrigin, EnsureOriginWithArg, Get, GetBacking, + InitializeMembers, QueryPreimage, StorageVersion, StorePreimage, }, weights::Weight, BoundedVec, CloneNoBound, EqNoBound, Parameter, PartialEqNoBound, @@ -234,6 +233,9 @@ pub mod pallet { /// The maximum weight of a dispatch call that can be proposed and executed. #[pallet::constant] type MaxProposalWeight: Get; + + /// The preimage provider with which we look up call hashes to get the call. + type Preimages: QueryPreimage + StorePreimage; } #[pallet::genesis_config] @@ -267,25 +269,13 @@ pub mod pallet { #[pallet::origin] pub type Origin = RawOrigin<::AccountId, I>; - /// The hashes of the active proposals. - #[pallet::storage] - #[pallet::getter(fn proposals)] - pub type Proposals, I: 'static = ()> = - StorageValue<_, BoundedVec, ValueQuery>; - - /// Actual proposal for a given hash, if it's current. - #[pallet::storage] - #[pallet::getter(fn proposal_of)] - pub type ProposalOf, I: 'static = ()> = - StorageMap<_, Identity, T::Hash, >::Proposal, OptionQuery>; - /// Votes on a given proposal, if it is ongoing. #[pallet::storage] #[pallet::getter(fn voting)] - pub type Voting, I: 'static = ()> = StorageMap< + pub type Voting, I: 'static = ()> = CountedStorageMap< _, Identity, - T::Hash, + Bounded<>::Proposal>, Votes, T::MaxMembers>, OptionQuery, >; @@ -314,28 +304,28 @@ pub mod pallet { Proposed { account: T::AccountId, proposal_index: ProposalIndex, - proposal_hash: T::Hash, + proposal_bounded: Bounded, threshold: MemberCount, }, /// A motion (given hash) has been voted on by given account, leaving /// a tally (yes votes and no votes given respectively as `MemberCount`). Voted { account: T::AccountId, - proposal_hash: T::Hash, + proposal_bounded: Bounded, voted: bool, yes: MemberCount, no: MemberCount, }, /// A motion was approved by the required threshold. - Approved { proposal_hash: T::Hash }, + Approved { proposal_bounded: Bounded }, /// A motion was not approved by the required threshold. - Disapproved { proposal_hash: T::Hash }, + Disapproved { proposal_bounded: Bounded }, /// A motion was executed; result will be `Ok` if it returned without error. - Executed { proposal_hash: T::Hash, result: DispatchResult }, + Executed { proposal_bounded: Bounded, result: DispatchResult }, /// A single member did some action; result will be `Ok` if it returned without error. - MemberExecuted { proposal_hash: T::Hash, result: DispatchResult }, + MemberExecuted { proposal_bounded: Bounded, result: DispatchResult }, /// A proposal was closed because its threshold was reached or after its duration was up. - Closed { proposal_hash: T::Hash, yes: MemberCount, no: MemberCount }, + Closed { proposal_bounded: Bounded, yes: MemberCount, no: MemberCount }, } #[pallet::error] @@ -477,10 +467,10 @@ pub mod pallet { let proposal_len = proposal.encoded_size(); ensure!(proposal_len <= length_bound as usize, Error::::WrongProposalLength); - let proposal_hash = T::Hashing::hash_of(&proposal); + let proposal_bounded = T::Preimages::bound(*proposal.clone())?; let result = proposal.dispatch(RawOrigin::Member(who).into()); Self::deposit_event(Event::MemberExecuted { - proposal_hash, + proposal_bounded, result: result.map(|_| ()).map_err(|e| e.error), }); @@ -573,7 +563,7 @@ pub mod pallet { #[pallet::weight((T::WeightInfo::vote(T::MaxMembers::get()), DispatchClass::Operational))] pub fn vote( origin: OriginFor, - proposal: T::Hash, + proposal: Bounded<>::Proposal>, #[pallet::compact] index: ProposalIndex, approve: bool, ) -> DispatchResultWithPostInfo { @@ -599,7 +589,7 @@ pub mod pallet { /// Must be called by the Root origin. /// /// Parameters: - /// * `proposal_hash`: The hash of the proposal that should be disapproved. + /// * `proposal`: The proposal that should be disapproved. /// /// ## Complexity /// O(P) where P is the number of max proposals @@ -607,10 +597,10 @@ pub mod pallet { #[pallet::weight(T::WeightInfo::disapprove_proposal(T::MaxProposals::get()))] pub fn disapprove_proposal( origin: OriginFor, - proposal_hash: T::Hash, + proposal: Bounded<>::Proposal>, ) -> DispatchResultWithPostInfo { ensure_root(origin)?; - let proposal_count = Self::do_disapprove_proposal(proposal_hash); + let proposal_count = Self::do_disapprove_proposal(proposal); Ok(Some(T::WeightInfo::disapprove_proposal(proposal_count)).into()) } @@ -655,14 +645,14 @@ pub mod pallet { ))] pub fn close( origin: OriginFor, - proposal_hash: T::Hash, + proposal_bounded: Bounded, #[pallet::compact] index: ProposalIndex, proposal_weight_bound: Weight, #[pallet::compact] length_bound: u32, ) -> DispatchResultWithPostInfo { let _ = ensure_signed(origin)?; - Self::do_close(proposal_hash, index, proposal_weight_bound, length_bound) + Self::do_close(proposal_bounded, index, proposal_weight_bound, length_bound) } } } @@ -678,6 +668,15 @@ fn get_result_weight(result: DispatchResultWithPostInfo) -> Option { } impl, I: 'static> Pallet { + /// The active proposals. + pub fn proposals() -> BoundedVec>::Proposal>, T::MaxProposals> { + Voting::::iter() + .map(|(k, _v)| k) + .collect::>() + .try_into() + .expect("proposals should always be less than MaxProposals; qed") + } + /// Check whether `who` is a member of the collective. pub fn is_member(who: &T::AccountId) -> bool { // Note: The dispatchables *do not* use this to check membership so make sure @@ -698,13 +697,15 @@ impl, I: 'static> Pallet { Error::::WrongProposalWeight ); - let proposal_hash = T::Hashing::hash_of(&proposal); - ensure!(!>::contains_key(proposal_hash), Error::::DuplicateProposal); + let proposal_bounded = T::Preimages::bound(*proposal.clone())?; + // Drop it from noted preimages to avoid an unnecessary storage write. + T::Preimages::drop(&proposal_bounded); + ensure!(!>::contains_key(&proposal_bounded), Error::::DuplicateProposal); let seats = Self::members().len() as MemberCount; let result = proposal.dispatch(RawOrigin::Members(1, seats).into()); Self::deposit_event(Event::Executed { - proposal_hash, + proposal_bounded, result: result.map(|_| ()).map_err(|e| e.error), }); Ok((proposal_len as u32, result)) @@ -725,48 +726,42 @@ impl, I: 'static> Pallet { Error::::WrongProposalWeight ); - let proposal_hash = T::Hashing::hash_of(&proposal); - ensure!(!>::contains_key(proposal_hash), Error::::DuplicateProposal); - - let active_proposals = - >::try_mutate(|proposals| -> Result { - proposals.try_push(proposal_hash).map_err(|_| Error::::TooManyProposals)?; - Ok(proposals.len()) - })?; + let proposal_bounded = T::Preimages::bound(*proposal)?; + ensure!(!>::contains_key(&proposal_bounded), Error::::DuplicateProposal); + ensure!(>::count() < T::MaxProposals::get(), Error::::TooManyProposals); let index = Self::proposal_count(); >::mutate(|i| *i += 1); - >::insert(proposal_hash, proposal); let votes = { let end = frame_system::Pallet::::block_number() + T::MotionDuration::get(); Votes { index, threshold, - ayes: sp_core::bounded_vec![], - nays: sp_core::bounded_vec![], + ayes: frame_support::bounded_vec![], + nays: frame_support::bounded_vec![], end, } }; - >::insert(proposal_hash, votes); + >::insert(&proposal_bounded, votes); Self::deposit_event(Event::Proposed { account: who, proposal_index: index, - proposal_hash, + proposal_bounded, threshold, }); - Ok((proposal_len as u32, active_proposals as u32)) + Ok((proposal_len as u32, index.saturating_add(1) as u32)) } /// Add an aye or nay vote for the member to the given proposal, returns true if it's the first /// vote of the member in the motion pub fn do_vote( who: T::AccountId, - proposal: T::Hash, + proposal_bounded: Bounded<>::Proposal>, index: ProposalIndex, approve: bool, ) -> Result { - let mut voting = Self::voting(&proposal).ok_or(Error::::ProposalMissing)?; + let mut voting = Self::voting(&proposal_bounded).ok_or(Error::::ProposalMissing)?; ensure!(voting.index == index, Error::::WrongIndex); let position_yes = voting.ayes.iter().position(|a| a == &who); @@ -803,27 +798,28 @@ impl, I: 'static> Pallet { let yes_votes = voting.ayes.len() as MemberCount; let no_votes = voting.nays.len() as MemberCount; + + Voting::::insert(&proposal_bounded, voting); + Self::deposit_event(Event::Voted { account: who, - proposal_hash: proposal, + proposal_bounded, voted: approve, yes: yes_votes, no: no_votes, }); - Voting::::insert(&proposal, voting); - Ok(is_account_voting_first_time) } /// Close a vote that is either approved, disapproved or whose voting period has ended. pub fn do_close( - proposal_hash: T::Hash, + proposal_bounded: Bounded<>::Proposal>, index: ProposalIndex, proposal_weight_bound: Weight, length_bound: u32, ) -> DispatchResultWithPostInfo { - let voting = Self::voting(&proposal_hash).ok_or(Error::::ProposalMissing)?; + let voting = Self::voting(&proposal_bounded).ok_or(Error::::ProposalMissing)?; ensure!(voting.index == index, Error::::WrongIndex); let mut no_votes = voting.nays.len() as MemberCount; @@ -834,13 +830,17 @@ impl, I: 'static> Pallet { // Allow (dis-)approving the proposal as soon as there are enough votes. if approved { let (proposal, len) = Self::validate_and_get_proposal( - &proposal_hash, + &proposal_bounded, length_bound, proposal_weight_bound, )?; - Self::deposit_event(Event::Closed { proposal_hash, yes: yes_votes, no: no_votes }); + Self::deposit_event(Event::Closed { + proposal_bounded: proposal_bounded.clone(), + yes: yes_votes, + no: no_votes, + }); let (proposal_weight, proposal_count) = - Self::do_approve_proposal(seats, yes_votes, proposal_hash, proposal); + Self::do_approve_proposal(seats, yes_votes, proposal_bounded, proposal); return Ok(( Some( T::WeightInfo::close_early_approved(len as u32, seats, proposal_count) @@ -850,8 +850,12 @@ impl, I: 'static> Pallet { ) .into()) } else if disapproved { - Self::deposit_event(Event::Closed { proposal_hash, yes: yes_votes, no: no_votes }); - let proposal_count = Self::do_disapprove_proposal(proposal_hash); + Self::deposit_event(Event::Closed { + proposal_bounded: proposal_bounded.clone(), + yes: yes_votes, + no: no_votes, + }); + let proposal_count = Self::do_disapprove_proposal(proposal_bounded); return Ok(( Some(T::WeightInfo::close_early_disapproved(seats, proposal_count)), Pays::No, @@ -876,13 +880,17 @@ impl, I: 'static> Pallet { if approved { let (proposal, len) = Self::validate_and_get_proposal( - &proposal_hash, + &proposal_bounded, length_bound, proposal_weight_bound, )?; - Self::deposit_event(Event::Closed { proposal_hash, yes: yes_votes, no: no_votes }); + Self::deposit_event(Event::Closed { + proposal_bounded: proposal_bounded.clone(), + yes: yes_votes, + no: no_votes, + }); let (proposal_weight, proposal_count) = - Self::do_approve_proposal(seats, yes_votes, proposal_hash, proposal); + Self::do_approve_proposal(seats, yes_votes, proposal_bounded, proposal); Ok(( Some( T::WeightInfo::close_approved(len as u32, seats, proposal_count) @@ -892,8 +900,12 @@ impl, I: 'static> Pallet { ) .into()) } else { - Self::deposit_event(Event::Closed { proposal_hash, yes: yes_votes, no: no_votes }); - let proposal_count = Self::do_disapprove_proposal(proposal_hash); + Self::deposit_event(Event::Closed { + proposal_bounded: proposal_bounded.clone(), + yes: yes_votes, + no: no_votes, + }); + let proposal_count = Self::do_disapprove_proposal(proposal_bounded); Ok((Some(T::WeightInfo::close_disapproved(seats, proposal_count)), Pays::No).into()) } } @@ -903,16 +915,18 @@ impl, I: 'static> Pallet { /// Checks the length in storage via `storage::read` which adds an extra `size_of::() == 4` /// to the length. fn validate_and_get_proposal( - hash: &T::Hash, + proposal_bounded: &Bounded<>::Proposal>, length_bound: u32, weight_bound: Weight, ) -> Result<(>::Proposal, usize), DispatchError> { - let key = ProposalOf::::hashed_key_for(hash); - // read the length of the proposal storage entry directly - let proposal_len = - storage::read(&key, &mut [0; 0], 0).ok_or(Error::::ProposalMissing)?; + // read the length of the proposal by using peek + let (proposal, proposal_len) = + T::Preimages::peek(&proposal_bounded).map_err(|_| Error::::ProposalMissing)?; + let proposal_len = proposal_len.unwrap_or_else(|| match proposal_bounded { + Bounded::Inline(data) => data.len() as u32, + _ => panic!("preimage should be inline, or len already given by peek; qed"), + }); ensure!(proposal_len <= length_bound, Error::::WrongProposalLength); - let proposal = ProposalOf::::get(hash).ok_or(Error::::ProposalMissing)?; let proposal_weight = proposal.get_dispatch_info().weight; ensure!(proposal_weight.all_lte(weight_bound), Error::::WrongProposalWeight); Ok((proposal, proposal_len as usize)) @@ -935,41 +949,36 @@ impl, I: 'static> Pallet { fn do_approve_proposal( seats: MemberCount, yes_votes: MemberCount, - proposal_hash: T::Hash, + proposal_bounded: Bounded<>::Proposal>, proposal: >::Proposal, ) -> (Weight, u32) { - Self::deposit_event(Event::Approved { proposal_hash }); + Self::deposit_event(Event::Approved { proposal_bounded: proposal_bounded.clone() }); let dispatch_weight = proposal.get_dispatch_info().weight; let origin = RawOrigin::Members(yes_votes, seats).into(); let result = proposal.dispatch(origin); Self::deposit_event(Event::Executed { - proposal_hash, + proposal_bounded: proposal_bounded.clone(), result: result.map(|_| ()).map_err(|e| e.error), }); // default to the dispatch info weight for safety let proposal_weight = get_result_weight(result).unwrap_or(dispatch_weight); // P1 - let proposal_count = Self::remove_proposal(proposal_hash); + let proposal_count = Self::remove_proposal(&proposal_bounded); (proposal_weight, proposal_count) } /// Removes a proposal from the pallet, and deposit the `Disapproved` event. - pub fn do_disapprove_proposal(proposal_hash: T::Hash) -> u32 { + pub fn do_disapprove_proposal(proposal_bounded: Bounded<>::Proposal>) -> u32 { // disapproved - Self::deposit_event(Event::Disapproved { proposal_hash }); - Self::remove_proposal(proposal_hash) + Self::deposit_event(Event::Disapproved { proposal_bounded: proposal_bounded.clone() }); + Self::remove_proposal(&proposal_bounded) } - // Removes a proposal from the pallet, cleaning up votes and the vector of proposals. - fn remove_proposal(proposal_hash: T::Hash) -> u32 { - // remove proposal and vote - ProposalOf::::remove(&proposal_hash); - Voting::::remove(&proposal_hash); - let num_proposals = Proposals::::mutate(|proposals| { - proposals.retain(|h| h != &proposal_hash); - proposals.len() + 1 // calculate weight based on original length - }); + // Removes a proposal from the pallet, cleaning up votes + fn remove_proposal(proposal_bounded: &Bounded<>::Proposal>) -> u32 { + let num_proposals = Voting::::count(); + Voting::::remove(&proposal_bounded); num_proposals as u32 } @@ -1003,64 +1012,28 @@ impl, I: 'static> Pallet { /// * The prime account must be a member of the collective. #[cfg(any(feature = "try-runtime", test))] fn do_try_state() -> Result<(), TryRuntimeError> { - Self::proposals() - .into_iter() - .try_for_each(|proposal| -> Result<(), TryRuntimeError> { - ensure!( - Self::proposal_of(proposal).is_some(), - "Proposal hash from `Proposals` is not found inside the `ProposalOf` mapping." - ); - Ok(()) - })?; - ensure!( Self::proposals().into_iter().count() <= Self::proposal_count() as usize, "The actual number of proposals is greater than `ProposalCount`" ); - ensure!( - Self::proposals().into_iter().count() == >::iter_keys().count(), - "Proposal count inside `Proposals` is not equal to the proposal count in `ProposalOf`" - ); - Self::proposals() - .into_iter() - .try_for_each(|proposal| -> Result<(), TryRuntimeError> { - if let Some(votes) = Self::voting(proposal) { - let ayes = votes.ayes.len(); - let nays = votes.nays.len(); - - ensure!( - ayes.saturating_add(nays) <= T::MaxMembers::get() as usize, - "The sum of ayes and nays is greater than `MaxMembers`" - ); - } - Ok(()) - })?; - - let mut proposal_indices = vec![]; - Self::proposals() - .into_iter() - .try_for_each(|proposal| -> Result<(), TryRuntimeError> { - if let Some(votes) = Self::voting(proposal) { - let proposal_index = votes.index; - ensure!( - !proposal_indices.contains(&proposal_index), - "The proposal index is not unique." - ); - proposal_indices.push(proposal_index); - } - Ok(()) - })?; - - >::iter_keys().try_for_each( - |proposal_hash| -> Result<(), TryRuntimeError> { - ensure!( - Self::proposals().contains(&proposal_hash), - "`Proposals` doesn't contain the proposal hash from the `Voting` storage map." - ); - Ok(()) - }, - )?; + Voting::::iter().try_fold(vec![], |mut proposal_indices, (_, votes)| { + let ayes = votes.ayes.len(); + let nays = votes.nays.len(); + + ensure!( + ayes.saturating_add(nays) <= T::MaxMembers::get() as usize, + "The sum of ayes and nays is greater than `MaxMembers`" + ); + + let proposal_index = votes.index; + ensure!( + !proposal_indices.contains(&proposal_index), + "The proposal index is not unique." + ); + proposal_indices.push(proposal_index); + Ok::, TryRuntimeError>(proposal_indices) + })?; ensure!( Self::members().len() <= T::MaxMembers::get() as usize, diff --git a/frame/collective/src/migrations/v5.rs b/frame/collective/src/migrations/v5.rs index 0f918263aa447..d9dc196d6ab03 100644 --- a/frame/collective/src/migrations/v5.rs +++ b/frame/collective/src/migrations/v5.rs @@ -20,7 +20,7 @@ use codec::{Decode, Encode}; use frame_support::{ pallet_prelude::{OptionQuery, StorageVersion, TypeInfo, ValueQuery}, sp_runtime::Saturating, - traits::Get, + traits::{Get, StorePreimage}, weights::Weight, BoundedVec, Identity, RuntimeDebug, }; @@ -67,40 +67,6 @@ pub struct OldVotes { pub end: BlockNumber, } -pub fn migrate_proposals, I: 'static>() -> Weight { - // TODO: implement - Weight::zero() -} - -pub fn migrate_votes, I: 'static>() -> Weight { - let mut count = 0u64; - - crate::Voting::::translate::>, _>(|_, vote| { - count.saturating_inc(); - Some(crate::Votes::, >::MaxMembers> { - index: vote.index, - threshold: vote.threshold, - ayes: vote.ayes.try_into().expect( - format!( - "runtime::collective migration failed, ayes for vote {:?} should not overflow", - vote.index - ) - .as_str(), - ), - nays: vote.nays.try_into().expect( - format!( - "runtime::collective migration failed, nays for vote {:?} should not overflow", - vote.index, - ) - .as_str(), - ), - end: vote.end, - }) - }); - - T::DbWeight::get().reads_writes(count, count) -} - pub fn migrate, I: 'static>() -> Weight { let storage_version = StorageVersion::get::>(); log::info!( @@ -110,14 +76,43 @@ pub fn migrate, I: 'static>() -> Weight { ); if storage_version <= 4 { - let weight = Weight::zero(); - - weight.saturating_add(migrate_votes::()); - weight.saturating_add(migrate_proposals::()); + let mut count = 0u64; + + Proposals::::kill(); + + Voting::::drain().for_each(|(hash, vote)| { + count.saturating_inc(); + + let proposal = ProposalOf::::take(hash).expect("proposal should exist"); + let proposal_bounded = >::Preimages::bound(proposal) + .expect("preimage bound failed, the call is too big"); + let vote = + crate::Votes::, >::MaxMembers> { + index: vote.index, + threshold: vote.threshold, + ayes: vote.ayes.try_into().expect( + format!( + "runtime::collective migration failed, ayes for vote {:?} should not overflow", + vote.index + ) + .as_str(), + ), + nays: vote.nays.try_into().expect( + format!( + "runtime::collective migration failed, nays for vote {:?} should not overflow", + vote.index, + ) + .as_str(), + ), + end: vote.end, + }; + + crate::Voting::::insert(proposal_bounded, vote); + }); StorageVersion::new(5).put::>(); - weight + T::DbWeight::get().reads_writes(count, count) } else { log::warn!( target: "runtime::collective", diff --git a/frame/collective/src/tests.rs b/frame/collective/src/tests.rs index 920ba9a7acd18..1fc8cf4b264cb 100644 --- a/frame/collective/src/tests.rs +++ b/frame/collective/src/tests.rs @@ -21,7 +21,7 @@ use frame_support::{ assert_noop, assert_ok, dispatch::Pays, parameter_types, - traits::{ConstU32, ConstU64, StorageVersion}, + traits::{ConstU32, ConstU64, GenesisBuild, StorageVersion}, Hashable, }; use frame_system::{EnsureRoot, EventRecord, Phase}; @@ -43,6 +43,7 @@ frame_support::construct_runtime!( CollectiveMajority: pallet_collective::::{Pallet, Call, Event, Origin, Config}, DefaultCollective: pallet_collective::{Pallet, Call, Event, Origin, Config}, Democracy: mock_democracy::{Pallet, Call, Event}, + Preimage: pallet_preimage } ); @@ -90,6 +91,7 @@ parameter_types! { frame_system::limits::BlockWeights::simple_max(Weight::MAX); pub static MaxProposalWeight: Weight = default_max_proposal_weight(); } + impl frame_system::Config for Test { type BaseCallFilter = frame_support::traits::Everything; type BlockWeights = BlockWeights; @@ -115,6 +117,7 @@ impl frame_system::Config for Test { type OnSetCode = (); type MaxConsumers = ConstU32<16>; } + impl Config for Test { type RuntimeOrigin = RuntimeOrigin; type Proposal = RuntimeCall; @@ -126,7 +129,9 @@ impl Config for Test { type WeightInfo = (); type SetMembersOrigin = EnsureRoot; type MaxProposalWeight = MaxProposalWeight; + type Preimages = Preimage; } + impl Config for Test { type RuntimeOrigin = RuntimeOrigin; type Proposal = RuntimeCall; @@ -138,11 +143,14 @@ impl Config for Test { type WeightInfo = (); type SetMembersOrigin = EnsureRoot; type MaxProposalWeight = MaxProposalWeight; + type Preimages = Preimage; } + impl mock_democracy::Config for Test { type RuntimeEvent = RuntimeEvent; type ExternalMajorityOrigin = EnsureProportionAtLeast; } + impl Config for Test { type RuntimeOrigin = RuntimeOrigin; type Proposal = RuntimeCall; @@ -154,6 +162,16 @@ impl Config for Test { type WeightInfo = (); type SetMembersOrigin = EnsureRoot; type MaxProposalWeight = MaxProposalWeight; + type Preimages = Preimage; +} + +impl pallet_preimage::Config for Test { + type RuntimeEvent = RuntimeEvent; + type WeightInfo = (); + type Currency = (); + type ManagerOrigin = EnsureRoot; + type BaseDeposit = (); + type ByteDeposit = (); } pub struct ExtBuilder { @@ -217,7 +235,7 @@ fn default_max_proposal_weight() -> Weight { fn motions_basic_environment_works() { ExtBuilder::default().build_and_execute(|| { assert_eq!(Collective::members(), vec![1, 2, 3]); - assert_eq!(*Collective::proposals(), Vec::::new()); + assert_eq!(Collective::proposals(), vec![]); }); } @@ -287,7 +305,6 @@ fn close_works() { let proposal = make_proposal(42); let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); let proposal_weight = proposal.get_dispatch_info().weight; - let hash = BlakeTwo256::hash_of(&proposal); assert_ok!(Collective::propose( RuntimeOrigin::signed(1), @@ -295,19 +312,27 @@ fn close_works() { Box::new(proposal.clone()), proposal_len )); - assert_ok!(Collective::vote(RuntimeOrigin::signed(1), hash, 0, true)); - assert_ok!(Collective::vote(RuntimeOrigin::signed(2), hash, 0, true)); + + let proposal_bounded = Preimage::bound(proposal).unwrap(); + assert_ok!(Collective::vote(RuntimeOrigin::signed(1), proposal_bounded.clone(), 0, true)); + assert_ok!(Collective::vote(RuntimeOrigin::signed(2), proposal_bounded.clone(), 0, true)); System::set_block_number(3); assert_noop!( - Collective::close(RuntimeOrigin::signed(4), hash, 0, proposal_weight, proposal_len), + Collective::close( + RuntimeOrigin::signed(4), + proposal_bounded.clone(), + 0, + proposal_weight, + proposal_len + ), Error::::TooEarly ); System::set_block_number(4); assert_ok!(Collective::close( RuntimeOrigin::signed(4), - hash, + proposal_bounded.clone(), 0, proposal_weight, proposal_len @@ -319,31 +344,29 @@ fn close_works() { record(RuntimeEvent::Collective(CollectiveEvent::Proposed { account: 1, proposal_index: 0, - proposal_hash: hash, + proposal_bounded: proposal_bounded.clone(), threshold: 3 })), record(RuntimeEvent::Collective(CollectiveEvent::Voted { account: 1, - proposal_hash: hash, + proposal_bounded: proposal_bounded.clone(), voted: true, yes: 1, no: 0 })), record(RuntimeEvent::Collective(CollectiveEvent::Voted { account: 2, - proposal_hash: hash, + proposal_bounded: proposal_bounded.clone(), voted: true, yes: 2, no: 0 })), record(RuntimeEvent::Collective(CollectiveEvent::Closed { - proposal_hash: hash, + proposal_bounded: proposal_bounded.clone(), yes: 2, no: 1 })), - record(RuntimeEvent::Collective(CollectiveEvent::Disapproved { - proposal_hash: hash - })) + record(RuntimeEvent::Collective(CollectiveEvent::Disapproved { proposal_bounded })) ] ); }); @@ -359,7 +382,6 @@ fn proposal_weight_limit_works_on_approve() { }); let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); let proposal_weight = proposal.get_dispatch_info().weight; - let hash = BlakeTwo256::hash_of(&proposal); // Set 1 as prime voter Prime::::set(Some(1)); assert_ok!(Collective::propose( @@ -368,13 +390,14 @@ fn proposal_weight_limit_works_on_approve() { Box::new(proposal.clone()), proposal_len )); - assert_ok!(Collective::vote(RuntimeOrigin::signed(1), hash, 0, true)); + let proposal_bounded = Preimage::bound(proposal).unwrap(); + assert_ok!(Collective::vote(RuntimeOrigin::signed(1), proposal_bounded.clone(), 0, true)); // With 1's prime vote, this should pass System::set_block_number(4); assert_noop!( Collective::close( RuntimeOrigin::signed(4), - hash, + proposal_bounded.clone(), 0, proposal_weight - Weight::from_parts(100, 0), proposal_len @@ -383,7 +406,7 @@ fn proposal_weight_limit_works_on_approve() { ); assert_ok!(Collective::close( RuntimeOrigin::signed(4), - hash, + proposal_bounded, 0, proposal_weight, proposal_len @@ -401,7 +424,6 @@ fn proposal_weight_limit_ignored_on_disapprove() { }); let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); let proposal_weight = proposal.get_dispatch_info().weight; - let hash = BlakeTwo256::hash_of(&proposal); assert_ok!(Collective::propose( RuntimeOrigin::signed(1), @@ -409,11 +431,13 @@ fn proposal_weight_limit_ignored_on_disapprove() { Box::new(proposal.clone()), proposal_len )); + + let proposal_bounded = Preimage::bound(proposal).unwrap(); // No votes, this proposal wont pass System::set_block_number(4); assert_ok!(Collective::close( RuntimeOrigin::signed(4), - hash, + proposal_bounded, 0, proposal_weight - Weight::from_parts(100, 0), proposal_len @@ -427,7 +451,6 @@ fn close_with_prime_works() { let proposal = make_proposal(42); let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); let proposal_weight = proposal.get_dispatch_info().weight; - let hash = BlakeTwo256::hash_of(&proposal); assert_ok!(Collective::set_members( RuntimeOrigin::root(), vec![1, 2, 3], @@ -441,13 +464,15 @@ fn close_with_prime_works() { Box::new(proposal.clone()), proposal_len )); - assert_ok!(Collective::vote(RuntimeOrigin::signed(1), hash, 0, true)); - assert_ok!(Collective::vote(RuntimeOrigin::signed(2), hash, 0, true)); + + let proposal_bounded = Preimage::bound(proposal).unwrap(); + assert_ok!(Collective::vote(RuntimeOrigin::signed(1), proposal_bounded.clone(), 0, true)); + assert_ok!(Collective::vote(RuntimeOrigin::signed(2), proposal_bounded.clone(), 0, true)); System::set_block_number(4); assert_ok!(Collective::close( RuntimeOrigin::signed(4), - hash, + proposal_bounded.clone(), 0, proposal_weight, proposal_len @@ -459,31 +484,29 @@ fn close_with_prime_works() { record(RuntimeEvent::Collective(CollectiveEvent::Proposed { account: 1, proposal_index: 0, - proposal_hash: hash, + proposal_bounded: proposal_bounded.clone(), threshold: 3 })), record(RuntimeEvent::Collective(CollectiveEvent::Voted { account: 1, - proposal_hash: hash, + proposal_bounded: proposal_bounded.clone(), voted: true, yes: 1, no: 0 })), record(RuntimeEvent::Collective(CollectiveEvent::Voted { account: 2, - proposal_hash: hash, + proposal_bounded: proposal_bounded.clone(), voted: true, yes: 2, no: 0 })), record(RuntimeEvent::Collective(CollectiveEvent::Closed { - proposal_hash: hash, + proposal_bounded: proposal_bounded.clone(), yes: 2, no: 1 })), - record(RuntimeEvent::Collective(CollectiveEvent::Disapproved { - proposal_hash: hash - })) + record(RuntimeEvent::Collective(CollectiveEvent::Disapproved { proposal_bounded })) ] ); }); @@ -495,7 +518,6 @@ fn close_with_voting_prime_works() { let proposal = make_proposal(42); let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); let proposal_weight = proposal.get_dispatch_info().weight; - let hash = BlakeTwo256::hash_of(&proposal); assert_ok!(Collective::set_members( RuntimeOrigin::root(), vec![1, 2, 3], @@ -509,13 +531,15 @@ fn close_with_voting_prime_works() { Box::new(proposal.clone()), proposal_len )); - assert_ok!(Collective::vote(RuntimeOrigin::signed(1), hash, 0, true)); - assert_ok!(Collective::vote(RuntimeOrigin::signed(2), hash, 0, true)); + + let proposal_bounded = Preimage::bound(proposal).unwrap(); + assert_ok!(Collective::vote(RuntimeOrigin::signed(1), proposal_bounded.clone(), 0, true)); + assert_ok!(Collective::vote(RuntimeOrigin::signed(2), proposal_bounded.clone(), 0, true)); System::set_block_number(4); assert_ok!(Collective::close( RuntimeOrigin::signed(4), - hash, + proposal_bounded.clone(), 0, proposal_weight, proposal_len @@ -527,31 +551,33 @@ fn close_with_voting_prime_works() { record(RuntimeEvent::Collective(CollectiveEvent::Proposed { account: 1, proposal_index: 0, - proposal_hash: hash, + proposal_bounded: proposal_bounded.clone(), threshold: 3 })), record(RuntimeEvent::Collective(CollectiveEvent::Voted { account: 1, - proposal_hash: hash, + proposal_bounded: proposal_bounded.clone(), voted: true, yes: 1, no: 0 })), record(RuntimeEvent::Collective(CollectiveEvent::Voted { account: 2, - proposal_hash: hash, + proposal_bounded: proposal_bounded.clone(), voted: true, yes: 2, no: 0 })), record(RuntimeEvent::Collective(CollectiveEvent::Closed { - proposal_hash: hash, + proposal_bounded: proposal_bounded.clone(), yes: 3, no: 0 })), - record(RuntimeEvent::Collective(CollectiveEvent::Approved { proposal_hash: hash })), + record(RuntimeEvent::Collective(CollectiveEvent::Approved { + proposal_bounded: proposal_bounded.clone(), + })), record(RuntimeEvent::Collective(CollectiveEvent::Executed { - proposal_hash: hash, + proposal_bounded, result: Err(DispatchError::BadOrigin) })) ] @@ -565,7 +591,6 @@ fn close_with_no_prime_but_majority_works() { let proposal = make_proposal(42); let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); let proposal_weight = proposal.get_dispatch_info().weight; - let hash = BlakeTwo256::hash_of(&proposal); assert_ok!(CollectiveMajority::set_members( RuntimeOrigin::root(), vec![1, 2, 3, 4, 5], @@ -579,14 +604,31 @@ fn close_with_no_prime_but_majority_works() { Box::new(proposal.clone()), proposal_len )); - assert_ok!(CollectiveMajority::vote(RuntimeOrigin::signed(1), hash, 0, true)); - assert_ok!(CollectiveMajority::vote(RuntimeOrigin::signed(2), hash, 0, true)); - assert_ok!(CollectiveMajority::vote(RuntimeOrigin::signed(3), hash, 0, true)); + + let proposal_bounded = Preimage::bound(proposal).unwrap(); + assert_ok!(CollectiveMajority::vote( + RuntimeOrigin::signed(1), + proposal_bounded.clone(), + 0, + true + )); + assert_ok!(CollectiveMajority::vote( + RuntimeOrigin::signed(2), + proposal_bounded.clone(), + 0, + true + )); + assert_ok!(CollectiveMajority::vote( + RuntimeOrigin::signed(3), + proposal_bounded.clone(), + 0, + true + )); System::set_block_number(4); assert_ok!(CollectiveMajority::close( RuntimeOrigin::signed(4), - hash, + proposal_bounded.clone(), 0, proposal_weight, proposal_len @@ -598,40 +640,40 @@ fn close_with_no_prime_but_majority_works() { record(RuntimeEvent::CollectiveMajority(CollectiveEvent::Proposed { account: 1, proposal_index: 0, - proposal_hash: hash, + proposal_bounded: proposal_bounded.clone(), threshold: 5 })), record(RuntimeEvent::CollectiveMajority(CollectiveEvent::Voted { account: 1, - proposal_hash: hash, + proposal_bounded: proposal_bounded.clone(), voted: true, yes: 1, no: 0 })), record(RuntimeEvent::CollectiveMajority(CollectiveEvent::Voted { account: 2, - proposal_hash: hash, + proposal_bounded: proposal_bounded.clone(), voted: true, yes: 2, no: 0 })), record(RuntimeEvent::CollectiveMajority(CollectiveEvent::Voted { account: 3, - proposal_hash: hash, + proposal_bounded: proposal_bounded.clone(), voted: true, yes: 3, no: 0 })), record(RuntimeEvent::CollectiveMajority(CollectiveEvent::Closed { - proposal_hash: hash, + proposal_bounded: proposal_bounded.clone(), yes: 5, no: 0 })), record(RuntimeEvent::CollectiveMajority(CollectiveEvent::Approved { - proposal_hash: hash + proposal_bounded: proposal_bounded.clone(), })), record(RuntimeEvent::CollectiveMajority(CollectiveEvent::Executed { - proposal_hash: hash, + proposal_bounded, result: Err(DispatchError::BadOrigin) })) ] @@ -644,7 +686,6 @@ fn removal_of_old_voters_votes_works() { ExtBuilder::default().build_and_execute(|| { let proposal = make_proposal(42); let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); - let hash = BlakeTwo256::hash_of(&proposal); let end = 4; assert_ok!(Collective::propose( RuntimeOrigin::signed(1), @@ -652,10 +693,12 @@ fn removal_of_old_voters_votes_works() { Box::new(proposal.clone()), proposal_len )); - assert_ok!(Collective::vote(RuntimeOrigin::signed(1), hash, 0, true)); - assert_ok!(Collective::vote(RuntimeOrigin::signed(2), hash, 0, true)); + + let proposal_bounded = Preimage::bound(proposal).unwrap(); + assert_ok!(Collective::vote(RuntimeOrigin::signed(1), proposal_bounded.clone(), 0, true)); + assert_ok!(Collective::vote(RuntimeOrigin::signed(2), proposal_bounded.clone(), 0, true)); assert_eq!( - Collective::voting(&hash), + Collective::voting(&proposal_bounded), Some(Votes { index: 0, threshold: 3, @@ -666,7 +709,7 @@ fn removal_of_old_voters_votes_works() { ); Collective::change_members_sorted(&[4], &[1], &[2, 3, 4]); assert_eq!( - Collective::voting(&hash), + Collective::voting(&proposal_bounded), Some(Votes { index: 0, threshold: 3, @@ -678,17 +721,18 @@ fn removal_of_old_voters_votes_works() { let proposal = make_proposal(69); let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); - let hash = BlakeTwo256::hash_of(&proposal); assert_ok!(Collective::propose( RuntimeOrigin::signed(2), 2, Box::new(proposal.clone()), proposal_len )); - assert_ok!(Collective::vote(RuntimeOrigin::signed(2), hash, 1, true)); - assert_ok!(Collective::vote(RuntimeOrigin::signed(3), hash, 1, false)); + + let proposal_bounded = Preimage::bound(proposal).unwrap(); + assert_ok!(Collective::vote(RuntimeOrigin::signed(2), proposal_bounded.clone(), 1, true)); + assert_ok!(Collective::vote(RuntimeOrigin::signed(3), proposal_bounded.clone(), 1, false)); assert_eq!( - Collective::voting(&hash), + Collective::voting(&proposal_bounded), Some(Votes { index: 1, threshold: 2, @@ -699,7 +743,7 @@ fn removal_of_old_voters_votes_works() { ); Collective::change_members_sorted(&[], &[3], &[2, 4]); assert_eq!( - Collective::voting(&hash), + Collective::voting(&proposal_bounded), Some(Votes { index: 1, threshold: 2, @@ -716,7 +760,6 @@ fn removal_of_old_voters_votes_works_with_set_members() { ExtBuilder::default().build_and_execute(|| { let proposal = make_proposal(42); let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); - let hash = BlakeTwo256::hash_of(&proposal); let end = 4; assert_ok!(Collective::propose( RuntimeOrigin::signed(1), @@ -724,10 +767,12 @@ fn removal_of_old_voters_votes_works_with_set_members() { Box::new(proposal.clone()), proposal_len )); - assert_ok!(Collective::vote(RuntimeOrigin::signed(1), hash, 0, true)); - assert_ok!(Collective::vote(RuntimeOrigin::signed(2), hash, 0, true)); + + let proposal_bounded = Preimage::bound(proposal).unwrap(); + assert_ok!(Collective::vote(RuntimeOrigin::signed(1), proposal_bounded.clone(), 0, true)); + assert_ok!(Collective::vote(RuntimeOrigin::signed(2), proposal_bounded.clone(), 0, true)); assert_eq!( - Collective::voting(&hash), + Collective::voting(&proposal_bounded), Some(Votes { index: 0, threshold: 3, @@ -743,7 +788,7 @@ fn removal_of_old_voters_votes_works_with_set_members() { MaxMembers::get() )); assert_eq!( - Collective::voting(&hash), + Collective::voting(&proposal_bounded), Some(Votes { index: 0, threshold: 3, @@ -755,17 +800,18 @@ fn removal_of_old_voters_votes_works_with_set_members() { let proposal = make_proposal(69); let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); - let hash = BlakeTwo256::hash_of(&proposal); assert_ok!(Collective::propose( RuntimeOrigin::signed(2), 2, Box::new(proposal.clone()), proposal_len )); - assert_ok!(Collective::vote(RuntimeOrigin::signed(2), hash, 1, true)); - assert_ok!(Collective::vote(RuntimeOrigin::signed(3), hash, 1, false)); + + let proposal_bounded = Preimage::bound(proposal).unwrap(); + assert_ok!(Collective::vote(RuntimeOrigin::signed(2), proposal_bounded.clone(), 1, true)); + assert_ok!(Collective::vote(RuntimeOrigin::signed(3), proposal_bounded.clone(), 1, false)); assert_eq!( - Collective::voting(&hash), + Collective::voting(&proposal_bounded), Some(Votes { index: 1, threshold: 2, @@ -781,7 +827,7 @@ fn removal_of_old_voters_votes_works_with_set_members() { MaxMembers::get() )); assert_eq!( - Collective::voting(&hash), + Collective::voting(&proposal_bounded), Some(Votes { index: 1, threshold: 2, @@ -798,7 +844,6 @@ fn propose_works() { ExtBuilder::default().build_and_execute(|| { let proposal = make_proposal(42); let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); - let hash = proposal.blake2_256().into(); let end = 4; assert_ok!(Collective::propose( RuntimeOrigin::signed(1), @@ -806,10 +851,10 @@ fn propose_works() { Box::new(proposal.clone()), proposal_len )); - assert_eq!(*Collective::proposals(), vec![hash]); - assert_eq!(Collective::proposal_of(&hash), Some(proposal)); + let proposal_bounded = Preimage::bound(proposal).unwrap(); + assert_eq!(Collective::proposals(), vec![proposal_bounded.clone()]); assert_eq!( - Collective::voting(&hash), + Collective::voting(&proposal_bounded), Some(Votes { index: 0, threshold: 3, ayes: bounded_vec![], nays: bounded_vec![], end }) ); @@ -818,7 +863,7 @@ fn propose_works() { vec![record(RuntimeEvent::Collective(CollectiveEvent::Proposed { account: 1, proposal_index: 0, - proposal_hash: hash, + proposal_bounded, threshold: 3 }))] ); @@ -868,29 +913,29 @@ fn correct_validate_and_get_proposal() { length )); - let hash = BlakeTwo256::hash_of(&proposal); let weight = proposal.get_dispatch_info().weight; + let proposal_bounded = Preimage::bound(proposal.clone()).unwrap(); assert_noop!( Collective::validate_and_get_proposal( - &BlakeTwo256::hash_of(&vec![3; 4]), + &Bounded::Inline(bounded_vec![3; 4]), length, weight ), Error::::ProposalMissing ); assert_noop!( - Collective::validate_and_get_proposal(&hash, length - 2, weight), + Collective::validate_and_get_proposal(&proposal_bounded, length - 2, weight), Error::::WrongProposalLength ); assert_noop!( Collective::validate_and_get_proposal( - &hash, + &proposal_bounded, length, weight - Weight::from_parts(10, 0) ), Error::::WrongProposalWeight ); - let res = Collective::validate_and_get_proposal(&hash, length, weight); + let res = Collective::validate_and_get_proposal(&proposal_bounded, length, weight); assert_ok!(res.clone()); let (retrieved_proposal, len) = res.unwrap(); assert_eq!(length as usize, len); @@ -920,15 +965,15 @@ fn motions_ignoring_non_collective_votes_works() { ExtBuilder::default().build_and_execute(|| { let proposal = make_proposal(42); let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); - let hash: H256 = proposal.blake2_256().into(); assert_ok!(Collective::propose( RuntimeOrigin::signed(1), 3, Box::new(proposal.clone()), proposal_len )); + let proposal_bounded = Preimage::bound(proposal).unwrap(); assert_noop!( - Collective::vote(RuntimeOrigin::signed(42), hash, 0, true), + Collective::vote(RuntimeOrigin::signed(42), proposal_bounded, 0, true), Error::::NotMember, ); }); @@ -940,15 +985,15 @@ fn motions_ignoring_bad_index_collective_vote_works() { System::set_block_number(3); let proposal = make_proposal(42); let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); - let hash: H256 = proposal.blake2_256().into(); assert_ok!(Collective::propose( RuntimeOrigin::signed(1), 3, Box::new(proposal.clone()), proposal_len )); + let proposal_bounded = Preimage::bound(proposal).unwrap(); assert_noop!( - Collective::vote(RuntimeOrigin::signed(2), hash, 1, true), + Collective::vote(RuntimeOrigin::signed(2), proposal_bounded, 1, true), Error::::WrongIndex, ); }); @@ -959,7 +1004,6 @@ fn motions_vote_after_works() { ExtBuilder::default().build_and_execute(|| { let proposal = make_proposal(42); let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); - let hash: H256 = proposal.blake2_256().into(); let end = 4; assert_ok!(Collective::propose( RuntimeOrigin::signed(1), @@ -967,15 +1011,16 @@ fn motions_vote_after_works() { Box::new(proposal.clone()), proposal_len )); - // Initially there a no votes when the motion is proposed. + let proposal_bounded = Preimage::bound(proposal).unwrap(); + // Initially there are no votes when the motion is proposed. assert_eq!( - Collective::voting(&hash), + Collective::voting(&proposal_bounded), Some(Votes { index: 0, threshold: 2, ayes: bounded_vec![], nays: bounded_vec![], end }) ); // Cast first aye vote. - assert_ok!(Collective::vote(RuntimeOrigin::signed(1), hash, 0, true)); + assert_ok!(Collective::vote(RuntimeOrigin::signed(1), proposal_bounded.clone(), 0, true)); assert_eq!( - Collective::voting(&hash), + Collective::voting(&proposal_bounded), Some(Votes { index: 0, threshold: 2, @@ -986,13 +1031,13 @@ fn motions_vote_after_works() { ); // Try to cast a duplicate aye vote. assert_noop!( - Collective::vote(RuntimeOrigin::signed(1), hash, 0, true), + Collective::vote(RuntimeOrigin::signed(1), proposal_bounded.clone(), 0, true), Error::::DuplicateVote, ); // Cast a nay vote. - assert_ok!(Collective::vote(RuntimeOrigin::signed(1), hash, 0, false)); + assert_ok!(Collective::vote(RuntimeOrigin::signed(1), proposal_bounded.clone(), 0, false)); assert_eq!( - Collective::voting(&hash), + Collective::voting(&proposal_bounded), Some(Votes { index: 0, threshold: 2, @@ -1003,7 +1048,7 @@ fn motions_vote_after_works() { ); // Try to cast a duplicate nay vote. assert_noop!( - Collective::vote(RuntimeOrigin::signed(1), hash, 0, false), + Collective::vote(RuntimeOrigin::signed(1), proposal_bounded.clone(), 0, false), Error::::DuplicateVote, ); @@ -1013,19 +1058,19 @@ fn motions_vote_after_works() { record(RuntimeEvent::Collective(CollectiveEvent::Proposed { account: 1, proposal_index: 0, - proposal_hash: hash, + proposal_bounded: proposal_bounded.clone(), threshold: 2 })), record(RuntimeEvent::Collective(CollectiveEvent::Voted { account: 1, - proposal_hash: hash, + proposal_bounded: proposal_bounded.clone(), voted: true, yes: 1, no: 0 })), record(RuntimeEvent::Collective(CollectiveEvent::Voted { account: 1, - proposal_hash: hash, + proposal_bounded, voted: false, yes: 0, no: 1 @@ -1040,7 +1085,6 @@ fn motions_all_first_vote_free_works() { ExtBuilder::default().build_and_execute(|| { let proposal = make_proposal(42); let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); - let hash: H256 = proposal.blake2_256().into(); let end = 4; assert_ok!(Collective::propose( RuntimeOrigin::signed(1), @@ -1048,47 +1092,58 @@ fn motions_all_first_vote_free_works() { Box::new(proposal.clone()), proposal_len, )); + let proposal_bounded = Preimage::bound(proposal.clone()).unwrap(); assert_eq!( - Collective::voting(&hash), + Collective::voting(&proposal_bounded), Some(Votes { index: 0, threshold: 2, ayes: bounded_vec![], nays: bounded_vec![], end }) ); // For the motion, acc 2's first vote, expecting Ok with Pays::No. let vote_rval: DispatchResultWithPostInfo = - Collective::vote(RuntimeOrigin::signed(2), hash, 0, true); + Collective::vote(RuntimeOrigin::signed(2), proposal_bounded.clone(), 0, true); assert_eq!(vote_rval.unwrap().pays_fee, Pays::No); // Duplicate vote, expecting error with Pays::Yes. let vote_rval: DispatchResultWithPostInfo = - Collective::vote(RuntimeOrigin::signed(2), hash, 0, true); + Collective::vote(RuntimeOrigin::signed(2), proposal_bounded.clone(), 0, true); assert_eq!(vote_rval.unwrap_err().post_info.pays_fee, Pays::Yes); // Modifying vote, expecting ok with Pays::Yes. let vote_rval: DispatchResultWithPostInfo = - Collective::vote(RuntimeOrigin::signed(2), hash, 0, false); + Collective::vote(RuntimeOrigin::signed(2), proposal_bounded.clone(), 0, false); assert_eq!(vote_rval.unwrap().pays_fee, Pays::Yes); // For the motion, acc 3's first vote, expecting Ok with Pays::No. let vote_rval: DispatchResultWithPostInfo = - Collective::vote(RuntimeOrigin::signed(3), hash, 0, true); + Collective::vote(RuntimeOrigin::signed(3), proposal_bounded.clone(), 0, true); assert_eq!(vote_rval.unwrap().pays_fee, Pays::No); // acc 3 modify the vote, expecting Ok with Pays::Yes. let vote_rval: DispatchResultWithPostInfo = - Collective::vote(RuntimeOrigin::signed(3), hash, 0, false); + Collective::vote(RuntimeOrigin::signed(3), proposal_bounded.clone(), 0, false); assert_eq!(vote_rval.unwrap().pays_fee, Pays::Yes); // Test close() Extrincis | Check DispatchResultWithPostInfo with Pay Info let proposal_weight = proposal.get_dispatch_info().weight; - let close_rval: DispatchResultWithPostInfo = - Collective::close(RuntimeOrigin::signed(2), hash, 0, proposal_weight, proposal_len); + let close_rval: DispatchResultWithPostInfo = Collective::close( + RuntimeOrigin::signed(2), + proposal_bounded.clone(), + 0, + proposal_weight, + proposal_len, + ); assert_eq!(close_rval.unwrap().pays_fee, Pays::No); // trying to close the proposal, which is already closed. // Expecting error "ProposalMissing" with Pays::Yes - let close_rval: DispatchResultWithPostInfo = - Collective::close(RuntimeOrigin::signed(2), hash, 0, proposal_weight, proposal_len); + let close_rval: DispatchResultWithPostInfo = Collective::close( + RuntimeOrigin::signed(2), + proposal_bounded, + 0, + proposal_weight, + proposal_len, + ); assert_eq!(close_rval.unwrap_err().post_info.pays_fee, Pays::Yes); }); } @@ -1099,29 +1154,30 @@ fn motions_reproposing_disapproved_works() { let proposal = make_proposal(42); let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); let proposal_weight = proposal.get_dispatch_info().weight; - let hash: H256 = proposal.blake2_256().into(); assert_ok!(Collective::propose( RuntimeOrigin::signed(1), 3, Box::new(proposal.clone()), proposal_len )); - assert_ok!(Collective::vote(RuntimeOrigin::signed(2), hash, 0, false)); + + let proposal_bounded = Preimage::bound(proposal.clone()).unwrap(); + assert_ok!(Collective::vote(RuntimeOrigin::signed(2), proposal_bounded.clone(), 0, false)); assert_ok!(Collective::close( RuntimeOrigin::signed(2), - hash, + proposal_bounded.clone(), 0, proposal_weight, proposal_len )); - assert_eq!(*Collective::proposals(), vec![]); + assert_eq!(Collective::proposals(), vec![]); assert_ok!(Collective::propose( RuntimeOrigin::signed(1), 2, - Box::new(proposal.clone()), + Box::new(proposal), proposal_len )); - assert_eq!(*Collective::proposals(), vec![hash]); + assert_eq!(Collective::proposals(), vec![proposal_bounded]); }); } @@ -1131,7 +1187,6 @@ fn motions_approval_with_enough_votes_and_lower_voting_threshold_works() { let proposal = RuntimeCall::Democracy(mock_democracy::Call::external_propose_majority {}); let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); let proposal_weight = proposal.get_dispatch_info().weight; - let hash: H256 = proposal.blake2_256().into(); // The voting threshold is 2, but the required votes for `ExternalMajorityOrigin` is 3. // The proposal will be executed regardless of the voting threshold // as long as we have enough yes votes. @@ -1143,11 +1198,12 @@ fn motions_approval_with_enough_votes_and_lower_voting_threshold_works() { Box::new(proposal.clone()), proposal_len )); - assert_ok!(Collective::vote(RuntimeOrigin::signed(1), hash, 0, true)); - assert_ok!(Collective::vote(RuntimeOrigin::signed(2), hash, 0, true)); + let proposal_bounded = Preimage::bound(proposal.clone()).unwrap(); + assert_ok!(Collective::vote(RuntimeOrigin::signed(1), proposal_bounded.clone(), 0, true)); + assert_ok!(Collective::vote(RuntimeOrigin::signed(2), proposal_bounded.clone(), 0, true)); assert_ok!(Collective::close( RuntimeOrigin::signed(2), - hash, + proposal_bounded.clone(), 0, proposal_weight, proposal_len @@ -1158,31 +1214,33 @@ fn motions_approval_with_enough_votes_and_lower_voting_threshold_works() { record(RuntimeEvent::Collective(CollectiveEvent::Proposed { account: 1, proposal_index: 0, - proposal_hash: hash, + proposal_bounded: proposal_bounded.clone(), threshold: 2 })), record(RuntimeEvent::Collective(CollectiveEvent::Voted { account: 1, - proposal_hash: hash, + proposal_bounded: proposal_bounded.clone(), voted: true, yes: 1, no: 0 })), record(RuntimeEvent::Collective(CollectiveEvent::Voted { account: 2, - proposal_hash: hash, + proposal_bounded: proposal_bounded.clone(), voted: true, yes: 2, no: 0 })), record(RuntimeEvent::Collective(CollectiveEvent::Closed { - proposal_hash: hash, + proposal_bounded: proposal_bounded.clone(), yes: 2, no: 0 })), - record(RuntimeEvent::Collective(CollectiveEvent::Approved { proposal_hash: hash })), + record(RuntimeEvent::Collective(CollectiveEvent::Approved { + proposal_bounded: proposal_bounded.clone(), + })), record(RuntimeEvent::Collective(CollectiveEvent::Executed { - proposal_hash: hash, + proposal_bounded: proposal_bounded.clone(), result: Err(DispatchError::BadOrigin) })), ] @@ -1194,15 +1252,15 @@ fn motions_approval_with_enough_votes_and_lower_voting_threshold_works() { assert_ok!(Collective::propose( RuntimeOrigin::signed(1), 2, - Box::new(proposal.clone()), + Box::new(proposal), proposal_len )); - assert_ok!(Collective::vote(RuntimeOrigin::signed(1), hash, 1, true)); - assert_ok!(Collective::vote(RuntimeOrigin::signed(2), hash, 1, true)); - assert_ok!(Collective::vote(RuntimeOrigin::signed(3), hash, 1, true)); + assert_ok!(Collective::vote(RuntimeOrigin::signed(1), proposal_bounded.clone(), 1, true)); + assert_ok!(Collective::vote(RuntimeOrigin::signed(2), proposal_bounded.clone(), 1, true)); + assert_ok!(Collective::vote(RuntimeOrigin::signed(3), proposal_bounded.clone(), 1, true)); assert_ok!(Collective::close( RuntimeOrigin::signed(2), - hash, + proposal_bounded.clone(), 1, proposal_weight, proposal_len @@ -1213,41 +1271,43 @@ fn motions_approval_with_enough_votes_and_lower_voting_threshold_works() { record(RuntimeEvent::Collective(CollectiveEvent::Proposed { account: 1, proposal_index: 1, - proposal_hash: hash, + proposal_bounded: proposal_bounded.clone(), threshold: 2 })), record(RuntimeEvent::Collective(CollectiveEvent::Voted { account: 1, - proposal_hash: hash, + proposal_bounded: proposal_bounded.clone(), voted: true, yes: 1, no: 0 })), record(RuntimeEvent::Collective(CollectiveEvent::Voted { account: 2, - proposal_hash: hash, + proposal_bounded: proposal_bounded.clone(), voted: true, yes: 2, no: 0 })), record(RuntimeEvent::Collective(CollectiveEvent::Voted { account: 3, - proposal_hash: hash, + proposal_bounded: proposal_bounded.clone(), voted: true, yes: 3, no: 0 })), record(RuntimeEvent::Collective(CollectiveEvent::Closed { - proposal_hash: hash, + proposal_bounded: proposal_bounded.clone(), yes: 3, no: 0 })), - record(RuntimeEvent::Collective(CollectiveEvent::Approved { proposal_hash: hash })), + record(RuntimeEvent::Collective(CollectiveEvent::Approved { + proposal_bounded: proposal_bounded.clone(), + })), record(RuntimeEvent::Democracy( mock_democracy::pallet::Event::::ExternalProposed )), record(RuntimeEvent::Collective(CollectiveEvent::Executed { - proposal_hash: hash, + proposal_bounded, result: Ok(()) })), ] @@ -1261,18 +1321,18 @@ fn motions_disapproval_works() { let proposal = make_proposal(42); let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); let proposal_weight = proposal.get_dispatch_info().weight; - let hash: H256 = proposal.blake2_256().into(); assert_ok!(Collective::propose( RuntimeOrigin::signed(1), 3, Box::new(proposal.clone()), proposal_len )); - assert_ok!(Collective::vote(RuntimeOrigin::signed(1), hash, 0, true)); - assert_ok!(Collective::vote(RuntimeOrigin::signed(2), hash, 0, false)); + let proposal_bounded = Preimage::bound(proposal).unwrap(); + assert_ok!(Collective::vote(RuntimeOrigin::signed(1), proposal_bounded.clone(), 0, true)); + assert_ok!(Collective::vote(RuntimeOrigin::signed(2), proposal_bounded.clone(), 0, false)); assert_ok!(Collective::close( RuntimeOrigin::signed(2), - hash, + proposal_bounded.clone(), 0, proposal_weight, proposal_len @@ -1284,31 +1344,29 @@ fn motions_disapproval_works() { record(RuntimeEvent::Collective(CollectiveEvent::Proposed { account: 1, proposal_index: 0, - proposal_hash: hash, + proposal_bounded: proposal_bounded.clone(), threshold: 3 })), record(RuntimeEvent::Collective(CollectiveEvent::Voted { account: 1, - proposal_hash: hash, + proposal_bounded: proposal_bounded.clone(), voted: true, yes: 1, no: 0 })), record(RuntimeEvent::Collective(CollectiveEvent::Voted { account: 2, - proposal_hash: hash, + proposal_bounded: proposal_bounded.clone(), voted: false, yes: 1, no: 1 })), record(RuntimeEvent::Collective(CollectiveEvent::Closed { - proposal_hash: hash, + proposal_bounded: proposal_bounded.clone(), yes: 1, no: 1 })), - record(RuntimeEvent::Collective(CollectiveEvent::Disapproved { - proposal_hash: hash - })), + record(RuntimeEvent::Collective(CollectiveEvent::Disapproved { proposal_bounded })), ] ); }); @@ -1320,18 +1378,18 @@ fn motions_approval_works() { let proposal = make_proposal(42); let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); let proposal_weight = proposal.get_dispatch_info().weight; - let hash: H256 = proposal.blake2_256().into(); assert_ok!(Collective::propose( RuntimeOrigin::signed(1), 2, Box::new(proposal.clone()), proposal_len )); - assert_ok!(Collective::vote(RuntimeOrigin::signed(1), hash, 0, true)); - assert_ok!(Collective::vote(RuntimeOrigin::signed(2), hash, 0, true)); + let proposal_bounded = Preimage::bound(proposal).unwrap(); + assert_ok!(Collective::vote(RuntimeOrigin::signed(1), proposal_bounded.clone(), 0, true)); + assert_ok!(Collective::vote(RuntimeOrigin::signed(2), proposal_bounded.clone(), 0, true)); assert_ok!(Collective::close( RuntimeOrigin::signed(2), - hash, + proposal_bounded.clone(), 0, proposal_weight, proposal_len @@ -1343,31 +1401,33 @@ fn motions_approval_works() { record(RuntimeEvent::Collective(CollectiveEvent::Proposed { account: 1, proposal_index: 0, - proposal_hash: hash, + proposal_bounded: proposal_bounded.clone(), threshold: 2 })), record(RuntimeEvent::Collective(CollectiveEvent::Voted { account: 1, - proposal_hash: hash, + proposal_bounded: proposal_bounded.clone(), voted: true, yes: 1, no: 0 })), record(RuntimeEvent::Collective(CollectiveEvent::Voted { account: 2, - proposal_hash: hash, + proposal_bounded: proposal_bounded.clone(), voted: true, yes: 2, no: 0 })), record(RuntimeEvent::Collective(CollectiveEvent::Closed { - proposal_hash: hash, + proposal_bounded: proposal_bounded.clone(), yes: 2, no: 0 })), - record(RuntimeEvent::Collective(CollectiveEvent::Approved { proposal_hash: hash })), + record(RuntimeEvent::Collective(CollectiveEvent::Approved { + proposal_bounded: proposal_bounded.clone(), + })), record(RuntimeEvent::Collective(CollectiveEvent::Executed { - proposal_hash: hash, + proposal_bounded, result: Err(DispatchError::BadOrigin) })), ] @@ -1381,19 +1441,19 @@ fn motion_with_no_votes_closes_with_disapproval() { let proposal = make_proposal(42); let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); let proposal_weight = proposal.get_dispatch_info().weight; - let hash: H256 = proposal.blake2_256().into(); assert_ok!(Collective::propose( RuntimeOrigin::signed(1), 3, Box::new(proposal.clone()), proposal_len )); + let proposal_bounded = Preimage::bound(proposal).unwrap(); assert_eq!( System::events()[0], record(RuntimeEvent::Collective(CollectiveEvent::Proposed { account: 1, proposal_index: 0, - proposal_hash: hash, + proposal_bounded: proposal_bounded.clone(), threshold: 3 })) ); @@ -1401,7 +1461,13 @@ fn motion_with_no_votes_closes_with_disapproval() { // Closing the motion too early is not possible because it has neither // an approving or disapproving simple majority due to the lack of votes. assert_noop!( - Collective::close(RuntimeOrigin::signed(2), hash, 0, proposal_weight, proposal_len), + Collective::close( + RuntimeOrigin::signed(2), + proposal_bounded.clone(), + 0, + proposal_weight, + proposal_len + ), Error::::TooEarly ); @@ -1411,7 +1477,7 @@ fn motion_with_no_votes_closes_with_disapproval() { // we can successfully close the motion. assert_ok!(Collective::close( RuntimeOrigin::signed(2), - hash, + proposal_bounded.clone(), 0, proposal_weight, proposal_len @@ -1421,14 +1487,14 @@ fn motion_with_no_votes_closes_with_disapproval() { assert_eq!( System::events()[1], record(RuntimeEvent::Collective(CollectiveEvent::Closed { - proposal_hash: hash, + proposal_bounded: proposal_bounded.clone(), yes: 0, no: 3 })) ); assert_eq!( System::events()[2], - record(RuntimeEvent::Collective(CollectiveEvent::Disapproved { proposal_hash: hash })) + record(RuntimeEvent::Collective(CollectiveEvent::Disapproved { proposal_bounded })) ); }) } @@ -1441,30 +1507,48 @@ fn close_disapprove_does_not_care_about_weight_or_len() { ExtBuilder::default().build_and_execute(|| { let proposal = make_proposal(42); let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); - let hash: H256 = proposal.blake2_256().into(); assert_ok!(Collective::propose( RuntimeOrigin::signed(1), 2, Box::new(proposal.clone()), proposal_len )); + let proposal_bounded = Preimage::bound(proposal).unwrap(); // First we make the proposal succeed - assert_ok!(Collective::vote(RuntimeOrigin::signed(1), hash, 0, true)); - assert_ok!(Collective::vote(RuntimeOrigin::signed(2), hash, 0, true)); + assert_ok!(Collective::vote(RuntimeOrigin::signed(1), proposal_bounded.clone(), 0, true)); + assert_ok!(Collective::vote(RuntimeOrigin::signed(2), proposal_bounded.clone(), 0, true)); // It will not close with bad weight/len information assert_noop!( - Collective::close(RuntimeOrigin::signed(2), hash, 0, Weight::zero(), 0), + Collective::close( + RuntimeOrigin::signed(2), + proposal_bounded.clone(), + 0, + Weight::zero(), + 0 + ), Error::::WrongProposalLength, ); assert_noop!( - Collective::close(RuntimeOrigin::signed(2), hash, 0, Weight::zero(), proposal_len), + Collective::close( + RuntimeOrigin::signed(2), + proposal_bounded.clone(), + 0, + Weight::zero(), + proposal_len + ), Error::::WrongProposalWeight, ); // Now we make the proposal fail - assert_ok!(Collective::vote(RuntimeOrigin::signed(1), hash, 0, false)); - assert_ok!(Collective::vote(RuntimeOrigin::signed(2), hash, 0, false)); + assert_ok!(Collective::vote(RuntimeOrigin::signed(1), proposal_bounded.clone(), 0, false)); + assert_ok!(Collective::vote(RuntimeOrigin::signed(2), proposal_bounded.clone(), 0, false)); // It can close even if the weight/len information is bad - assert_ok!(Collective::close(RuntimeOrigin::signed(2), hash, 0, Weight::zero(), 0)); + assert_ok!(Collective::close( + RuntimeOrigin::signed(2), + proposal_bounded, + 0, + Weight::zero(), + 0 + )); }) } @@ -1473,44 +1557,45 @@ fn disapprove_proposal_works() { ExtBuilder::default().build_and_execute(|| { let proposal = make_proposal(42); let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); - let hash: H256 = proposal.blake2_256().into(); assert_ok!(Collective::propose( RuntimeOrigin::signed(1), 2, Box::new(proposal.clone()), proposal_len )); + let proposal_bounded = Preimage::bound(proposal).unwrap(); // Proposal would normally succeed - assert_ok!(Collective::vote(RuntimeOrigin::signed(1), hash, 0, true)); - assert_ok!(Collective::vote(RuntimeOrigin::signed(2), hash, 0, true)); + assert_ok!(Collective::vote(RuntimeOrigin::signed(1), proposal_bounded.clone(), 0, true)); + assert_ok!(Collective::vote(RuntimeOrigin::signed(2), proposal_bounded.clone(), 0, true)); // But Root can disapprove and remove it anyway - assert_ok!(Collective::disapprove_proposal(RuntimeOrigin::root(), hash)); + assert_ok!(Collective::disapprove_proposal( + RuntimeOrigin::root(), + proposal_bounded.clone() + )); assert_eq!( System::events(), vec![ record(RuntimeEvent::Collective(CollectiveEvent::Proposed { account: 1, proposal_index: 0, - proposal_hash: hash, + proposal_bounded: proposal_bounded.clone(), threshold: 2 })), record(RuntimeEvent::Collective(CollectiveEvent::Voted { account: 1, - proposal_hash: hash, + proposal_bounded: proposal_bounded.clone(), voted: true, yes: 1, no: 0 })), record(RuntimeEvent::Collective(CollectiveEvent::Voted { account: 2, - proposal_hash: hash, + proposal_bounded: proposal_bounded.clone(), voted: true, yes: 2, no: 0 })), - record(RuntimeEvent::Collective(CollectiveEvent::Disapproved { - proposal_hash: hash - })), + record(RuntimeEvent::Collective(CollectiveEvent::Disapproved { proposal_bounded })), ] ); }) @@ -1586,6 +1671,7 @@ fn migration_v4() { #[test] fn migration_v5() { ExtBuilder::default().build_and_execute(|| { + use sp_runtime::traits::Hash; assert_eq!(StorageVersion::get::>(), 4); // Create a proposal. @@ -1596,7 +1682,7 @@ fn migration_v5() { crate::migrations::v5::Proposals::::put::>(bounded_vec![ proposal_hash ]); - crate::migrations::v5::ProposalOf::::insert(proposal_hash, proposal); + crate::migrations::v5::ProposalOf::::insert(proposal_hash, proposal.clone()); // Create some votes. let ayes: Vec<::AccountId> = @@ -1618,12 +1704,14 @@ fn migration_v5() { // Check that the storage version is updated. assert_eq!(StorageVersion::get::>(), 5); + let proposal_bounded = Preimage::bound(proposal).unwrap(); + // Check that the vote is there and is bounded. assert_eq!( - crate::Voting::::get(proposal_hash).unwrap().ayes, - Vec::< + crate::Voting::::get(proposal_bounded).unwrap().ayes, + BoundedVec::< ::AccountId, - // ::MaxMembers + ::MaxMembers >::try_from(ayes) .unwrap() ); From 69dca687fea1512993506861c32341c8f50715c4 Mon Sep 17 00:00:00 2001 From: muraca Date: Wed, 14 Jun 2023 17:17:37 +0200 Subject: [PATCH 3/8] update mock & test for pallet utility Signed-off-by: muraca --- Cargo.lock | 1 + frame/collective/src/tests.rs | 1 - frame/utility/Cargo.toml | 1 + frame/utility/src/tests.rs | 44 ++++++++++++++++++++++------------- 4 files changed, 30 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 21f00b2f58ccf..0ad5d558cec49 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7611,6 +7611,7 @@ dependencies = [ "frame-system", "pallet-balances", "pallet-collective", + "pallet-preimage", "pallet-root-testing", "pallet-timestamp", "parity-scale-codec", diff --git a/frame/collective/src/tests.rs b/frame/collective/src/tests.rs index 1fc8cf4b264cb..eea2f19da7efd 100644 --- a/frame/collective/src/tests.rs +++ b/frame/collective/src/tests.rs @@ -22,7 +22,6 @@ use frame_support::{ dispatch::Pays, parameter_types, traits::{ConstU32, ConstU64, GenesisBuild, StorageVersion}, - Hashable, }; use frame_system::{EnsureRoot, EventRecord, Phase}; use sp_core::{bounded_vec, H256}; diff --git a/frame/utility/Cargo.toml b/frame/utility/Cargo.toml index 6c5f7fa48a88d..11891e442beb5 100644 --- a/frame/utility/Cargo.toml +++ b/frame/utility/Cargo.toml @@ -29,6 +29,7 @@ pallet-root-testing = { version = "1.0.0-dev", path = "../root-testing" } pallet-collective = { version = "4.0.0-dev", path = "../collective" } pallet-timestamp = { version = "4.0.0-dev", path = "../timestamp" } sp-core = { version = "21.0.0", path = "../../primitives/core" } +pallet-preimage = { version = "4.0.0-dev", path = "../preimage" } [features] default = ["std"] diff --git a/frame/utility/src/tests.rs b/frame/utility/src/tests.rs index c2fd3a851c319..d7e532030b15c 100644 --- a/frame/utility/src/tests.rs +++ b/frame/utility/src/tests.rs @@ -27,13 +27,14 @@ use frame_support::{ dispatch::{DispatchError, DispatchErrorWithPostInfo, Dispatchable, Pays}, error::BadOrigin, parameter_types, storage, - traits::{ConstU32, ConstU64, Contains}, + traits::{ConstU32, ConstU64, Contains, GenesisBuild, StorePreimage}, weights::Weight, }; use pallet_collective::{EnsureProportionAtLeast, Instance1}; use sp_core::H256; use sp_runtime::{ - traits::{BlakeTwo256, Hash, IdentityLookup}, + testing::Header, + traits::{BlakeTwo256, IdentityLookup}, BuildStorage, TokenError, }; @@ -137,6 +138,7 @@ frame_support::construct_runtime!( Utility: utility::{Pallet, Call, Event}, Example: example::{Pallet, Call}, Democracy: mock_democracy::{Pallet, Call, Event}, + Preimage: pallet_preimage, } ); @@ -218,10 +220,20 @@ impl pallet_collective::Config for Test { type WeightInfo = (); type SetMembersOrigin = frame_system::EnsureRoot; type MaxProposalWeight = MaxProposalWeight; + type Preimages = Preimage; } impl example::Config for Test {} +impl pallet_preimage::Config for Test { + type RuntimeEvent = RuntimeEvent; + type WeightInfo = (); + type Currency = (); + type ManagerOrigin = frame_system::EnsureRoot; + type BaseDeposit = (); + type ByteDeposit = (); +} + pub struct TestBaseCallFilter; impl Contains for TestBaseCallFilter { fn contains(c: &RuntimeCall) -> bool { @@ -831,7 +843,6 @@ fn batch_works_with_council_origin() { }); let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); let proposal_weight = proposal.get_dispatch_info().weight; - let hash = BlakeTwo256::hash_of(&proposal); assert_ok!(Council::propose( RuntimeOrigin::signed(1), @@ -840,21 +851,22 @@ fn batch_works_with_council_origin() { proposal_len )); - assert_ok!(Council::vote(RuntimeOrigin::signed(1), hash, 0, true)); - assert_ok!(Council::vote(RuntimeOrigin::signed(2), hash, 0, true)); - assert_ok!(Council::vote(RuntimeOrigin::signed(3), hash, 0, true)); + let proposal_bounded = Preimage::bound(proposal).unwrap(); + assert_ok!(Council::vote(RuntimeOrigin::signed(1), proposal_bounded.clone(), 0, true)); + assert_ok!(Council::vote(RuntimeOrigin::signed(2), proposal_bounded.clone(), 0, true)); + assert_ok!(Council::vote(RuntimeOrigin::signed(3), proposal_bounded.clone(), 0, true)); System::set_block_number(4); assert_ok!(Council::close( RuntimeOrigin::signed(4), - hash, + proposal_bounded.clone(), 0, proposal_weight, proposal_len )); - System::assert_last_event(RuntimeEvent::Council(pallet_collective::Event::Executed { - proposal_hash: hash, + System::assert_has_event(RuntimeEvent::Council(pallet_collective::Event::Executed { + proposal_bounded, result: Ok(()), })); }) @@ -868,7 +880,6 @@ fn force_batch_works_with_council_origin() { }); let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); let proposal_weight = proposal.get_dispatch_info().weight; - let hash = BlakeTwo256::hash_of(&proposal); assert_ok!(Council::propose( RuntimeOrigin::signed(1), @@ -877,21 +888,22 @@ fn force_batch_works_with_council_origin() { proposal_len )); - assert_ok!(Council::vote(RuntimeOrigin::signed(1), hash, 0, true)); - assert_ok!(Council::vote(RuntimeOrigin::signed(2), hash, 0, true)); - assert_ok!(Council::vote(RuntimeOrigin::signed(3), hash, 0, true)); + let proposal_bounded = Preimage::bound(proposal).unwrap(); + assert_ok!(Council::vote(RuntimeOrigin::signed(1), proposal_bounded.clone(), 0, true)); + assert_ok!(Council::vote(RuntimeOrigin::signed(2), proposal_bounded.clone(), 0, true)); + assert_ok!(Council::vote(RuntimeOrigin::signed(3), proposal_bounded.clone(), 0, true)); System::set_block_number(4); assert_ok!(Council::close( RuntimeOrigin::signed(4), - hash, + proposal_bounded.clone(), 0, proposal_weight, proposal_len )); - System::assert_last_event(RuntimeEvent::Council(pallet_collective::Event::Executed { - proposal_hash: hash, + System::assert_has_event(RuntimeEvent::Council(pallet_collective::Event::Executed { + proposal_bounded, result: Ok(()), })); }) From 1ebede2ca6919f9bb4d863bee807aeb3d6b77902 Mon Sep 17 00:00:00 2001 From: muraca Date: Thu, 15 Jun 2023 15:44:30 +0200 Subject: [PATCH 4/8] update trait ProposalProvider, mock & test for pallet alliance Signed-off-by: muraca --- Cargo.lock | 1 + frame/alliance/Cargo.toml | 2 + frame/alliance/src/benchmarking.rs | 91 ++++++++------- frame/alliance/src/lib.rs | 29 ++--- frame/alliance/src/mock.rs | 45 +++++--- frame/alliance/src/tests.rs | 175 ++++++++++++++--------------- frame/collective/src/lib.rs | 11 ++ 7 files changed, 192 insertions(+), 162 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0ad5d558cec49..c32d55feb0857 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5946,6 +5946,7 @@ dependencies = [ "pallet-balances", "pallet-collective", "pallet-identity", + "pallet-preimage", "parity-scale-codec", "scale-info", "sp-core", diff --git a/frame/alliance/Cargo.toml b/frame/alliance/Cargo.toml index b411df760f616..0d8414e7ac435 100644 --- a/frame/alliance/Cargo.toml +++ b/frame/alliance/Cargo.toml @@ -37,6 +37,7 @@ array-bytes = "6.1" sp-core-hashing = { version = "9.0.0", default-features = false, path = "../../primitives/core/hashing" } pallet-balances = { version = "4.0.0-dev", path = "../balances" } pallet-collective = { version = "4.0.0-dev", path = "../collective" } +pallet-preimage = { version = "4.0.0-dev", path = "../preimage" } [features] default = ["std"] @@ -54,6 +55,7 @@ std = [ "frame-support/std", "frame-system/std", "pallet-identity/std", + "pallet-preimage/std", ] runtime-benchmarks = [ "array-bytes", diff --git a/frame/alliance/src/benchmarking.rs b/frame/alliance/src/benchmarking.rs index eb32c6c466c91..5b9f9c73b5694 100644 --- a/frame/alliance/src/benchmarking.rs +++ b/frame/alliance/src/benchmarking.rs @@ -17,7 +17,7 @@ //! Alliance pallet benchmarking. -use sp_runtime::traits::{Bounded, Hash, StaticLookup}; +use sp_runtime::traits::{Bounded, StaticLookup}; use sp_std::{ cmp, convert::{TryFrom, TryInto}, @@ -26,7 +26,10 @@ use sp_std::{ }; use frame_benchmarking::v1::{account, benchmarks_instance_pallet, BenchmarkError}; -use frame_support::traits::{EnsureOrigin, Get, UnfilteredDispatchable}; +use frame_support::{ + bounded_vec, + traits::{EnsureOrigin, Get, UnfilteredDispatchable}, +}; use frame_system::{pallet_prelude::BlockNumberFor, Pallet as System, RawOrigin as SystemOrigin}; use super::{Call as AllianceCall, Pallet as Alliance, *}; @@ -116,7 +119,7 @@ benchmarks_instance_pallet! { let threshold = m; // Add previous proposals. for i in 0 .. p - 1 { - // Proposals should be different so that different proposal hashes are generated + // Proposals should be different let proposal: T::Proposal = AllianceCall::::set_rule { rule: rule(vec![i as u8; b as usize]) }.into(); @@ -133,8 +136,8 @@ benchmarks_instance_pallet! { }: propose(SystemOrigin::Signed(proposer.clone()), threshold, Box::new(proposal.clone()), bytes_in_storage) verify { // New proposal is recorded - let proposal_hash = T::Hashing::hash_of(&proposal); - assert_eq!(T::ProposalProvider::proposal_of(proposal_hash), Some(proposal)); + let proposal_bounded = T::ProposalProvider::bound_proposal(proposal.clone()).unwrap(); + assert_eq!(T::ProposalProvider::proposal_of(proposal_bounded), Some(proposal)); } vote { @@ -161,9 +164,9 @@ benchmarks_instance_pallet! { let threshold = m - 1; // Add previous proposals - let mut last_hash = T::Hash::default(); + let mut last_bound = frame_support::traits::Bounded::Inline(bounded_vec![]); for i in 0 .. p { - // Proposals should be different so that different proposal hashes are generated + // Proposals should be different let proposal: T::Proposal = AllianceCall::::set_rule { rule: rule(vec![i as u8; b as usize]) }.into(); @@ -173,7 +176,7 @@ benchmarks_instance_pallet! { Box::new(proposal.clone()), b, )?; - last_hash = T::Hashing::hash_of(&proposal); + last_bound = T::ProposalProvider::bound_proposal(proposal).unwrap(); } let index = p - 1; @@ -182,7 +185,7 @@ benchmarks_instance_pallet! { let voter = &members[j as usize]; Alliance::::vote( SystemOrigin::Signed(voter.clone()).into(), - last_hash.clone(), + last_bound.clone(), index, true, )?; @@ -192,7 +195,7 @@ benchmarks_instance_pallet! { // Voter votes aye without resolving the vote. Alliance::::vote( SystemOrigin::Signed(voter.clone()).into(), - last_hash.clone(), + last_bound.clone(), index, true, )?; @@ -203,7 +206,7 @@ benchmarks_instance_pallet! { // Whitelist voter account from further DB operations. let voter_key = frame_system::Account::::hashed_key_for(&voter); frame_benchmarking::benchmarking::add_to_whitelist(voter_key.into()); - }: _(SystemOrigin::Signed(voter), last_hash.clone(), index, approve) + }: _(SystemOrigin::Signed(voter), last_bound.clone(), index, approve) verify { } @@ -233,9 +236,9 @@ benchmarks_instance_pallet! { let threshold = m; // Add previous proposals - let mut last_hash = T::Hash::default(); + let mut last_bound = frame_support::traits::Bounded::Inline(bounded_vec![]); for i in 0 .. p { - // Proposals should be different so that different proposal hashes are generated + // Proposals should be different let proposal: T::Proposal = AllianceCall::::set_rule { rule: rule(vec![i as u8; bytes as usize]) }.into(); @@ -245,8 +248,7 @@ benchmarks_instance_pallet! { Box::new(proposal.clone()), bytes_in_storage, )?; - last_hash = T::Hashing::hash_of(&proposal); - assert_eq!(T::ProposalProvider::proposal_of(last_hash), Some(proposal)); + last_bound = T::ProposalProvider::bound_proposal(proposal).unwrap(); } let index = p - 1; @@ -255,7 +257,7 @@ benchmarks_instance_pallet! { let voter = &members[j as usize]; Alliance::::vote( SystemOrigin::Signed(voter.clone()).into(), - last_hash.clone(), + last_bound.clone(), index, true, )?; @@ -264,7 +266,7 @@ benchmarks_instance_pallet! { // Voter votes aye without resolving the vote. Alliance::::vote( SystemOrigin::Signed(voter.clone()).into(), - last_hash.clone(), + last_bound.clone(), index, true, )?; @@ -272,7 +274,7 @@ benchmarks_instance_pallet! { // Voter switches vote to nay, which kills the vote Alliance::::vote( SystemOrigin::Signed(voter.clone()).into(), - last_hash.clone(), + last_bound.clone(), index, false, )?; @@ -280,10 +282,10 @@ benchmarks_instance_pallet! { // Whitelist voter account from further DB operations. let voter_key = frame_system::Account::::hashed_key_for(&voter); frame_benchmarking::benchmarking::add_to_whitelist(voter_key.into()); - }: close(SystemOrigin::Signed(voter), last_hash.clone(), index, Weight::MAX, bytes_in_storage) + }: close(SystemOrigin::Signed(voter), last_bound.clone(), index, Weight::MAX, bytes_in_storage) verify { // The last proposal is removed. - assert_eq!(T::ProposalProvider::proposal_of(last_hash), None); + assert_eq!(T::ProposalProvider::proposal_of(last_bound), None); } close_early_approved { @@ -312,9 +314,9 @@ benchmarks_instance_pallet! { let threshold = 2; // Add previous proposals - let mut last_hash = T::Hash::default(); + let mut last_bound = frame_support::traits::Bounded::Inline(bounded_vec![]); for i in 0 .. p { - // Proposals should be different so that different proposal hashes are generated + // Proposals should be different let proposal: T::Proposal = AllianceCall::::set_rule { rule: rule(vec![i as u8; b as usize]) }.into(); @@ -324,15 +326,14 @@ benchmarks_instance_pallet! { Box::new(proposal.clone()), bytes_in_storage, )?; - last_hash = T::Hashing::hash_of(&proposal); - assert_eq!(T::ProposalProvider::proposal_of(last_hash), Some(proposal)); + last_bound = T::ProposalProvider::bound_proposal(proposal).unwrap(); } let index = p - 1; // Caller switches vote to nay on their own proposal, allowing them to be the deciding approval vote Alliance::::vote( SystemOrigin::Signed(proposer.clone()).into(), - last_hash.clone(), + last_bound.clone(), index, false, )?; @@ -342,7 +343,7 @@ benchmarks_instance_pallet! { let voter = &members[j as usize]; Alliance::::vote( SystemOrigin::Signed(voter.clone()).into(), - last_hash.clone(), + last_bound.clone(), index, false, )?; @@ -351,7 +352,7 @@ benchmarks_instance_pallet! { // Member zero is the first aye Alliance::::vote( SystemOrigin::Signed(members[0].clone()).into(), - last_hash.clone(), + last_bound.clone(), index, true, )?; @@ -360,14 +361,14 @@ benchmarks_instance_pallet! { // Caller switches vote to aye, which passes the vote Alliance::::vote( SystemOrigin::Signed(voter.clone()).into(), - last_hash.clone(), + last_bound.clone(), index, true, )?; - }: close(SystemOrigin::Signed(voter), last_hash.clone(), index, Weight::MAX, bytes_in_storage) + }: close(SystemOrigin::Signed(voter), last_bound.clone(), index, Weight::MAX, bytes_in_storage) verify { // The last proposal is removed. - assert_eq!(T::ProposalProvider::proposal_of(last_hash), None); + assert_eq!(T::ProposalProvider::proposal_of(last_bound), None); } close_disapproved { @@ -396,9 +397,9 @@ benchmarks_instance_pallet! { let threshold = m - 1; // Add proposals - let mut last_hash = T::Hash::default(); + let mut last_bound = frame_support::traits::Bounded::Inline(bounded_vec![]); for i in 0 .. p { - // Proposals should be different so that different proposal hashes are generated + // Proposals should be different let proposal: T::Proposal = AllianceCall::::set_rule { rule: rule(vec![i as u8; bytes as usize]) }.into(); @@ -408,8 +409,7 @@ benchmarks_instance_pallet! { Box::new(proposal.clone()), bytes_in_storage, )?; - last_hash = T::Hashing::hash_of(&proposal); - assert_eq!(T::ProposalProvider::proposal_of(last_hash), Some(proposal)); + last_bound = T::ProposalProvider::bound_proposal(proposal).unwrap(); } let index = p - 1; @@ -419,7 +419,7 @@ benchmarks_instance_pallet! { let voter = &members[j as usize]; Alliance::::vote( SystemOrigin::Signed(voter.clone()).into(), - last_hash.clone(), + last_bound.clone(), index, true, )?; @@ -427,17 +427,17 @@ benchmarks_instance_pallet! { Alliance::::vote( SystemOrigin::Signed(voter.clone()).into(), - last_hash.clone(), + last_bound.clone(), index, false, )?; System::::set_block_number(BlockNumberFor::::max_value()); - }: close(SystemOrigin::Signed(voter), last_hash.clone(), index, Weight::MAX, bytes_in_storage) + }: close(SystemOrigin::Signed(voter), last_bound.clone(), index, Weight::MAX, bytes_in_storage) verify { // The last proposal is removed. - assert_eq!(T::ProposalProvider::proposal_of(last_hash), None); + assert_eq!(T::ProposalProvider::proposal_of(last_bound), None); } close_approved { @@ -466,9 +466,9 @@ benchmarks_instance_pallet! { let threshold = 2; // Add proposals - let mut last_hash = T::Hash::default(); + let mut last_bound = frame_support::traits::Bounded::Inline(bounded_vec![]); for i in 0 .. p { - // Proposals should be different so that different proposal hashes are generated + // Proposals should be different let proposal: T::Proposal = AllianceCall::::set_rule { rule: rule(vec![i as u8; b as usize]) }.into(); @@ -478,14 +478,13 @@ benchmarks_instance_pallet! { Box::new(proposal.clone()), bytes_in_storage, )?; - last_hash = T::Hashing::hash_of(&proposal); - assert_eq!(T::ProposalProvider::proposal_of(last_hash), Some(proposal)); + last_bound = T::ProposalProvider::bound_proposal(proposal).unwrap(); } // The prime member votes aye, so abstentions default to aye. Alliance::::vote( SystemOrigin::Signed(proposer.clone()).into(), - last_hash.clone(), + last_bound.clone(), p - 1, true // Vote aye. )?; @@ -497,7 +496,7 @@ benchmarks_instance_pallet! { let voter = &members[j as usize]; Alliance::::vote( SystemOrigin::Signed(voter.clone()).into(), - last_hash.clone(), + last_bound.clone(), index, false )?; @@ -506,10 +505,10 @@ benchmarks_instance_pallet! { // caller is prime, prime already votes aye by creating the proposal System::::set_block_number(BlockNumberFor::::max_value()); - }: close(SystemOrigin::Signed(voter), last_hash.clone(), index, Weight::MAX, bytes_in_storage) + }: close(SystemOrigin::Signed(voter), last_bound.clone(), index, Weight::MAX, bytes_in_storage) verify { // The last proposal is removed. - assert_eq!(T::ProposalProvider::proposal_of(last_hash), None); + assert_eq!(T::ProposalProvider::proposal_of(last_bound), None); } init_members { diff --git a/frame/alliance/src/lib.rs b/frame/alliance/src/lib.rs index c103f975f23be..f366a048a0959 100644 --- a/frame/alliance/src/lib.rs +++ b/frame/alliance/src/lib.rs @@ -111,7 +111,7 @@ use frame_support::{ ensure, scale_info::TypeInfo, traits::{ - ChangeMembers, Currency, Get, InitializeMembers, IsSubType, OnUnbalanced, + Bounded, ChangeMembers, Currency, Get, InitializeMembers, IsSubType, OnUnbalanced, ReservableCurrency, }, weights::Weight, @@ -166,7 +166,7 @@ impl IdentityVerifier for () { } /// The provider of a collective action interface, for example an instance of `pallet-collective`. -pub trait ProposalProvider { +pub trait ProposalProvider { /// Add a new proposal. /// Returns a proposal length and active proposals count if successful. fn propose_proposal( @@ -180,21 +180,24 @@ pub trait ProposalProvider { /// Returns true if the sender votes first time if successful. fn vote_proposal( who: AccountId, - proposal: Hash, + proposal_bounded: Bounded, index: ProposalIndex, approve: bool, ) -> Result; /// Close a proposal that is either approved, disapproved, or whose voting period has ended. fn close_proposal( - proposal_hash: Hash, + proposal_bounded: Bounded, index: ProposalIndex, proposal_weight_bound: Weight, length_bound: u32, ) -> DispatchResultWithPostInfo; - /// Return a proposal of the given hash. - fn proposal_of(proposal_hash: Hash) -> Option; + /// Return an active proposal by its Bounded counterpart. + fn proposal_of(proposal_bounded: Bounded) -> Option; + + /// Return the Bounded counterpart of a proposal. + fn bound_proposal(proposal: Proposal) -> Result, DispatchError>; } /// The various roles that a member can hold. @@ -265,7 +268,7 @@ pub mod pallet { type IdentityVerifier: IdentityVerifier; /// The provider of the proposal operation. - type ProposalProvider: ProposalProvider; + type ProposalProvider: ProposalProvider; /// Maximum number of proposals allowed to be active in parallel. type MaxProposals: Get; @@ -523,14 +526,14 @@ pub mod pallet { #[pallet::weight(T::WeightInfo::vote(T::MaxFellows::get()))] pub fn vote( origin: OriginFor, - proposal: T::Hash, + proposal_bounded: Bounded<>::Proposal>, #[pallet::compact] index: ProposalIndex, approve: bool, ) -> DispatchResult { let who = ensure_signed(origin)?; ensure!(Self::has_voting_rights(&who), Error::::NoVotingRights); - T::ProposalProvider::vote_proposal(who, proposal, index, approve)?; + T::ProposalProvider::vote_proposal(who, proposal_bounded, index, approve)?; Ok(()) } @@ -893,7 +896,7 @@ pub mod pallet { })] pub fn close( origin: OriginFor, - proposal_hash: T::Hash, + proposal_bounded: Bounded<>::Proposal>, #[pallet::compact] index: ProposalIndex, proposal_weight_bound: Weight, #[pallet::compact] length_bound: u32, @@ -901,7 +904,7 @@ pub mod pallet { let who = ensure_signed(origin)?; ensure!(Self::has_voting_rights(&who), Error::::NoVotingRights); - Self::do_close(proposal_hash, index, proposal_weight_bound, length_bound) + Self::do_close(proposal_bounded, index, proposal_weight_bound, length_bound) } /// Abdicate one's position as a voting member and just be an Ally. May be used by Fellows @@ -1110,13 +1113,13 @@ impl, I: 'static> Pallet { } fn do_close( - proposal_hash: T::Hash, + proposal_bounded: Bounded<>::Proposal>, index: ProposalIndex, proposal_weight_bound: Weight, length_bound: u32, ) -> DispatchResultWithPostInfo { let info = T::ProposalProvider::close_proposal( - proposal_hash, + proposal_bounded, index, proposal_weight_bound, length_bound, diff --git a/frame/alliance/src/mock.rs b/frame/alliance/src/mock.rs index f04e7e414ed94..6b04ae5e7dd6d 100644 --- a/frame/alliance/src/mock.rs +++ b/frame/alliance/src/mock.rs @@ -27,7 +27,7 @@ use sp_std::convert::{TryFrom, TryInto}; pub use frame_support::{ assert_noop, assert_ok, ord_parameter_types, parameter_types, - traits::{EitherOfDiverse, SortedMembers}, + traits::{EitherOfDiverse, GenesisBuild, QueryPreimage, SortedMembers, StorePreimage}, BoundedVec, }; use frame_system::{EnsureRoot, EnsureSignedBy}; @@ -91,6 +91,15 @@ impl pallet_balances::Config for Test { type MaxHolds = (); } +impl pallet_preimage::Config for Test { + type RuntimeEvent = RuntimeEvent; + type WeightInfo = (); + type Currency = (); + type ManagerOrigin = EnsureRoot; + type BaseDeposit = (); + type ByteDeposit = (); +} + const MOTION_DURATION_IN_BLOCKS: BlockNumber = 3; parameter_types! { @@ -111,6 +120,7 @@ impl pallet_collective::Config for Test { type WeightInfo = (); type SetMembersOrigin = EnsureRoot; type MaxProposalWeight = MaxProposalWeight; + type Preimages = Preimage; } parameter_types! { @@ -170,7 +180,7 @@ impl IdentityVerifier for AllianceIdentityVerifier { } pub struct AllianceProposalProvider; -impl ProposalProvider for AllianceProposalProvider { +impl ProposalProvider for AllianceProposalProvider { fn propose_proposal( who: AccountId, threshold: u32, @@ -182,24 +192,33 @@ impl ProposalProvider for AllianceProposalProvider fn vote_proposal( who: AccountId, - proposal: H256, + proposal_bounded: Bounded, index: ProposalIndex, approve: bool, ) -> Result { - AllianceMotion::do_vote(who, proposal, index, approve) + AllianceMotion::do_vote(who, proposal_bounded, index, approve) } fn close_proposal( - proposal_hash: H256, + proposal_bounded: Bounded, proposal_index: ProposalIndex, proposal_weight_bound: Weight, length_bound: u32, ) -> DispatchResultWithPostInfo { - AllianceMotion::do_close(proposal_hash, proposal_index, proposal_weight_bound, length_bound) + AllianceMotion::do_close( + proposal_bounded, + proposal_index, + proposal_weight_bound, + length_bound, + ) + } + + fn proposal_of(proposal_bounded: Bounded) -> Option { + AllianceMotion::proposal_of(proposal_bounded) } - fn proposal_of(proposal_hash: H256) -> Option { - AllianceMotion::proposal_of(proposal_hash) + fn bound_proposal(proposal: RuntimeCall) -> Result, DispatchError> { + Preimage::bound(proposal) } } @@ -246,6 +265,7 @@ frame_support::construct_runtime!( Identity: pallet_identity, AllianceMotion: pallet_collective::, Alliance: pallet_alliance, + Preimage: pallet_preimage } ); @@ -372,18 +392,17 @@ pub fn test_cid() -> Cid { Cid::new_v0(result) } -pub fn make_remark_proposal(value: u64) -> (RuntimeCall, u32, H256) { +pub fn make_remark_proposal(value: u64) -> (RuntimeCall, u32) { make_proposal(RuntimeCall::System(frame_system::Call::remark { remark: value.encode() })) } -pub fn make_kick_member_proposal(who: AccountId) -> (RuntimeCall, u32, H256) { +pub fn make_kick_member_proposal(who: AccountId) -> (RuntimeCall, u32) { make_proposal(RuntimeCall::Alliance(pallet_alliance::Call::kick_member { who })) } -pub fn make_proposal(proposal: RuntimeCall) -> (RuntimeCall, u32, H256) { +pub fn make_proposal(proposal: RuntimeCall) -> (RuntimeCall, u32) { let len: u32 = proposal.using_encoded(|p| p.len() as u32); - let hash = BlakeTwo256::hash_of(&proposal); - (proposal, len, hash) + (proposal, len) } pub fn is_fellow(who: &AccountId) -> bool { diff --git a/frame/alliance/src/tests.rs b/frame/alliance/src/tests.rs index 098fd86bbae1e..c3b7ebd20012a 100644 --- a/frame/alliance/src/tests.rs +++ b/frame/alliance/src/tests.rs @@ -17,8 +17,7 @@ //! Tests for the alliance pallet. -use frame_support::{assert_noop, assert_ok, error::BadOrigin}; -use frame_system::{EventRecord, Phase}; +use frame_support::{assert_noop, assert_ok, error::BadOrigin, traits::StorePreimage}; use super::*; use crate::mock::*; @@ -28,7 +27,7 @@ type AllianceMotionEvent = pallet_collective::Event, I: 'static> Pallet { .expect("proposals should always be less than MaxProposals; qed") } + /// The bounded counterpart of an active proposal. + pub fn proposal_of( + proposal_bounded: Bounded<>::Proposal>, + ) -> Option<>::Proposal> { + match Voting::::contains_key(&proposal_bounded) { + false => None, + true => T::Preimages::peek(&proposal_bounded).ok().map(|x| x.0), + } + } + /// Check whether `who` is a member of the collective. pub fn is_member(who: &T::AccountId) -> bool { // Note: The dispatchables *do not* use this to check membership so make sure @@ -979,6 +989,7 @@ impl, I: 'static> Pallet { fn remove_proposal(proposal_bounded: &Bounded<>::Proposal>) -> u32 { let num_proposals = Voting::::count(); Voting::::remove(&proposal_bounded); + T::Preimages::drop(&proposal_bounded); num_proposals as u32 } From 54cf9e67805c41512a20ad3301dfb28cd06b2b50 Mon Sep 17 00:00:00 2001 From: muraca Date: Thu, 15 Jun 2023 21:59:32 +0200 Subject: [PATCH 5/8] updated kitchensink runtime Signed-off-by: muraca --- Cargo.lock | 1004 +++++++++++++------------ bin/node/runtime/src/impls.rs | 27 +- bin/node/runtime/src/lib.rs | 3 + frame/alliance/src/benchmarking.rs | 15 +- frame/collective/src/benchmarking.rs | 13 +- frame/collective/src/lib.rs | 4 +- frame/collective/src/migrations/v5.rs | 22 +- frame/utility/src/tests.rs | 1 - 8 files changed, 576 insertions(+), 513 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c32d55feb0857..62f3a7f5bc44b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -21,6 +21,15 @@ dependencies = [ "gimli", ] +[[package]] +name = "addr2line" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4fa78e18c64fce05e902adecd7a5eed15a5e0a3439f7b0e169f0252214865e3" +dependencies = [ + "gimli", +] + [[package]] name = "adler" version = "1.0.2" @@ -81,9 +90,9 @@ dependencies = [ [[package]] name = "aes" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "433cfd6710c9986c576a25ca913c39d66a6474107b406f34f91d4a8923395241" +checksum = "ac1f845298e95f983ff1944b728ae08b8cebab80d684f0a832ed0fc74dfa27e2" dependencies = [ "cfg-if", "cipher 0.4.4", @@ -111,7 +120,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "209b47e8954a928e1d72e86eca7000ebb6655fe1436d33eefc2201cad027e237" dependencies = [ "aead 0.5.2", - "aes 0.8.2", + "aes 0.8.3", "cipher 0.4.4", "ctr 0.9.2", "ghash 0.5.0", @@ -144,7 +153,7 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" dependencies = [ - "getrandom 0.2.9", + "getrandom 0.2.10", "once_cell", "version_check", ] @@ -156,7 +165,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" dependencies = [ "cfg-if", - "getrandom 0.2.9", + "getrandom 0.2.10", "once_cell", "version_check", ] @@ -226,15 +235,15 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d" +checksum = "3a30da5c5f2d5e72842e00bcb57657162cdabef0931f40e2deb9b4140440cecd" [[package]] name = "anstyle-parse" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e765fd216e48e067936442276d1d57399e37bce53c264d6fefbe298080cb57ee" +checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333" dependencies = [ "utf8parse", ] @@ -302,7 +311,7 @@ dependencies = [ "serde", "serde_derive", "serde_json", - "sha2 0.10.6", + "sha2 0.10.7", ] [[package]] @@ -531,9 +540,9 @@ checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" [[package]] name = "arrayvec" -version = "0.7.2" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" [[package]] name = "asn1-rs" @@ -548,7 +557,7 @@ dependencies = [ "num-traits", "rusticata-macros", "thiserror", - "time 0.3.21", + "time 0.3.22", ] [[package]] @@ -564,7 +573,7 @@ dependencies = [ "num-traits", "rusticata-macros", "thiserror", - "time 0.3.21", + "time 0.3.22", ] [[package]] @@ -625,9 +634,9 @@ checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" [[package]] name = "async-channel" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf46fee83e5ccffc220104713af3292ff9bc7c64c7de289f66dae8e38d826833" +checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" dependencies = [ "concurrent-queue", "event-listener", @@ -648,9 +657,9 @@ dependencies = [ "log", "parking", "polling", - "rustix 0.37.19", + "rustix 0.37.23", "slab", - "socket2", + "socket2 0.4.9", "waker-fn", ] @@ -671,7 +680,7 @@ checksum = "0e97ce7de6cf12de5d7226c73f5ba9811622f4db3a5b91b55c53e987e5f91cba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.23", ] [[package]] @@ -682,7 +691,7 @@ checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51" dependencies = [ "async-stream-impl", "futures-core", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.10", ] [[package]] @@ -693,18 +702,18 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.23", ] [[package]] name = "async-trait" -version = "0.1.68" +version = "0.1.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842" +checksum = "a564d521dd56509c4c47480d00b80ee55f7e385ae48db5744c67ad50c92d2ebf" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.23", ] [[package]] @@ -717,7 +726,7 @@ dependencies = [ "futures-sink", "futures-util", "memchr", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.10", ] [[package]] @@ -745,16 +754,16 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "backtrace" -version = "0.3.67" +version = "0.3.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "233d376d6d185f2a3093e58f283f60f880315b6c60075b01f36b3b85154564ca" +checksum = "4319208da049c43661739c5fade2ba182f09d1dc2299b32298d3a31692b17e12" dependencies = [ - "addr2line", + "addr2line 0.20.0", "cc", "cfg-if", "libc", - "miniz_oxide 0.6.2", - "object", + "miniz_oxide", + "object 0.31.1", "rustc-demangle", ] @@ -796,9 +805,9 @@ checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "basic-toml" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c0de75129aa8d0cceaf750b89013f0e08804d6ec61416da787b35ad0d7cddf1" +checksum = "f838d03a705d72b12389b8930bd14cacf493be1380bfb15720d4d12db5ab03ac" dependencies = [ "serde", ] @@ -839,19 +848,19 @@ version = "0.65.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cfdf7b466f9a4903edc73f95d6d2bcd5baf8ae620638762244d3f60143643cc5" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cexpr", "clang-sys", "lazy_static", "lazycell", "peeking_take_while", - "prettyplease 0.2.6", + "prettyplease 0.2.10", "proc-macro2", "quote", "regex", "rustc-hash", "shlex", - "syn 2.0.18", + "syn 2.0.23", ] [[package]] @@ -860,6 +869,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42" + [[package]] name = "bitvec" version = "1.0.1" @@ -888,8 +903,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c2f0dc9a68c6317d884f97cc36cf5a3d20ba14ce404227df55e1af708ab04bc" dependencies = [ "arrayref", - "arrayvec 0.7.2", - "constant_time_eq", + "arrayvec 0.7.4", + "constant_time_eq 0.2.6", ] [[package]] @@ -899,21 +914,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6637f448b9e61dfadbdcbae9a885fadee1f3eaffb1f8d3c1965d3ade8bdfd44f" dependencies = [ "arrayref", - "arrayvec 0.7.2", - "constant_time_eq", + "arrayvec 0.7.4", + "constant_time_eq 0.2.6", ] [[package]] name = "blake3" -version = "1.3.3" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ae2468a89544a466886840aa467a25b766499f4f04bf7d9fcd10ecee9fccef" +checksum = "199c42ab6972d92c9f8995f086273d25c42fc0f7b2a1fcefba465c1352d25ba5" dependencies = [ "arrayref", - "arrayvec 0.7.2", + "arrayvec 0.7.4", "cc", "cfg-if", - "constant_time_eq", + "constant_time_eq 0.3.0", ] [[package]] @@ -991,13 +1006,12 @@ checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" [[package]] name = "bstr" -version = "1.5.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a246e68bb43f6cd9db24bea052a53e40405417c5fb372e3d1a8a7f770a564ef5" +checksum = "6798148dccfbff0fae41c7574d2fa8f1ef3492fba0face179de5d8d447d67b05" dependencies = [ "memchr", - "once_cell", - "regex-automata", + "regex-automata 0.3.2", "serde", ] @@ -1126,9 +1140,9 @@ dependencies = [ [[package]] name = "cfg-expr" -version = "0.15.2" +version = "0.15.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e70d3ad08698a0568b0562f22710fe6bfc1f4a61a367c77d0398c562eadd453a" +checksum = "215c0072ecc28f92eeb0eea38ba63ddfcb65c2828c46311d646f1a3ff5f9841c" dependencies = [ "smallvec", ] @@ -1175,7 +1189,7 @@ name = "chain-spec-builder" version = "2.0.0" dependencies = [ "ansi_term", - "clap 4.3.2", + "clap 4.3.11", "node-cli", "rand 0.8.5", "sc-chain-spec", @@ -1293,17 +1307,17 @@ version = "3.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" dependencies = [ - "bitflags", + "bitflags 1.3.2", "clap_lex 0.2.4", - "indexmap", + "indexmap 1.9.3", "textwrap", ] [[package]] name = "clap" -version = "4.3.2" +version = "4.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "401a4694d2bf92537b6867d94de48c4842089645fdcdf6c71865b175d836e9c2" +checksum = "1640e5cc7fb47dbb8338fd471b105e7ed6c3cb2aeb00c2e067127ffd3764a05d" dependencies = [ "clap_builder", "clap_derive", @@ -1312,24 +1326,23 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.3.1" +version = "4.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72394f3339a76daf211e57d4bcb374410f3965dcc606dd0e03738c7888766980" +checksum = "98c59138d527eeaf9b53f35a77fcc1fad9d883116070c63d5de1c7dc7b00c72b" dependencies = [ "anstream", "anstyle", - "bitflags", "clap_lex 0.5.0", "strsim", ] [[package]] name = "clap_complete" -version = "4.3.1" +version = "4.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f6b5c519bab3ea61843a7923d074b04245624bb84a64a8c150f5deb014e388b" +checksum = "5fc443334c81a804575546c5a8a79b4913b50e28d69232903604cada1de817ce" dependencies = [ - "clap 4.3.2", + "clap 4.3.11", ] [[package]] @@ -1341,7 +1354,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.23", ] [[package]] @@ -1377,9 +1390,9 @@ checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" [[package]] name = "comfy-table" -version = "7.0.0" +version = "7.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9e1f7e5d046697d34b593bdba8ee31f4649366e452a2ccabb3baf3511e503d1" +checksum = "9ab77dbd8adecaf3f0db40581631b995f312a8a5ae3aa9993188bb8f23d83a5b" dependencies = [ "strum", "strum_macros", @@ -1416,15 +1429,21 @@ dependencies = [ [[package]] name = "const-oid" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "520fbf3c07483f94e3e3ca9d0cfd913d7718ef2483d2cfd91c0d9e91474ab913" +checksum = "6340df57935414636969091153f35f68d9f00bbc8fb4a9c6054706c213e6c6bc" [[package]] name = "constant_time_eq" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13418e745008f7349ec7e449155f419a61b92b58a99cc3616942b926825ec76b" +checksum = "21a53c0a4d288377e7415b53dcfc3c04da5cdc2cc95c8d5ac178b58f0b861ad6" + +[[package]] +name = "constant_time_eq" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" [[package]] name = "constcat" @@ -1468,9 +1487,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.7" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e4c1eaa2012c47becbbad2ab175484c2a84d1185b566fb2cc5b8707343dfe58" +checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" dependencies = [ "libc", ] @@ -1658,22 +1677,22 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.14" +version = "0.9.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46bd5f3f85273295a9d14aedfb86f6aadbff6d8f5295c4a9edb08e819dcf5695" +checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" dependencies = [ "autocfg", "cfg-if", "crossbeam-utils", - "memoffset 0.8.0", + "memoffset 0.9.0", "scopeguard", ] [[package]] name = "crossbeam-utils" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b" +checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" dependencies = [ "cfg-if", ] @@ -1739,16 +1758,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "ctor" -version = "0.1.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d2301688392eb071b0bf1a37be05c469d3cc4dbbd95df672fe28ab021e6a096" -dependencies = [ - "quote", - "syn 1.0.109", -] - [[package]] name = "ctr" version = "0.8.0" @@ -1809,9 +1818,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.95" +version = "1.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "109308c20e8445959c2792e81871054c6a17e6976489a93d2769641a2ba5839c" +checksum = "e928d50d5858b744d1ea920b790641129c347a770d1530c3a85b77705a5ee031" dependencies = [ "cc", "cxxbridge-flags", @@ -1821,9 +1830,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.95" +version = "1.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daf4c6755cdf10798b97510e0e2b3edb9573032bd9379de8fffa59d68165494f" +checksum = "8332ba63f8a8040ca479de693150129067304a3496674477fff6d0c372cc34ae" dependencies = [ "cc", "codespan-reporting", @@ -1831,24 +1840,24 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn 2.0.18", + "syn 2.0.23", ] [[package]] name = "cxxbridge-flags" -version = "1.0.95" +version = "1.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "882074421238e84fe3b4c65d0081de34e5b323bf64555d3e61991f76eb64a7bb" +checksum = "5966a5a87b6e9bb342f5fab7170a93c77096efe199872afffc4b477cfeb86957" [[package]] name = "cxxbridge-macro" -version = "1.0.95" +version = "1.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a076022ece33e7686fb76513518e219cca4fce5750a8ae6d1ce6c0f48fd1af9" +checksum = "81b2dab6991c7ab1572fea8cb049db819b1aeea1e2dac74c0869f244d9f21a7c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.23", ] [[package]] @@ -1925,9 +1934,9 @@ dependencies = [ [[package]] name = "der" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56acb310e15652100da43d130af8d97b509e95af61aab1c5a7939ef24337ee17" +checksum = "0c7ed52955ce76b1554f509074bb357d3fb8ac9b51288a65a3fd480d1dfba946" dependencies = [ "const-oid", "zeroize", @@ -2116,7 +2125,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.23", ] [[package]] @@ -2152,7 +2161,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn 2.0.18", + "syn 2.0.23", "termcolor", "walkdir", ] @@ -2171,9 +2180,9 @@ checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" [[package]] name = "dtoa" -version = "1.0.6" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65d09067bfacaa79114679b279d7f5885b53295b1e2cfb4e79c8e4bd3d633169" +checksum = "519b83cd10f5f6e969625a409f735182bea5558cd8b64c655806ceaae36f1999" [[package]] name = "dyn-clonable" @@ -2220,7 +2229,7 @@ version = "0.16.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0997c976637b606099b9985693efa3581e84e41f5c11ba5255f88711058ad428" dependencies = [ - "der 0.7.6", + "der 0.7.7", "digest 0.10.7", "elliptic-curve 0.13.5", "rfc6979 0.4.0", @@ -2347,7 +2356,7 @@ checksum = "5e9a1f9f7d83e59740248a6e14ecf93929ade55027844dfcea78beafccc15745" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.23", ] [[package]] @@ -2382,6 +2391,12 @@ version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e48c92028aaa870e83d51c64e5d4e0b6981b360c522198c23959f219a4e1b15b" +[[package]] +name = "equivalent" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88bffebc5d80432c9b140ee17875ff173a8ab62faad5b257da912bd2f6c1c0a1" + [[package]] name = "errno" version = "0.3.1" @@ -2428,7 +2443,7 @@ dependencies = [ "fs-err", "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.23", ] [[package]] @@ -2552,7 +2567,7 @@ checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743" dependencies = [ "crc32fast", "libz-sys", - "miniz_oxide 0.7.1", + "miniz_oxide", ] [[package]] @@ -2636,7 +2651,7 @@ dependencies = [ "Inflector", "array-bytes", "chrono", - "clap 4.3.2", + "clap 4.3.11", "comfy-table", "frame-benchmarking", "frame-support", @@ -2702,7 +2717,7 @@ dependencies = [ "quote", "scale-info", "sp-arithmetic", - "syn 2.0.18", + "syn 2.0.23", "trybuild", ] @@ -2728,7 +2743,7 @@ dependencies = [ name = "frame-election-solution-type-fuzzer" version = "2.0.0-alpha.5" dependencies = [ - "clap 4.3.2", + "clap 4.3.11", "frame-election-provider-solution-type", "frame-election-provider-support", "frame-support", @@ -2803,7 +2818,7 @@ version = "4.0.0-dev" dependencies = [ "array-bytes", "assert_matches", - "bitflags", + "bitflags 1.3.2", "environmental", "frame-metadata", "frame-support-procedural", @@ -2849,7 +2864,7 @@ dependencies = [ "proc-macro-warning", "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.23", ] [[package]] @@ -2860,7 +2875,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.23", ] [[package]] @@ -2869,7 +2884,7 @@ version = "3.0.0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.23", ] [[package]] @@ -2998,11 +3013,11 @@ dependencies = [ [[package]] name = "fs4" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7672706608ecb74ab2e055c68327ffc25ae4cac1e12349204fd5fb0f3487cce2" +checksum = "2eeb4ed9e12f43b7fa0baae3f9cdda28352770132ef2e09a23760c29cae8bd47" dependencies = [ - "rustix 0.37.19", + "rustix 0.38.3", "windows-sys 0.48.0", ] @@ -3078,7 +3093,7 @@ dependencies = [ "futures-io", "memchr", "parking", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.10", "waker-fn", ] @@ -3090,7 +3105,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.23", ] [[package]] @@ -3135,7 +3150,7 @@ dependencies = [ "futures-sink", "futures-task", "memchr", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.10", "pin-utils", "slab", ] @@ -3205,9 +3220,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" +checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" dependencies = [ "cfg-if", "js-sys", @@ -3233,17 +3248,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d930750de5717d2dd0b8c0d42c076c0e884c81a73e6cab859bbd2339c71e3e40" dependencies = [ "opaque-debug 0.3.0", - "polyval 0.6.0", + "polyval 0.6.1", ] [[package]] name = "gimli" -version = "0.27.2" +version = "0.27.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad0a93d233ebf96623465aad4046a8d3aa4da22d4f4beba5388838c8a434bbb4" +checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" dependencies = [ "fallible-iterator", - "indexmap", + "indexmap 1.9.3", "stable_deref_trait", ] @@ -3290,9 +3305,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.19" +version = "0.3.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d357c7ae988e7d2182f7d7871d0b963962420b0678b0997ce7de72001aeab782" +checksum = "97ec8491ebaf99c8eaa73058b045fe58073cd6be7f596ac993ced0b0a0c01049" dependencies = [ "bytes", "fnv", @@ -3300,7 +3315,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap", + "indexmap 1.9.3", "slab", "tokio", "tokio-util", @@ -3360,6 +3375,12 @@ dependencies = [ "ahash 0.8.3", ] +[[package]] +name = "hashbrown" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" + [[package]] name = "heck" version = "0.4.1" @@ -3377,18 +3398,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" -dependencies = [ - "libc", -] - -[[package]] -name = "hermit-abi" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" +checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" [[package]] name = "hex" @@ -3493,7 +3505,7 @@ checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" dependencies = [ "bytes", "http", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.10", ] [[package]] @@ -3522,9 +3534,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.14.26" +version = "0.14.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab302d72a6f11a3b910431ff93aae7e773078c769f0a3ef15fb9ec692ed147d4" +checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" dependencies = [ "bytes", "futures-channel", @@ -3536,8 +3548,8 @@ dependencies = [ "httparse", "httpdate", "itoa", - "pin-project-lite 0.2.9", - "socket2", + "pin-project-lite 0.2.10", + "socket2 0.4.9", "tokio", "tower-service", "tracing", @@ -3562,24 +3574,25 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.24.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0646026eb1b3eea4cd9ba47912ea5ce9cc07713d105b1a14698f4e6433d348b7" +checksum = "8d78e1e73ec14cf7375674f74d7dde185c8206fd9dea6fb6295e8a98098aaa97" dependencies = [ + "futures-util", "http", "hyper", "log", - "rustls 0.21.1", + "rustls 0.21.3", "rustls-native-certs", "tokio", - "tokio-rustls 0.24.0", + "tokio-rustls 0.24.1", ] [[package]] name = "iana-time-zone" -version = "0.1.56" +version = "0.1.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0722cd7114b7de04316e7ea5456a0bbb20e4adb46fd27a3697adb812cff0f37c" +checksum = "2fad5b825842d2b38bd206f3e81d6957625fd7f0a361e345c30e01a0ae2dd613" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -3705,6 +3718,16 @@ dependencies = [ "serde", ] +[[package]] +name = "indexmap" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +dependencies = [ + "equivalent", + "hashbrown 0.14.0", +] + [[package]] name = "indexmap-nostd" version = "0.4.0" @@ -3782,7 +3805,7 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ - "hermit-abi 0.3.1", + "hermit-abi 0.3.2", "libc", "windows-sys 0.48.0", ] @@ -3795,31 +3818,30 @@ checksum = "aa2f047c0a98b2f299aa5d6d7088443570faae494e9ae1305e48be000c9e0eb1" [[package]] name = "ipconfig" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd302af1b90f2463a98fa5ad469fc212c8e3175a41c3068601bfa2727591c5be" +checksum = "b58db92f96b720de98181bbbe63c831e87005ab460c1bf306eb2622b4707997f" dependencies = [ - "socket2", + "socket2 0.5.3", "widestring", - "winapi", + "windows-sys 0.48.0", "winreg", ] [[package]] name = "ipnet" -version = "2.7.2" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12b6ee2129af8d4fb011108c73d99a1b83a85977f23b82460c0ae2e25bb4b57f" +checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6" [[package]] name = "is-terminal" -version = "0.4.7" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" +checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ - "hermit-abi 0.3.1", - "io-lifetimes", - "rustix 0.37.19", + "hermit-abi 0.3.2", + "rustix 0.38.3", "windows-sys 0.48.0", ] @@ -3834,9 +3856,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.6" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" +checksum = "62b02a5381cc465bd3041d84623d0fa3b66738b52b8e2fc3bab8ad63ab032f4a" [[package]] name = "jobserver" @@ -3849,9 +3871,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.63" +version = "0.3.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f37a4a5928311ac501dee68b3c7613a1037d0edb30c8e5427bd832d55d1b790" +checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" dependencies = [ "wasm-bindgen", ] @@ -3899,7 +3921,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4e70b4439a751a5de7dd5ed55eacff78ebf4ffe0fc009cb1ebb11417f5b536b" dependencies = [ "anyhow", - "arrayvec 0.7.2", + "arrayvec 0.7.4", "async-lock", "async-trait", "beef", @@ -4010,7 +4032,7 @@ dependencies = [ "ecdsa 0.16.7", "elliptic-curve 0.13.5", "once_cell", - "sha2 0.10.6", + "sha2 0.10.7", ] [[package]] @@ -4195,9 +4217,9 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.145" +version = "0.2.147" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc86cde3ff845662b8f4ef6cb50ea0e20c524eb3d29ae048287e06a1b3fa6a81" +checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" [[package]] name = "libloading" @@ -4230,7 +4252,7 @@ dependencies = [ "bytes", "futures", "futures-timer", - "getrandom 0.2.9", + "getrandom 0.2.10", "instant", "libp2p-allow-block-list", "libp2p-connection-limits", @@ -4356,7 +4378,7 @@ dependencies = [ "multihash", "quick-protobuf", "rand 0.8.5", - "sha2 0.10.6", + "sha2 0.10.7", "thiserror", "zeroize", ] @@ -4367,7 +4389,7 @@ version = "0.43.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39d5ef876a2b2323d63c258e63c2f8e36f205fe5a11f0b3095d59635650790ff" dependencies = [ - "arrayvec 0.7.2", + "arrayvec 0.7.4", "asynchronous-codec", "bytes", "either", @@ -4381,7 +4403,7 @@ dependencies = [ "log", "quick-protobuf", "rand 0.8.5", - "sha2 0.10.6", + "sha2 0.10.7", "smallvec", "thiserror", "uint", @@ -4404,7 +4426,7 @@ dependencies = [ "log", "rand 0.8.5", "smallvec", - "socket2", + "socket2 0.4.9", "tokio", "trust-dns-proto", "void", @@ -4439,7 +4461,7 @@ dependencies = [ "once_cell", "quick-protobuf", "rand 0.8.5", - "sha2 0.10.6", + "sha2 0.10.7", "snow", "static_assertions", "thiserror", @@ -4546,7 +4568,7 @@ dependencies = [ "libc", "libp2p-core", "log", - "socket2", + "socket2 0.4.9", "tokio", ] @@ -4722,9 +4744,9 @@ dependencies = [ [[package]] name = "link-cplusplus" -version = "1.0.8" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5" +checksum = "9d240c6f7e1ba3a28b0249f774e6a9dd0175054b52dfbb61b16eb8505c3785c9" dependencies = [ "cc", ] @@ -4746,9 +4768,9 @@ dependencies = [ [[package]] name = "linregress" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "475015a7f8f017edb28d2e69813be23500ad4b32cfe3421c4148efc97324ee52" +checksum = "4de0b5f52a9f84544d268f5fabb71b38962d6aa3c6600b8bcd27d44ccf9c9c45" dependencies = [ "nalgebra", ] @@ -4765,6 +4787,12 @@ version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" +[[package]] +name = "linux-raw-sys" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09fc20d2ca12cb9f044c93e3bd6d32d523e6e2ec3db4f7b2939cd99026ecd3f0" + [[package]] name = "lite-json" version = "0.2.0" @@ -4795,15 +4823,15 @@ dependencies = [ [[package]] name = "log" -version = "0.4.18" +version = "0.4.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "518ef76f2f87365916b142844c16d8fefd85039bc5699050210a7778ee1cd1de" +checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" [[package]] name = "lru" -version = "0.10.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03f1160296536f10c833a82dca22267d5486734230d47bf00bf435885814ba1e" +checksum = "718e8fae447df0c7e1ba7f5189829e63fd536945c8988d61444c19039f16b670" dependencies = [ "hashbrown 0.13.2", ] @@ -4855,7 +4883,7 @@ dependencies = [ "macro_magic_core", "macro_magic_macros", "quote", - "syn 2.0.18", + "syn 2.0.23", ] [[package]] @@ -4868,7 +4896,7 @@ dependencies = [ "macro_magic_core_macros", "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.23", ] [[package]] @@ -4879,7 +4907,7 @@ checksum = "93d7d9e6e234c040dafc745c7592738d56a03ad04b1fa04ab60821deb597466a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.23", ] [[package]] @@ -4890,7 +4918,7 @@ checksum = "ffd19f13cfd2bfbd83692adfef8c244fe5109b3eb822a1fb4e0a6253b406cd81" dependencies = [ "macro_magic_core", "quote", - "syn 2.0.18", + "syn 2.0.23", ] [[package]] @@ -4911,7 +4939,7 @@ version = "0.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1" dependencies = [ - "regex-automata", + "regex-automata 0.1.10", ] [[package]] @@ -4920,7 +4948,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" dependencies = [ - "regex-automata", + "regex-automata 0.1.10", ] [[package]] @@ -4960,7 +4988,7 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ffc89ccdc6e10d6907450f753537ebc5c5d3460d2e4e62ea74bd571db62c0f9e" dependencies = [ - "rustix 0.37.19", + "rustix 0.37.23", ] [[package]] @@ -4999,6 +5027,15 @@ dependencies = [ "autocfg", ] +[[package]] +name = "memoffset" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" +dependencies = [ + "autocfg", +] + [[package]] name = "memory-db" version = "0.32.0" @@ -5026,15 +5063,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" -[[package]] -name = "miniz_oxide" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" -dependencies = [ - "adler", -] - [[package]] name = "miniz_oxide" version = "0.7.1" @@ -5163,7 +5191,7 @@ dependencies = [ "core2", "digest 0.10.7", "multihash-derive", - "sha2 0.10.6", + "sha2 0.10.7", "sha3", "unsigned-varint", ] @@ -5257,7 +5285,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9ea4302b9759a7a88242299225ea3688e63c85ea136371bb6cf94fd674efaab" dependencies = [ "anyhow", - "bitflags", + "bitflags 1.3.2", "byteorder", "libc", "netlink-packet-core", @@ -5310,7 +5338,7 @@ version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cfg-if", "libc", "memoffset 0.6.5", @@ -5322,7 +5350,7 @@ version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cfg-if", "libc", "memoffset 0.7.1", @@ -5335,7 +5363,7 @@ name = "node-bench" version = "0.9.0-dev" dependencies = [ "array-bytes", - "clap 4.3.2", + "clap 4.3.11", "derive_more", "fs_extra", "futures", @@ -5372,7 +5400,7 @@ version = "3.0.0-dev" dependencies = [ "array-bytes", "assert_cmd", - "clap 4.3.2", + "clap 4.3.11", "clap_complete", "criterion", "frame-benchmarking-cli", @@ -5498,7 +5526,7 @@ dependencies = [ name = "node-inspect" version = "0.9.0-dev" dependencies = [ - "clap 4.3.2", + "clap 4.3.11", "parity-scale-codec", "sc-cli", "sc-client-api", @@ -5552,7 +5580,7 @@ dependencies = [ name = "node-runtime-generate-bags" version = "3.0.0" dependencies = [ - "clap 4.3.2", + "clap 4.3.11", "generate-bags", "kitchensink-runtime", ] @@ -5561,7 +5589,7 @@ dependencies = [ name = "node-template" version = "4.0.0-dev" dependencies = [ - "clap 4.3.2", + "clap 4.3.11", "frame-benchmarking", "frame-benchmarking-cli", "frame-system", @@ -5604,7 +5632,7 @@ dependencies = [ name = "node-template-release" version = "3.0.0" dependencies = [ - "clap 4.3.2", + "clap 4.3.11", "flate2", "fs_extra", "glob", @@ -5758,7 +5786,7 @@ version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a652d9771a63711fd3c3deb670acfbe5c30a4072e664d7a3bf5a9e1056ac72c3" dependencies = [ - "arrayvec 0.7.2", + "arrayvec 0.7.4", "itoa", ] @@ -5807,11 +5835,11 @@ dependencies = [ [[package]] name = "num_cpus" -version = "1.15.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.2.6", + "hermit-abi 0.3.2", "libc", ] @@ -5829,7 +5857,16 @@ checksum = "03b4680b86d9cfafba8fc491dc9b6df26b68cf40e9e6cd73909194759a63c385" dependencies = [ "crc32fast", "hashbrown 0.13.2", - "indexmap", + "indexmap 1.9.3", + "memchr", +] + +[[package]] +name = "object" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bda667d9f2b5051b8833f59f3bf748b28ef54f850f4fcb389a252aa383866d1" +dependencies = [ "memchr", ] @@ -5883,18 +5920,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "os_str_bytes" -version = "6.5.0" +version = "6.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ceedf44fb00f2d1984b0bc98102627ce622e083e49a5bacdb3e514fa4238e267" - -[[package]] -name = "output_vt100" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "628223faebab4e3e40667ee0b2336d34a5b960ff60ea743ddfdbcf7770bcfb66" -dependencies = [ - "winapi", -] +checksum = "4d5d9eb14b174ee9aa2ef96dc2b94637a2d4b6e7cb873c7e171f0c20c6cf3eac" [[package]] name = "overload" @@ -5910,7 +5938,7 @@ checksum = "51f44edd08f51e2ade572f141051021c5af22677e42b7dd28a88155151c33594" dependencies = [ "ecdsa 0.14.8", "elliptic-curve 0.12.3", - "sha2 0.10.6", + "sha2 0.10.7", ] [[package]] @@ -5921,7 +5949,7 @@ checksum = "dfc8c5bf642dde52bb9e87c0ecd8ca5a76faac2eeed98dedb7c717997e1080aa" dependencies = [ "ecdsa 0.14.8", "elliptic-curve 0.12.3", - "sha2 0.10.6", + "sha2 0.10.7", ] [[package]] @@ -6316,7 +6344,7 @@ version = "4.0.0-dev" dependencies = [ "array-bytes", "assert_matches", - "bitflags", + "bitflags 1.3.2", "env_logger 0.9.3", "environmental", "frame-benchmarking", @@ -6353,7 +6381,7 @@ dependencies = [ name = "pallet-contracts-primitives" version = "24.0.0" dependencies = [ - "bitflags", + "bitflags 1.3.2", "parity-scale-codec", "scale-info", "sp-runtime", @@ -6367,7 +6395,7 @@ version = "4.0.0-dev" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.23", ] [[package]] @@ -7374,7 +7402,7 @@ dependencies = [ "proc-macro2", "quote", "sp-runtime", - "syn 2.0.18", + "syn 2.0.23", ] [[package]] @@ -7660,9 +7688,9 @@ dependencies = [ [[package]] name = "parity-db" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4890dcb9556136a4ec2b0c51fa4a08c8b733b829506af8fff2e853f3a065985b" +checksum = "0dab3ac198341b2f0fec6e7f8a6eeed07a41201d98a124260611598c142e76df" dependencies = [ "blake2", "crc32fast", @@ -7680,11 +7708,11 @@ dependencies = [ [[package]] name = "parity-scale-codec" -version = "3.6.1" +version = "3.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2287753623c76f953acd29d15d8100bcab84d29db78fb6f352adb3c53e83b967" +checksum = "756d439303e94fae44f288ba881ad29670c65b0c4b0e05674ca81061bb65f2c5" dependencies = [ - "arrayvec 0.7.2", + "arrayvec 0.7.4", "bitvec", "byte-slice-cast", "bytes", @@ -7695,9 +7723,9 @@ dependencies = [ [[package]] name = "parity-scale-codec-derive" -version = "3.6.1" +version = "3.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b6937b5e67bfba3351b87b040d48352a2fcb6ad72f81855412ce97b45c8f110" +checksum = "9d884d78fcf214d70b1e239fcd1c6e5e95aa3be1881918da2e488cc946c7a476" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -7768,7 +7796,7 @@ dependencies = [ "libc", "redox_syscall 0.3.5", "smallvec", - "windows-targets 0.48.0", + "windows-targets 0.48.1", ] [[package]] @@ -7779,9 +7807,9 @@ checksum = "7924d1d0ad836f665c9065e26d016c673ece3993f30d340068b16f282afc1156" [[package]] name = "paste" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" +checksum = "b4b27ab7be369122c218afc2079489cdcb4b517c0a3fc386ff11e1fedfcc2b35" [[package]] name = "pbkdf2" @@ -7833,9 +7861,9 @@ checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pest" -version = "2.6.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e68e84bfb01f0507134eac1e9b410a12ba379d064eab48c50ba4ce329a527b70" +checksum = "f73935e4d55e2abf7f130186537b19e7a4abc886a0252380b59248af473a3fc9" dependencies = [ "thiserror", "ucd-trie", @@ -7843,9 +7871,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.6.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b79d4c71c865a25a4322296122e3924d30bc8ee0834c8bfc8b95f7f054afbfb" +checksum = "aef623c9bbfa0eedf5a0efba11a5ee83209c326653ca31ff019bec3a95bfff2b" dependencies = [ "pest", "pest_generator", @@ -7853,26 +7881,26 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.6.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c435bf1076437b851ebc8edc3a18442796b30f1728ffea6262d59bbe28b077e" +checksum = "b3e8cba4ec22bada7fc55ffe51e2deb6a0e0db2d0b7ab0b103acc80d2510c190" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.23", ] [[package]] name = "pest_meta" -version = "2.6.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "745a452f8eb71e39ffd8ee32b3c5f51d03845f99786fa9b68db6ff509c505411" +checksum = "a01f71cb40bd8bb94232df14b946909e14660e33fc05db3e50ae2a82d7ea0ca0" dependencies = [ "once_cell", "pest", - "sha2 0.10.6", + "sha2 0.10.7", ] [[package]] @@ -7882,27 +7910,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4dd7d28ee937e54fe3080c91faa1c3a46c06de6252988a7f4592ba2310ef22a4" dependencies = [ "fixedbitset", - "indexmap", + "indexmap 1.9.3", ] [[package]] name = "pin-project" -version = "1.1.0" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c95a7476719eab1e366eaf73d0260af3021184f18177925b07f54b30089ceead" +checksum = "030ad2bc4db10a8944cb0d837f158bdfec4d4a4873ab701a95046770d11f8842" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.0" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39407670928234ebc5e6e580247dd567ad73a3578460c5990f9503df207e8f07" +checksum = "ec2e072ecce94ec471b13398d5402c188e76ac03cf74dd1a975161b23a3f6d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.23", ] [[package]] @@ -7913,9 +7941,9 @@ checksum = "257b64915a082f7811703966789728173279bdebb956b143dbcd23f6f970a777" [[package]] name = "pin-project-lite" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" +checksum = "4c40d25201921e5ff0c862a505c6557ea88568a4e3ace775ab55e93f2f4f9d57" [[package]] name = "pin-utils" @@ -7939,7 +7967,7 @@ version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" dependencies = [ - "der 0.7.6", + "der 0.7.7", "spki 0.7.2", ] @@ -7957,9 +7985,9 @@ checksum = "e3d7ddaed09e0eb771a79ab0fd64609ba0afb0a8366421957936ad14cbd13630" [[package]] name = "plotters" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2538b639e642295546c50fcd545198c9d64ee2a38620a628724a3b266d5fbf97" +checksum = "d2c224ba00d7cadd4d5c660deaf2098e5e80e07846537c51f9cfa4be50c1fd45" dependencies = [ "num-traits", "plotters-backend", @@ -7970,15 +7998,15 @@ dependencies = [ [[package]] name = "plotters-backend" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "193228616381fecdc1224c62e96946dfbc73ff4384fba576e052ff8c1bea8142" +checksum = "9e76628b4d3a7581389a35d5b6e2139607ad7c75b17aed325f210aa91f4a9609" [[package]] name = "plotters-svg" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9a81d2759aae1dae668f783c308bc5c8ebd191ff4184aaa1b37f65a6ae5a56f" +checksum = "38f6d39893cca0701371e3c27294f09797214b86f1fb951b89ade8ec04e2abab" dependencies = [ "plotters-backend", ] @@ -7990,12 +8018,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" dependencies = [ "autocfg", - "bitflags", + "bitflags 1.3.2", "cfg-if", "concurrent-queue", "libc", "log", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.10", "windows-sys 0.48.0", ] @@ -8024,9 +8052,9 @@ dependencies = [ [[package]] name = "polyval" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef234e08c11dfcb2e56f79fd70f6f2eb7f025c0ce2333e82f4f0518ecad30c6" +checksum = "d52cff9d1d4dee5fe6d03729099f4a310a41179e0a10dbf542039873f2e826fb" dependencies = [ "cfg-if", "cpufeatures", @@ -8090,13 +8118,11 @@ dependencies = [ [[package]] name = "pretty_assertions" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a25e9bcb20aa780fd0bb16b72403a9064d6b3f22f026946029acb941a50af755" +checksum = "af7cee1a6c8a5b9208b3cb1061f10c0cb689087b3d8ce85fb9d2dd7a29b6ba66" dependencies = [ - "ctor", "diff", - "output_vt100", "yansi", ] @@ -8112,12 +8138,12 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.6" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b69d39aab54d069e7f2fe8cb970493e7834601ca2d8c65fd7bbd183578080d1" +checksum = "92139198957b410250d43fad93e630d956499a625c527eda65175c8680f83387" dependencies = [ "proc-macro2", - "syn 2.0.18", + "syn 2.0.23", ] [[package]] @@ -8176,14 +8202,14 @@ checksum = "70550716265d1ec349c41f70dd4f964b4fd88394efe4405f0c1da679c4799a07" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.23", ] [[package]] name = "proc-macro2" -version = "1.0.60" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dec2b086b7a862cf4de201096214fa870344cf922b2b30c167badb3af3195406" +checksum = "7b368fba921b0dce7e60f5e04ec15e565b3303972b42bcfde1d0713b881959eb" dependencies = [ "unicode-ident", ] @@ -8356,9 +8382,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.28" +version = "1.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488" +checksum = "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105" dependencies = [ "proc-macro2", ] @@ -8428,7 +8454,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.9", + "getrandom 0.2.10", ] [[package]] @@ -8495,7 +8521,7 @@ checksum = "6413f3de1edee53342e6138e75b56d32e7bc6e332b3bd62d497b1929d4cfbcdd" dependencies = [ "pem", "ring", - "time 0.3.21", + "time 0.3.22", "x509-parser 0.13.2", "yasna", ] @@ -8508,7 +8534,7 @@ checksum = "ffbe84efe2f38dea12e9bfc1f65377fdf03e53a18cb3b995faedf7934c7e785b" dependencies = [ "pem", "ring", - "time 0.3.21", + "time 0.3.22", "yasna", ] @@ -8518,7 +8544,7 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -8527,7 +8553,7 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -8536,29 +8562,29 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ - "getrandom 0.2.9", + "getrandom 0.2.10", "redox_syscall 0.2.16", "thiserror", ] [[package]] name = "ref-cast" -version = "1.0.16" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43faa91b1c8b36841ee70e97188a869d37ae21759da6846d4be66de5bf7b12c" +checksum = "1641819477c319ef452a075ac34a4be92eb9ba09f6841f62d594d50fdcf0bf6b" dependencies = [ "ref-cast-impl", ] [[package]] name = "ref-cast-impl" -version = "1.0.16" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d2275aab483050ab2a7364c1a46604865ee7d6906684e08db0f090acf74f9e7" +checksum = "68bf53dad9b6086826722cdc99140793afd9f62faa14a1ad07eb4f955e7a7216" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.23", ] [[package]] @@ -8575,13 +8601,14 @@ dependencies = [ [[package]] name = "regex" -version = "1.8.4" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0ab3ca65655bb1e41f2a8c8cd662eb4fb035e67c3f78da1d61dffe89d07300f" +checksum = "b2eae68fc220f7cf2532e4494aded17545fce192d59cd996e0fe7887f4ceb575" dependencies = [ "aho-corasick 1.0.2", "memchr", - "regex-syntax 0.7.2", + "regex-automata 0.3.2", + "regex-syntax 0.7.3", ] [[package]] @@ -8593,6 +8620,17 @@ dependencies = [ "regex-syntax 0.6.29", ] +[[package]] +name = "regex-automata" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83d3daa6976cffb758ec878f108ba0e062a45b2d6ca3a2cca965338855476caf" +dependencies = [ + "aho-corasick 1.0.2", + "memchr", + "regex-syntax 0.7.3", +] + [[package]] name = "regex-syntax" version = "0.6.29" @@ -8601,9 +8639,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78" +checksum = "2ab07dc67230e4a4718e70fd5c20055a4334b121f1f9db8fe63ef39ce9b8c846" [[package]] name = "resolv-conf" @@ -8769,11 +8807,11 @@ dependencies = [ [[package]] name = "rustix" -version = "0.36.14" +version = "0.36.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14e4d67015953998ad0eb82887a0eb0129e18a7e2f3b7b0f6c422fddcd503d62" +checksum = "c37f1bd5ef1b5422177b7646cba67430579cfe2ace80f284fee876bca52ad941" dependencies = [ - "bitflags", + "bitflags 1.3.2", "errno", "io-lifetimes", "libc", @@ -8783,11 +8821,11 @@ dependencies = [ [[package]] name = "rustix" -version = "0.37.19" +version = "0.37.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acf8729d8542766f1b2cf77eb034d52f40d375bb8b615d0b147089946e16613d" +checksum = "4d69718bf81c6127a49dc64e44a742e8bb9213c0ff8869a22c308f84c1d4ab06" dependencies = [ - "bitflags", + "bitflags 1.3.2", "errno", "io-lifetimes", "libc", @@ -8795,6 +8833,19 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "rustix" +version = "0.38.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac5ffa1efe7548069688cd7028f32591853cd7b5b756d41bcffd2353e4fc75b4" +dependencies = [ + "bitflags 2.3.3", + "errno", + "libc", + "linux-raw-sys 0.4.3", + "windows-sys 0.48.0", +] + [[package]] name = "rustls" version = "0.19.1" @@ -8822,9 +8873,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.21.1" +version = "0.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c911ba11bc8433e811ce56fde130ccf32f5127cab0e0194e9c68c5a5b671791e" +checksum = "b19faa85ecb5197342b54f987b142fb3e30d0c90da40f80ef4fa9a726e6676ed" dependencies = [ "log", "ring", @@ -8834,9 +8885,9 @@ dependencies = [ [[package]] name = "rustls-native-certs" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0167bac7a9f490495f3c33013e7722b53cb087ecbe082fb0c6387c96f634ea50" +checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" dependencies = [ "openssl-probe", "rustls-pemfile", @@ -8846,18 +8897,18 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d194b56d58803a43635bdc398cd17e383d6f71f9182b9a192c127ca42494a59b" +checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" dependencies = [ "base64 0.21.2", ] [[package]] name = "rustls-webpki" -version = "0.100.1" +version = "0.101.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6207cd5ed3d8dca7816f8f3725513a34609c0c765bf652b8c3cb4cfd87db46b" +checksum = "15f36a6828982f422756984e47912a7a51dcbc2a197aa791158f8ca61cd8204e" dependencies = [ "ring", "untrusted", @@ -8865,9 +8916,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f3208ce4d8448b3f3e7d168a73f5e0c43a61e32930de3bceeccedb388b6bf06" +checksum = "dc31bd9b61a32c31f9650d18add92aa83a49ba979c143eefd27fe7177b05bd5f" [[package]] name = "rusty-fork" @@ -8893,9 +8944,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" +checksum = "fe232bdf6be8c8de797b22184ee71118d63780ea42ac85b61d1baa6d3b782ae9" [[package]] name = "safe-mix" @@ -8908,9 +8959,9 @@ dependencies = [ [[package]] name = "safe_arch" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "794821e4ccb0d9f979512f9c1973480123f9bd62a90d74ab0f9426fcf8f4a529" +checksum = "62a7484307bd40f8f7ccbacccac730108f2cae119a3b11c74485b48aa9ea650f" dependencies = [ "bytemuck", ] @@ -9030,7 +9081,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.23", ] [[package]] @@ -9039,7 +9090,7 @@ version = "0.10.0-dev" dependencies = [ "array-bytes", "chrono", - "clap 4.3.2", + "clap 4.3.11", "fdlimit", "futures", "futures-timer", @@ -9561,7 +9612,7 @@ dependencies = [ "log", "parity-scale-codec", "paste", - "rustix 0.36.14", + "rustix 0.36.15", "sc-allocator", "sc-executor-common", "sc-runtime-test", @@ -9685,7 +9736,7 @@ name = "sc-network-common" version = "0.10.0-dev" dependencies = [ "async-trait", - "bitflags", + "bitflags 1.3.2", "futures", "libp2p-identity", "parity-scale-codec", @@ -9850,7 +9901,7 @@ dependencies = [ "futures", "futures-timer", "hyper", - "hyper-rustls 0.24.0", + "hyper-rustls 0.24.1", "lazy_static", "libp2p", "log", @@ -10142,7 +10193,7 @@ dependencies = [ name = "sc-storage-monitor" version = "0.1.0" dependencies = [ - "clap 4.3.2", + "clap 4.3.11", "fs4", "log", "sc-client-db", @@ -10242,7 +10293,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.23", ] [[package]] @@ -10311,9 +10362,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.7.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b569c32c806ec3abdf3b5869fb8bf1e0d275a7c1c9b0b05603d9464632649edf" +checksum = "35c0a159d0c45c12b20c5a844feb1fe4bea86e28f17b92a5f0c42193634d3782" dependencies = [ "bitvec", "cfg-if", @@ -10325,9 +10376,9 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.6.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53012eae69e5aa5c14671942a5dd47de59d4cdcff8532a6dd0e081faf1119482" +checksum = "912e55f6d20e0e80d63733872b40e1227c0bce1e1ab81ba67d696339bfd7fd29" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -10381,9 +10432,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "scratch" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1792db035ce95be60c3f8853017b3999209281c24e2ba5bc8e59bf97a0c590c1" +checksum = "764cad9e7e1ca5fe15b552859ff5d96a314e6ed2934f2260168cd5dfa5891409" [[package]] name = "sct" @@ -10438,7 +10489,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0aec48e813d6b90b15f0b8948af3c63483992dee44c03e9930b3eebdabe046e" dependencies = [ "base16ct 0.2.0", - "der 0.7.6", + "der 0.7.7", "generic-array 0.14.7", "pkcs8 0.10.2", "subtle", @@ -10478,7 +10529,7 @@ version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fc758eb7bffce5b308734e9b0c1468893cae9ff70ebf13e7090be8dcbcc83a8" dependencies = [ - "bitflags", + "bitflags 1.3.2", "core-foundation", "core-foundation-sys", "libc", @@ -10530,29 +10581,29 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.164" +version = "1.0.167" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e8c8cf938e98f769bc164923b06dce91cea1751522f46f8466461af04c9027d" +checksum = "7daf513456463b42aa1d94cff7e0c24d682b429f020b9afa4f5ba5c40a22b237" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.164" +version = "1.0.167" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9735b638ccc51c28bf6914d90a2e9725b377144fc612c49a611fddd1b631d68" +checksum = "b69b106b68bc8054f0e974e70d19984040f8a5cf9215ca82626ea4853f82c4b9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.23", ] [[package]] name = "serde_json" -version = "1.0.96" +version = "1.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" +checksum = "0f1e14e89be7aa4c4b78bdbdc9eb5bf8517829a600ae8eaa39a6e1d960b5185c" dependencies = [ "itoa", "ryu", @@ -10561,9 +10612,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93107647184f6027e3b7dcb2e11034cf95ffa1e3a682c67951963ac69c1c007d" +checksum = "96426c9936fd7a0124915f9185ea1d20aa9445cc9821142f0a73bc9207a2e186" dependencies = [ "serde", ] @@ -10619,9 +10670,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.6" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" +checksum = "479fb9d862239e610720565ca91403019f2f00410f1864c5aa7479b950a76ed8" dependencies = [ "cfg-if", "cpufeatures", @@ -10718,9 +10769,9 @@ checksum = "826167069c09b99d56f31e9ae5c99049e932a98c9dc2dac47645b08dbbf76ba7" [[package]] name = "smallvec" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" +checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" [[package]] name = "snap" @@ -10741,7 +10792,7 @@ dependencies = [ "rand_core 0.6.4", "ring", "rustc_version 0.4.0", - "sha2 0.10.6", + "sha2 0.10.7", "subtle", ] @@ -10755,6 +10806,16 @@ dependencies = [ "winapi", ] +[[package]] +name = "socket2" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2538b18701741680e0322a2302176d3253a35388e2e62f172f64f4f16605f877" +dependencies = [ + "libc", + "windows-sys 0.48.0", +] + [[package]] name = "soketto" version = "0.7.1" @@ -10804,7 +10865,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.23", ] [[package]] @@ -10969,7 +11030,7 @@ dependencies = [ "ark-serialize", "ark-std", "derivative", - "getrandom 0.2.9", + "getrandom 0.2.10", "itertools", "num-traits", "zeroize", @@ -11127,7 +11188,7 @@ name = "sp-core" version = "21.0.0" dependencies = [ "array-bytes", - "bitflags", + "bitflags 1.3.2", "blake2", "bounded-collections", "bs58", @@ -11178,7 +11239,7 @@ dependencies = [ "blake2b_simd", "byteorder", "digest 0.10.7", - "sha2 0.10.6", + "sha2 0.10.7", "sha3", "twox-hash", ] @@ -11189,7 +11250,7 @@ version = "9.0.0" dependencies = [ "quote", "sp-core-hashing", - "syn 2.0.18", + "syn 2.0.23", ] [[package]] @@ -11233,7 +11294,7 @@ version = "8.0.0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.23", ] [[package]] @@ -11372,7 +11433,7 @@ dependencies = [ name = "sp-npos-elections-fuzzer" version = "2.0.0-alpha.5" dependencies = [ - "clap 4.3.2", + "clap 4.3.11", "honggfuzz", "rand 0.8.5", "sp-npos-elections", @@ -11465,7 +11526,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.23", ] [[package]] @@ -11698,7 +11759,7 @@ dependencies = [ "proc-macro2", "quote", "sp-version", - "syn 2.0.18", + "syn 2.0.23", ] [[package]] @@ -11767,14 +11828,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" dependencies = [ "base64ct", - "der 0.7.6", + "der 0.7.7", ] [[package]] name = "ss58-registry" -version = "1.40.0" +version = "1.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb47a8ad42e5fc72d5b1eb104a5546937eaf39843499948bb666d6e93c62423b" +checksum = "bfc443bad666016e012538782d9e3006213a7db43e9fb1dda91657dc06a6fa08" dependencies = [ "Inflector", "num-format", @@ -11803,7 +11864,7 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a2a1c578e98c1c16fc3b8ec1328f7659a500737d7a0c6d625e73e830ff9c1f6" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cfg_aliases", "libc", "parking_lot 0.11.2", @@ -11876,7 +11937,7 @@ dependencies = [ name = "subkey" version = "3.0.0" dependencies = [ - "clap 4.3.2", + "clap 4.3.11", "sc-cli", ] @@ -11915,7 +11976,7 @@ dependencies = [ name = "substrate-frame-cli" version = "4.0.0-dev" dependencies = [ - "clap 4.3.2", + "clap 4.3.11", "frame-support", "frame-system", "sc-cli", @@ -12125,7 +12186,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.23", ] [[package]] @@ -12149,7 +12210,7 @@ dependencies = [ "sp-maybe-compressed-blob", "strum", "tempfile", - "toml 0.7.4", + "toml 0.7.6", "walkdir", "wasm-opt", ] @@ -12182,9 +12243,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.18" +version = "2.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32d41677bcbe24c20c52e7c70b0d8db04134c5d1066bf98662e2871ad200ea3e" +checksum = "59fb7d6d8281a51045d62b8eb3a7d1ce347b76f312af50cd3dc0af39c87c1737" dependencies = [ "proc-macro2", "quote", @@ -12209,7 +12270,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" dependencies = [ - "bitflags", + "bitflags 1.3.2", "core-foundation", "system-configuration-sys", ] @@ -12243,9 +12304,9 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.12.7" +version = "0.12.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd1ba337640d60c3e96bc6f0638a939b9c9a7f2c316a1598c279828b3d1dc8c5" +checksum = "1b1c7f239eb94671427157bd93b3694320f3668d4e1eff08c7285366fd777fac" [[package]] name = "tempfile" @@ -12257,7 +12318,7 @@ dependencies = [ "cfg-if", "fastrand", "redox_syscall 0.3.5", - "rustix 0.37.19", + "rustix 0.37.23", "windows-sys 0.48.0", ] @@ -12284,22 +12345,22 @@ checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" [[package]] name = "thiserror" -version = "1.0.40" +version = "1.0.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" +checksum = "a35fc5b8971143ca348fa6df4f024d4d55264f3468c71ad1c2f365b0a4d58c42" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.40" +version = "1.0.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" +checksum = "463fe12d7993d3b327787537ce8dd4dfa058de32fc2b195ef3cde03dc4771e8f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.23", ] [[package]] @@ -12350,9 +12411,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.21" +version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f3403384eaacbca9923fa06940178ac13e4edb725486d70e8e15881d0c836cc" +checksum = "ea9e1b3cf1243ae005d9e74085d4d542f3125458f3a81af210d901dcd7411efd" dependencies = [ "itoa", "serde", @@ -12387,7 +12448,7 @@ dependencies = [ "pbkdf2 0.11.0", "rand 0.8.5", "rustc-hash", - "sha2 0.10.6", + "sha2 0.10.7", "thiserror", "unicode-normalization", "wasm-bindgen", @@ -12430,19 +12491,20 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.28.2" +version = "1.29.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94d7b1cfd2aa4011f2de74c2c4c63665e27a71006b0a192dcd2710272e73dfa2" +checksum = "532826ff75199d5833b9d2c5fe410f29235e25704ee5f0ef599fb51c21f4a4da" dependencies = [ "autocfg", + "backtrace", "bytes", "libc", "mio", "num_cpus", "parking_lot 0.12.1", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.10", "signal-hook-registry", - "socket2", + "socket2 0.4.9", "tokio-macros", "windows-sys 0.48.0", ] @@ -12455,7 +12517,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.23", ] [[package]] @@ -12482,11 +12544,11 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.24.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0d409377ff5b1e3ca6437aa86c1eb7d40c134bfec254e44c830defa92669db5" +checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls 0.21.1", + "rustls 0.21.3", "tokio", ] @@ -12497,7 +12559,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" dependencies = [ "futures-core", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.10", "tokio", "tokio-util", ] @@ -12525,7 +12587,7 @@ dependencies = [ "futures-core", "futures-io", "futures-sink", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.10", "tokio", "tracing", ] @@ -12541,9 +12603,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.7.4" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6135d499e69981f9ff0ef2167955a5333c35e36f6937d382974566b3d5b94ec" +checksum = "c17e963a819c331dcacd7ab957d80bc2b9a9c1e71c804826d2f283dd65306542" dependencies = [ "serde", "serde_spanned", @@ -12553,20 +12615,20 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a76a9312f5ba4c2dec6b9161fdf25d87ad8a09256ccea5a556fef03c706a10f" +checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" dependencies = [ "serde", ] [[package]] name = "toml_edit" -version = "0.19.10" +version = "0.19.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2380d56e8670370eee6566b0bfd4265f65b3f432e8c6d85623f728d4fa31f739" +checksum = "c500344a19072298cd05a7224b3c0c629348b78692bf48466c5238656e315a78" dependencies = [ - "indexmap", + "indexmap 2.0.0", "serde", "serde_spanned", "toml_datetime", @@ -12586,18 +12648,18 @@ dependencies = [ [[package]] name = "tower-http" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d1d42a9b3f3ec46ba828e8d376aec14592ea199f70a06a548587ecd1c4ab658" +checksum = "a8bd22a874a2d0b70452d5597b12c537331d49060824a95f49f108994f94aa4c" dependencies = [ - "bitflags", + "bitflags 2.3.3", "bytes", "futures-core", "futures-util", "http", "http-body", "http-range-header", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.10", "tower-layer", "tower-service", ] @@ -12622,20 +12684,20 @@ checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" dependencies = [ "cfg-if", "log", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.10", "tracing-attributes", "tracing-core", ] [[package]] name = "tracing-attributes" -version = "0.1.24" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f57e3ca2a01450b1a921183a9c9cbfda207fd822cef4ccb00a65402cbba7a74" +checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.23", ] [[package]] @@ -12786,7 +12848,7 @@ dependencies = [ "lazy_static", "rand 0.8.5", "smallvec", - "socket2", + "socket2 0.4.9", "thiserror", "tinyvec", "tokio", @@ -12826,7 +12888,7 @@ version = "0.10.0-dev" dependencies = [ "assert_cmd", "async-trait", - "clap 4.3.2", + "clap 4.3.11", "frame-remote-externalities", "frame-try-runtime", "hex", @@ -12863,9 +12925,9 @@ dependencies = [ [[package]] name = "trybuild" -version = "1.0.80" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501dbdbb99861e4ab6b60eb6a7493956a9defb644fd034bc4a5ef27c693c8a3a" +checksum = "04366e99ff743345622cd00af2af01d711dc2d1ef59250d7347698d21b546729" dependencies = [ "basic-toml", "dissimilar", @@ -12922,9 +12984,9 @@ checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" [[package]] name = "ucd-trie" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e79c4d996edb816c91e4308506774452e55e95c3c9de07b6729e17e15a5ef81" +checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" [[package]] name = "uint" @@ -12946,9 +13008,9 @@ checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" +checksum = "22049a19f4a68748a168c0fc439f9516686aa045927ff767eca0a85101fb6e73" [[package]] name = "unicode-normalization" @@ -13028,11 +13090,11 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "uuid" -version = "1.3.3" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "345444e32442451b267fc254ae85a209c64be56d2890e601a0c37ff0c3c5ecd2" +checksum = "d023da39d1fde5a8a3fe1f3e01ca9632ada0a63e9797de55a879d6e2236277be" dependencies = [ - "getrandom 0.2.9", + "getrandom 0.2.10", ] [[package]] @@ -13077,7 +13139,7 @@ dependencies = [ "rand 0.8.5", "rand_chacha 0.3.1", "rand_core 0.6.4", - "sha2 0.10.6", + "sha2 0.10.7", "sha3", "thiserror", "zeroize", @@ -13119,11 +13181,10 @@ dependencies = [ [[package]] name = "want" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" dependencies = [ - "log", "try-lock", ] @@ -13147,9 +13208,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.86" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bba0e8cb82ba49ff4e229459ff22a191bbe9a1cb3a341610c9c33efc27ddf73" +checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -13157,24 +13218,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.86" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b04bc93f9d6bdee709f6bd2118f57dd6679cf1176a1af464fca3ab0d66d8fb" +checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.23", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.36" +version = "0.4.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d1985d03709c53167ce907ff394f5316aa22cb4e12761295c5dc57dacb6297e" +checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03" dependencies = [ "cfg-if", "js-sys", @@ -13184,9 +13245,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.86" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14d6b024f1a526bb0234f52840389927257beb670610081360e5a03c5df9c258" +checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -13194,22 +13255,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.86" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e128beba882dd1eb6200e1dc92ae6c5dbaa4311aa7bb211ca035779e5efc39f8" +checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.23", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.86" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed9d5b4305409d1fc9482fee2d7f9bcbf24b3972bf59817ef757e23982242a93" +checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" [[package]] name = "wasm-encoder" @@ -13331,7 +13392,7 @@ version = "0.102.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48134de3d7598219ab9eaf6b91b15d8e50d31da76b8519fe4ecfcec2cf35104b" dependencies = [ - "indexmap", + "indexmap 1.9.3", "url", ] @@ -13353,10 +13414,10 @@ dependencies = [ "anyhow", "bincode", "cfg-if", - "indexmap", + "indexmap 1.9.3", "libc", "log", - "object", + "object 0.30.4", "once_cell", "paste", "psm", @@ -13393,9 +13454,9 @@ dependencies = [ "directories-next", "file-per-thread-logger", "log", - "rustix 0.36.14", + "rustix 0.36.15", "serde", - "sha2 0.10.6", + "sha2 0.10.7", "toml 0.5.11", "windows-sys 0.45.0", "zstd 0.11.2+zstd.1.5.2", @@ -13415,7 +13476,7 @@ dependencies = [ "cranelift-wasm", "gimli", "log", - "object", + "object 0.30.4", "target-lexicon", "thiserror", "wasmparser", @@ -13433,7 +13494,7 @@ dependencies = [ "cranelift-codegen", "cranelift-native", "gimli", - "object", + "object 0.30.4", "target-lexicon", "wasmtime-environ", ] @@ -13447,9 +13508,9 @@ dependencies = [ "anyhow", "cranelift-entity", "gimli", - "indexmap", + "indexmap 1.9.3", "log", - "object", + "object 0.30.4", "serde", "target-lexicon", "thiserror", @@ -13463,14 +13524,14 @@ version = "8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0de48df552cfca1c9b750002d3e07b45772dd033b0b206d5c0968496abf31244" dependencies = [ - "addr2line", + "addr2line 0.19.0", "anyhow", "bincode", "cfg-if", "cpp_demangle", "gimli", "log", - "object", + "object 0.30.4", "rustc-demangle", "serde", "target-lexicon", @@ -13487,9 +13548,9 @@ version = "8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e0554b84c15a27d76281d06838aed94e13a77d7bf604bbbaf548aa20eb93846" dependencies = [ - "object", + "object 0.30.4", "once_cell", - "rustix 0.36.14", + "rustix 0.36.15", ] [[package]] @@ -13512,7 +13573,7 @@ dependencies = [ "anyhow", "cc", "cfg-if", - "indexmap", + "indexmap 1.9.3", "libc", "log", "mach", @@ -13520,7 +13581,7 @@ dependencies = [ "memoffset 0.8.0", "paste", "rand 0.8.5", - "rustix 0.36.14", + "rustix 0.36.15", "wasmtime-asm-macros", "wasmtime-environ", "wasmtime-jit-debug", @@ -13562,9 +13623,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.63" +version = "0.3.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bdd9ef4e984da1187bf8110c5cf5b845fbc87a23602cdf912386a76fcd3a7c2" +checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" dependencies = [ "js-sys", "wasm-bindgen", @@ -13622,10 +13683,10 @@ dependencies = [ "sdp", "serde", "serde_json", - "sha2 0.10.6", + "sha2 0.10.7", "stun", "thiserror", - "time 0.3.21", + "time 0.3.22", "tokio", "turn", "url", @@ -13685,7 +13746,7 @@ dependencies = [ "sec1 0.3.0", "serde", "sha1", - "sha2 0.10.6", + "sha2 0.10.7", "signature 1.6.4", "subtle", "thiserror", @@ -13727,7 +13788,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f08dfd7a6e3987e255c4dbe710dde5d94d0f0574f8a21afa95d171376c143106" dependencies = [ "log", - "socket2", + "socket2 0.4.9", "thiserror", "tokio", "webrtc-util", @@ -13794,7 +13855,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "93f1db1727772c05cf7a2cfece52c3aca8045ca1e176cd517d323489aa3c6d87" dependencies = [ "async-trait", - "bitflags", + "bitflags 1.3.2", "bytes", "cc", "ipnet", @@ -13821,9 +13882,9 @@ dependencies = [ [[package]] name = "wide" -version = "0.7.9" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cd0496a71f3cc6bc4bf0ed91346426a5099e93d89807e663162dc5a1069ff65" +checksum = "40018623e2dba2602a9790faba8d33f2ebdebf4b86561b83928db735f8784728" dependencies = [ "bytemuck", "safe_arch", @@ -13831,9 +13892,9 @@ dependencies = [ [[package]] name = "widestring" -version = "0.5.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17882f045410753661207383517a6f62ec3dbeb6a4ed2acce01f0728238d1983" +checksum = "653f141f39ec16bba3c5abe400a0c60da7468261cc2cbf36805022876bc721a8" [[package]] name = "winapi" @@ -13885,7 +13946,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" dependencies = [ - "windows-targets 0.48.0", + "windows-targets 0.48.1", ] [[package]] @@ -13903,7 +13964,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets 0.48.0", + "windows-targets 0.48.1", ] [[package]] @@ -13923,9 +13984,9 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.48.0" +version = "0.48.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" dependencies = [ "windows_aarch64_gnullvm 0.48.0", "windows_aarch64_msvc 0.48.0", @@ -14052,20 +14113,21 @@ checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" [[package]] name = "winnow" -version = "0.4.6" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61de7bac303dc551fe038e2b3cef0f571087a47571ea6e79a87692ac99b99699" +checksum = "81a2094c43cc94775293eaa0e499fbc30048a6d824ac82c0351a8c0bf9112529" dependencies = [ "memchr", ] [[package]] name = "winreg" -version = "0.10.1" +version = "0.50.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" dependencies = [ - "winapi", + "cfg-if", + "windows-sys 0.48.0", ] [[package]] @@ -14115,7 +14177,7 @@ dependencies = [ "ring", "rusticata-macros", "thiserror", - "time 0.3.21", + "time 0.3.22", ] [[package]] @@ -14133,7 +14195,7 @@ dependencies = [ "oid-registry 0.6.1", "rusticata-macros", "thiserror", - "time 0.3.21", + "time 0.3.22", ] [[package]] @@ -14171,7 +14233,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e17bb3549cc1321ae1296b9cdc2698e2b6cb1992adfa19a8c72e5b7a738f44cd" dependencies = [ - "time 0.3.21", + "time 0.3.22", ] [[package]] @@ -14191,7 +14253,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.23", ] [[package]] diff --git a/bin/node/runtime/src/impls.rs b/bin/node/runtime/src/impls.rs index 430a1ac2824b8..6cb874683421e 100644 --- a/bin/node/runtime/src/impls.rs +++ b/bin/node/runtime/src/impls.rs @@ -21,7 +21,7 @@ use frame_support::{ pallet_prelude::*, traits::{ fungibles::{Balanced, Credit}, - Currency, OnUnbalanced, + Bounded, Currency, OnUnbalanced, StorePreimage, }, }; use pallet_alliance::{IdentityVerifier, ProposalIndex, ProposalProvider}; @@ -29,7 +29,7 @@ use pallet_asset_tx_payment::HandleCredit; use sp_std::prelude::*; use crate::{ - AccountId, AllianceMotion, Assets, Authorship, Balances, Hash, NegativeImbalance, Runtime, + AccountId, AllianceMotion, Assets, Authorship, Balances, NegativeImbalance, Preimage, Runtime, RuntimeCall, }; @@ -77,7 +77,7 @@ impl IdentityVerifier for AllianceIdentityVerifier { } pub struct AllianceProposalProvider; -impl ProposalProvider for AllianceProposalProvider { +impl ProposalProvider for AllianceProposalProvider { fn propose_proposal( who: AccountId, threshold: u32, @@ -89,24 +89,33 @@ impl ProposalProvider for AllianceProposalProvider fn vote_proposal( who: AccountId, - proposal: Hash, + proposal_bounded: Bounded, index: ProposalIndex, approve: bool, ) -> Result { - AllianceMotion::do_vote(who, proposal, index, approve) + AllianceMotion::do_vote(who, proposal_bounded, index, approve) } fn close_proposal( - proposal_hash: Hash, + proposal_bounded: Bounded, proposal_index: ProposalIndex, proposal_weight_bound: Weight, length_bound: u32, ) -> DispatchResultWithPostInfo { - AllianceMotion::do_close(proposal_hash, proposal_index, proposal_weight_bound, length_bound) + AllianceMotion::do_close( + proposal_bounded, + proposal_index, + proposal_weight_bound, + length_bound, + ) } - fn proposal_of(proposal_hash: Hash) -> Option { - AllianceMotion::proposal_of(proposal_hash) + fn proposal_of(proposal_bounded: Bounded) -> Option { + AllianceMotion::proposal_of(proposal_bounded) + } + + fn bound_proposal(proposal: RuntimeCall) -> Result, DispatchError> { + Preimage::bound(proposal) } } diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 6a093996e8e52..b85123e3b09c2 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -1018,6 +1018,7 @@ impl pallet_collective::Config for Runtime { type WeightInfo = pallet_collective::weights::SubstrateWeight; type SetMembersOrigin = EnsureRoot; type MaxProposalWeight = MaxCollectivesProposalWeight; + type Preimages = Preimage; } parameter_types! { @@ -1079,6 +1080,7 @@ impl pallet_collective::Config for Runtime { type WeightInfo = pallet_collective::weights::SubstrateWeight; type SetMembersOrigin = EnsureRoot; type MaxProposalWeight = MaxCollectivesProposalWeight; + type Preimages = Preimage; } type EnsureRootOrHalfCouncil = EitherOfDiverse< @@ -1797,6 +1799,7 @@ impl pallet_collective::Config for Runtime { type WeightInfo = pallet_collective::weights::SubstrateWeight; type SetMembersOrigin = EnsureRoot; type MaxProposalWeight = MaxCollectivesProposalWeight; + type Preimages = Preimage; } parameter_types! { diff --git a/frame/alliance/src/benchmarking.rs b/frame/alliance/src/benchmarking.rs index 5b9f9c73b5694..bdd85cb3526a6 100644 --- a/frame/alliance/src/benchmarking.rs +++ b/frame/alliance/src/benchmarking.rs @@ -26,10 +26,7 @@ use sp_std::{ }; use frame_benchmarking::v1::{account, benchmarks_instance_pallet, BenchmarkError}; -use frame_support::{ - bounded_vec, - traits::{EnsureOrigin, Get, UnfilteredDispatchable}, -}; +use frame_support::traits::{EnsureOrigin, Get, UnfilteredDispatchable}; use frame_system::{pallet_prelude::BlockNumberFor, Pallet as System, RawOrigin as SystemOrigin}; use super::{Call as AllianceCall, Pallet as Alliance, *}; @@ -164,7 +161,7 @@ benchmarks_instance_pallet! { let threshold = m - 1; // Add previous proposals - let mut last_bound = frame_support::traits::Bounded::Inline(bounded_vec![]); + let mut last_bound = frame_support::traits::Bounded::Inline(vec![].try_into().unwrap()); for i in 0 .. p { // Proposals should be different let proposal: T::Proposal = AllianceCall::::set_rule { @@ -236,7 +233,7 @@ benchmarks_instance_pallet! { let threshold = m; // Add previous proposals - let mut last_bound = frame_support::traits::Bounded::Inline(bounded_vec![]); + let mut last_bound = frame_support::traits::Bounded::Inline(vec![].try_into().unwrap()); for i in 0 .. p { // Proposals should be different let proposal: T::Proposal = AllianceCall::::set_rule { @@ -314,7 +311,7 @@ benchmarks_instance_pallet! { let threshold = 2; // Add previous proposals - let mut last_bound = frame_support::traits::Bounded::Inline(bounded_vec![]); + let mut last_bound = frame_support::traits::Bounded::Inline(vec![].try_into().unwrap()); for i in 0 .. p { // Proposals should be different let proposal: T::Proposal = AllianceCall::::set_rule { @@ -397,7 +394,7 @@ benchmarks_instance_pallet! { let threshold = m - 1; // Add proposals - let mut last_bound = frame_support::traits::Bounded::Inline(bounded_vec![]); + let mut last_bound = frame_support::traits::Bounded::Inline(vec![].try_into().unwrap()); for i in 0 .. p { // Proposals should be different let proposal: T::Proposal = AllianceCall::::set_rule { @@ -466,7 +463,7 @@ benchmarks_instance_pallet! { let threshold = 2; // Add proposals - let mut last_bound = frame_support::traits::Bounded::Inline(bounded_vec![]); + let mut last_bound = frame_support::traits::Bounded::Inline(vec![].try_into().unwrap()); for i in 0 .. p { // Proposals should be different let proposal: T::Proposal = AllianceCall::::set_rule { diff --git a/frame/collective/src/benchmarking.rs b/frame/collective/src/benchmarking.rs index 44dcc444eede8..5caabf79d8089 100644 --- a/frame/collective/src/benchmarking.rs +++ b/frame/collective/src/benchmarking.rs @@ -21,7 +21,6 @@ use super::*; use crate::Pallet as Collective; use frame_benchmarking::v1::{account, benchmarks_instance_pallet, whitelisted_caller}; -use frame_support::bounded_vec; use frame_system::{ pallet_prelude::BlockNumberFor, Call as SystemCall, Pallet as System, RawOrigin as SystemOrigin, }; @@ -237,7 +236,7 @@ benchmarks_instance_pallet! { let threshold = m - 1; // Add previous proposals - let mut last_bound = frame_support::traits::Bounded::Inline(bounded_vec![]); + let mut last_bound = frame_support::traits::Bounded::Inline(vec![].try_into().unwrap()); for i in 0 .. p { // Proposals should be different let proposal: T::Proposal = SystemCall::::remark { remark: id_to_remark_data(i, b as usize) }.into(); @@ -312,7 +311,7 @@ benchmarks_instance_pallet! { let threshold = m; // Add previous proposals - let mut last_bound = frame_support::traits::Bounded::Inline(bounded_vec![]); + let mut last_bound = frame_support::traits::Bounded::Inline(vec![].try_into().unwrap()); for i in 0 .. p { // Proposals should be different let proposal: T::Proposal = SystemCall::::remark { remark: id_to_remark_data(i, bytes as usize) }.into(); @@ -389,7 +388,7 @@ benchmarks_instance_pallet! { let threshold = 2; // Add previous proposals - let mut last_bound = frame_support::traits::Bounded::Inline(bounded_vec![]); + let mut last_bound = frame_support::traits::Bounded::Inline(vec![].try_into().unwrap()); for i in 0 .. p { // Proposals should be different let proposal: T::Proposal = SystemCall::::remark { remark: id_to_remark_data(i, b as usize) }.into(); @@ -475,7 +474,7 @@ benchmarks_instance_pallet! { let threshold = m - 1; // Add proposals - let mut last_bound = frame_support::traits::Bounded::Inline(bounded_vec![]); + let mut last_bound = frame_support::traits::Bounded::Inline(vec![].try_into().unwrap()); for i in 0 .. p { // Proposals should be different let proposal: T::Proposal = SystemCall::::remark { remark: id_to_remark_data(i, bytes as usize) }.into(); @@ -557,7 +556,7 @@ benchmarks_instance_pallet! { let threshold = 2; // Add proposals - let mut last_bound = frame_support::traits::Bounded::Inline(bounded_vec![]); + let mut last_bound = frame_support::traits::Bounded::Inline(vec![].try_into().unwrap()); for i in 0 .. p { // Proposals should be different let proposal: T::Proposal = SystemCall::::remark { remark: id_to_remark_data(i, b as usize) }.into(); @@ -628,7 +627,7 @@ benchmarks_instance_pallet! { let threshold = m - 1; // Add proposals - let mut last_bound = frame_support::traits::Bounded::Inline(bounded_vec![]); + let mut last_bound = frame_support::traits::Bounded::Inline(vec![].try_into().unwrap()); for i in 0 .. p { // Proposals should be different let proposal: T::Proposal = SystemCall::::remark { remark: id_to_remark_data(i, b as usize) }.into(); diff --git a/frame/collective/src/lib.rs b/frame/collective/src/lib.rs index 4c6a170ee0b57..f56ac85e49849 100644 --- a/frame/collective/src/lib.rs +++ b/frame/collective/src/lib.rs @@ -747,8 +747,8 @@ impl, I: 'static> Pallet { Votes { index, threshold, - ayes: frame_support::bounded_vec![], - nays: frame_support::bounded_vec![], + ayes: vec![].try_into().expect("empty vec is always bounded; qed"), + nays: vec![].try_into().expect("empty vec is always bounded; qed"), end, } }; diff --git a/frame/collective/src/migrations/v5.rs b/frame/collective/src/migrations/v5.rs index d9dc196d6ab03..f7cdc5e3cd3a9 100644 --- a/frame/collective/src/migrations/v5.rs +++ b/frame/collective/src/migrations/v5.rs @@ -90,20 +90,14 @@ pub fn migrate, I: 'static>() -> Weight { crate::Votes::, >::MaxMembers> { index: vote.index, threshold: vote.threshold, - ayes: vote.ayes.try_into().expect( - format!( - "runtime::collective migration failed, ayes for vote {:?} should not overflow", - vote.index - ) - .as_str(), - ), - nays: vote.nays.try_into().expect( - format!( - "runtime::collective migration failed, nays for vote {:?} should not overflow", - vote.index, - ) - .as_str(), - ), + ayes: vote + .ayes + .try_into() + .expect("runtime::collective migration failed, ayes overflow"), + nays: vote + .nays + .try_into() + .expect("runtime::collective migration failed, nays overflow"), end: vote.end, }; diff --git a/frame/utility/src/tests.rs b/frame/utility/src/tests.rs index d7e532030b15c..ed1e21cd7add0 100644 --- a/frame/utility/src/tests.rs +++ b/frame/utility/src/tests.rs @@ -33,7 +33,6 @@ use frame_support::{ use pallet_collective::{EnsureProportionAtLeast, Instance1}; use sp_core::H256; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, IdentityLookup}, BuildStorage, TokenError, }; From fb89761a5b27f45073298aebbdb21d9c5204fabe Mon Sep 17 00:00:00 2001 From: muraca Date: Tue, 20 Jun 2023 17:03:51 +0200 Subject: [PATCH 6/8] bounded Members, removed without_storage_info Signed-off-by: muraca --- frame/collective/src/benchmarking.rs | 22 +++++++++---------- frame/collective/src/lib.rs | 21 ++++++------------ frame/collective/src/migrations/v5.rs | 4 ++++ frame/collective/src/tests.rs | 31 +++++++++++++++------------ 4 files changed, 39 insertions(+), 39 deletions(-) diff --git a/frame/collective/src/benchmarking.rs b/frame/collective/src/benchmarking.rs index 5caabf79d8089..f88085bd12ac4 100644 --- a/frame/collective/src/benchmarking.rs +++ b/frame/collective/src/benchmarking.rs @@ -56,7 +56,7 @@ benchmarks_instance_pallet! { Collective::::set_members( SystemOrigin::Root.into(), - old_members.clone(), + old_members.clone().try_into().unwrap(), old_members.last().cloned(), T::MaxMembers::get(), )?; @@ -101,7 +101,7 @@ benchmarks_instance_pallet! { new_members.push(member); } - }: _(SystemOrigin::Root, new_members.clone(), new_members.last().cloned(), T::MaxMembers::get()) + }: _(SystemOrigin::Root, new_members.clone().try_into().unwrap(), new_members.last().cloned(), T::MaxMembers::get()) verify { new_members.sort(); assert_eq!(Collective::::members(), new_members); @@ -123,7 +123,7 @@ benchmarks_instance_pallet! { let caller: T::AccountId = whitelisted_caller(); members.push(caller.clone()); - Collective::::set_members(SystemOrigin::Root.into(), members, None, T::MaxMembers::get())?; + Collective::::set_members(SystemOrigin::Root.into(), members.try_into().unwrap(), None, T::MaxMembers::get())?; let proposal: T::Proposal = SystemCall::::remark { remark: id_to_remark_data(1, b as usize) }.into(); @@ -153,7 +153,7 @@ benchmarks_instance_pallet! { let caller: T::AccountId = whitelisted_caller(); members.push(caller.clone()); - Collective::::set_members(SystemOrigin::Root.into(), members, None, T::MaxMembers::get())?; + Collective::::set_members(SystemOrigin::Root.into(), members.try_into().unwrap(), None, T::MaxMembers::get())?; let proposal: T::Proposal = SystemCall::::remark { remark: id_to_remark_data(1, b as usize) }.into(); let threshold = 1; @@ -183,7 +183,7 @@ benchmarks_instance_pallet! { } let caller: T::AccountId = whitelisted_caller(); members.push(caller.clone()); - Collective::::set_members(SystemOrigin::Root.into(), members, None, T::MaxMembers::get())?; + Collective::::set_members(SystemOrigin::Root.into(), members.try_into().unwrap(), None, T::MaxMembers::get())?; let threshold = m; // Add previous proposals. @@ -230,7 +230,7 @@ benchmarks_instance_pallet! { } let voter: T::AccountId = account::("voter", 0, SEED); members.push(voter.clone()); - Collective::::set_members(SystemOrigin::Root.into(), members.clone(), None, T::MaxMembers::get())?; + Collective::::set_members(SystemOrigin::Root.into(), members.clone().try_into().unwrap(), None, T::MaxMembers::get())?; // Threshold is 1 less than the number of members so that one person can vote nay let threshold = m - 1; @@ -305,7 +305,7 @@ benchmarks_instance_pallet! { } let voter = account::("voter", 0, SEED); members.push(voter.clone()); - Collective::::set_members(SystemOrigin::Root.into(), members.clone(), None, T::MaxMembers::get())?; + Collective::::set_members(SystemOrigin::Root.into(), members.clone().try_into().unwrap(), None, T::MaxMembers::get())?; // Threshold is total members so that one nay will disapprove the vote let threshold = m; @@ -382,7 +382,7 @@ benchmarks_instance_pallet! { } let caller: T::AccountId = whitelisted_caller(); members.push(caller.clone()); - Collective::::set_members(SystemOrigin::Root.into(), members.clone(), None, T::MaxMembers::get())?; + Collective::::set_members(SystemOrigin::Root.into(), members.clone().try_into().unwrap(), None, T::MaxMembers::get())?; // Threshold is 2 so any two ayes will approve the vote let threshold = 2; @@ -465,7 +465,7 @@ benchmarks_instance_pallet! { members.push(caller.clone()); Collective::::set_members( SystemOrigin::Root.into(), - members.clone(), + members.clone().try_into().unwrap(), Some(caller.clone()), T::MaxMembers::get(), )?; @@ -547,7 +547,7 @@ benchmarks_instance_pallet! { members.push(caller.clone()); Collective::::set_members( SystemOrigin::Root.into(), - members.clone(), + members.clone().try_into().unwrap(), Some(caller.clone()), T::MaxMembers::get(), )?; @@ -618,7 +618,7 @@ benchmarks_instance_pallet! { members.push(caller.clone()); Collective::::set_members( SystemOrigin::Root.into(), - members.clone(), + members.clone().try_into().unwrap(), Some(caller.clone()), T::MaxMembers::get(), )?; diff --git a/frame/collective/src/lib.rs b/frame/collective/src/lib.rs index f56ac85e49849..a7d551d8590ce 100644 --- a/frame/collective/src/lib.rs +++ b/frame/collective/src/lib.rs @@ -184,11 +184,10 @@ pub mod pallet { use frame_system::pallet_prelude::*; /// The current storage version. - const STORAGE_VERSION: StorageVersion = StorageVersion::new(4); + const STORAGE_VERSION: StorageVersion = StorageVersion::new(5); #[pallet::pallet] #[pallet::storage_version(STORAGE_VERSION)] - #[pallet::without_storage_info] pub struct Pallet(PhantomData<(T, I)>); #[pallet::config] @@ -289,7 +288,7 @@ pub mod pallet { #[pallet::storage] #[pallet::getter(fn members)] pub type Members, I: 'static = ()> = - StorageValue<_, Vec, ValueQuery>; + StorageValue<_, BoundedVec, ValueQuery>; /// The prime member that helps determine the default vote behavior in case of absentations. #[pallet::storage] @@ -400,19 +399,11 @@ pub mod pallet { ))] pub fn set_members( origin: OriginFor, - new_members: Vec, + new_members: BoundedVec, prime: Option, old_count: MemberCount, ) -> DispatchResultWithPostInfo { T::SetMembersOrigin::ensure_origin(origin)?; - if new_members.len() > T::MaxMembers::get() as usize { - log::error!( - target: LOG_TARGET, - "New members count ({}) exceeds maximum amount of members expected ({}).", - new_members.len(), - T::MaxMembers::get(), - ); - } let old = Members::::get(); if old.len() > old_count as usize { @@ -1113,7 +1104,9 @@ impl, I: 'static> ChangeMembers for Pallet { } }); } - Members::::put(new); + Members::::put( + BoundedVec::try_from(new.to_vec()).expect("Members bound was already checked; qed"), + ); Prime::::kill(); } @@ -1132,7 +1125,7 @@ impl, I: 'static> InitializeMembers for Pallet assert!(>::get().is_empty(), "Members are already initialized!"); let mut members = members.to_vec(); members.sort(); - >::put(members); + >::put(BoundedVec::try_from(members).expect("Members are too many")); } } } diff --git a/frame/collective/src/migrations/v5.rs b/frame/collective/src/migrations/v5.rs index f7cdc5e3cd3a9..77366c69ac344 100644 --- a/frame/collective/src/migrations/v5.rs +++ b/frame/collective/src/migrations/v5.rs @@ -52,6 +52,10 @@ pub type Voting, I: 'static> = StorageMap< OptionQuery, >; +#[frame_support::storage_alias] +pub type Members, I: 'static> = + StorageValue, Vec<::AccountId>, ValueQuery>; + /// Info for keeping track of a motion being voted on. #[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, TypeInfo)] pub struct OldVotes { diff --git a/frame/collective/src/tests.rs b/frame/collective/src/tests.rs index eea2f19da7efd..f304fe55bb807 100644 --- a/frame/collective/src/tests.rs +++ b/frame/collective/src/tests.rs @@ -375,7 +375,7 @@ fn close_works() { fn proposal_weight_limit_works_on_approve() { ExtBuilder::default().build_and_execute(|| { let proposal = RuntimeCall::Collective(crate::Call::set_members { - new_members: vec![1, 2, 3], + new_members: vec![1, 2, 3].try_into().unwrap(), prime: None, old_count: MaxMembers::get(), }); @@ -417,7 +417,7 @@ fn proposal_weight_limit_works_on_approve() { fn proposal_weight_limit_ignored_on_disapprove() { ExtBuilder::default().build_and_execute(|| { let proposal = RuntimeCall::Collective(crate::Call::set_members { - new_members: vec![1, 2, 3], + new_members: vec![1, 2, 3].try_into().unwrap(), prime: None, old_count: MaxMembers::get(), }); @@ -452,7 +452,7 @@ fn close_with_prime_works() { let proposal_weight = proposal.get_dispatch_info().weight; assert_ok!(Collective::set_members( RuntimeOrigin::root(), - vec![1, 2, 3], + vec![1, 2, 3].try_into().unwrap(), Some(3), MaxMembers::get() )); @@ -519,7 +519,7 @@ fn close_with_voting_prime_works() { let proposal_weight = proposal.get_dispatch_info().weight; assert_ok!(Collective::set_members( RuntimeOrigin::root(), - vec![1, 2, 3], + vec![1, 2, 3].try_into().unwrap(), Some(1), MaxMembers::get() )); @@ -592,7 +592,7 @@ fn close_with_no_prime_but_majority_works() { let proposal_weight = proposal.get_dispatch_info().weight; assert_ok!(CollectiveMajority::set_members( RuntimeOrigin::root(), - vec![1, 2, 3, 4, 5], + vec![1, 2, 3, 4, 5].try_into().unwrap(), Some(5), MaxMembers::get() )); @@ -782,7 +782,7 @@ fn removal_of_old_voters_votes_works_with_set_members() { ); assert_ok!(Collective::set_members( RuntimeOrigin::root(), - vec![2, 3, 4], + vec![2, 3, 4].try_into().unwrap(), None, MaxMembers::get() )); @@ -821,7 +821,7 @@ fn removal_of_old_voters_votes_works_with_set_members() { ); assert_ok!(Collective::set_members( RuntimeOrigin::root(), - vec![2, 4], + vec![2, 4].try_into().unwrap(), None, MaxMembers::get() )); @@ -900,7 +900,7 @@ fn limit_active_proposals() { fn correct_validate_and_get_proposal() { ExtBuilder::default().build_and_execute(|| { let proposal = RuntimeCall::Collective(crate::Call::set_members { - new_members: vec![1, 2, 3], + new_members: vec![1, 2, 3].try_into().unwrap(), prime: None, old_count: MaxMembers::get(), }); @@ -1671,7 +1671,13 @@ fn migration_v4() { fn migration_v5() { ExtBuilder::default().build_and_execute(|| { use sp_runtime::traits::Hash; - assert_eq!(StorageVersion::get::>(), 4); + StorageVersion::put::>(&StorageVersion::new(4)); + + // Setup the members. + let members: Vec<::AccountId> = + (1..::MaxMembers::get()).map(|i| i.into()).collect(); + + crate::migrations::v5::Members::::put(members.clone()); // Create a proposal. let proposal = ::RuntimeCall::System( @@ -1684,13 +1690,10 @@ fn migration_v5() { crate::migrations::v5::ProposalOf::::insert(proposal_hash, proposal.clone()); // Create some votes. - let ayes: Vec<::AccountId> = - (1..::MaxMembers::get()).map(|i| i.into()).collect(); - let vote = crate::migrations::v5::OldVotes { index: 0, threshold: 1, - ayes: ayes.clone(), + ayes: members.clone(), nays: bounded_vec![], end: 100, }; @@ -1711,7 +1714,7 @@ fn migration_v5() { BoundedVec::< ::AccountId, ::MaxMembers - >::try_from(ayes) + >::try_from(members) .unwrap() ); }); From 88ed80438b446231e9ee52693d0f24dc06023763 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Tue, 20 Jun 2023 19:03:44 +0000 Subject: [PATCH 7/8] ".git/.scripts/commands/bench/bench.sh" pallet dev pallet-collective --- frame/collective/src/weights.rs | 632 ++++++++++++++++---------------- 1 file changed, 311 insertions(+), 321 deletions(-) diff --git a/frame/collective/src/weights.rs b/frame/collective/src/weights.rs index eece6a006b8f2..ac6c2621d21c4 100644 --- a/frame/collective/src/weights.rs +++ b/frame/collective/src/weights.rs @@ -18,28 +18,26 @@ //! Autogenerated weights for pallet_collective //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-06-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-06-20, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `runner-e8ezs4ez-project-145-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: -// ./target/production/substrate +// target/production/substrate // benchmark // pallet -// --chain=dev // --steps=50 // --repeat=20 -// --pallet=pallet_collective -// --no-storage-info -// --no-median-slopes -// --no-min-squares // --extrinsic=* // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --output=./frame/collective/src/weights.rs +// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/substrate/.git/.artifacts/bench.json +// --pallet=pallet-collective +// --chain=dev // --header=./HEADER-APACHE2 +// --output=./frame/collective/src/weights.rs // --template=./.maintain/frame-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -68,491 +66,483 @@ pub trait WeightInfo { pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { /// Storage: Council Members (r:1 w:1) - /// Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Council Proposals (r:1 w:0) - /// Proof Skipped: Council Proposals (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Council Voting (r:100 w:100) - /// Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) + /// Proof: Council Members (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Council Voting (r:101 w:100) + /// Proof: Council Voting (max_values: None, max_size: Some(6547), added: 9022, mode: MaxEncodedLen) /// Storage: Council Prime (r:0 w:1) - /// Proof Skipped: Council Prime (max_values: Some(1), max_size: None, mode: Measured) + /// Proof: Council Prime (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) /// The range of component `m` is `[0, 100]`. /// The range of component `n` is `[0, 100]`. /// The range of component `p` is `[0, 100]`. fn set_members(m: u32, _n: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `0 + m * (3232 ±0) + p * (3190 ±0)` - // Estimated: `15861 + m * (1967 ±24) + p * (4332 ±24)` - // Minimum execution time: 17_506_000 picoseconds. - Weight::from_parts(17_767_000, 15861) - // Standard Error: 60_220 - .saturating_add(Weight::from_parts(4_374_805, 0).saturating_mul(m.into())) - // Standard Error: 60_220 - .saturating_add(Weight::from_parts(8_398_316, 0).saturating_mul(p.into())) + // Measured: `0 + m * (3233 ±0) + p * (3227 ±0)` + // Estimated: `10012 + m * (334 ±45) + p * (8826 ±45)` + // Minimum execution time: 23_002_000 picoseconds. + Weight::from_parts(23_136_000, 10012) + // Standard Error: 75_511 + .saturating_add(Weight::from_parts(5_821_035, 0).saturating_mul(m.into())) + // Standard Error: 75_511 + .saturating_add(Weight::from_parts(10_356_635, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(p.into()))) .saturating_add(T::DbWeight::get().writes(2_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(p.into()))) - .saturating_add(Weight::from_parts(0, 1967).saturating_mul(m.into())) - .saturating_add(Weight::from_parts(0, 4332).saturating_mul(p.into())) + .saturating_add(Weight::from_parts(0, 334).saturating_mul(m.into())) + .saturating_add(Weight::from_parts(0, 8826).saturating_mul(p.into())) } /// Storage: Council Members (r:1 w:0) - /// Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) + /// Proof: Council Members (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Preimage StatusFor (r:1 w:1) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) + /// Storage: Preimage PreimageFor (r:0 w:1) + /// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: MaxEncodedLen) /// The range of component `b` is `[2, 1024]`. /// The range of component `m` is `[1, 100]`. fn execute(b: u32, m: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `202 + m * (32 ±0)` - // Estimated: `1688 + m * (32 ±0)` - // Minimum execution time: 16_203_000 picoseconds. - Weight::from_parts(15_348_267, 1688) - // Standard Error: 37 - .saturating_add(Weight::from_parts(1_766, 0).saturating_mul(b.into())) - // Standard Error: 382 - .saturating_add(Weight::from_parts(15_765, 0).saturating_mul(m.into())) + // Measured: `244 + m * (32 ±0)` + // Estimated: `4687` + // Minimum execution time: 16_842_000 picoseconds. + Weight::from_parts(22_610_183, 4687) + // Standard Error: 515 + .saturating_add(Weight::from_parts(6_030, 0).saturating_mul(b.into())) + // Standard Error: 5_309 + .saturating_add(Weight::from_parts(36_145, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(Weight::from_parts(0, 32).saturating_mul(m.into())) + .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: Council Members (r:1 w:0) - /// Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Council ProposalOf (r:1 w:0) - /// Proof Skipped: Council ProposalOf (max_values: None, max_size: None, mode: Measured) + /// Proof: Council Members (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Preimage StatusFor (r:1 w:1) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) + /// Storage: Council Voting (r:1 w:0) + /// Proof: Council Voting (max_values: None, max_size: Some(6547), added: 9022, mode: MaxEncodedLen) + /// Storage: Preimage PreimageFor (r:0 w:1) + /// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: MaxEncodedLen) /// The range of component `b` is `[2, 1024]`. /// The range of component `m` is `[1, 100]`. fn propose_execute(b: u32, m: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `202 + m * (32 ±0)` - // Estimated: `3668 + m * (32 ±0)` - // Minimum execution time: 18_642_000 picoseconds. - Weight::from_parts(17_708_609, 3668) - // Standard Error: 58 - .saturating_add(Weight::from_parts(2_285, 0).saturating_mul(b.into())) - // Standard Error: 598 - .saturating_add(Weight::from_parts(30_454, 0).saturating_mul(m.into())) + // Measured: `244 + m * (32 ±0)` + // Estimated: `10012` + // Minimum execution time: 20_433_000 picoseconds. + Weight::from_parts(27_303_080, 10012) + // Standard Error: 698 + .saturating_add(Weight::from_parts(9_912, 0).saturating_mul(b.into())) + // Standard Error: 7_198 + .saturating_add(Weight::from_parts(69_523, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(Weight::from_parts(0, 32).saturating_mul(m.into())) + .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: Council Members (r:1 w:0) - /// Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Council ProposalOf (r:1 w:1) - /// Proof Skipped: Council ProposalOf (max_values: None, max_size: None, mode: Measured) - /// Storage: Council Proposals (r:1 w:1) - /// Proof Skipped: Council Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Proof: Council Members (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Preimage StatusFor (r:1 w:1) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) + /// Storage: Council Voting (r:1 w:1) + /// Proof: Council Voting (max_values: None, max_size: Some(6547), added: 9022, mode: MaxEncodedLen) + /// Storage: Council CounterForVoting (r:1 w:1) + /// Proof: Council CounterForVoting (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: Council ProposalCount (r:1 w:1) - /// Proof Skipped: Council ProposalCount (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Council Voting (r:0 w:1) - /// Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) + /// Proof: Council ProposalCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Preimage PreimageFor (r:0 w:1) + /// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: MaxEncodedLen) /// The range of component `b` is `[2, 1024]`. /// The range of component `m` is `[2, 100]`. /// The range of component `p` is `[1, 100]`. fn propose_proposed(b: u32, m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `492 + m * (32 ±0) + p * (36 ±0)` - // Estimated: `3884 + m * (33 ±0) + p * (36 ±0)` - // Minimum execution time: 27_067_000 picoseconds. - Weight::from_parts(25_456_964, 3884) - // Standard Error: 112 - .saturating_add(Weight::from_parts(3_773, 0).saturating_mul(b.into())) - // Standard Error: 1_177 - .saturating_add(Weight::from_parts(32_783, 0).saturating_mul(m.into())) - // Standard Error: 1_162 - .saturating_add(Weight::from_parts(194_388, 0).saturating_mul(p.into())) + // Measured: `689 + m * (32 ±0) + p * (9 ±0)` + // Estimated: `10012` + // Minimum execution time: 30_349_000 picoseconds. + Weight::from_parts(31_624_126, 10012) + // Standard Error: 326 + .saturating_add(Weight::from_parts(8_551, 0).saturating_mul(b.into())) + // Standard Error: 3_403 + .saturating_add(Weight::from_parts(45_550, 0).saturating_mul(m.into())) + // Standard Error: 3_360 + .saturating_add(Weight::from_parts(52_641, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) - .saturating_add(Weight::from_parts(0, 33).saturating_mul(m.into())) - .saturating_add(Weight::from_parts(0, 36).saturating_mul(p.into())) } /// Storage: Council Members (r:1 w:0) - /// Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) + /// Proof: Council Members (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) /// Storage: Council Voting (r:1 w:1) - /// Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) + /// Proof: Council Voting (max_values: None, max_size: Some(6547), added: 9022, mode: MaxEncodedLen) /// The range of component `m` is `[5, 100]`. fn vote(m: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `941 + m * (64 ±0)` - // Estimated: `4405 + m * (64 ±0)` - // Minimum execution time: 26_055_000 picoseconds. - Weight::from_parts(27_251_907, 4405) - // Standard Error: 1_008 - .saturating_add(Weight::from_parts(65_947, 0).saturating_mul(m.into())) + // Measured: `891 + m * (64 ±0)` + // Estimated: `10012` + // Minimum execution time: 23_810_000 picoseconds. + Weight::from_parts(24_512_099, 10012) + // Standard Error: 627 + .saturating_add(Weight::from_parts(52_608, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) - .saturating_add(Weight::from_parts(0, 64).saturating_mul(m.into())) } /// Storage: Council Voting (r:1 w:1) - /// Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) + /// Proof: Council Voting (max_values: None, max_size: Some(6547), added: 9022, mode: MaxEncodedLen) /// Storage: Council Members (r:1 w:0) - /// Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Council Proposals (r:1 w:1) - /// Proof Skipped: Council Proposals (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Council ProposalOf (r:0 w:1) - /// Proof Skipped: Council ProposalOf (max_values: None, max_size: None, mode: Measured) + /// Proof: Council Members (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Council CounterForVoting (r:1 w:1) + /// Proof: Council CounterForVoting (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// The range of component `m` is `[4, 100]`. /// The range of component `p` is `[1, 100]`. fn close_early_disapproved(m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `530 + m * (64 ±0) + p * (36 ±0)` - // Estimated: `3975 + m * (65 ±0) + p * (36 ±0)` - // Minimum execution time: 28_363_000 picoseconds. - Weight::from_parts(28_733_464, 3975) - // Standard Error: 1_275 - .saturating_add(Weight::from_parts(43_236, 0).saturating_mul(m.into())) - // Standard Error: 1_244 - .saturating_add(Weight::from_parts(180_187, 0).saturating_mul(p.into())) + // Measured: `455 + m * (64 ±0) + p * (2 ±0)` + // Estimated: `10012` + // Minimum execution time: 31_272_000 picoseconds. + Weight::from_parts(29_968_548, 10012) + // Standard Error: 508 + .saturating_add(Weight::from_parts(31_759, 0).saturating_mul(m.into())) + // Standard Error: 495 + .saturating_add(Weight::from_parts(19_121, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 65).saturating_mul(m.into())) - .saturating_add(Weight::from_parts(0, 36).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().writes(2_u64)) } /// Storage: Council Voting (r:1 w:1) - /// Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) + /// Proof: Council Voting (max_values: None, max_size: Some(6547), added: 9022, mode: MaxEncodedLen) /// Storage: Council Members (r:1 w:0) - /// Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Council ProposalOf (r:1 w:1) - /// Proof Skipped: Council ProposalOf (max_values: None, max_size: None, mode: Measured) - /// Storage: Council Proposals (r:1 w:1) - /// Proof Skipped: Council Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Proof: Council Members (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Preimage PreimageFor (r:1 w:1) + /// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: MaxEncodedLen) + /// Storage: Council CounterForVoting (r:1 w:1) + /// Proof: Council CounterForVoting (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Preimage StatusFor (r:1 w:1) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) /// The range of component `b` is `[2, 1024]`. /// The range of component `m` is `[4, 100]`. /// The range of component `p` is `[1, 100]`. fn close_early_approved(b: u32, m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `832 + b * (1 ±0) + m * (64 ±0) + p * (40 ±0)` - // Estimated: `4149 + b * (1 ±0) + m * (66 ±0) + p * (40 ±0)` - // Minimum execution time: 40_391_000 picoseconds. - Weight::from_parts(42_695_215, 4149) - // Standard Error: 167 - .saturating_add(Weight::from_parts(3_622, 0).saturating_mul(b.into())) - // Standard Error: 1_772 - .saturating_add(Weight::from_parts(33_830, 0).saturating_mul(m.into())) - // Standard Error: 1_727 - .saturating_add(Weight::from_parts(205_374, 0).saturating_mul(p.into())) + // Measured: `972 + b * (1 ±0) + m * (64 ±0) + p * (12 ±0)` + // Estimated: `4197809` + // Minimum execution time: 38_426_000 picoseconds. + Weight::from_parts(42_168_976, 4197809) + // Standard Error: 382 + .saturating_add(Weight::from_parts(11_597, 0).saturating_mul(b.into())) + // Standard Error: 4_041 + .saturating_add(Weight::from_parts(39_322, 0).saturating_mul(m.into())) + // Standard Error: 3_939 + .saturating_add(Weight::from_parts(73_805, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 1).saturating_mul(b.into())) - .saturating_add(Weight::from_parts(0, 66).saturating_mul(m.into())) - .saturating_add(Weight::from_parts(0, 40).saturating_mul(p.into())) } /// Storage: Council Voting (r:1 w:1) - /// Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) + /// Proof: Council Voting (max_values: None, max_size: Some(6547), added: 9022, mode: MaxEncodedLen) /// Storage: Council Members (r:1 w:0) - /// Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) + /// Proof: Council Members (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) /// Storage: Council Prime (r:1 w:0) - /// Proof Skipped: Council Prime (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Council Proposals (r:1 w:1) - /// Proof Skipped: Council Proposals (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Council ProposalOf (r:0 w:1) - /// Proof Skipped: Council ProposalOf (max_values: None, max_size: None, mode: Measured) + /// Proof: Council Prime (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) + /// Storage: Council CounterForVoting (r:1 w:1) + /// Proof: Council CounterForVoting (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// The range of component `m` is `[4, 100]`. /// The range of component `p` is `[1, 100]`. fn close_disapproved(m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `550 + m * (64 ±0) + p * (36 ±0)` - // Estimated: `3995 + m * (65 ±0) + p * (36 ±0)` - // Minimum execution time: 31_368_000 picoseconds. - Weight::from_parts(32_141_835, 3995) - // Standard Error: 1_451 - .saturating_add(Weight::from_parts(36_372, 0).saturating_mul(m.into())) - // Standard Error: 1_415 - .saturating_add(Weight::from_parts(210_635, 0).saturating_mul(p.into())) + // Measured: `474 + m * (64 ±0) + p * (2 ±0)` + // Estimated: `10012` + // Minimum execution time: 34_363_000 picoseconds. + Weight::from_parts(33_487_826, 10012) + // Standard Error: 685 + .saturating_add(Weight::from_parts(32_747, 0).saturating_mul(m.into())) + // Standard Error: 668 + .saturating_add(Weight::from_parts(15_881, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 65).saturating_mul(m.into())) - .saturating_add(Weight::from_parts(0, 36).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().writes(2_u64)) } /// Storage: Council Voting (r:1 w:1) - /// Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) + /// Proof: Council Voting (max_values: None, max_size: Some(6547), added: 9022, mode: MaxEncodedLen) /// Storage: Council Members (r:1 w:0) - /// Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) + /// Proof: Council Members (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) /// Storage: Council Prime (r:1 w:0) - /// Proof Skipped: Council Prime (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Council ProposalOf (r:1 w:1) - /// Proof Skipped: Council ProposalOf (max_values: None, max_size: None, mode: Measured) - /// Storage: Council Proposals (r:1 w:1) - /// Proof Skipped: Council Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Proof: Council Prime (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) + /// Storage: Preimage PreimageFor (r:1 w:1) + /// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: MaxEncodedLen) + /// Storage: Council CounterForVoting (r:1 w:1) + /// Proof: Council CounterForVoting (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Preimage StatusFor (r:1 w:1) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) /// The range of component `b` is `[2, 1024]`. /// The range of component `m` is `[4, 100]`. /// The range of component `p` is `[1, 100]`. fn close_approved(b: u32, m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `852 + b * (1 ±0) + m * (64 ±0) + p * (40 ±0)` - // Estimated: `4169 + b * (1 ±0) + m * (66 ±0) + p * (40 ±0)` - // Minimum execution time: 43_271_000 picoseconds. - Weight::from_parts(45_495_648, 4169) - // Standard Error: 174 - .saturating_add(Weight::from_parts(3_034, 0).saturating_mul(b.into())) - // Standard Error: 1_840 - .saturating_add(Weight::from_parts(42_209, 0).saturating_mul(m.into())) - // Standard Error: 1_793 - .saturating_add(Weight::from_parts(207_525, 0).saturating_mul(p.into())) + // Measured: `992 + b * (1 ±0) + m * (64 ±0) + p * (12 ±0)` + // Estimated: `4197809` + // Minimum execution time: 41_697_000 picoseconds. + Weight::from_parts(45_580_292, 4197809) + // Standard Error: 378 + .saturating_add(Weight::from_parts(11_125, 0).saturating_mul(b.into())) + // Standard Error: 4_003 + .saturating_add(Weight::from_parts(36_935, 0).saturating_mul(m.into())) + // Standard Error: 3_902 + .saturating_add(Weight::from_parts(71_157, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 1).saturating_mul(b.into())) - .saturating_add(Weight::from_parts(0, 66).saturating_mul(m.into())) - .saturating_add(Weight::from_parts(0, 40).saturating_mul(p.into())) } - /// Storage: Council Proposals (r:1 w:1) - /// Proof Skipped: Council Proposals (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Council Voting (r:0 w:1) - /// Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) - /// Storage: Council ProposalOf (r:0 w:1) - /// Proof Skipped: Council ProposalOf (max_values: None, max_size: None, mode: Measured) + /// Storage: Council CounterForVoting (r:1 w:1) + /// Proof: Council CounterForVoting (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Council Voting (r:1 w:1) + /// Proof: Council Voting (max_values: None, max_size: Some(6547), added: 9022, mode: MaxEncodedLen) + /// Storage: Preimage StatusFor (r:1 w:1) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) + /// Storage: Preimage PreimageFor (r:0 w:1) + /// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: MaxEncodedLen) /// The range of component `p` is `[1, 100]`. fn disapprove_proposal(p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `359 + p * (32 ±0)` - // Estimated: `1844 + p * (32 ±0)` - // Minimum execution time: 15_170_000 picoseconds. - Weight::from_parts(17_567_243, 1844) - // Standard Error: 1_430 - .saturating_add(Weight::from_parts(169_040, 0).saturating_mul(p.into())) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 32).saturating_mul(p.into())) + // Measured: `1131 + p * (9 ±0)` + // Estimated: `10012` + // Minimum execution time: 29_792_000 picoseconds. + Weight::from_parts(33_599_529, 10012) + // Standard Error: 2_176 + .saturating_add(Weight::from_parts(38_685, 0).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) } } // For backwards compatibility and tests impl WeightInfo for () { /// Storage: Council Members (r:1 w:1) - /// Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Council Proposals (r:1 w:0) - /// Proof Skipped: Council Proposals (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Council Voting (r:100 w:100) - /// Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) + /// Proof: Council Members (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Council Voting (r:101 w:100) + /// Proof: Council Voting (max_values: None, max_size: Some(6547), added: 9022, mode: MaxEncodedLen) /// Storage: Council Prime (r:0 w:1) - /// Proof Skipped: Council Prime (max_values: Some(1), max_size: None, mode: Measured) + /// Proof: Council Prime (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) /// The range of component `m` is `[0, 100]`. /// The range of component `n` is `[0, 100]`. /// The range of component `p` is `[0, 100]`. fn set_members(m: u32, _n: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `0 + m * (3232 ±0) + p * (3190 ±0)` - // Estimated: `15861 + m * (1967 ±24) + p * (4332 ±24)` - // Minimum execution time: 17_506_000 picoseconds. - Weight::from_parts(17_767_000, 15861) - // Standard Error: 60_220 - .saturating_add(Weight::from_parts(4_374_805, 0).saturating_mul(m.into())) - // Standard Error: 60_220 - .saturating_add(Weight::from_parts(8_398_316, 0).saturating_mul(p.into())) + // Measured: `0 + m * (3233 ±0) + p * (3227 ±0)` + // Estimated: `10012 + m * (334 ±45) + p * (8826 ±45)` + // Minimum execution time: 23_002_000 picoseconds. + Weight::from_parts(23_136_000, 10012) + // Standard Error: 75_511 + .saturating_add(Weight::from_parts(5_821_035, 0).saturating_mul(m.into())) + // Standard Error: 75_511 + .saturating_add(Weight::from_parts(10_356_635, 0).saturating_mul(p.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(p.into()))) .saturating_add(RocksDbWeight::get().writes(2_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(p.into()))) - .saturating_add(Weight::from_parts(0, 1967).saturating_mul(m.into())) - .saturating_add(Weight::from_parts(0, 4332).saturating_mul(p.into())) + .saturating_add(Weight::from_parts(0, 334).saturating_mul(m.into())) + .saturating_add(Weight::from_parts(0, 8826).saturating_mul(p.into())) } /// Storage: Council Members (r:1 w:0) - /// Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) + /// Proof: Council Members (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Preimage StatusFor (r:1 w:1) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) + /// Storage: Preimage PreimageFor (r:0 w:1) + /// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: MaxEncodedLen) /// The range of component `b` is `[2, 1024]`. /// The range of component `m` is `[1, 100]`. fn execute(b: u32, m: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `202 + m * (32 ±0)` - // Estimated: `1688 + m * (32 ±0)` - // Minimum execution time: 16_203_000 picoseconds. - Weight::from_parts(15_348_267, 1688) - // Standard Error: 37 - .saturating_add(Weight::from_parts(1_766, 0).saturating_mul(b.into())) - // Standard Error: 382 - .saturating_add(Weight::from_parts(15_765, 0).saturating_mul(m.into())) + // Measured: `244 + m * (32 ±0)` + // Estimated: `4687` + // Minimum execution time: 16_842_000 picoseconds. + Weight::from_parts(22_610_183, 4687) + // Standard Error: 515 + .saturating_add(Weight::from_parts(6_030, 0).saturating_mul(b.into())) + // Standard Error: 5_309 + .saturating_add(Weight::from_parts(36_145, 0).saturating_mul(m.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) - .saturating_add(Weight::from_parts(0, 32).saturating_mul(m.into())) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: Council Members (r:1 w:0) - /// Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Council ProposalOf (r:1 w:0) - /// Proof Skipped: Council ProposalOf (max_values: None, max_size: None, mode: Measured) + /// Proof: Council Members (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Preimage StatusFor (r:1 w:1) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) + /// Storage: Council Voting (r:1 w:0) + /// Proof: Council Voting (max_values: None, max_size: Some(6547), added: 9022, mode: MaxEncodedLen) + /// Storage: Preimage PreimageFor (r:0 w:1) + /// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: MaxEncodedLen) /// The range of component `b` is `[2, 1024]`. /// The range of component `m` is `[1, 100]`. fn propose_execute(b: u32, m: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `202 + m * (32 ±0)` - // Estimated: `3668 + m * (32 ±0)` - // Minimum execution time: 18_642_000 picoseconds. - Weight::from_parts(17_708_609, 3668) - // Standard Error: 58 - .saturating_add(Weight::from_parts(2_285, 0).saturating_mul(b.into())) - // Standard Error: 598 - .saturating_add(Weight::from_parts(30_454, 0).saturating_mul(m.into())) + // Measured: `244 + m * (32 ±0)` + // Estimated: `10012` + // Minimum execution time: 20_433_000 picoseconds. + Weight::from_parts(27_303_080, 10012) + // Standard Error: 698 + .saturating_add(Weight::from_parts(9_912, 0).saturating_mul(b.into())) + // Standard Error: 7_198 + .saturating_add(Weight::from_parts(69_523, 0).saturating_mul(m.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) - .saturating_add(Weight::from_parts(0, 32).saturating_mul(m.into())) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: Council Members (r:1 w:0) - /// Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Council ProposalOf (r:1 w:1) - /// Proof Skipped: Council ProposalOf (max_values: None, max_size: None, mode: Measured) - /// Storage: Council Proposals (r:1 w:1) - /// Proof Skipped: Council Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Proof: Council Members (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Preimage StatusFor (r:1 w:1) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) + /// Storage: Council Voting (r:1 w:1) + /// Proof: Council Voting (max_values: None, max_size: Some(6547), added: 9022, mode: MaxEncodedLen) + /// Storage: Council CounterForVoting (r:1 w:1) + /// Proof: Council CounterForVoting (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: Council ProposalCount (r:1 w:1) - /// Proof Skipped: Council ProposalCount (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Council Voting (r:0 w:1) - /// Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) + /// Proof: Council ProposalCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Preimage PreimageFor (r:0 w:1) + /// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: MaxEncodedLen) /// The range of component `b` is `[2, 1024]`. /// The range of component `m` is `[2, 100]`. /// The range of component `p` is `[1, 100]`. fn propose_proposed(b: u32, m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `492 + m * (32 ±0) + p * (36 ±0)` - // Estimated: `3884 + m * (33 ±0) + p * (36 ±0)` - // Minimum execution time: 27_067_000 picoseconds. - Weight::from_parts(25_456_964, 3884) - // Standard Error: 112 - .saturating_add(Weight::from_parts(3_773, 0).saturating_mul(b.into())) - // Standard Error: 1_177 - .saturating_add(Weight::from_parts(32_783, 0).saturating_mul(m.into())) - // Standard Error: 1_162 - .saturating_add(Weight::from_parts(194_388, 0).saturating_mul(p.into())) + // Measured: `689 + m * (32 ±0) + p * (9 ±0)` + // Estimated: `10012` + // Minimum execution time: 30_349_000 picoseconds. + Weight::from_parts(31_624_126, 10012) + // Standard Error: 326 + .saturating_add(Weight::from_parts(8_551, 0).saturating_mul(b.into())) + // Standard Error: 3_403 + .saturating_add(Weight::from_parts(45_550, 0).saturating_mul(m.into())) + // Standard Error: 3_360 + .saturating_add(Weight::from_parts(52_641, 0).saturating_mul(p.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) - .saturating_add(Weight::from_parts(0, 33).saturating_mul(m.into())) - .saturating_add(Weight::from_parts(0, 36).saturating_mul(p.into())) } /// Storage: Council Members (r:1 w:0) - /// Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) + /// Proof: Council Members (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) /// Storage: Council Voting (r:1 w:1) - /// Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) + /// Proof: Council Voting (max_values: None, max_size: Some(6547), added: 9022, mode: MaxEncodedLen) /// The range of component `m` is `[5, 100]`. fn vote(m: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `941 + m * (64 ±0)` - // Estimated: `4405 + m * (64 ±0)` - // Minimum execution time: 26_055_000 picoseconds. - Weight::from_parts(27_251_907, 4405) - // Standard Error: 1_008 - .saturating_add(Weight::from_parts(65_947, 0).saturating_mul(m.into())) + // Measured: `891 + m * (64 ±0)` + // Estimated: `10012` + // Minimum execution time: 23_810_000 picoseconds. + Weight::from_parts(24_512_099, 10012) + // Standard Error: 627 + .saturating_add(Weight::from_parts(52_608, 0).saturating_mul(m.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) - .saturating_add(Weight::from_parts(0, 64).saturating_mul(m.into())) } /// Storage: Council Voting (r:1 w:1) - /// Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) + /// Proof: Council Voting (max_values: None, max_size: Some(6547), added: 9022, mode: MaxEncodedLen) /// Storage: Council Members (r:1 w:0) - /// Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Council Proposals (r:1 w:1) - /// Proof Skipped: Council Proposals (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Council ProposalOf (r:0 w:1) - /// Proof Skipped: Council ProposalOf (max_values: None, max_size: None, mode: Measured) + /// Proof: Council Members (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Council CounterForVoting (r:1 w:1) + /// Proof: Council CounterForVoting (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// The range of component `m` is `[4, 100]`. /// The range of component `p` is `[1, 100]`. fn close_early_disapproved(m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `530 + m * (64 ±0) + p * (36 ±0)` - // Estimated: `3975 + m * (65 ±0) + p * (36 ±0)` - // Minimum execution time: 28_363_000 picoseconds. - Weight::from_parts(28_733_464, 3975) - // Standard Error: 1_275 - .saturating_add(Weight::from_parts(43_236, 0).saturating_mul(m.into())) - // Standard Error: 1_244 - .saturating_add(Weight::from_parts(180_187, 0).saturating_mul(p.into())) + // Measured: `455 + m * (64 ±0) + p * (2 ±0)` + // Estimated: `10012` + // Minimum execution time: 31_272_000 picoseconds. + Weight::from_parts(29_968_548, 10012) + // Standard Error: 508 + .saturating_add(Weight::from_parts(31_759, 0).saturating_mul(m.into())) + // Standard Error: 495 + .saturating_add(Weight::from_parts(19_121, 0).saturating_mul(p.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) - .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 65).saturating_mul(m.into())) - .saturating_add(Weight::from_parts(0, 36).saturating_mul(p.into())) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } /// Storage: Council Voting (r:1 w:1) - /// Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) + /// Proof: Council Voting (max_values: None, max_size: Some(6547), added: 9022, mode: MaxEncodedLen) /// Storage: Council Members (r:1 w:0) - /// Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Council ProposalOf (r:1 w:1) - /// Proof Skipped: Council ProposalOf (max_values: None, max_size: None, mode: Measured) - /// Storage: Council Proposals (r:1 w:1) - /// Proof Skipped: Council Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Proof: Council Members (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Preimage PreimageFor (r:1 w:1) + /// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: MaxEncodedLen) + /// Storage: Council CounterForVoting (r:1 w:1) + /// Proof: Council CounterForVoting (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Preimage StatusFor (r:1 w:1) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) /// The range of component `b` is `[2, 1024]`. /// The range of component `m` is `[4, 100]`. /// The range of component `p` is `[1, 100]`. fn close_early_approved(b: u32, m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `832 + b * (1 ±0) + m * (64 ±0) + p * (40 ±0)` - // Estimated: `4149 + b * (1 ±0) + m * (66 ±0) + p * (40 ±0)` - // Minimum execution time: 40_391_000 picoseconds. - Weight::from_parts(42_695_215, 4149) - // Standard Error: 167 - .saturating_add(Weight::from_parts(3_622, 0).saturating_mul(b.into())) - // Standard Error: 1_772 - .saturating_add(Weight::from_parts(33_830, 0).saturating_mul(m.into())) - // Standard Error: 1_727 - .saturating_add(Weight::from_parts(205_374, 0).saturating_mul(p.into())) + // Measured: `972 + b * (1 ±0) + m * (64 ±0) + p * (12 ±0)` + // Estimated: `4197809` + // Minimum execution time: 38_426_000 picoseconds. + Weight::from_parts(42_168_976, 4197809) + // Standard Error: 382 + .saturating_add(Weight::from_parts(11_597, 0).saturating_mul(b.into())) + // Standard Error: 4_041 + .saturating_add(Weight::from_parts(39_322, 0).saturating_mul(m.into())) + // Standard Error: 3_939 + .saturating_add(Weight::from_parts(73_805, 0).saturating_mul(p.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 1).saturating_mul(b.into())) - .saturating_add(Weight::from_parts(0, 66).saturating_mul(m.into())) - .saturating_add(Weight::from_parts(0, 40).saturating_mul(p.into())) } /// Storage: Council Voting (r:1 w:1) - /// Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) + /// Proof: Council Voting (max_values: None, max_size: Some(6547), added: 9022, mode: MaxEncodedLen) /// Storage: Council Members (r:1 w:0) - /// Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) + /// Proof: Council Members (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) /// Storage: Council Prime (r:1 w:0) - /// Proof Skipped: Council Prime (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Council Proposals (r:1 w:1) - /// Proof Skipped: Council Proposals (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Council ProposalOf (r:0 w:1) - /// Proof Skipped: Council ProposalOf (max_values: None, max_size: None, mode: Measured) + /// Proof: Council Prime (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) + /// Storage: Council CounterForVoting (r:1 w:1) + /// Proof: Council CounterForVoting (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// The range of component `m` is `[4, 100]`. /// The range of component `p` is `[1, 100]`. fn close_disapproved(m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `550 + m * (64 ±0) + p * (36 ±0)` - // Estimated: `3995 + m * (65 ±0) + p * (36 ±0)` - // Minimum execution time: 31_368_000 picoseconds. - Weight::from_parts(32_141_835, 3995) - // Standard Error: 1_451 - .saturating_add(Weight::from_parts(36_372, 0).saturating_mul(m.into())) - // Standard Error: 1_415 - .saturating_add(Weight::from_parts(210_635, 0).saturating_mul(p.into())) + // Measured: `474 + m * (64 ±0) + p * (2 ±0)` + // Estimated: `10012` + // Minimum execution time: 34_363_000 picoseconds. + Weight::from_parts(33_487_826, 10012) + // Standard Error: 685 + .saturating_add(Weight::from_parts(32_747, 0).saturating_mul(m.into())) + // Standard Error: 668 + .saturating_add(Weight::from_parts(15_881, 0).saturating_mul(p.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) - .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 65).saturating_mul(m.into())) - .saturating_add(Weight::from_parts(0, 36).saturating_mul(p.into())) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } /// Storage: Council Voting (r:1 w:1) - /// Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) + /// Proof: Council Voting (max_values: None, max_size: Some(6547), added: 9022, mode: MaxEncodedLen) /// Storage: Council Members (r:1 w:0) - /// Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) + /// Proof: Council Members (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) /// Storage: Council Prime (r:1 w:0) - /// Proof Skipped: Council Prime (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Council ProposalOf (r:1 w:1) - /// Proof Skipped: Council ProposalOf (max_values: None, max_size: None, mode: Measured) - /// Storage: Council Proposals (r:1 w:1) - /// Proof Skipped: Council Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Proof: Council Prime (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) + /// Storage: Preimage PreimageFor (r:1 w:1) + /// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: MaxEncodedLen) + /// Storage: Council CounterForVoting (r:1 w:1) + /// Proof: Council CounterForVoting (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Preimage StatusFor (r:1 w:1) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) /// The range of component `b` is `[2, 1024]`. /// The range of component `m` is `[4, 100]`. /// The range of component `p` is `[1, 100]`. fn close_approved(b: u32, m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `852 + b * (1 ±0) + m * (64 ±0) + p * (40 ±0)` - // Estimated: `4169 + b * (1 ±0) + m * (66 ±0) + p * (40 ±0)` - // Minimum execution time: 43_271_000 picoseconds. - Weight::from_parts(45_495_648, 4169) - // Standard Error: 174 - .saturating_add(Weight::from_parts(3_034, 0).saturating_mul(b.into())) - // Standard Error: 1_840 - .saturating_add(Weight::from_parts(42_209, 0).saturating_mul(m.into())) - // Standard Error: 1_793 - .saturating_add(Weight::from_parts(207_525, 0).saturating_mul(p.into())) + // Measured: `992 + b * (1 ±0) + m * (64 ±0) + p * (12 ±0)` + // Estimated: `4197809` + // Minimum execution time: 41_697_000 picoseconds. + Weight::from_parts(45_580_292, 4197809) + // Standard Error: 378 + .saturating_add(Weight::from_parts(11_125, 0).saturating_mul(b.into())) + // Standard Error: 4_003 + .saturating_add(Weight::from_parts(36_935, 0).saturating_mul(m.into())) + // Standard Error: 3_902 + .saturating_add(Weight::from_parts(71_157, 0).saturating_mul(p.into())) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 1).saturating_mul(b.into())) - .saturating_add(Weight::from_parts(0, 66).saturating_mul(m.into())) - .saturating_add(Weight::from_parts(0, 40).saturating_mul(p.into())) } - /// Storage: Council Proposals (r:1 w:1) - /// Proof Skipped: Council Proposals (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: Council Voting (r:0 w:1) - /// Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) - /// Storage: Council ProposalOf (r:0 w:1) - /// Proof Skipped: Council ProposalOf (max_values: None, max_size: None, mode: Measured) + /// Storage: Council CounterForVoting (r:1 w:1) + /// Proof: Council CounterForVoting (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Council Voting (r:1 w:1) + /// Proof: Council Voting (max_values: None, max_size: Some(6547), added: 9022, mode: MaxEncodedLen) + /// Storage: Preimage StatusFor (r:1 w:1) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) + /// Storage: Preimage PreimageFor (r:0 w:1) + /// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: MaxEncodedLen) /// The range of component `p` is `[1, 100]`. fn disapprove_proposal(p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `359 + p * (32 ±0)` - // Estimated: `1844 + p * (32 ±0)` - // Minimum execution time: 15_170_000 picoseconds. - Weight::from_parts(17_567_243, 1844) - // Standard Error: 1_430 - .saturating_add(Weight::from_parts(169_040, 0).saturating_mul(p.into())) - .saturating_add(RocksDbWeight::get().reads(1_u64)) - .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 32).saturating_mul(p.into())) + // Measured: `1131 + p * (9 ±0)` + // Estimated: `10012` + // Minimum execution time: 29_792_000 picoseconds. + Weight::from_parts(33_599_529, 10012) + // Standard Error: 2_176 + .saturating_add(Weight::from_parts(38_685, 0).saturating_mul(p.into())) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) } } From 53dad99186fd5f3d4d26cd97b5e743a412a5a7c4 Mon Sep 17 00:00:00 2001 From: muraca Date: Sat, 8 Jul 2023 12:11:52 +0200 Subject: [PATCH 8/8] addressed some review comments Signed-off-by: muraca --- frame/alliance/Cargo.toml | 1 - frame/alliance/src/mock.rs | 2 +- frame/collective/Cargo.toml | 1 - frame/collective/src/lib.rs | 106 ++++++++++++++++------------------ frame/collective/src/tests.rs | 11 +++- frame/utility/src/tests.rs | 2 +- 6 files changed, 60 insertions(+), 63 deletions(-) diff --git a/frame/alliance/Cargo.toml b/frame/alliance/Cargo.toml index 0d8414e7ac435..d37edec2874c8 100644 --- a/frame/alliance/Cargo.toml +++ b/frame/alliance/Cargo.toml @@ -55,7 +55,6 @@ std = [ "frame-support/std", "frame-system/std", "pallet-identity/std", - "pallet-preimage/std", ] runtime-benchmarks = [ "array-bytes", diff --git a/frame/alliance/src/mock.rs b/frame/alliance/src/mock.rs index 6b04ae5e7dd6d..c1ec895038665 100644 --- a/frame/alliance/src/mock.rs +++ b/frame/alliance/src/mock.rs @@ -27,7 +27,7 @@ use sp_std::convert::{TryFrom, TryInto}; pub use frame_support::{ assert_noop, assert_ok, ord_parameter_types, parameter_types, - traits::{EitherOfDiverse, GenesisBuild, QueryPreimage, SortedMembers, StorePreimage}, + traits::{EitherOfDiverse, QueryPreimage, SortedMembers, StorePreimage}, BoundedVec, }; use frame_system::{EnsureRoot, EnsureSignedBy}; diff --git a/frame/collective/Cargo.toml b/frame/collective/Cargo.toml index 70ac480b15ed3..cfc7c6a426a70 100644 --- a/frame/collective/Cargo.toml +++ b/frame/collective/Cargo.toml @@ -40,7 +40,6 @@ std = [ "sp-io/std", "sp-runtime/std", "sp-std/std", - "pallet-preimage/std", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", diff --git a/frame/collective/src/lib.rs b/frame/collective/src/lib.rs index a7d551d8590ce..fbd2f2808bfd4 100644 --- a/frame/collective/src/lib.rs +++ b/frame/collective/src/lib.rs @@ -58,7 +58,7 @@ use frame_support::{ InitializeMembers, QueryPreimage, StorageVersion, StorePreimage, }, weights::Weight, - BoundedVec, CloneNoBound, EqNoBound, Parameter, PartialEqNoBound, + BoundedVec, CloneNoBound, EqNoBound, PalletError, Parameter, PartialEqNoBound, }; #[cfg(any(feature = "try-runtime", test))] @@ -351,6 +351,17 @@ pub mod pallet { WrongProposalLength, /// Prime account is not a member PrimeAccountNotMember, + /// The bound for votes was exceeded. + TooManyVotes, + /// Some error occurred that should never happen. This should be reported to the + /// maintainers. + Defensive(DefensiveError), + } + + #[derive(Encode, Decode, PartialEq, TypeInfo, PalletError, RuntimeDebug)] + pub enum DefensiveError { + /// Preimage length cannot be deduced from type. + PreimageLen, } #[pallet::hooks] @@ -660,6 +671,7 @@ fn get_result_weight(result: DispatchResultWithPostInfo) -> Option { impl, I: 'static> Pallet { /// The active proposals. + #[cfg(any(feature = "std", feature = "runtime-benchmarks"))] pub fn proposals() -> BoundedVec>::Proposal>, T::MaxProposals> { Voting::::iter() .map(|(k, _v)| k) @@ -735,13 +747,7 @@ impl, I: 'static> Pallet { >::mutate(|i| *i += 1); let votes = { let end = frame_system::Pallet::::block_number() + T::MotionDuration::get(); - Votes { - index, - threshold, - ayes: vec![].try_into().expect("empty vec is always bounded; qed"), - nays: vec![].try_into().expect("empty vec is always bounded; qed"), - end, - } + Votes { index, threshold, ayes: Default::default(), nays: Default::default(), end } }; >::insert(&proposal_bounded, votes); @@ -773,10 +779,7 @@ impl, I: 'static> Pallet { if approve { if position_yes.is_none() { - voting - .ayes - .try_push(who.clone()) - .expect("Proposal voting ayes can't overflow; qed"); + voting.ayes.try_push(who.clone()).map_err(|_| Error::::TooManyVotes)?; } else { return Err(Error::::DuplicateVote.into()) } @@ -785,10 +788,7 @@ impl, I: 'static> Pallet { } } else { if position_no.is_none() { - voting - .nays - .try_push(who.clone()) - .expect("Proposal voting nays can't overflow; qed"); + voting.nays.try_push(who.clone()).map_err(|_| Error::::TooManyVotes)?; } else { return Err(Error::::DuplicateVote.into()) } @@ -923,30 +923,19 @@ impl, I: 'static> Pallet { // read the length of the proposal by using peek let (proposal, proposal_len) = T::Preimages::peek(&proposal_bounded).map_err(|_| Error::::ProposalMissing)?; - let proposal_len = proposal_len.unwrap_or_else(|| match proposal_bounded { - Bounded::Inline(data) => data.len() as u32, - _ => panic!("preimage should be inline, or len already given by peek; qed"), - }); + let proposal_len = match proposal_len { + Some(len) => Ok(len), + None => match proposal_bounded { + Bounded::Inline(data) => Ok(data.len() as u32), + _ => Err(Error::::Defensive(DefensiveError::PreimageLen)), + }, + }?; ensure!(proposal_len <= length_bound, Error::::WrongProposalLength); let proposal_weight = proposal.get_dispatch_info().weight; ensure!(proposal_weight.all_lte(weight_bound), Error::::WrongProposalWeight); Ok((proposal, proposal_len as usize)) } - /// Weight: - /// If `approved`: - /// - the weight of `proposal` preimage. - /// - two events deposited. - /// - two removals, one mutation. - /// - computation and i/o `O(P + L)` where: - /// - `P` is number of active proposals, - /// - `L` is the encoded length of `proposal` preimage. - /// - /// If not `approved`: - /// - one event deposited. - /// Two removals, one mutation. - /// Computation and i/o `O(P)` where: - /// - `P` is number of active proposals fn do_approve_proposal( seats: MemberCount, yes_votes: MemberCount, @@ -1082,28 +1071,33 @@ impl, I: 'static> ChangeMembers for Pallet { // remove accounts from all current voting in motions. let mut outgoing = outgoing.to_vec(); outgoing.sort(); - for h in Self::proposals().into_iter() { - >::mutate(h, |v| { - if let Some(mut votes) = v.take() { - votes.ayes = votes - .ayes - .into_iter() - .filter(|i| outgoing.binary_search(i).is_err()) - .collect::>() - .try_into() - .expect("The filtered elements should be at most equal to the original length; qed"); - votes.nays = votes - .nays - .into_iter() - .filter(|i| outgoing.binary_search(i).is_err()) - .collect::>() - .try_into() - .expect("The filtered elements should be at most equal to the original length; qed"); - - *v = Some(votes); - } - }); - } + >::translate_values( + |mut votes: Votes< + T::AccountId, + frame_system::pallet_prelude::BlockNumberFor, + T::MaxMembers, + >| { + votes.ayes = votes + .ayes + .into_iter() + .filter(|i| outgoing.binary_search(i).is_err()) + .collect::>() + .try_into() + .expect( + "The filtered elements should be at most equal to the original length; qed", + ); + votes.nays = votes + .nays + .into_iter() + .filter(|i| outgoing.binary_search(i).is_err()) + .collect::>() + .try_into() + .expect( + "The filtered elements should be at most equal to the original length; qed", + ); + Some(votes) + }, + ); Members::::put( BoundedVec::try_from(new.to_vec()).expect("Members bound was already checked; qed"), ); diff --git a/frame/collective/src/tests.rs b/frame/collective/src/tests.rs index f304fe55bb807..e990aaab7d843 100644 --- a/frame/collective/src/tests.rs +++ b/frame/collective/src/tests.rs @@ -21,7 +21,7 @@ use frame_support::{ assert_noop, assert_ok, dispatch::Pays, parameter_types, - traits::{ConstU32, ConstU64, GenesisBuild, StorageVersion}, + traits::{ConstU32, ConstU64, StorageVersion}, }; use frame_system::{EnsureRoot, EventRecord, Phase}; use sp_core::{bounded_vec, H256}; @@ -255,14 +255,19 @@ fn set_members_with_prime_works() { let members = vec![1, 2, 3]; assert_ok!(Collective::set_members( RuntimeOrigin::root(), - members.clone(), + members.clone().try_into().unwrap(), Some(3), MaxMembers::get() )); assert_eq!(Collective::members(), members.clone()); assert_eq!(Collective::prime(), Some(3)); assert_noop!( - Collective::set_members(RuntimeOrigin::root(), members, Some(4), MaxMembers::get()), + Collective::set_members( + RuntimeOrigin::root(), + members.try_into().unwrap(), + Some(4), + MaxMembers::get() + ), Error::::PrimeAccountNotMember ); }); diff --git a/frame/utility/src/tests.rs b/frame/utility/src/tests.rs index ed1e21cd7add0..5d06084e501c6 100644 --- a/frame/utility/src/tests.rs +++ b/frame/utility/src/tests.rs @@ -27,7 +27,7 @@ use frame_support::{ dispatch::{DispatchError, DispatchErrorWithPostInfo, Dispatchable, Pays}, error::BadOrigin, parameter_types, storage, - traits::{ConstU32, ConstU64, Contains, GenesisBuild, StorePreimage}, + traits::{ConstU32, ConstU64, Contains, StorePreimage}, weights::Weight, }; use pallet_collective::{EnsureProportionAtLeast, Instance1};