From 8cb3404d01a9db4b835757d7ad1d5ef758410c5c Mon Sep 17 00:00:00 2001 From: gpestana Date: Fri, 16 Dec 2022 13:57:04 +0100 Subject: [PATCH 01/80] Implements dynamic nominations per nominator --- frame/staking/src/lib.rs | 32 ++++++++++++++++++++++++++++++- frame/staking/src/mock.rs | 2 +- frame/staking/src/pallet/impls.rs | 9 +++++---- frame/staking/src/pallet/mod.rs | 20 ++++++++++--------- 4 files changed, 48 insertions(+), 15 deletions(-) diff --git a/frame/staking/src/lib.rs b/frame/staking/src/lib.rs index 0f5b8e0123ab6..13948e935a01c 100644 --- a/frame/staking/src/lib.rs +++ b/frame/staking/src/lib.rs @@ -337,6 +337,9 @@ macro_rules! log { /// pallet. pub type MaxWinnersOf = <::ElectionProvider as frame_election_provider_support::ElectionProviderBase>::MaxWinners; +/// Absolute maximum number of nominations per nominator. +type AbsoluteMaxNominationsOf = <::NominationsQuota as NominationsQuota>>::AbsoluteMaxNominations; + /// Counter for the number of "reward" points earned by a given validator. pub type RewardPoint = u32; @@ -691,7 +694,7 @@ impl StakingLedger { #[scale_info(skip_type_params(T))] pub struct Nominations { /// The targets of nomination. - pub targets: BoundedVec, + pub targets: BoundedVec>, /// The era the nominations were submitted. /// /// Except for initial nominations which are considered submitted at era 0. @@ -761,6 +764,33 @@ impl UnappliedSlash { } } +/// Something that defines the maximum number of nominations per nominator. +pub trait NominationsQuota: Get { + const ABSOLUTE_MAX_NOMINATIONS: u32; + + type AbsoluteMaxNominations: Get; + + fn nomination_quota(balance: Balance) -> u32; +} + +/// A nomination quota that allows up to MAX nominations for all validators. +pub struct FixedNominationsQuota; +impl NominationsQuota for FixedNominationsQuota { + const ABSOLUTE_MAX_NOMINATIONS: u32 = MAX; + + type AbsoluteMaxNominations = Self; + + fn nomination_quota(_: Balance) -> u32 { + MAX + } +} + +impl Get for FixedNominationsQuota { + fn get() -> u32 { + MAX + } +} + /// Means for interacting with a specialized version of the `session` trait. /// /// This is needed because `Staking` sets the `ValidatorIdOf` of the `pallet_session::Config` diff --git a/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index d3affda05277a..059b664461001 100644 --- a/frame/staking/src/mock.rs +++ b/frame/staking/src/mock.rs @@ -281,7 +281,7 @@ impl sp_staking::OnStakerSlash for OnStakerSlashM } impl crate::pallet::pallet::Config for Test { - type MaxNominations = MaxNominations; + type NominationsQuota = FixedNominationsQuota<16>; type Currency = Balances; type CurrencyBalance = ::Balance; type UnixTime = Timestamp; diff --git a/frame/staking/src/pallet/impls.rs b/frame/staking/src/pallet/impls.rs index a7190d70c7061..282b6cb29dd83 100644 --- a/frame/staking/src/pallet/impls.rs +++ b/frame/staking/src/pallet/impls.rs @@ -43,9 +43,9 @@ use sp_staking::{ use sp_std::prelude::*; use crate::{ - log, slashing, weights::WeightInfo, ActiveEraInfo, BalanceOf, EraPayout, Exposure, ExposureOf, - Forcing, IndividualExposure, MaxWinnersOf, Nominations, PositiveImbalanceOf, RewardDestination, - SessionInterface, StakingLedger, ValidatorPrefs, + log, slashing, weights::WeightInfo, AbsoluteMaxNominationsOf, ActiveEraInfo, BalanceOf, + EraPayout, Exposure, ExposureOf, Forcing, IndividualExposure, MaxWinnersOf, Nominations, + PositiveImbalanceOf, RewardDestination, SessionInterface, StakingLedger, ValidatorPrefs, }; use super::{pallet::*, STAKING_ID}; @@ -968,7 +968,8 @@ impl Pallet { impl ElectionDataProvider for Pallet { type AccountId = T::AccountId; type BlockNumber = BlockNumberFor; - type MaxVotesPerVoter = T::MaxNominations; + //type MaxVotesPerVoter = T::NominationsQuota; + type MaxVotesPerVoter = AbsoluteMaxNominationsOf; fn desired_targets() -> data_provider::Result { Self::register_weight(T::DbWeight::get().reads(1)); diff --git a/frame/staking/src/pallet/mod.rs b/frame/staking/src/pallet/mod.rs index 1d5babe7ffa8f..e34c9a1cc8e0e 100644 --- a/frame/staking/src/pallet/mod.rs +++ b/frame/staking/src/pallet/mod.rs @@ -45,9 +45,9 @@ pub use impls::*; use crate::{ slashing, weights::WeightInfo, AccountIdLookupOf, ActiveEraInfo, BalanceOf, EraPayout, - EraRewardPoints, Exposure, Forcing, NegativeImbalanceOf, Nominations, PositiveImbalanceOf, - Releases, RewardDestination, SessionInterface, StakingLedger, UnappliedSlash, UnlockChunk, - ValidatorPrefs, + EraRewardPoints, Exposure, Forcing, NegativeImbalanceOf, Nominations, NominationsQuota, + PositiveImbalanceOf, Releases, RewardDestination, SessionInterface, StakingLedger, + UnappliedSlash, UnlockChunk, ValidatorPrefs, }; const STAKING_ID: LockIdentifier = *b"staking "; @@ -126,9 +126,8 @@ pub mod pallet { DataProvider = Pallet, >; - /// Maximum number of nominations per nominator. - #[pallet::constant] - type MaxNominations: Get; + /// Something that defines the maximum number of nominations per nominator. + type NominationsQuota: NominationsQuota>; /// Number of eras to keep in history. /// @@ -792,11 +791,11 @@ pub mod pallet { fn integrity_test() { // ensure that we funnel the correct value to the `DataProvider::MaxVotesPerVoter`; assert_eq!( - T::MaxNominations::get(), + T::NominationsQuota::get(), ::MaxVotesPerVoter::get() ); // and that MaxNominations is always greater than 1, since we count on this. - assert!(!T::MaxNominations::get().is_zero()); + assert!(!T::NominationsQuota::get().is_zero()); // ensure election results are always bounded with the same value assert!( @@ -1158,7 +1157,10 @@ pub mod pallet { } ensure!(!targets.is_empty(), Error::::EmptyTargets); - ensure!(targets.len() <= T::MaxNominations::get() as usize, Error::::TooManyTargets); + ensure!( + targets.len() <= T::NominationsQuota::get() as usize, + Error::::TooManyTargets + ); let old = Nominators::::get(stash).map_or_else(Vec::new, |x| x.targets.into_inner()); From c9b8a17d3c942b27dc78b8103c29f729ee49096d Mon Sep 17 00:00:00 2001 From: gpestana Date: Mon, 19 Dec 2022 01:26:43 +0100 Subject: [PATCH 02/80] Adds SnapshotBounds and ElectionSizeTracker --- .../election-provider-multi-phase/src/lib.rs | 13 ++- .../election-provider-multi-phase/src/mock.rs | 6 +- frame/election-provider-support/src/lib.rs | 88 ++++++++++++++++++- frame/staking/src/lib.rs | 76 +++++++++++++--- frame/staking/src/mock.rs | 2 +- frame/staking/src/pallet/impls.rs | 27 +++++- frame/staking/src/pallet/mod.rs | 6 +- 7 files changed, 196 insertions(+), 22 deletions(-) diff --git a/frame/election-provider-multi-phase/src/lib.rs b/frame/election-provider-multi-phase/src/lib.rs index 6c4a55800f7e8..780e83f0d92da 100644 --- a/frame/election-provider-multi-phase/src/lib.rs +++ b/frame/election-provider-multi-phase/src/lib.rs @@ -232,7 +232,7 @@ use codec::{Decode, Encode}; use frame_election_provider_support::{ BoundedSupportsOf, ElectionDataProvider, ElectionProvider, ElectionProviderBase, - InstantElectionProvider, NposSolution, + InstantElectionProvider, NposSolution, SnapshotBounds, }; use frame_support::{ dispatch::DispatchClass, @@ -671,6 +671,14 @@ pub mod pallet { #[pallet::constant] type MaxWinners: Get; + // The limits of targets to include in the snapshot per block. + #[pallet::constant] + type TargetSnapshotBounds: Get; + + // The limits of voters to include in the snapshot per block. + #[pallet::constant] + type VoterSnapshotBounds: Get; + /// Handler for the slashed deposits. type SlashHandler: OnUnbalanced>; @@ -1404,6 +1412,9 @@ impl Pallet { let target_limit = T::MaxElectableTargets::get().saturated_into::(); let voter_limit = T::MaxElectingVoters::get().saturated_into::(); + let target_bounds = T::TargetSnapshotBounds::get(); + let voter_bounds = T::VoterSnapshotBounds::get(); + let targets = T::DataProvider::electable_targets(Some(target_limit)) .map_err(ElectionError::DataProvider)?; diff --git a/frame/election-provider-multi-phase/src/mock.rs b/frame/election-provider-multi-phase/src/mock.rs index 347a4f19185f9..38023ca8c75cf 100644 --- a/frame/election-provider-multi-phase/src/mock.rs +++ b/frame/election-provider-multi-phase/src/mock.rs @@ -20,7 +20,7 @@ use crate::{self as multi_phase, unsigned::MinerConfig}; use frame_election_provider_support::{ data_provider, onchain::{self}, - ElectionDataProvider, NposSolution, SequentialPhragmen, + ElectionDataProvider, NposSolution, SequentialPhragmen, SnapshotBounds, }; pub use frame_support::{assert_noop, assert_ok, pallet_prelude::GetDefault}; use frame_support::{ @@ -298,6 +298,8 @@ parameter_types! { pub static MaxElectingVoters: VoterIndex = u32::max_value(); pub static MaxElectableTargets: TargetIndex = TargetIndex::max_value(); pub static MaxWinners: u32 = 200; + pub static VoterSnapshotBounds: SnapshotBounds = SnapshotBounds::new_unbounded(); + pub static TargetSnapshotBounds: SnapshotBounds = SnapshotBounds::new_unbounded(); pub static EpochLength: u64 = 30; pub static OnChainFallback: bool = true; @@ -405,6 +407,8 @@ impl crate::Config for Runtime { type MaxWinners = MaxWinners; type MinerConfig = Self; type Solver = SequentialPhragmen, Balancing>; + type VoterSnapshotBounds = VoterSnapshotBounds; + type TargetSnapshotBounds = TargetSnapshotBounds; } impl frame_system::offchain::SendTransactionTypes for Runtime diff --git a/frame/election-provider-support/src/lib.rs b/frame/election-provider-support/src/lib.rs index 9d5d6c018e5e1..e859cf9c3a45b 100644 --- a/frame/election-provider-support/src/lib.rs +++ b/frame/election-provider-support/src/lib.rs @@ -178,6 +178,7 @@ pub mod traits; use sp_runtime::traits::{Bounded, Saturating, Zero}; use sp_std::{fmt::Debug, prelude::*}; +pub use codec::{Decode, Encode}; /// Re-export the solution generation macro. pub use frame_election_provider_solution_type::generate_solution_type; pub use frame_support::{traits::Get, weights::Weight, BoundedVec, RuntimeDebug}; @@ -227,7 +228,7 @@ impl __OrInvalidIndex for Option { /// making it fast to repeatedly encode into a `SolutionOf`. This property turns out /// to be important when trimming for solution length. #[derive(RuntimeDebug, Clone, Default)] -#[cfg_attr(feature = "std", derive(PartialEq, Eq, codec::Encode, codec::Decode))] +#[cfg_attr(feature = "std", derive(PartialEq, Eq, Encode, Decode))] pub struct IndexAssignment { /// Index of the voter among the voters list. pub who: VoterIndex, @@ -674,3 +675,88 @@ pub type BoundedSupportsOf = BoundedSupports< sp_core::generate_feature_enabled_macro!(runtime_benchmarks_enabled, feature = "runtime-benchmarks", $); sp_core::generate_feature_enabled_macro!(runtime_benchmarks_or_fuzz_enabled, any(feature = "runtime-benchmarks", feature = "fuzzing"), $); + +/// The voter or target bounds of an election +pub struct ElectionBounds { + pub count: Option, +} + +impl ElectionBounds { + pub fn new(count: Option) -> Self { + ElectionBounds { count } + } +} + +impl ElectionBounds { + pub fn exhausted(self, count: usize) -> bool { + self.count.map_or(false, |c| c > count as u32) + } +} + +impl From for ElectionBounds { + fn from(bounds: SnapshotBounds) -> Self { + ElectionBounds { count: bounds.count } + } +} + +impl From> for ElectionBounds { + fn from(bounds: Option) -> Self { + ElectionBounds { count: bounds.map(|b| b as u32) } + } +} + +/// The limits of an election snapshot. +#[derive(Clone, Copy, RuntimeDebug, scale_info::TypeInfo, Encode, Decode)] +pub struct SnapshotBounds { + /// The bound on number of elements. `None` means unbounded. + count: Option, + /// The bound on size, in bytes. `None` means unbounded. + size: Option, +} + +impl SnapshotBounds { + /// Returns a new instance of self without bounds. + pub const fn new_unbounded() -> Self { + SnapshotBounds { count: None, size: None } + } + + // Returns true if `given_size` or `given_count` exhausts `self.size` or `self_count` + // respectively. + pub fn exhausted(self, given_size: u32, given_count: u32) -> bool { + self.size.map_or(false, |size| given_size > size) || + self.count.map_or(false, |count| given_count > count) + } +} + +/// Utility builder for [`SnapshotBounds`]. +/// +/// The main purpose of this is to prevent mixing the order of similarly typed arguments (e.g. u32 +/// size and count). +pub struct SnapshotBoundsBuilder { + count: Option, + size: Option, +} + +impl SnapshotBoundsBuilder { + /// set the count of the snapshot. + pub fn count(mut self, count: Option) -> SnapshotBoundsBuilder { + self.count = count; + self + } + + /// Set the size of the snapshot. + pub fn size(mut self, size: Option) -> SnapshotBoundsBuilder { + self.size = size; + self + } + + /// Returns an instance of `SnapshotBounds` from the current state. + pub fn build(self) -> SnapshotBounds { + SnapshotBounds { count: self.count, size: self.size } + } +} + +#[cfg(test)] +mod snapshot_bounds { + // TODO(gpestana) +} diff --git a/frame/staking/src/lib.rs b/frame/staking/src/lib.rs index 13948e935a01c..5af980823e84d 100644 --- a/frame/staking/src/lib.rs +++ b/frame/staking/src/lib.rs @@ -300,6 +300,7 @@ pub mod weights; mod pallet; use codec::{Decode, Encode, HasCompact, MaxEncodedLen}; +use frame_election_provider_support::VoteWeight; use frame_support::{ traits::{Currency, Defensive, Get}, weights::Weight, @@ -316,6 +317,7 @@ use sp_staking::{ EraIndex, SessionIndex, }; use sp_std::{collections::btree_map::BTreeMap, prelude::*}; + pub use weights::WeightInfo; pub use pallet::{pallet::*, *}; @@ -338,7 +340,8 @@ macro_rules! log { pub type MaxWinnersOf = <::ElectionProvider as frame_election_provider_support::ElectionProviderBase>::MaxWinners; /// Absolute maximum number of nominations per nominator. -type AbsoluteMaxNominationsOf = <::NominationsQuota as NominationsQuota>>::AbsoluteMaxNominations; +type AbsoluteMaxNominationsOf = + <::NominationsQuota as NominationsQuota>>::AbsoluteMaxNominations; /// Counter for the number of "reward" points earned by a given validator. pub type RewardPoint = u32; @@ -766,29 +769,78 @@ impl UnappliedSlash { /// Something that defines the maximum number of nominations per nominator. pub trait NominationsQuota: Get { - const ABSOLUTE_MAX_NOMINATIONS: u32; + const ABSOLUTE_MAX_NOMINATIONS: u32; + + type AbsoluteMaxNominations: Get; - type AbsoluteMaxNominations: Get; + fn get_quota_capped(balance: Balance) -> u32 { + let quota = Self::get_quota(balance); + if quota < Self::ABSOLUTE_MAX_NOMINATIONS { + quota + } else { + Self::ABSOLUTE_MAX_NOMINATIONS + } + } - fn nomination_quota(balance: Balance) -> u32; + fn get_quota(balance: Balance) -> u32; } /// A nomination quota that allows up to MAX nominations for all validators. pub struct FixedNominationsQuota; impl NominationsQuota for FixedNominationsQuota { - const ABSOLUTE_MAX_NOMINATIONS: u32 = MAX; + const ABSOLUTE_MAX_NOMINATIONS: u32 = MAX; - type AbsoluteMaxNominations = Self; + type AbsoluteMaxNominations = Self; - fn nomination_quota(_: Balance) -> u32 { - MAX - } + fn get_quota(_: Balance) -> u32 { + MAX + } } impl Get for FixedNominationsQuota { - fn get() -> u32 { - MAX - } + fn get() -> u32 { + MAX + } +} + +pub(crate) struct ElectionSizeTracker { + size: usize, + limit: Option, + _marker: sp_std::marker::PhantomData, +} + +impl ElectionSizeTracker { + pub(crate) fn new(limit: Option) -> Self { + ElectionSizeTracker { size: 0, limit, _marker: Default::default() } + } + + // TODO: finish by calculating if current size vote fits in the tracker, result err if not + pub(crate) fn try_register_voter(&mut self, votes: usize) -> Result<(), ()> { + Ok(self.size = self.size.saturating_add(Self::voter_size(votes))) + } + + fn voter_size(votes: usize) -> usize { + Self::length_prefix(votes) + // and each element + .saturating_add(votes * sp_std::mem::size_of::()) + // 1 vote-weight + .saturating_add(sp_std::mem::size_of::()) + // 1 voter account + .saturating_add(sp_std::mem::size_of::()) + } + + /// The length prefix of a vector with the given length. + #[inline] + pub(crate) fn length_prefix(length: usize) -> usize { + use codec::{Compact, CompactLen}; + let length = length as u32; + Compact::::compact_len(&length) + } + + // Final size: size of all internal elements, plus the length prefix. + pub(crate) fn final_byte_size_of(&self, length: usize) -> usize { + self.size + Self::length_prefix(length) + } } /// Means for interacting with a specialized version of the `session` trait. diff --git a/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index 059b664461001..36d8e71bedc04 100644 --- a/frame/staking/src/mock.rs +++ b/frame/staking/src/mock.rs @@ -281,7 +281,7 @@ impl sp_staking::OnStakerSlash for OnStakerSlashM } impl crate::pallet::pallet::Config for Test { - type NominationsQuota = FixedNominationsQuota<16>; + type NominationsQuota = FixedNominationsQuota<16>; type Currency = Balances; type CurrencyBalance = ::Balance; type UnixTime = Timestamp; diff --git a/frame/staking/src/pallet/impls.rs b/frame/staking/src/pallet/impls.rs index 282b6cb29dd83..70b9add365cd7 100644 --- a/frame/staking/src/pallet/impls.rs +++ b/frame/staking/src/pallet/impls.rs @@ -44,8 +44,9 @@ use sp_std::prelude::*; use crate::{ log, slashing, weights::WeightInfo, AbsoluteMaxNominationsOf, ActiveEraInfo, BalanceOf, - EraPayout, Exposure, ExposureOf, Forcing, IndividualExposure, MaxWinnersOf, Nominations, - PositiveImbalanceOf, RewardDestination, SessionInterface, StakingLedger, ValidatorPrefs, + ElectionSizeTracker, EraPayout, Exposure, ExposureOf, Forcing, IndividualExposure, + MaxWinnersOf, Nominations, NominationsQuota, PositiveImbalanceOf, RewardDestination, + SessionInterface, StakingLedger, ValidatorPrefs, }; use super::{pallet::*, STAKING_ID}; @@ -748,9 +749,15 @@ impl Pallet { /// /// This function is self-weighing as [`DispatchClass::Mandatory`]. pub fn get_npos_voters(maybe_max_len: Option) -> Vec> { + // TODO: limits are snapshot/election bounds passed as input (election_bounds: ElectionBounds) + let (size, count) = (None, Some(10)); + + let mut voters_size_tracker: ElectionSizeTracker = + ElectionSizeTracker::new(size); + let max_allowed_len = { let all_voter_count = T::VoterList::count() as usize; - maybe_max_len.unwrap_or(all_voter_count).min(all_voter_count) + count.unwrap_or(all_voter_count).min(all_voter_count) }; let mut all_voters = Vec::<_>::with_capacity(max_allowed_len); @@ -777,7 +784,15 @@ impl Pallet { if let Some(Nominations { targets, .. }) = >::get(&voter) { let voter_weight = weight_of(&voter); + let target_quota = T::NominationsQuota::get_quota_capped(voter_weight.into()); if !targets.is_empty() { + if voters_size_tracker.try_register_voter(targets.len()).is_err() { + // TODO(gpestana): needs logging? + // no more space in the election result, stop iterating over the voters. + // TODO(gpestana): needs logging? + break + } + all_voters.push((voter.clone(), voter_weight, targets)); nominators_taken.saturating_inc(); } else { @@ -787,6 +802,11 @@ impl Pallet { if voter_weight < min_active_stake { voter_weight } else { min_active_stake }; } else if Validators::::contains_key(&voter) { // if this voter is a validator: + if voters_size_tracker.try_register_voter(1).is_err() { + // no more space in the election result, stop iterating over the voters. + // TODO(gpestana): needs logging? + break + } let self_vote = ( voter.clone(), weight_of(&voter), @@ -968,7 +988,6 @@ impl Pallet { impl ElectionDataProvider for Pallet { type AccountId = T::AccountId; type BlockNumber = BlockNumberFor; - //type MaxVotesPerVoter = T::NominationsQuota; type MaxVotesPerVoter = AbsoluteMaxNominationsOf; fn desired_targets() -> data_provider::Result { diff --git a/frame/staking/src/pallet/mod.rs b/frame/staking/src/pallet/mod.rs index e34c9a1cc8e0e..8ba1df7d9caf4 100644 --- a/frame/staking/src/pallet/mod.rs +++ b/frame/staking/src/pallet/mod.rs @@ -129,7 +129,8 @@ pub mod pallet { /// Something that defines the maximum number of nominations per nominator. type NominationsQuota: NominationsQuota>; - /// Number of eras to keep in history. + /// Maximum number of nominations per nominator, regardless of the + /// `Config::NominationsQuota` Number of eras to keep in history. /// /// Following information is kept for eras in `[current_era - /// HistoryDepth, current_era]`: `ErasStakers`, `ErasStakersClipped`, @@ -1158,7 +1159,8 @@ pub mod pallet { ensure!(!targets.is_empty(), Error::::EmptyTargets); ensure!( - targets.len() <= T::NominationsQuota::get() as usize, + // TODO(gpestana): this is the absolute max nomination, make it more explicit + targets.len() <= T::NominationsQuota::get() as usize, Error::::TooManyTargets ); From fcc765729654e48e2f836499a4d10d219b87e8e8 Mon Sep 17 00:00:00 2001 From: gpestana Date: Mon, 19 Dec 2022 09:31:09 +0100 Subject: [PATCH 03/80] Changes the ElectionDataProvider interface to receive ElectionBounds as input --- frame/babe/src/mock.rs | 4 +- .../election-provider-multi-phase/src/lib.rs | 61 +++++----- .../election-provider-multi-phase/src/mock.rs | 39 ++++--- frame/election-provider-support/src/lib.rs | 109 +++++++++--------- .../election-provider-support/src/onchain.rs | 34 +++--- frame/session/benchmarking/src/mock.rs | 4 +- frame/staking/src/mock.rs | 8 +- frame/staking/src/pallet/impls.rs | 23 ++-- frame/staking/src/pallet/mod.rs | 4 +- frame/staking/src/tests.rs | 64 +++++++--- 10 files changed, 194 insertions(+), 156 deletions(-) diff --git a/frame/babe/src/mock.rs b/frame/babe/src/mock.rs index 204de8aae172e..855bd873a3f0d 100644 --- a/frame/babe/src/mock.rs +++ b/frame/babe/src/mock.rs @@ -179,8 +179,8 @@ impl onchain::Config for OnChainSeqPhragmen { type DataProvider = Staking; type WeightInfo = (); type MaxWinners = ConstU32<100>; - type VotersBound = ConstU32<{ u32::MAX }>; - type TargetsBound = ConstU32<{ u32::MAX }>; + type VotersBounds = ElectionBounds::new_unbounded(); + type TargetsBounds = ElectionBounds::new_unbounded(); } impl pallet_staking::Config for Test { diff --git a/frame/election-provider-multi-phase/src/lib.rs b/frame/election-provider-multi-phase/src/lib.rs index 780e83f0d92da..0550c8ded4f28 100644 --- a/frame/election-provider-multi-phase/src/lib.rs +++ b/frame/election-provider-multi-phase/src/lib.rs @@ -231,8 +231,8 @@ use codec::{Decode, Encode}; use frame_election_provider_support::{ - BoundedSupportsOf, ElectionDataProvider, ElectionProvider, ElectionProviderBase, - InstantElectionProvider, NposSolution, SnapshotBounds, + BoundedSupportsOf, ElectionBounds, ElectionBoundsBuilder, ElectionDataProvider, + ElectionProvider, ElectionProviderBase, InstantElectionProvider, NposSolution, }; use frame_support::{ dispatch::DispatchClass, @@ -671,13 +671,13 @@ pub mod pallet { #[pallet::constant] type MaxWinners: Get; - // The limits of targets to include in the snapshot per block. - #[pallet::constant] - type TargetSnapshotBounds: Get; + // The limits of targets to include in the snapshot per block. + #[pallet::constant] + type TargetsBounds: Get; - // The limits of voters to include in the snapshot per block. - #[pallet::constant] - type VoterSnapshotBounds: Get; + // The limits of voters to include in the snapshot per block. + #[pallet::constant] + type VotersBounds: Get; /// Handler for the slashed deposits. type SlashHandler: OnUnbalanced>; @@ -1086,14 +1086,13 @@ pub mod pallet { ) -> DispatchResult { T::ForceOrigin::ensure_origin(origin)?; ensure!(Self::current_phase().is_emergency(), >::CallNotAllowed); - - let supports = - T::GovernanceFallback::instant_elect(maybe_max_voters, maybe_max_targets).map_err( - |e| { - log!(error, "GovernanceFallback failed: {:?}", e); - Error::::FallbackFailed - }, - )?; + let voters_bounds = ElectionBoundsBuilder::new().count(maybe_max_voters).build(); + let targets_bounds = ElectionBoundsBuilder::new().count(maybe_max_voters).build(); + let supports = T::GovernanceFallback::instant_elect(voters_bounds, targets_bounds) + .map_err(|e| { + log!(error, "GovernanceFallback failed: {:?}", e); + Error::::FallbackFailed + })?; // transform BoundedVec<_, T::GovernanceFallback::MaxWinners> into // `BoundedVec<_, T::MaxWinners>` @@ -1409,17 +1408,18 @@ impl Pallet { /// Extracted for easier weight calculation. fn create_snapshot_external( ) -> Result<(Vec, Vec>, u32), ElectionError> { + // TODO: do we need T::MaxElect* limits now or can we rely on T::*Bounds? let target_limit = T::MaxElectableTargets::get().saturated_into::(); let voter_limit = T::MaxElectingVoters::get().saturated_into::(); - let target_bounds = T::TargetSnapshotBounds::get(); - let voter_bounds = T::VoterSnapshotBounds::get(); + let targets_bounds = T::TargetsBounds::get(); + let voters_bounds = T::VotersBounds::get(); - let targets = T::DataProvider::electable_targets(Some(target_limit)) + let targets = T::DataProvider::electable_targets(targets_bounds) .map_err(ElectionError::DataProvider)?; - let voters = T::DataProvider::electing_voters(Some(voter_limit)) - .map_err(ElectionError::DataProvider)?; + let voters = + T::DataProvider::electing_voters(voters_bounds).map_err(ElectionError::DataProvider)?; if targets.len() > target_limit || voters.len() > voter_limit { return Err(ElectionError::DataProvider("Snapshot too big for submission.")) @@ -1600,15 +1600,18 @@ impl Pallet { >::take() .ok_or(ElectionError::::NothingQueued) .or_else(|_| { - T::Fallback::instant_elect(None, None) - .map_err(|fe| ElectionError::Fallback(fe)) - .and_then(|supports| { - Ok(ReadySolution { - supports, - score: Default::default(), - compute: ElectionCompute::Fallback, - }) + T::Fallback::instant_elect( + ElectionBounds::new_unbounded(), + ElectionBounds::new_unbounded(), + ) + .map_err(|fe| ElectionError::Fallback(fe)) + .and_then(|supports| { + Ok(ReadySolution { + supports, + score: Default::default(), + compute: ElectionCompute::Fallback, }) + }) }) .map(|ReadySolution { compute, score, supports }| { Self::deposit_event(Event::ElectionFinalized { compute, score }); diff --git a/frame/election-provider-multi-phase/src/mock.rs b/frame/election-provider-multi-phase/src/mock.rs index 38023ca8c75cf..74a966535fd0a 100644 --- a/frame/election-provider-multi-phase/src/mock.rs +++ b/frame/election-provider-multi-phase/src/mock.rs @@ -20,7 +20,7 @@ use crate::{self as multi_phase, unsigned::MinerConfig}; use frame_election_provider_support::{ data_provider, onchain::{self}, - ElectionDataProvider, NposSolution, SequentialPhragmen, SnapshotBounds, + ElectionBounds, ElectionDataProvider, NposSolution, SequentialPhragmen, }; pub use frame_support::{assert_noop, assert_ok, pallet_prelude::GetDefault}; use frame_support::{ @@ -298,8 +298,8 @@ parameter_types! { pub static MaxElectingVoters: VoterIndex = u32::max_value(); pub static MaxElectableTargets: TargetIndex = TargetIndex::max_value(); pub static MaxWinners: u32 = 200; - pub static VoterSnapshotBounds: SnapshotBounds = SnapshotBounds::new_unbounded(); - pub static TargetSnapshotBounds: SnapshotBounds = SnapshotBounds::new_unbounded(); + pub static VotersBounds: ElectionBounds = ElectionBounds::new_unbounded(); + pub static TargetsBounds: ElectionBounds = ElectionBounds::new_unbounded(); pub static EpochLength: u64 = 30; pub static OnChainFallback: bool = true; @@ -312,8 +312,8 @@ impl onchain::Config for OnChainSeqPhragmen { type DataProvider = StakingMock; type WeightInfo = (); type MaxWinners = MaxWinners; - type VotersBound = ConstU32<{ u32::MAX }>; - type TargetsBound = ConstU32<{ u32::MAX }>; + type VotersBounds = VotersBounds; + type TargetsBounds = TargetsBounds; } pub struct MockFallback; @@ -327,12 +327,15 @@ impl ElectionProviderBase for MockFallback { impl InstantElectionProvider for MockFallback { fn instant_elect( - max_voters: Option, - max_targets: Option, + voters_bounds: ElectionBounds, + targets_bounds: ElectionBounds, ) -> Result, Self::Error> { if OnChainFallback::get() { - onchain::OnChainExecution::::instant_elect(max_voters, max_targets) - .map_err(|_| "onchain::OnChainExecution failed.") + onchain::OnChainExecution::::instant_elect( + voters_bounds, + targets_bounds, + ) + .map_err(|_| "onchain::OnChainExecution failed.") } else { Err("NoFallback.") } @@ -407,8 +410,8 @@ impl crate::Config for Runtime { type MaxWinners = MaxWinners; type MinerConfig = Self; type Solver = SequentialPhragmen, Balancing>; - type VoterSnapshotBounds = VoterSnapshotBounds; - type TargetSnapshotBounds = TargetSnapshotBounds; + type VotersBounds = VotersBounds; + type TargetsBounds = TargetsBounds; } impl frame_system::offchain::SendTransactionTypes for Runtime @@ -436,11 +439,11 @@ impl ElectionDataProvider for StakingMock { type BlockNumber = u64; type MaxVotesPerVoter = MaxNominations; - fn electable_targets(maybe_max_len: Option) -> data_provider::Result> { + fn electable_targets(bounds: ElectionBounds) -> data_provider::Result> { let targets = Targets::get(); if !DataProviderAllowBadData::get() && - maybe_max_len.map_or(false, |max_len| targets.len() > max_len) + bounds.count.map_or(false, |max_len| targets.len() > max_len as usize) { return Err("Targets too big") } @@ -448,13 +451,12 @@ impl ElectionDataProvider for StakingMock { Ok(targets) } - fn electing_voters( - maybe_max_len: Option, - ) -> data_provider::Result>> { + fn electing_voters(bounds: ElectionBounds) -> data_provider::Result>> { let mut voters = Voters::get(); + if !DataProviderAllowBadData::get() { - if let Some(max_len) = maybe_max_len { - voters.truncate(max_len) + if let Some(max_len) = bounds.count { + voters.truncate(max_len as usize) } } @@ -474,6 +476,7 @@ impl ElectionDataProvider for StakingMock { voters: Vec>, targets: Vec, _target_stake: Option, + /* TODO(gpestana): this is the absolute max nomination, make it more explicit */ ) { Targets::set(targets); Voters::set(voters); diff --git a/frame/election-provider-support/src/lib.rs b/frame/election-provider-support/src/lib.rs index e859cf9c3a45b..f42aa7486343f 100644 --- a/frame/election-provider-support/src/lib.rs +++ b/frame/election-provider-support/src/lib.rs @@ -283,25 +283,23 @@ pub trait ElectionDataProvider { /// All possible targets for the election, i.e. the targets that could become elected, thus /// "electable". /// - /// If `maybe_max_len` is `Some(v)` then the resulting vector MUST NOT be longer than `v` items - /// long. + /// If `bounds` are defined, then the resulting vector MUST NOT be longer or larger in MB than + /// `v` items long. /// /// This should be implemented as a self-weighing function. The implementor should register its /// appropriate weight at the end of execution with the system pallet directly. - fn electable_targets( - maybe_max_len: Option, - ) -> data_provider::Result>; + fn electable_targets(bounds: ElectionBounds) -> data_provider::Result>; /// All the voters that participate in the election, thus "electing". /// /// Note that if a notion of self-vote exists, it should be represented here. /// - /// If `maybe_max_len` is `Some(v)` then the resulting vector MUST NOT be longer than `v` items - /// long. + /// If `bounds` are defined, then the resulting vector MUST NOT be longer or larger in bytes + /// than `v` items long. /// /// This should be implemented as a self-weighing function. The implementor should register its /// appropriate weight at the end of execution with the system pallet directly. - fn electing_voters(maybe_max_len: Option) -> data_provider::Result>>; + fn electing_voters(bounds: ElectionBounds) -> data_provider::Result>>; /// The number of targets to elect. /// @@ -422,8 +420,8 @@ pub trait ElectionProvider: ElectionProviderBase { /// data provider at runtime via `forced_input_voters_bound` and `forced_input_target_bound`. pub trait InstantElectionProvider: ElectionProviderBase { fn instant_elect( - forced_input_voters_bound: Option, - forced_input_target_bound: Option, + forced_input_voters_bound: ElectionBounds, + forced_input_target_bound: ElectionBounds, ) -> Result, Self::Error>; } @@ -465,8 +463,8 @@ where MaxWinners: Get, { fn instant_elect( - _: Option, - _: Option, + _: ElectionBounds, + _: ElectionBounds, ) -> Result, Self::Error> { Err("`NoElection` cannot do anything.") } @@ -676,83 +674,86 @@ pub type BoundedSupportsOf = BoundedSupports< sp_core::generate_feature_enabled_macro!(runtime_benchmarks_enabled, feature = "runtime-benchmarks", $); sp_core::generate_feature_enabled_macro!(runtime_benchmarks_or_fuzz_enabled, any(feature = "runtime-benchmarks", feature = "fuzzing"), $); -/// The voter or target bounds of an election +/// The limits of an election result. The bounds are defined over the count of element of the +/// election (voters or targets) or the overall datastructure size. +/// +/// Ordering: when comparing two instances of `ElectionBounds`, the `count` has priority over the +/// `size`, ie. if `A.count > B.count`, then `A > B` regardless of their relative `size`. +#[derive(Clone, Copy, RuntimeDebug, scale_info::TypeInfo, Encode, Decode, Eq)] pub struct ElectionBounds { + /// The bound on number of elements. `None` means unbounded. pub count: Option, + /// The bound on size, in bytes. `None` means unbounded. + pub size: Option, } impl ElectionBounds { - pub fn new(count: Option) -> Self { - ElectionBounds { count } + /// Returns a new instance of self without bounds. + pub const fn new_unbounded() -> Self { + ElectionBounds { count: None, size: None } } -} -impl ElectionBounds { - pub fn exhausted(self, count: usize) -> bool { - self.count.map_or(false, |c| c > count as u32) + // Returns true if `given_size` or `given_count` exhausts `self.size` or `self_count` + // respectively. + pub fn exhausted(self, given_size: Option, given_count: Option) -> bool { + self.size.map_or(false, |size| given_size.unwrap_or(0) > size) || + self.count.map_or(false, |count| given_count.unwrap_or(0) > count) } } -impl From for ElectionBounds { - fn from(bounds: SnapshotBounds) -> Self { - ElectionBounds { count: bounds.count } +impl PartialEq for ElectionBounds { + fn eq(&self, other: &Self) -> bool { + self.count == other.count || self.size == self.size } } -impl From> for ElectionBounds { - fn from(bounds: Option) -> Self { - ElectionBounds { count: bounds.map(|b| b as u32) } +impl PartialOrd for ElectionBounds { + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) } } -/// The limits of an election snapshot. -#[derive(Clone, Copy, RuntimeDebug, scale_info::TypeInfo, Encode, Decode)] -pub struct SnapshotBounds { - /// The bound on number of elements. `None` means unbounded. - count: Option, - /// The bound on size, in bytes. `None` means unbounded. - size: Option, -} - -impl SnapshotBounds { - /// Returns a new instance of self without bounds. - pub const fn new_unbounded() -> Self { - SnapshotBounds { count: None, size: None } - } - - // Returns true if `given_size` or `given_count` exhausts `self.size` or `self_count` - // respectively. - pub fn exhausted(self, given_size: u32, given_count: u32) -> bool { - self.size.map_or(false, |size| given_size > size) || - self.count.map_or(false, |count| given_count > count) +impl Ord for ElectionBounds { + fn cmp(&self, other: &Self) -> std::cmp::Ordering { + if self.count == other.count { + self.size.cmp(&other.size) + } else { + self.count.cmp(&other.count) + } } } -/// Utility builder for [`SnapshotBounds`]. +/// Utility builder for [`ElectionBounds`]. /// /// The main purpose of this is to prevent mixing the order of similarly typed arguments (e.g. u32 /// size and count). -pub struct SnapshotBoundsBuilder { +#[derive(Copy, Clone)] +pub struct ElectionBoundsBuilder { count: Option, size: Option, } -impl SnapshotBoundsBuilder { - /// set the count of the snapshot. - pub fn count(mut self, count: Option) -> SnapshotBoundsBuilder { +impl ElectionBoundsBuilder { + /// Returns a new election bounds builder + pub fn new() -> Self { + ElectionBoundsBuilder { count: None, size: None } + } + + /// Set the count of the snapshot. + pub fn count(mut self, count: Option) -> Self { self.count = count; self } /// Set the size of the snapshot. - pub fn size(mut self, size: Option) -> SnapshotBoundsBuilder { + pub fn size(mut self, size: Option) -> Self { self.size = size; self } - /// Returns an instance of `SnapshotBounds` from the current state. - pub fn build(self) -> SnapshotBounds { - SnapshotBounds { count: self.count, size: self.size } + /// Returns an instance of `ElectionBounds` from the current state. + pub fn build(self) -> ElectionBounds { + ElectionBounds { count: self.count, size: self.size } } } diff --git a/frame/election-provider-support/src/onchain.rs b/frame/election-provider-support/src/onchain.rs index 483c402fe249c..b0cbfc8d05a25 100644 --- a/frame/election-provider-support/src/onchain.rs +++ b/frame/election-provider-support/src/onchain.rs @@ -20,8 +20,8 @@ //! careful when using it onchain. use crate::{ - BoundedSupportsOf, Debug, ElectionDataProvider, ElectionProvider, ElectionProviderBase, - InstantElectionProvider, NposSolver, WeightInfo, + BoundedSupportsOf, Debug, ElectionBounds, ElectionDataProvider, ElectionProvider, + ElectionProviderBase, InstantElectionProvider, NposSolver, WeightInfo, }; use frame_support::{dispatch::DispatchClass, traits::Get}; use sp_npos_elections::{ @@ -87,11 +87,11 @@ pub trait Config { /// Bounds the number of voters, when calling into [`Config::DataProvider`]. It might be /// overwritten in the `InstantElectionProvider` impl. - type VotersBound: Get; + type VotersBounds: Get; /// Bounds the number of targets, when calling into [`Config::DataProvider`]. It might be /// overwritten in the `InstantElectionProvider` impl. - type TargetsBound: Get; + type TargetsBounds: Get; } /// Same as `BoundedSupportsOf` but for `onchain::Config`. @@ -101,12 +101,11 @@ pub type OnChainBoundedSupportsOf = BoundedSupports< >; fn elect_with_input_bounds( - maybe_max_voters: Option, - maybe_max_targets: Option, + voter_bounds: ElectionBounds, + target_bounds: ElectionBounds, ) -> Result, Error> { - let voters = T::DataProvider::electing_voters(maybe_max_voters).map_err(Error::DataProvider)?; - let targets = - T::DataProvider::electable_targets(maybe_max_targets).map_err(Error::DataProvider)?; + let voters = T::DataProvider::electing_voters(voter_bounds).map_err(Error::DataProvider)?; + let targets = T::DataProvider::electable_targets(target_bounds).map_err(Error::DataProvider)?; let desired_targets = T::DataProvider::desired_targets().map_err(Error::DataProvider)?; if desired_targets > T::MaxWinners::get() { @@ -159,12 +158,12 @@ impl ElectionProviderBase for OnChainExecution { impl InstantElectionProvider for OnChainExecution { fn instant_elect( - forced_input_voters_bound: Option, - forced_input_target_bound: Option, + voters_bounds: ElectionBounds, + targets_bounds: ElectionBounds, ) -> Result, Self::Error> { elect_with_input_bounds::( - Some(T::VotersBound::get().min(forced_input_voters_bound.unwrap_or(u32::MAX)) as usize), - Some(T::TargetsBound::get().min(forced_input_target_bound.unwrap_or(u32::MAX)) as usize), + T::VotersBounds::get().min(voters_bounds), + T::TargetsBounds::get().min(targets_bounds), ) } } @@ -175,10 +174,7 @@ impl ElectionProvider for OnChainExecution { } fn elect() -> Result, Self::Error> { - elect_with_input_bounds::( - Some(T::VotersBound::get() as usize), - Some(T::TargetsBound::get() as usize), - ) + elect_with_input_bounds::(T::VotersBounds::get(), T::TargetsBounds::get()) } } @@ -272,7 +268,7 @@ mod tests { type AccountId = AccountId; type BlockNumber = BlockNumber; type MaxVotesPerVoter = ConstU32<2>; - fn electing_voters(_: Option) -> data_provider::Result>> { + fn electing_voters(_: ElectionBounds) -> data_provider::Result>> { Ok(vec![ (1, 10, bounded_vec![10, 20]), (2, 20, bounded_vec![30, 20]), @@ -280,7 +276,7 @@ mod tests { ]) } - fn electable_targets(_: Option) -> data_provider::Result> { + fn electable_targets(_: ElectionBounds) -> data_provider::Result> { Ok(vec![10, 20, 30]) } diff --git a/frame/session/benchmarking/src/mock.rs b/frame/session/benchmarking/src/mock.rs index 2db7eb385111c..3c733657d22ad 100644 --- a/frame/session/benchmarking/src/mock.rs +++ b/frame/session/benchmarking/src/mock.rs @@ -151,8 +151,8 @@ impl onchain::Config for OnChainSeqPhragmen { type DataProvider = Staking; type WeightInfo = (); type MaxWinners = ConstU32<100>; - type VotersBound = ConstU32<{ u32::MAX }>; - type TargetsBound = ConstU32<{ u32::MAX }>; + type VotersBounds = ElectionsBounds::new_unbounded(); + type TargetsBounds = ElectionsBounds::new_unbounded(); } impl pallet_staking::Config for Test { diff --git a/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index 36d8e71bedc04..1bdb0431c5fe1 100644 --- a/frame/staking/src/mock.rs +++ b/frame/staking/src/mock.rs @@ -18,7 +18,7 @@ //! Test utilities use crate::{self as pallet_staking, *}; -use frame_election_provider_support::{onchain, SequentialPhragmen, VoteWeight}; +use frame_election_provider_support::{onchain, ElectionBounds, SequentialPhragmen, VoteWeight}; use frame_support::{ assert_ok, parameter_types, traits::{ @@ -239,6 +239,8 @@ parameter_types! { pub static RewardOnUnbalanceWasCalled: bool = false; pub static LedgerSlashPerEra: (BalanceOf, BTreeMap>) = (Zero::zero(), BTreeMap::new()); pub static MaxWinners: u32 = 100; + pub static VotersBounds: ElectionBounds = ElectionBounds::new_unbounded(); + pub static TargetsBounds: ElectionBounds = ElectionBounds::new_unbounded(); } type VoterBagsListInstance = pallet_bags_list::Instance1; @@ -258,8 +260,8 @@ impl onchain::Config for OnChainSeqPhragmen { type DataProvider = Staking; type WeightInfo = (); type MaxWinners = MaxWinners; - type VotersBound = ConstU32<{ u32::MAX }>; - type TargetsBound = ConstU32<{ u32::MAX }>; + type VotersBounds = VotersBounds; + type TargetsBounds = TargetsBounds; } pub struct MockReward {} diff --git a/frame/staking/src/pallet/impls.rs b/frame/staking/src/pallet/impls.rs index 70b9add365cd7..01313e7f24334 100644 --- a/frame/staking/src/pallet/impls.rs +++ b/frame/staking/src/pallet/impls.rs @@ -18,8 +18,8 @@ //! Implementations for the Staking FRAME Pallet. use frame_election_provider_support::{ - data_provider, BoundedSupportsOf, ElectionDataProvider, ElectionProvider, ScoreProvider, - SortedListProvider, VoteWeight, VoterOf, + data_provider, BoundedSupportsOf, ElectionBounds, ElectionDataProvider, ElectionProvider, + ScoreProvider, SortedListProvider, VoteWeight, VoterOf, }; use frame_support::{ dispatch::WithPostDispatchInfo, @@ -748,8 +748,9 @@ impl Pallet { /// nominators. /// /// This function is self-weighing as [`DispatchClass::Mandatory`]. - pub fn get_npos_voters(maybe_max_len: Option) -> Vec> { - // TODO: limits are snapshot/election bounds passed as input (election_bounds: ElectionBounds) + pub fn get_npos_voters(voter_bounds: ElectionBounds) -> Vec> { + // TODO: limits are snapshot/election bounds passed as input (election_bounds: + // ElectionBounds) let (size, count) = (None, Some(10)); let mut voters_size_tracker: ElectionSizeTracker = @@ -787,7 +788,7 @@ impl Pallet { let target_quota = T::NominationsQuota::get_quota_capped(voter_weight.into()); if !targets.is_empty() { if voters_size_tracker.try_register_voter(targets.len()).is_err() { - // TODO(gpestana): needs logging? + // TODO(gpestana): needs logging? // no more space in the election result, stop iterating over the voters. // TODO(gpestana): needs logging? break @@ -995,19 +996,21 @@ impl ElectionDataProvider for Pallet { Ok(Self::validator_count()) } - fn electing_voters(maybe_max_len: Option) -> data_provider::Result>> { + fn electing_voters(bounds: ElectionBounds) -> data_provider::Result>> { // This can never fail -- if `maybe_max_len` is `Some(_)` we handle it. - let voters = Self::get_npos_voters(maybe_max_len); - debug_assert!(maybe_max_len.map_or(true, |max| voters.len() <= max)); + let voters = Self::get_npos_voters(bounds); + debug_assert!( + !bounds.exhausted(Some(voters.len() as u32), Some(voters.encoded_size() as u32)) + ); Ok(voters) } - fn electable_targets(maybe_max_len: Option) -> data_provider::Result> { + fn electable_targets(bounds: ElectionBounds) -> data_provider::Result> { let target_count = T::TargetList::count(); // We can't handle this case yet -- return an error. - if maybe_max_len.map_or(false, |max_len| target_count > max_len as u32) { + if bounds.exhausted(Some(target_count as u32), None) { return Err("Target snapshot too big") } diff --git a/frame/staking/src/pallet/mod.rs b/frame/staking/src/pallet/mod.rs index 8ba1df7d9caf4..270190b4bf7ee 100644 --- a/frame/staking/src/pallet/mod.rs +++ b/frame/staking/src/pallet/mod.rs @@ -1159,8 +1159,8 @@ pub mod pallet { ensure!(!targets.is_empty(), Error::::EmptyTargets); ensure!( - // TODO(gpestana): this is the absolute max nomination, make it more explicit - targets.len() <= T::NominationsQuota::get() as usize, + // TODO(gpestana): this is the absolute max nomination, make it more explicit + targets.len() <= T::NominationsQuota::get() as usize, Error::::TooManyTargets ); diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index fc6fc68e66d5d..28ea7187b205e 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -18,7 +18,9 @@ //! Tests for the module. use super::{ConfigOp, Event, *}; -use frame_election_provider_support::{ElectionProvider, SortedListProvider, Support}; +use frame_election_provider_support::{ + ElectionBounds, ElectionBoundsBuilder, ElectionProvider, SortedListProvider, Support, +}; use frame_support::{ assert_noop, assert_ok, assert_storage_noop, bounded_vec, dispatch::{extract_actual_weight, GetDispatchInfo, WithPostDispatchInfo}, @@ -4503,12 +4505,15 @@ mod election_data_provider { .add_staker(71, 70, 10, StakerStatus::::Nominator(vec![21])) .add_staker(81, 80, 50, StakerStatus::::Nominator(vec![21])) .build_and_execute(|| { - assert_ok!(::electing_voters(None)); + assert_ok!(::electing_voters( + ElectionBounds::new_unbounded() + )); assert_eq!(MinimumActiveStake::::get(), 10); // remove staker with lower bond by limiting the number of voters and check // `MinimumActiveStake` again after electing voters. - assert_ok!(::electing_voters(Some(5))); + let bounds = ElectionBoundsBuilder::new().count(Some(5)).build(); + assert_ok!(::electing_voters(bounds)); assert_eq!(MinimumActiveStake::::get(), 50); }); } @@ -4516,7 +4521,9 @@ mod election_data_provider { #[test] fn set_minimum_active_stake_zero_correct() { ExtBuilder::default().has_stakers(false).build_and_execute(|| { - assert_ok!(::electing_voters(None)); + assert_ok!(::electing_voters( + ElectionBounds::new_unbounded() + )); assert_eq!(MinimumActiveStake::::get(), 0); }); } @@ -4525,7 +4532,7 @@ mod election_data_provider { fn voters_include_self_vote() { ExtBuilder::default().nominate(false).build_and_execute(|| { assert!(>::iter().map(|(x, _)| x).all(|v| Staking::electing_voters( - None + ElectionBounds::new_unbounded() ) .unwrap() .into_iter() @@ -4541,22 +4548,43 @@ mod election_data_provider { // sum of all nominators who'd be voters (1), plus the self-votes (4). assert_eq!(::VoterList::count(), 5); + let bounds_builder = ElectionBoundsBuilder::new(); + // if limits is less.. - assert_eq!(Staking::electing_voters(Some(1)).unwrap().len(), 1); + assert_eq!( + Staking::electing_voters(bounds_builder.count(Some(1)).build()).unwrap().len(), + 1 + ); // if limit is equal.. - assert_eq!(Staking::electing_voters(Some(5)).unwrap().len(), 5); + assert_eq!( + Staking::electing_voters(bounds_builder.count(Some(5)).build()).unwrap().len(), + 5 + ); // if limit is more. - assert_eq!(Staking::electing_voters(Some(55)).unwrap().len(), 5); + assert_eq!( + Staking::electing_voters(bounds_builder.count(Some(55)).build()).unwrap().len(), + 5 + ); // if target limit is more.. - assert_eq!(Staking::electable_targets(Some(6)).unwrap().len(), 4); - assert_eq!(Staking::electable_targets(Some(4)).unwrap().len(), 4); + assert_eq!( + Staking::electable_targets(bounds_builder.count(Some(6)).build()) + .unwrap() + .len(), + 4 + ); + assert_eq!( + Staking::electable_targets(bounds_builder.count(Some(4)).build()) + .unwrap() + .len(), + 4 + ); // if target limit is less, then we return an error. assert_eq!( - Staking::electable_targets(Some(1)).unwrap_err(), + Staking::electable_targets(bounds_builder.count(Some(1)).build()).unwrap_err(), "Target snapshot too big" ); }); @@ -4605,7 +4633,7 @@ mod election_data_provider { // 11 is taken; // we finish since the 2x limit is reached. assert_eq!( - Staking::electing_voters(Some(2)) + Staking::electing_voters(ElectionBoundsBuilder::new().count(Some(2)).build()) .unwrap() .iter() .map(|(stash, _, _)| stash) @@ -5063,6 +5091,8 @@ fn change_of_max_nominations() { // pre-condition assert_eq!(MaxNominations::get(), 16); + let unbonded_election = ElectionBounds::new_unbounded(); + assert_eq!( Nominators::::iter() .map(|(k, n)| (k, n.targets.len())) @@ -5070,7 +5100,7 @@ fn change_of_max_nominations() { vec![(70, 3), (101, 2), (60, 1)] ); // 3 validators and 3 nominators - assert_eq!(Staking::electing_voters(None).unwrap().len(), 3 + 3); + assert_eq!(Staking::electing_voters(unbonded_election).unwrap().len(), 3 + 3); // abrupt change from 16 to 4, everyone should be fine. MaxNominations::set(4); @@ -5081,7 +5111,7 @@ fn change_of_max_nominations() { .collect::>(), vec![(70, 3), (101, 2), (60, 1)] ); - assert_eq!(Staking::electing_voters(None).unwrap().len(), 3 + 3); + assert_eq!(Staking::electing_voters(unbonded_election).unwrap().len(), 3 + 3); // abrupt change from 4 to 3, everyone should be fine. MaxNominations::set(3); @@ -5092,7 +5122,7 @@ fn change_of_max_nominations() { .collect::>(), vec![(70, 3), (101, 2), (60, 1)] ); - assert_eq!(Staking::electing_voters(None).unwrap().len(), 3 + 3); + assert_eq!(Staking::electing_voters(unbonded_election).unwrap().len(), 3 + 3); // abrupt change from 3 to 2, this should cause some nominators to be non-decodable, and // thus non-existent unless if they update. @@ -5109,7 +5139,7 @@ fn change_of_max_nominations() { // but its value cannot be decoded and default is returned. assert!(Nominators::::get(70).is_none()); - assert_eq!(Staking::electing_voters(None).unwrap().len(), 3 + 2); + assert_eq!(Staking::electing_voters(unbonded_election).unwrap().len(), 3 + 2); assert!(Nominators::::contains_key(101)); // abrupt change from 2 to 1, this should cause some nominators to be non-decodable, and @@ -5126,7 +5156,7 @@ fn change_of_max_nominations() { assert!(Nominators::::contains_key(60)); assert!(Nominators::::get(70).is_none()); assert!(Nominators::::get(60).is_some()); - assert_eq!(Staking::electing_voters(None).unwrap().len(), 3 + 1); + assert_eq!(Staking::electing_voters(unbonded_election).unwrap().len(), 3 + 1); // now one of them can revive themselves by re-nominating to a proper value. assert_ok!(Staking::nominate(RuntimeOrigin::signed(71), vec![1])); From 3ae3e2952fdcfa113d75959e61d0b2371e5405c4 Mon Sep 17 00:00:00 2001 From: gpestana Date: Mon, 19 Dec 2022 11:03:51 +0100 Subject: [PATCH 04/80] Implements get_npos_voters with ElectionBounds --- frame/election-provider-support/src/lib.rs | 11 +++++-- frame/staking/src/lib.rs | 22 ++++++++++---- frame/staking/src/pallet/impls.rs | 34 ++++++++++------------ 3 files changed, 41 insertions(+), 26 deletions(-) diff --git a/frame/election-provider-support/src/lib.rs b/frame/election-provider-support/src/lib.rs index f42aa7486343f..6c0247771a71f 100644 --- a/frame/election-provider-support/src/lib.rs +++ b/frame/election-provider-support/src/lib.rs @@ -693,11 +693,18 @@ impl ElectionBounds { ElectionBounds { count: None, size: None } } + pub fn count_exhausted(self, given_count: Option) -> bool { + self.count.map_or(false, |count| given_count.unwrap_or(0) > count) + } + + pub fn size_exhausted(self, given_size: Option) -> bool { + self.size.map_or(false, |count| given_size.unwrap_or(0) > count) + } + // Returns true if `given_size` or `given_count` exhausts `self.size` or `self_count` // respectively. pub fn exhausted(self, given_size: Option, given_count: Option) -> bool { - self.size.map_or(false, |size| given_size.unwrap_or(0) > size) || - self.count.map_or(false, |count| given_count.unwrap_or(0) > count) + self.count_exhausted(given_count) || self.size_exhausted(given_size) } } diff --git a/frame/staking/src/lib.rs b/frame/staking/src/lib.rs index 5af980823e84d..4a6c6db5a361b 100644 --- a/frame/staking/src/lib.rs +++ b/frame/staking/src/lib.rs @@ -300,7 +300,7 @@ pub mod weights; mod pallet; use codec::{Decode, Encode, HasCompact, MaxEncodedLen}; -use frame_election_provider_support::VoteWeight; +use frame_election_provider_support::{ElectionBounds, VoteWeight}; use frame_support::{ traits::{Currency, Defensive, Get}, weights::Weight, @@ -797,6 +797,8 @@ impl NominationsQuota for FixedNominationsQuot } } +// TODO(gpestana): temporary -- `Get` is returning the ABSOLUTE_MAX_NOMINATIONS, make it more +// explicit (unclear which u32 instance is returning) impl Get for FixedNominationsQuota { fn get() -> u32 { MAX @@ -805,18 +807,26 @@ impl Get for FixedNominationsQuota { pub(crate) struct ElectionSizeTracker { size: usize, - limit: Option, _marker: sp_std::marker::PhantomData, } impl ElectionSizeTracker { pub(crate) fn new(limit: Option) -> Self { - ElectionSizeTracker { size: 0, limit, _marker: Default::default() } + ElectionSizeTracker { size: 0, _marker: Default::default() } } - // TODO: finish by calculating if current size vote fits in the tracker, result err if not - pub(crate) fn try_register_voter(&mut self, votes: usize) -> Result<(), ()> { - Ok(self.size = self.size.saturating_add(Self::voter_size(votes))) + pub(crate) fn try_register_voter( + &mut self, + votes: usize, + bounds: ElectionBounds, + ) -> Result<(), ()> { + let voter_size = Self::voter_size(votes); + // refactor + if bounds.size_exhausted(Some(self.size.saturating_add(voter_size) as u32)) { + Err(()) + } else { + Ok(self.size = self.size.saturating_add(voter_size)) + } } fn voter_size(votes: usize) -> usize { diff --git a/frame/staking/src/pallet/impls.rs b/frame/staking/src/pallet/impls.rs index 01313e7f24334..1b141af2bcdcc 100644 --- a/frame/staking/src/pallet/impls.rs +++ b/frame/staking/src/pallet/impls.rs @@ -749,19 +749,15 @@ impl Pallet { /// /// This function is self-weighing as [`DispatchClass::Mandatory`]. pub fn get_npos_voters(voter_bounds: ElectionBounds) -> Vec> { - // TODO: limits are snapshot/election bounds passed as input (election_bounds: - // ElectionBounds) - let (size, count) = (None, Some(10)); - let mut voters_size_tracker: ElectionSizeTracker = - ElectionSizeTracker::new(size); + ElectionSizeTracker::new(voter_bounds.size.map_or(None, |s| Some(s as usize))); let max_allowed_len = { - let all_voter_count = T::VoterList::count() as usize; - count.unwrap_or(all_voter_count).min(all_voter_count) + let all_voter_count = T::VoterList::count(); + voter_bounds.count.unwrap_or(all_voter_count).min(all_voter_count) }; - let mut all_voters = Vec::<_>::with_capacity(max_allowed_len); + let mut all_voters = Vec::<_>::with_capacity(max_allowed_len as usize); // cache a few things. let weight_of = Self::weight_of_fn(); @@ -772,7 +768,7 @@ impl Pallet { let mut min_active_stake = u64::MAX; let mut sorted_voters = T::VoterList::iter(); - while all_voters.len() < max_allowed_len && + while all_voters.len() < max_allowed_len as usize && voters_seen < (NPOS_MAX_ITERATIONS_COEFFICIENT * max_allowed_len as u32) { let voter = match sorted_voters.next() { @@ -785,12 +781,14 @@ impl Pallet { if let Some(Nominations { targets, .. }) = >::get(&voter) { let voter_weight = weight_of(&voter); - let target_quota = T::NominationsQuota::get_quota_capped(voter_weight.into()); + let nominations_quota = T::NominationsQuota::get_quota_capped(voter_weight.into()); if !targets.is_empty() { - if voters_size_tracker.try_register_voter(targets.len()).is_err() { - // TODO(gpestana): needs logging? - // no more space in the election result, stop iterating over the voters. - // TODO(gpestana): needs logging? + if voters_size_tracker + .try_register_voter(nominations_quota as usize, voter_bounds) + .is_err() + { + // no more space left for the election result, stop iterating over the + // voters. break } @@ -799,13 +797,13 @@ impl Pallet { } else { // Technically should never happen, but not much we can do about it. } + min_active_stake = if voter_weight < min_active_stake { voter_weight } else { min_active_stake }; } else if Validators::::contains_key(&voter) { // if this voter is a validator: - if voters_size_tracker.try_register_voter(1).is_err() { - // no more space in the election result, stop iterating over the voters. - // TODO(gpestana): needs logging? + if voters_size_tracker.try_register_voter(1, voter_bounds).is_err() { + // no more space left for the election result, stop iterating over the voters. break } let self_vote = ( @@ -832,7 +830,7 @@ impl Pallet { } // all_voters should have not re-allocated. - debug_assert!(all_voters.capacity() == max_allowed_len); + debug_assert!(all_voters.capacity() == max_allowed_len as usize); Self::register_weight(T::WeightInfo::get_npos_voters(validators_taken, nominators_taken)); From 98f6e82f8cc2239e89d6e530425e6952b12f58b1 Mon Sep 17 00:00:00 2001 From: gpestana Date: Mon, 19 Dec 2022 11:13:50 +0100 Subject: [PATCH 05/80] Implements get_npos_targets with ElectionBounds --- frame/staking/src/pallet/impls.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/frame/staking/src/pallet/impls.rs b/frame/staking/src/pallet/impls.rs index 1b141af2bcdcc..2d9eede38142a 100644 --- a/frame/staking/src/pallet/impls.rs +++ b/frame/staking/src/pallet/impls.rs @@ -853,13 +853,17 @@ impl Pallet { /// Get the targets for an upcoming npos election. /// /// This function is self-weighing as [`DispatchClass::Mandatory`]. - pub fn get_npos_targets(maybe_max_len: Option) -> Vec { - let max_allowed_len = maybe_max_len.unwrap_or_else(|| T::TargetList::count() as usize); - let mut all_targets = Vec::::with_capacity(max_allowed_len); + pub fn get_npos_targets(target_bounds: ElectionBounds) -> Vec { + let max_allowed_len = { + let all_target_count = T::TargetList::count(); + target_bounds.count.unwrap_or(all_target_count).min(all_target_count) + }; + + let mut all_targets = Vec::::with_capacity(max_allowed_len as usize); let mut targets_seen = 0; let mut targets_iter = T::TargetList::iter(); - while all_targets.len() < max_allowed_len && + while all_targets.len() < max_allowed_len as usize && targets_seen < (NPOS_MAX_ITERATIONS_COEFFICIENT * max_allowed_len as u32) { let target = match targets_iter.next() { @@ -1012,7 +1016,7 @@ impl ElectionDataProvider for Pallet { return Err("Target snapshot too big") } - Ok(Self::get_npos_targets(None)) + Ok(Self::get_npos_targets(bounds)) } fn next_election_prediction(now: T::BlockNumber) -> T::BlockNumber { From 5434b47bb694efe2fa50402b21b6235e6e938efd Mon Sep 17 00:00:00 2001 From: gpestana Date: Mon, 19 Dec 2022 11:31:14 +0100 Subject: [PATCH 06/80] Adds comments --- frame/election-provider-support/src/lib.rs | 2 ++ frame/staking/src/lib.rs | 23 +++++++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/frame/election-provider-support/src/lib.rs b/frame/election-provider-support/src/lib.rs index 6c0247771a71f..02f3a30f4aef4 100644 --- a/frame/election-provider-support/src/lib.rs +++ b/frame/election-provider-support/src/lib.rs @@ -693,10 +693,12 @@ impl ElectionBounds { ElectionBounds { count: None, size: None } } + // Returns true if `given_count` exhausts `self.count`. pub fn count_exhausted(self, given_count: Option) -> bool { self.count.map_or(false, |count| given_count.unwrap_or(0) > count) } + // Returns true if `given_size` exhausts `self.size`. pub fn size_exhausted(self, given_size: Option) -> bool { self.size.map_or(false, |count| given_size.unwrap_or(0) > count) } diff --git a/frame/staking/src/lib.rs b/frame/staking/src/lib.rs index 4a6c6db5a361b..4ef0ac4dedcfc 100644 --- a/frame/staking/src/lib.rs +++ b/frame/staking/src/lib.rs @@ -805,27 +805,44 @@ impl Get for FixedNominationsQuota { } } +/// A static tracker for the election data snapshot. +/// +/// Computes the (SCALE) encoded byte length of a snapshot based on static rules, without any actual +/// encoding. +/// +/// ## Details +/// +/// The snapshot has a the form `Vec` where `Voter = (Account, u64, Vec)`. For each +/// voter added to the snapshot, [`try_register_voter`] should be called, with the number of votes +/// (length of the internal `Vec`). +/// +/// Whilst doing this, [`size`] will track the entire size of the `Vec`, except for the +/// length prefix of the outer `Vec`. To get the final size at any point, use +/// [`final_byte_size_of`]. pub(crate) struct ElectionSizeTracker { size: usize, _marker: sp_std::marker::PhantomData, } impl ElectionSizeTracker { - pub(crate) fn new(limit: Option) -> Self { + pub(crate) fn new() -> Self { ElectionSizeTracker { size: 0, _marker: Default::default() } } + /// Attempts to register a new voter with `votes` for a given election `bounds`. Returns an + /// error if the size of the new votes exceed the capacity of the tracker. pub(crate) fn try_register_voter( &mut self, votes: usize, bounds: ElectionBounds, ) -> Result<(), ()> { + // TODO(gpestana): it is not accurately calculating/setting the size yet, fix let voter_size = Self::voter_size(votes); - // refactor if bounds.size_exhausted(Some(self.size.saturating_add(voter_size) as u32)) { Err(()) } else { - Ok(self.size = self.size.saturating_add(voter_size)) + self.size = self.size.saturating_add(voter_size); + Ok(()) } } From 0a7b714a6d1cc198a88e98592b247482fa3588cc Mon Sep 17 00:00:00 2001 From: gpestana Date: Wed, 21 Dec 2022 09:54:08 +0100 Subject: [PATCH 07/80] tests --- frame/election-provider-support/src/lib.rs | 3 +- frame/staking/src/lib.rs | 24 +++--- frame/staking/src/mock.rs | 29 ++++++- frame/staking/src/pallet/impls.rs | 19 +++-- frame/staking/src/pallet/mod.rs | 30 ++++--- frame/staking/src/tests.rs | 97 ++++------------------ 6 files changed, 88 insertions(+), 114 deletions(-) diff --git a/frame/election-provider-support/src/lib.rs b/frame/election-provider-support/src/lib.rs index 02f3a30f4aef4..6888e420d383f 100644 --- a/frame/election-provider-support/src/lib.rs +++ b/frame/election-provider-support/src/lib.rs @@ -695,6 +695,7 @@ impl ElectionBounds { // Returns true if `given_count` exhausts `self.count`. pub fn count_exhausted(self, given_count: Option) -> bool { + println!("{:?} > {:?}?", given_count, self.count); self.count.map_or(false, |count| given_count.unwrap_or(0) > count) } @@ -767,6 +768,6 @@ impl ElectionBoundsBuilder { } #[cfg(test)] -mod snapshot_bounds { +mod elections_bounds { // TODO(gpestana) } diff --git a/frame/staking/src/lib.rs b/frame/staking/src/lib.rs index 4ef0ac4dedcfc..5b2fd4af92f05 100644 --- a/frame/staking/src/lib.rs +++ b/frame/staking/src/lib.rs @@ -768,7 +768,7 @@ impl UnappliedSlash { } /// Something that defines the maximum number of nominations per nominator. -pub trait NominationsQuota: Get { +pub trait NominationsQuota { const ABSOLUTE_MAX_NOMINATIONS: u32; type AbsoluteMaxNominations: Get; @@ -797,8 +797,6 @@ impl NominationsQuota for FixedNominationsQuot } } -// TODO(gpestana): temporary -- `Get` is returning the ABSOLUTE_MAX_NOMINATIONS, make it more -// explicit (unclear which u32 instance is returning) impl Get for FixedNominationsQuota { fn get() -> u32 { MAX @@ -836,16 +834,19 @@ impl ElectionSizeTracker { votes: usize, bounds: ElectionBounds, ) -> Result<(), ()> { - // TODO(gpestana): it is not accurately calculating/setting the size yet, fix let voter_size = Self::voter_size(votes); - if bounds.size_exhausted(Some(self.size.saturating_add(voter_size) as u32)) { - Err(()) - } else { - self.size = self.size.saturating_add(voter_size); - Ok(()) + let size_after = self.size.saturating_add(voter_size); + + match bounds.size_exhausted(Some(size_after as u32)) { + true => Err(()), + false => { + self.size = size_after; + Ok(()) + }, } } + /// Returns the size taken by a voter with `votes`. fn voter_size(votes: usize) -> usize { Self::length_prefix(votes) // and each element @@ -863,11 +864,6 @@ impl ElectionSizeTracker { let length = length as u32; Compact::::compact_len(&length) } - - // Final size: size of all internal elements, plus the length prefix. - pub(crate) fn final_byte_size_of(&self, length: usize) -> usize { - self.size + Self::length_prefix(length) - } } /// Means for interacting with a specialized version of the `session` trait. diff --git a/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index 1bdb0431c5fe1..f936a56605024 100644 --- a/frame/staking/src/mock.rs +++ b/frame/staking/src/mock.rs @@ -233,7 +233,6 @@ const THRESHOLDS: [sp_npos_elections::VoteWeight; 9] = parameter_types! { pub static BagThresholds: &'static [sp_npos_elections::VoteWeight] = &THRESHOLDS; - pub static MaxNominations: u32 = 16; pub static HistoryDepth: u32 = 80; pub static MaxUnlockingChunks: u32 = 32; pub static RewardOnUnbalanceWasCalled: bool = false; @@ -283,7 +282,6 @@ impl sp_staking::OnStakerSlash for OnStakerSlashM } impl crate::pallet::pallet::Config for Test { - type NominationsQuota = FixedNominationsQuota<16>; type Currency = Balances; type CurrencyBalance = ::Balance; type UnixTime = Timestamp; @@ -306,6 +304,8 @@ impl crate::pallet::pallet::Config for Test { // NOTE: consider a macro and use `UseNominatorsAndValidatorsMap` as well. type VoterList = VoterBagsList; type TargetList = UseValidatorsMap; + type NominationsQuota = WeightedNominationsQuota<16>; + //type NominationsQuota = FixedNominationsQuota<16>; type MaxUnlockingChunks = MaxUnlockingChunks; type HistoryDepth = HistoryDepth; type OnStakerSlash = OnStakerSlashMock; @@ -313,6 +313,31 @@ impl crate::pallet::pallet::Config for Test { type WeightInfo = (); } +pub struct WeightedNominationsQuota; +impl NominationsQuota for WeightedNominationsQuota +where + u128: From, +{ + const ABSOLUTE_MAX_NOMINATIONS: u32 = MAX; + type AbsoluteMaxNominations = Self; + + fn get_quota(balance: Balance) -> u32 { + match balance.into() { + // random quota per balance for testing + 0..=300 => 16, + 301..=500 => 3, + 501..=600 => 1, + _ => MAX, + } + } +} + +impl Get for WeightedNominationsQuota { + fn get() -> u32 { + MAX + } +} + pub(crate) type StakingCall = crate::Call; pub(crate) type TestCall = ::RuntimeCall; diff --git a/frame/staking/src/pallet/impls.rs b/frame/staking/src/pallet/impls.rs index 2d9eede38142a..8d18dc14f4fbd 100644 --- a/frame/staking/src/pallet/impls.rs +++ b/frame/staking/src/pallet/impls.rs @@ -749,8 +749,7 @@ impl Pallet { /// /// This function is self-weighing as [`DispatchClass::Mandatory`]. pub fn get_npos_voters(voter_bounds: ElectionBounds) -> Vec> { - let mut voters_size_tracker: ElectionSizeTracker = - ElectionSizeTracker::new(voter_bounds.size.map_or(None, |s| Some(s as usize))); + let mut voters_size_tracker: ElectionSizeTracker = ElectionSizeTracker::new(); let max_allowed_len = { let all_voter_count = T::VoterList::count(); @@ -780,6 +779,7 @@ impl Pallet { }; if let Some(Nominations { targets, .. }) = >::get(&voter) { + // if this voter is a nominator: let voter_weight = weight_of(&voter); let nominations_quota = T::NominationsQuota::get_quota_capped(voter_weight.into()); if !targets.is_empty() { @@ -787,23 +787,20 @@ impl Pallet { .try_register_voter(nominations_quota as usize, voter_bounds) .is_err() { - // no more space left for the election result, stop iterating over the - // voters. + // no more space left for the election result, stop iterating. break } - all_voters.push((voter.clone(), voter_weight, targets)); nominators_taken.saturating_inc(); } else { // Technically should never happen, but not much we can do about it. } - min_active_stake = if voter_weight < min_active_stake { voter_weight } else { min_active_stake }; } else if Validators::::contains_key(&voter) { // if this voter is a validator: if voters_size_tracker.try_register_voter(1, voter_bounds).is_err() { - // no more space left for the election result, stop iterating over the voters. + // no more space left for the election result, stop iterating over. break } let self_vote = ( @@ -1001,6 +998,14 @@ impl ElectionDataProvider for Pallet { fn electing_voters(bounds: ElectionBounds) -> data_provider::Result>> { // This can never fail -- if `maybe_max_len` is `Some(_)` we handle it. let voters = Self::get_npos_voters(bounds); + println!("===="); + println!("{:?}", bounds); + println!("{:?}", voters); + println!( + "{:?}", + bounds.exhausted(Some(voters.len() as u32), Some(voters.encoded_size() as u32)) + ); + debug_assert!( !bounds.exhausted(Some(voters.len() as u32), Some(voters.encoded_size() as u32)) ); diff --git a/frame/staking/src/pallet/mod.rs b/frame/staking/src/pallet/mod.rs index 270190b4bf7ee..724015d33264e 100644 --- a/frame/staking/src/pallet/mod.rs +++ b/frame/staking/src/pallet/mod.rs @@ -44,10 +44,10 @@ mod impls; pub use impls::*; use crate::{ - slashing, weights::WeightInfo, AccountIdLookupOf, ActiveEraInfo, BalanceOf, EraPayout, - EraRewardPoints, Exposure, Forcing, NegativeImbalanceOf, Nominations, NominationsQuota, - PositiveImbalanceOf, Releases, RewardDestination, SessionInterface, StakingLedger, - UnappliedSlash, UnlockChunk, ValidatorPrefs, + slashing, weights::WeightInfo, AbsoluteMaxNominationsOf, AccountIdLookupOf, ActiveEraInfo, + BalanceOf, EraPayout, EraRewardPoints, Exposure, Forcing, NegativeImbalanceOf, Nominations, + NominationsQuota, PositiveImbalanceOf, Releases, RewardDestination, SessionInterface, + StakingLedger, UnappliedSlash, UnlockChunk, ValidatorPrefs, }; const STAKING_ID: LockIdentifier = *b"staking "; @@ -129,8 +129,7 @@ pub mod pallet { /// Something that defines the maximum number of nominations per nominator. type NominationsQuota: NominationsQuota>; - /// Maximum number of nominations per nominator, regardless of the - /// `Config::NominationsQuota` Number of eras to keep in history. + /// Number of eras to keep in history. /// /// Following information is kept for eras in `[current_era - /// HistoryDepth, current_era]`: `ErasStakers`, `ErasStakersClipped`, @@ -267,6 +266,15 @@ pub mod pallet { type WeightInfo: WeightInfo; } + /// Maximum limit of nominations per nominator, regardless of `T::NominationsQuota`. + #[pallet::extra_constants] + impl Pallet { + #[pallet::constant_name(AbsoluteMaxNominations)] + fn absolute_max_nominations() -> u32 { + >>::AbsoluteMaxNominations::get() + } + } + /// The ideal number of active validators. #[pallet::storage] #[pallet::getter(fn validator_count)] @@ -335,7 +343,8 @@ pub mod pallet { /// they wish to support. /// /// Note that the keys of this storage map might become non-decodable in case the - /// [`Config::MaxNominations`] configuration is decreased. In this rare case, these nominators + /// account's [`NominationsQuota::ABSOLUTE_MAX_NOMINATIONS`] configuration is decreased. + /// In this rare case, these nominators /// are still existent in storage, their key is correct and retrievable (i.e. `contains_key` /// indicates that they exist), but their value cannot be decoded. Therefore, the non-decodable /// nominators will effectively not-exist, until they re-submit their preferences such that it @@ -792,11 +801,11 @@ pub mod pallet { fn integrity_test() { // ensure that we funnel the correct value to the `DataProvider::MaxVotesPerVoter`; assert_eq!( - T::NominationsQuota::get(), + AbsoluteMaxNominationsOf::::get(), ::MaxVotesPerVoter::get() ); // and that MaxNominations is always greater than 1, since we count on this. - assert!(!T::NominationsQuota::get().is_zero()); + assert!(!AbsoluteMaxNominationsOf::::get().is_zero()); // ensure election results are always bounded with the same value assert!( @@ -1159,8 +1168,7 @@ pub mod pallet { ensure!(!targets.is_empty(), Error::::EmptyTargets); ensure!( - // TODO(gpestana): this is the absolute max nomination, make it more explicit - targets.len() <= T::NominationsQuota::get() as usize, + targets.len() <= AbsoluteMaxNominationsOf::::get() as usize, Error::::TooManyTargets ); diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index 28ea7187b205e..955f94c5f4de7 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -4541,7 +4541,7 @@ mod election_data_provider { } #[test] - fn respects_snapshot_len_limits() { + fn respects_snapshot_count_limits() { ExtBuilder::default() .set_status(41, StakerStatus::Validator) .build_and_execute(|| { @@ -4550,17 +4550,20 @@ mod election_data_provider { let bounds_builder = ElectionBoundsBuilder::new(); + println!("-- 0"); // if limits is less.. assert_eq!( Staking::electing_voters(bounds_builder.count(Some(1)).build()).unwrap().len(), 1 ); + println!("-- 1"); // if limit is equal.. assert_eq!( Staking::electing_voters(bounds_builder.count(Some(5)).build()).unwrap().len(), 5 ); + println!("2"); // if limit is more. assert_eq!( @@ -4568,6 +4571,7 @@ mod election_data_provider { 5 ); + println!("3"); // if target limit is more.. assert_eq!( Staking::electable_targets(bounds_builder.count(Some(6)).build()) @@ -4624,7 +4628,8 @@ mod election_data_provider { vec![61, 71, 81, 11, 21, 31] ); - MaxNominations::set(2); + // TODO(gpestana): change this test, no more MaxNominations::set + //MaxNominations::set(2); // we want 2 voters now, and in maximum we allow 4 iterations. This is what happens: // 61 is pruned; @@ -5081,15 +5086,17 @@ fn min_commission_works() { } #[test] -fn change_of_max_nominations() { +fn nomination_quota_max_changes_decoding() { use frame_election_provider_support::ElectionDataProvider; ExtBuilder::default() .add_staker(60, 61, 10, StakerStatus::Nominator(vec![1])) .add_staker(70, 71, 10, StakerStatus::Nominator(vec![1, 2, 3])) + .add_staker(30, 330, 10, StakerStatus::Nominator(vec![1, 2, 3, 4])) + .add_staker(50, 550, 10, StakerStatus::Nominator(vec![1, 2, 3, 4])) .balance_factor(10) .build_and_execute(|| { // pre-condition - assert_eq!(MaxNominations::get(), 16); + assert_eq!(AbsoluteMaxNominationsOf::::get(), 16); let unbonded_election = ElectionBounds::new_unbounded(); @@ -5097,83 +5104,15 @@ fn change_of_max_nominations() { Nominators::::iter() .map(|(k, n)| (k, n.targets.len())) .collect::>(), - vec![(70, 3), (101, 2), (60, 1)] + vec![(70, 3), (101, 2), (50, 4), (30, 4), (60, 1)] ); - // 3 validators and 3 nominators - assert_eq!(Staking::electing_voters(unbonded_election).unwrap().len(), 3 + 3); + // 4 validators and 4 nominators + assert_eq!(Staking::electing_voters(unbonded_election).unwrap().len(), 4 + 4); - // abrupt change from 16 to 4, everyone should be fine. - MaxNominations::set(4); - - assert_eq!( - Nominators::::iter() - .map(|(k, n)| (k, n.targets.len())) - .collect::>(), - vec![(70, 3), (101, 2), (60, 1)] - ); - assert_eq!(Staking::electing_voters(unbonded_election).unwrap().len(), 3 + 3); - - // abrupt change from 4 to 3, everyone should be fine. - MaxNominations::set(3); - - assert_eq!( - Nominators::::iter() - .map(|(k, n)| (k, n.targets.len())) - .collect::>(), - vec![(70, 3), (101, 2), (60, 1)] - ); - assert_eq!(Staking::electing_voters(unbonded_election).unwrap().len(), 3 + 3); - - // abrupt change from 3 to 2, this should cause some nominators to be non-decodable, and - // thus non-existent unless if they update. - MaxNominations::set(2); - - assert_eq!( - Nominators::::iter() - .map(|(k, n)| (k, n.targets.len())) - .collect::>(), - vec![(101, 2), (60, 1)] - ); - // 70 is still in storage.. - assert!(Nominators::::contains_key(70)); - // but its value cannot be decoded and default is returned. - assert!(Nominators::::get(70).is_none()); - - assert_eq!(Staking::electing_voters(unbonded_election).unwrap().len(), 3 + 2); - assert!(Nominators::::contains_key(101)); - - // abrupt change from 2 to 1, this should cause some nominators to be non-decodable, and - // thus non-existent unless if they update. - MaxNominations::set(1); - - assert_eq!( - Nominators::::iter() - .map(|(k, n)| (k, n.targets.len())) - .collect::>(), - vec![(60, 1)] - ); - assert!(Nominators::::contains_key(70)); - assert!(Nominators::::contains_key(60)); - assert!(Nominators::::get(70).is_none()); - assert!(Nominators::::get(60).is_some()); - assert_eq!(Staking::electing_voters(unbonded_election).unwrap().len(), 3 + 1); - - // now one of them can revive themselves by re-nominating to a proper value. - assert_ok!(Staking::nominate(RuntimeOrigin::signed(71), vec![1])); - assert_eq!( - Nominators::::iter() - .map(|(k, n)| (k, n.targets.len())) - .collect::>(), - vec![(70, 1), (60, 1)] - ); - - // or they can be chilled by any account. - assert!(Nominators::::contains_key(101)); - assert!(Nominators::::get(101).is_none()); - assert_ok!(Staking::chill_other(RuntimeOrigin::signed(70), 100)); - assert!(!Nominators::::contains_key(101)); - assert!(Nominators::::get(101).is_none()); - }) + // TODO(gpestana): test decoding error when Nominations_quota::ABSOLUTE_MAX_NOMINATIONS + // decreases and test the chilling in those cases too (see old test and [`Nominators`] + // comments) + }); } mod sorted_list_provider { From 1c347f9ce779799273326ffb748a74b7fbee1dad Mon Sep 17 00:00:00 2001 From: gpestana Date: Mon, 26 Dec 2022 14:49:36 +0000 Subject: [PATCH 08/80] Truncates nomninations that exceed nominations quota; Old tests passing --- frame/election-provider-support/src/lib.rs | 1 - frame/staking/src/lib.rs | 15 ++--- frame/staking/src/mock.rs | 8 +-- frame/staking/src/pallet/impls.rs | 37 +++++------ frame/staking/src/pallet/mod.rs | 21 +++++++ frame/staking/src/tests.rs | 73 +++++++++++----------- 6 files changed, 88 insertions(+), 67 deletions(-) diff --git a/frame/election-provider-support/src/lib.rs b/frame/election-provider-support/src/lib.rs index 6888e420d383f..08931305c7d39 100644 --- a/frame/election-provider-support/src/lib.rs +++ b/frame/election-provider-support/src/lib.rs @@ -695,7 +695,6 @@ impl ElectionBounds { // Returns true if `given_count` exhausts `self.count`. pub fn count_exhausted(self, given_count: Option) -> bool { - println!("{:?} > {:?}?", given_count, self.count); self.count.map_or(false, |count| given_count.unwrap_or(0) > count) } diff --git a/frame/staking/src/lib.rs b/frame/staking/src/lib.rs index 5b2fd4af92f05..ffeeaa6b678ed 100644 --- a/frame/staking/src/lib.rs +++ b/frame/staking/src/lib.rs @@ -771,17 +771,18 @@ impl UnappliedSlash { pub trait NominationsQuota { const ABSOLUTE_MAX_NOMINATIONS: u32; + /// Maximum number of nominations. The method `get_quota` may return a larger number of + /// nominations than `ABSOLUTE_MAX_NOMINATIONS`. However, `get_quota_safe` returns the bounded + /// maximum number of nominations. type AbsoluteMaxNominations: Get; - fn get_quota_capped(balance: Balance) -> u32 { - let quota = Self::get_quota(balance); - if quota < Self::ABSOLUTE_MAX_NOMINATIONS { - quota - } else { - Self::ABSOLUTE_MAX_NOMINATIONS - } + /// Returns the voter's nomination quota within reasonable bounds [`min`, `max`], where `min` + /// is 1 and `max` is ABSOLUTE_MAX_NOMINATIONS. + fn get_quota_safe(balance: Balance) -> u32 { + Self::get_quota(balance).max(1).min(Self::ABSOLUTE_MAX_NOMINATIONS) } + // Returns the voter's nomination quota based on the quota implementation. fn get_quota(balance: Balance) -> u32; } diff --git a/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index f936a56605024..6d7baba2a0afc 100644 --- a/frame/staking/src/mock.rs +++ b/frame/staking/src/mock.rs @@ -305,7 +305,6 @@ impl crate::pallet::pallet::Config for Test { type VoterList = VoterBagsList; type TargetList = UseValidatorsMap; type NominationsQuota = WeightedNominationsQuota<16>; - //type NominationsQuota = FixedNominationsQuota<16>; type MaxUnlockingChunks = MaxUnlockingChunks; type HistoryDepth = HistoryDepth; type OnStakerSlash = OnStakerSlashMock; @@ -324,9 +323,10 @@ where fn get_quota(balance: Balance) -> u32 { match balance.into() { // random quota per balance for testing - 0..=300 => 16, - 301..=500 => 3, - 501..=600 => 1, + 0..=110 => MAX, + 111 => 0, + 222 => 2, + 333 => MAX + 10, _ => MAX, } } diff --git a/frame/staking/src/pallet/impls.rs b/frame/staking/src/pallet/impls.rs index 8d18dc14f4fbd..86d2d7faa26fb 100644 --- a/frame/staking/src/pallet/impls.rs +++ b/frame/staking/src/pallet/impls.rs @@ -767,9 +767,7 @@ impl Pallet { let mut min_active_stake = u64::MAX; let mut sorted_voters = T::VoterList::iter(); - while all_voters.len() < max_allowed_len as usize && - voters_seen < (NPOS_MAX_ITERATIONS_COEFFICIENT * max_allowed_len as u32) - { + while all_voters.len() < max_allowed_len as usize { let voter = match sorted_voters.next() { Some(voter) => { voters_seen.saturating_inc(); @@ -778,22 +776,32 @@ impl Pallet { None => break, }; - if let Some(Nominations { targets, .. }) = >::get(&voter) { + if let Some(Nominations { mut targets, .. }) = >::get(&voter) { // if this voter is a nominator: let voter_weight = weight_of(&voter); - let nominations_quota = T::NominationsQuota::get_quota_capped(voter_weight.into()); if !targets.is_empty() { - if voters_size_tracker - .try_register_voter(nominations_quota as usize, voter_bounds) - .is_err() + // select only targets allowed by voter's nomination quota + let nominations_quota = + T::NominationsQuota::get_quota_safe(voter_weight.into()); + + if targets.len() > nominations_quota as usize { + Self::deposit_event(Event::::NominationsQuotaExceeded { + staker: voter.clone(), + exceeded_by: (targets.len() as u32 - nominations_quota).into(), + }); + } + + targets.truncate(nominations_quota as usize); + if voters_size_tracker.try_register_voter(targets.len(), voter_bounds).is_err() { // no more space left for the election result, stop iterating. break } + all_voters.push((voter.clone(), voter_weight, targets)); nominators_taken.saturating_inc(); } else { - // Technically should never happen, but not much we can do about it. + // technically should never happen, but not much we can do about it. } min_active_stake = if voter_weight < min_active_stake { voter_weight } else { min_active_stake }; @@ -998,16 +1006,9 @@ impl ElectionDataProvider for Pallet { fn electing_voters(bounds: ElectionBounds) -> data_provider::Result>> { // This can never fail -- if `maybe_max_len` is `Some(_)` we handle it. let voters = Self::get_npos_voters(bounds); - println!("===="); - println!("{:?}", bounds); - println!("{:?}", voters); - println!( - "{:?}", - bounds.exhausted(Some(voters.len() as u32), Some(voters.encoded_size() as u32)) - ); debug_assert!( - !bounds.exhausted(Some(voters.len() as u32), Some(voters.encoded_size() as u32)) + !bounds.exhausted(Some(voters.encoded_size() as u32), Some(voters.len() as u32)) ); Ok(voters) @@ -1017,7 +1018,7 @@ impl ElectionDataProvider for Pallet { let target_count = T::TargetList::count(); // We can't handle this case yet -- return an error. - if bounds.exhausted(Some(target_count as u32), None) { + if bounds.exhausted(None, Some(target_count as u32)) { return Err("Target snapshot too big") } diff --git a/frame/staking/src/pallet/mod.rs b/frame/staking/src/pallet/mod.rs index 724015d33264e..830e40ba6ee99 100644 --- a/frame/staking/src/pallet/mod.rs +++ b/frame/staking/src/pallet/mod.rs @@ -717,6 +717,10 @@ pub mod pallet { PayoutStarted { era_index: EraIndex, validator_stash: T::AccountId }, /// A validator has set their preferences. ValidatorPrefsSet { stash: T::AccountId, prefs: ValidatorPrefs }, + /// The number of nominations has exceeded the allowed by the voter's nomination quota. + NominationsQuotaExceeded { staker: T::AccountId, exceeded_by: BalanceOf }, + /// Encapsulates the nomination quota for a given balance. + NominationsQuotaForBalance { balance: BalanceOf, nominations_quota: u32 }, } #[pallet::error] @@ -1803,6 +1807,23 @@ pub mod pallet { })?; Ok(()) } + + /// Emits an event with the nominations quota for a given balance. + #[pallet::call_index(25)] + #[pallet::weight(1)] // TODO(gpestana): finish + pub fn nominations_quota( + origin: OriginFor, + #[pallet::compact] balance: BalanceOf, + ) -> DispatchResult { + ensure_signed(origin)?; + + Self::deposit_event(Event::::NominationsQuotaForBalance { + balance, + nominations_quota: + >>::get_quota_safe(balance), + }); + Ok(()) + } } } diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index 955f94c5f4de7..a63f12f5b517a 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -4550,20 +4550,17 @@ mod election_data_provider { let bounds_builder = ElectionBoundsBuilder::new(); - println!("-- 0"); // if limits is less.. assert_eq!( Staking::electing_voters(bounds_builder.count(Some(1)).build()).unwrap().len(), 1 ); - println!("-- 1"); // if limit is equal.. assert_eq!( Staking::electing_voters(bounds_builder.count(Some(5)).build()).unwrap().len(), 5 ); - println!("2"); // if limit is more. assert_eq!( @@ -4571,7 +4568,6 @@ mod election_data_provider { 5 ); - println!("3"); // if target limit is more.. assert_eq!( Staking::electable_targets(bounds_builder.count(Some(6)).build()) @@ -4594,57 +4590,60 @@ mod election_data_provider { }); } - // Tests the criteria that in `ElectionDataProvider::voters` function, we try to get at most - // `maybe_max_len` voters, and if some of them end up being skipped, we iterate at most `2 * - // maybe_max_len`. #[test] - fn only_iterates_max_2_times_max_allowed_len() { + fn nominations_quota_truncates() { ExtBuilder::default() .nominate(false) - // the best way to invalidate a bunch of nominators is to have them nominate a lot of - // ppl, but then lower the MaxNomination limit. .add_staker( 61, 60, - 2_000, + 222, // voters with balance == 222 have nomination quota of 2 nominations. StakerStatus::::Nominator(vec![21, 22, 23, 24, 25]), ) + .build_and_execute(|| { + assert_eq!( + Staking::electing_voters(ElectionBounds::new_unbounded()) + .unwrap() + .iter() + .map(|(stash, _, targets)| (*stash, targets.len())) + .collect::>(), + vec![(11, 1), (21, 1), (31, 1), (61, 2)], + ); + assert_eq!( + *staking_events().last().unwrap(), + Event::NominationsQuotaExceeded { staker: 61, exceeded_by: 3 } + ); + }); + } + + #[test] + fn nominations_quota_limits() { + ExtBuilder::default() + .nominate(false) .add_staker( - 71, - 70, - 2_000, + 61, + 60, + 111, /* voters with balance == 111 have nomination quota of 0 nominations, + * should be rounded to 1. */ StakerStatus::::Nominator(vec![21, 22, 23, 24, 25]), ) .add_staker( - 81, - 80, - 2_000, - StakerStatus::::Nominator(vec![21, 22, 23, 24, 25]), + 71, + 70, + 333, /* voters with balance == 333 have nomination quota of MAX + 10 + * nominations, should be rounded to MAX. */ + StakerStatus::::Nominator(vec![ + 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, + ]), ) .build_and_execute(|| { - // all voters ordered by stake, - assert_eq!( - ::VoterList::iter().collect::>(), - vec![61, 71, 81, 11, 21, 31] - ); - - // TODO(gpestana): change this test, no more MaxNominations::set - //MaxNominations::set(2); - - // we want 2 voters now, and in maximum we allow 4 iterations. This is what happens: - // 61 is pruned; - // 71 is pruned; - // 81 is pruned; - // 11 is taken; - // we finish since the 2x limit is reached. assert_eq!( - Staking::electing_voters(ElectionBoundsBuilder::new().count(Some(2)).build()) + Staking::electing_voters(ElectionBounds::new_unbounded()) .unwrap() .iter() - .map(|(stash, _, _)| stash) - .copied() + .map(|(stash, _, targets)| (*stash, targets.len())) .collect::>(), - vec![11], + vec![(11, 1), (21, 1), (31, 1), (61, 1), (71, 16)], ); }); } From 9bf66c3ee4bc7c976df53a6f2dedb1bd4245a28c Mon Sep 17 00:00:00 2001 From: gpestana Date: Tue, 27 Dec 2022 01:16:11 +0000 Subject: [PATCH 09/80] Uses DataProviderBounds and ElectionBounds (to continue) --- .../election-provider-multi-phase/src/lib.rs | 41 ++--- .../election-provider-multi-phase/src/mock.rs | 19 +- frame/election-provider-support/src/lib.rs | 162 +++++++++++++----- .../election-provider-support/src/onchain.rs | 56 +++--- frame/staking/src/mock.rs | 10 +- frame/staking/src/pallet/impls.rs | 12 +- 6 files changed, 186 insertions(+), 114 deletions(-) diff --git a/frame/election-provider-multi-phase/src/lib.rs b/frame/election-provider-multi-phase/src/lib.rs index 0550c8ded4f28..a338ba517f6c4 100644 --- a/frame/election-provider-multi-phase/src/lib.rs +++ b/frame/election-provider-multi-phase/src/lib.rs @@ -671,13 +671,7 @@ pub mod pallet { #[pallet::constant] type MaxWinners: Get; - // The limits of targets to include in the snapshot per block. - #[pallet::constant] - type TargetsBounds: Get; - - // The limits of voters to include in the snapshot per block. - #[pallet::constant] - type VotersBounds: Get; + type ElectionBounds: Get; /// Handler for the slashed deposits. type SlashHandler: OnUnbalanced>; @@ -1086,13 +1080,18 @@ pub mod pallet { ) -> DispatchResult { T::ForceOrigin::ensure_origin(origin)?; ensure!(Self::current_phase().is_emergency(), >::CallNotAllowed); - let voters_bounds = ElectionBoundsBuilder::new().count(maybe_max_voters).build(); - let targets_bounds = ElectionBoundsBuilder::new().count(maybe_max_voters).build(); - let supports = T::GovernanceFallback::instant_elect(voters_bounds, targets_bounds) - .map_err(|e| { - log!(error, "GovernanceFallback failed: {:?}", e); - Error::::FallbackFailed - })?; + let election_bounds = ElectionBoundsBuilder::new() + .voters_count(maybe_max_voters) + .targets_count(maybe_max_targets) + .build(); + let supports = T::GovernanceFallback::instant_elect( + election_bounds.voters, + election_bounds.targets, + ) + .map_err(|e| { + log!(error, "GovernanceFallback failed: {:?}", e); + Error::::FallbackFailed + })?; // transform BoundedVec<_, T::GovernanceFallback::MaxWinners> into // `BoundedVec<_, T::MaxWinners>` @@ -1408,18 +1407,16 @@ impl Pallet { /// Extracted for easier weight calculation. fn create_snapshot_external( ) -> Result<(Vec, Vec>, u32), ElectionError> { - // TODO: do we need T::MaxElect* limits now or can we rely on T::*Bounds? let target_limit = T::MaxElectableTargets::get().saturated_into::(); let voter_limit = T::MaxElectingVoters::get().saturated_into::(); - let targets_bounds = T::TargetsBounds::get(); - let voters_bounds = T::VotersBounds::get(); + let election_bounds = T::ElectionBounds::get(); - let targets = T::DataProvider::electable_targets(targets_bounds) + let targets = T::DataProvider::electable_targets(election_bounds.targets) .map_err(ElectionError::DataProvider)?; - let voters = - T::DataProvider::electing_voters(voters_bounds).map_err(ElectionError::DataProvider)?; + let voters = T::DataProvider::electing_voters(election_bounds.voters) + .map_err(ElectionError::DataProvider)?; if targets.len() > target_limit || voters.len() > voter_limit { return Err(ElectionError::DataProvider("Snapshot too big for submission.")) @@ -1601,8 +1598,8 @@ impl Pallet { .ok_or(ElectionError::::NothingQueued) .or_else(|_| { T::Fallback::instant_elect( - ElectionBounds::new_unbounded(), - ElectionBounds::new_unbounded(), + ElectionBoundsBuilder::new().build().voters, + ElectionBoundsBuilder::new().build().targets, ) .map_err(|fe| ElectionError::Fallback(fe)) .and_then(|supports| { diff --git a/frame/election-provider-multi-phase/src/mock.rs b/frame/election-provider-multi-phase/src/mock.rs index 74a966535fd0a..1486528e661b8 100644 --- a/frame/election-provider-multi-phase/src/mock.rs +++ b/frame/election-provider-multi-phase/src/mock.rs @@ -20,7 +20,7 @@ use crate::{self as multi_phase, unsigned::MinerConfig}; use frame_election_provider_support::{ data_provider, onchain::{self}, - ElectionBounds, ElectionDataProvider, NposSolution, SequentialPhragmen, + DataProviderBounds, ElectionBounds, ElectionDataProvider, NposSolution, SequentialPhragmen, }; pub use frame_support::{assert_noop, assert_ok, pallet_prelude::GetDefault}; use frame_support::{ @@ -298,8 +298,7 @@ parameter_types! { pub static MaxElectingVoters: VoterIndex = u32::max_value(); pub static MaxElectableTargets: TargetIndex = TargetIndex::max_value(); pub static MaxWinners: u32 = 200; - pub static VotersBounds: ElectionBounds = ElectionBounds::new_unbounded(); - pub static TargetsBounds: ElectionBounds = ElectionBounds::new_unbounded(); + pub static ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::new().build(); pub static EpochLength: u64 = 30; pub static OnChainFallback: bool = true; @@ -312,8 +311,7 @@ impl onchain::Config for OnChainSeqPhragmen { type DataProvider = StakingMock; type WeightInfo = (); type MaxWinners = MaxWinners; - type VotersBounds = VotersBounds; - type TargetsBounds = TargetsBounds; + type ElectionBounds = ElectionsBounds; } pub struct MockFallback; @@ -327,8 +325,8 @@ impl ElectionProviderBase for MockFallback { impl InstantElectionProvider for MockFallback { fn instant_elect( - voters_bounds: ElectionBounds, - targets_bounds: ElectionBounds, + voters_bounds: DataProviderBounds, + targets_bounds: DataProviderBounds, ) -> Result, Self::Error> { if OnChainFallback::get() { onchain::OnChainExecution::::instant_elect( @@ -410,8 +408,7 @@ impl crate::Config for Runtime { type MaxWinners = MaxWinners; type MinerConfig = Self; type Solver = SequentialPhragmen, Balancing>; - type VotersBounds = VotersBounds; - type TargetsBounds = TargetsBounds; + type ElectionBounds = ElectionsBounds; } impl frame_system::offchain::SendTransactionTypes for Runtime @@ -439,7 +436,7 @@ impl ElectionDataProvider for StakingMock { type BlockNumber = u64; type MaxVotesPerVoter = MaxNominations; - fn electable_targets(bounds: ElectionBounds) -> data_provider::Result> { + fn electable_targets(bounds: DataProviderBounds) -> data_provider::Result> { let targets = Targets::get(); if !DataProviderAllowBadData::get() && @@ -451,7 +448,7 @@ impl ElectionDataProvider for StakingMock { Ok(targets) } - fn electing_voters(bounds: ElectionBounds) -> data_provider::Result>> { + fn electing_voters(bounds: DataProviderBounds) -> data_provider::Result>> { let mut voters = Voters::get(); if !DataProviderAllowBadData::get() { diff --git a/frame/election-provider-support/src/lib.rs b/frame/election-provider-support/src/lib.rs index 08931305c7d39..3926df90de807 100644 --- a/frame/election-provider-support/src/lib.rs +++ b/frame/election-provider-support/src/lib.rs @@ -109,12 +109,12 @@ //! fn desired_targets() -> data_provider::Result { //! Ok(1) //! } -//! fn electing_voters(maybe_max_len: Option) +//! fn electing_voters(bounds: DataProviderBounds) //! -> data_provider::Result>> //! { //! Ok(Default::default()) //! } -//! fn electable_targets(maybe_max_len: Option) -> data_provider::Result> { +//! fn electable_targets(bounds: DataProviderBounds) -> data_provider::Result> { //! Ok(vec![10, 20, 30]) //! } //! fn next_election_prediction(now: BlockNumber) -> BlockNumber { @@ -145,7 +145,7 @@ //! impl ElectionProvider for GenericElectionProvider { //! fn ongoing() -> bool { false } //! fn elect() -> Result, Self::Error> { -//! Self::DataProvider::electable_targets(None) +//! Self::DataProvider::electable_targets(DataProviderBounds::new_unbounded()) //! .map_err(|_| "failed to elect") //! .map(|t| bounded_vec![(t[0], Support::default())]) //! } @@ -288,7 +288,8 @@ pub trait ElectionDataProvider { /// /// This should be implemented as a self-weighing function. The implementor should register its /// appropriate weight at the end of execution with the system pallet directly. - fn electable_targets(bounds: ElectionBounds) -> data_provider::Result>; + fn electable_targets(bounds: DataProviderBounds) + -> data_provider::Result>; /// All the voters that participate in the election, thus "electing". /// @@ -299,7 +300,7 @@ pub trait ElectionDataProvider { /// /// This should be implemented as a self-weighing function. The implementor should register its /// appropriate weight at the end of execution with the system pallet directly. - fn electing_voters(bounds: ElectionBounds) -> data_provider::Result>>; + fn electing_voters(bounds: DataProviderBounds) -> data_provider::Result>>; /// The number of targets to elect. /// @@ -420,8 +421,8 @@ pub trait ElectionProvider: ElectionProviderBase { /// data provider at runtime via `forced_input_voters_bound` and `forced_input_target_bound`. pub trait InstantElectionProvider: ElectionProviderBase { fn instant_elect( - forced_input_voters_bound: ElectionBounds, - forced_input_target_bound: ElectionBounds, + forced_input_voters_bound: DataProviderBounds, + forced_input_target_bound: DataProviderBounds, ) -> Result, Self::Error>; } @@ -463,8 +464,8 @@ where MaxWinners: Get, { fn instant_elect( - _: ElectionBounds, - _: ElectionBounds, + _: DataProviderBounds, + _: DataProviderBounds, ) -> Result, Self::Error> { Err("`NoElection` cannot do anything.") } @@ -674,55 +675,49 @@ pub type BoundedSupportsOf = BoundedSupports< sp_core::generate_feature_enabled_macro!(runtime_benchmarks_enabled, feature = "runtime-benchmarks", $); sp_core::generate_feature_enabled_macro!(runtime_benchmarks_or_fuzz_enabled, any(feature = "runtime-benchmarks", feature = "fuzzing"), $); -/// The limits of an election result. The bounds are defined over the count of element of the -/// election (voters or targets) or the overall datastructure size. -/// -/// Ordering: when comparing two instances of `ElectionBounds`, the `count` has priority over the -/// `size`, ie. if `A.count > B.count`, then `A > B` regardless of their relative `size`. -#[derive(Clone, Copy, RuntimeDebug, scale_info::TypeInfo, Encode, Decode, Eq)] -pub struct ElectionBounds { - /// The bound on number of elements. `None` means unbounded. +#[derive(Clone, Copy, Eq, Default)] +pub struct DataProviderBounds { pub count: Option, - /// The bound on size, in bytes. `None` means unbounded. pub size: Option, } -impl ElectionBounds { - /// Returns a new instance of self without bounds. - pub const fn new_unbounded() -> Self { - ElectionBounds { count: None, size: None } +impl DataProviderBounds { + /// Unbonded data provider limit. + pub fn new_unbounded() -> Self { + DataProviderBounds { count: None, size: None } } - // Returns true if `given_count` exhausts `self.count`. + /// Returns true if `given_count` exhausts `self.count`. pub fn count_exhausted(self, given_count: Option) -> bool { self.count.map_or(false, |count| given_count.unwrap_or(0) > count) } - // Returns true if `given_size` exhausts `self.size`. + /// Returns true if `given_size` exhausts `self.size`. pub fn size_exhausted(self, given_size: Option) -> bool { - self.size.map_or(false, |count| given_size.unwrap_or(0) > count) + self.size.map_or(false, |size| given_size.unwrap_or(0) > size) } - // Returns true if `given_size` or `given_count` exhausts `self.size` or `self_count` - // respectively. + /// Returns true if `given_size` or `given_count` exhausts `self.size` or `self_count` + /// respectively. pub fn exhausted(self, given_size: Option, given_count: Option) -> bool { self.count_exhausted(given_count) || self.size_exhausted(given_size) } } -impl PartialEq for ElectionBounds { +impl PartialEq for DataProviderBounds { fn eq(&self, other: &Self) -> bool { - self.count == other.count || self.size == self.size + self.count == other.count && self.size == self.size } } -impl PartialOrd for ElectionBounds { +impl PartialOrd for DataProviderBounds { fn partial_cmp(&self, other: &Self) -> Option { Some(self.cmp(other)) } } -impl Ord for ElectionBounds { +// TODO(gpestana): is this correct? +impl Ord for DataProviderBounds { fn cmp(&self, other: &Self) -> std::cmp::Ordering { if self.count == other.count { self.size.cmp(&other.size) @@ -732,37 +727,122 @@ impl Ord for ElectionBounds { } } +/// The limits of an election result. The bounds are defined over the count of element of the +/// election (voters or targets) or the overall datastructure size. +/// +/// Ordering: when comparing two instances of `ElectionBounds`, the `count` has priority over the +/// `size`, ie. if `A.count > B.count`, then `A > B` regardless of their relative `size`. +#[derive(Eq, PartialEq, Ord, PartialOrd, Clone)] +pub struct ElectionBounds { + pub voters: DataProviderBounds, + pub targets: DataProviderBounds, +} + /// Utility builder for [`ElectionBounds`]. /// /// The main purpose of this is to prevent mixing the order of similarly typed arguments (e.g. u32 /// size and count). #[derive(Copy, Clone)] pub struct ElectionBoundsBuilder { - count: Option, - size: Option, + voters: Option, + targets: Option, } impl ElectionBoundsBuilder { /// Returns a new election bounds builder pub fn new() -> Self { - ElectionBoundsBuilder { count: None, size: None } + ElectionBoundsBuilder { voters: None, targets: None } } - /// Set the count of the snapshot. - pub fn count(mut self, count: Option) -> Self { - self.count = count; + /// Returns a new election bounds builder from an instance of `ElectionBounds`. + pub fn from(bounds: ElectionBounds) -> Self { + ElectionBoundsBuilder { voters: Some(bounds.voters), targets: Some(bounds.targets) } + } + + // Sets the voters count bounds. + pub fn voters_count(mut self, count: Option) -> Self { + self.voters = + self.voters + .map_or(Some(DataProviderBounds { count, size: None }), |mut bounds| { + bounds.count = count; + Some(bounds) + }); self } - /// Set the size of the snapshot. - pub fn size(mut self, size: Option) -> Self { - self.size = size; + // Sets the voters size bounds. + pub fn voters_size(mut self, size: Option) -> Self { + self.voters = + self.voters + .map_or(Some(DataProviderBounds { count: None, size }), |mut bounds| { + bounds.size = size; + Some(bounds) + }); + self + } + + // Sets the targets count bounds. + pub fn targets_count(mut self, count: Option) -> Self { + self.targets = + self.targets + .map_or(Some(DataProviderBounds { count, size: None }), |mut bounds| { + bounds.count = count; + Some(bounds) + }); + self + } + + // Sets the targets size bounds. + pub fn targets_size(mut self, size: Option) -> Self { + self.targets = + self.targets + .map_or(Some(DataProviderBounds { count: None, size }), |mut bounds| { + bounds.size = size; + Some(bounds) + }); + self + } + + /// Set the voters bounds. + pub fn voters(mut self, bounds: Option) -> Self { + self.voters = bounds; + self + } + + /// Set the targets bounds. + pub fn targets(mut self, bounds: Option) -> Self { + self.targets = bounds; + self + } + + /// Caps the maximum number of voters. + pub fn max_voters(mut self, voters: DataProviderBounds) -> Self { + self.voters = self.voters.map_or(None, |v| { + Some(DataProviderBounds { + count: v.count.max(voters.count), + size: v.size.max(voters.size), + }) + }); + self + } + + /// Caps the maximum number of targets. + pub fn max_targets(mut self, targets: DataProviderBounds) -> Self { + self.targets = self.targets.map_or(None, |t| { + Some(DataProviderBounds { + count: t.count.max(targets.count), + size: t.size.max(targets.size), + }) + }); self } /// Returns an instance of `ElectionBounds` from the current state. pub fn build(self) -> ElectionBounds { - ElectionBounds { count: self.count, size: self.size } + ElectionBounds { + voters: self.voters.unwrap_or_default(), + targets: self.targets.unwrap_or_default(), + } } } diff --git a/frame/election-provider-support/src/onchain.rs b/frame/election-provider-support/src/onchain.rs index b0cbfc8d05a25..aa8e03890d4b5 100644 --- a/frame/election-provider-support/src/onchain.rs +++ b/frame/election-provider-support/src/onchain.rs @@ -20,8 +20,9 @@ //! careful when using it onchain. use crate::{ - BoundedSupportsOf, Debug, ElectionBounds, ElectionDataProvider, ElectionProvider, - ElectionProviderBase, InstantElectionProvider, NposSolver, WeightInfo, + BoundedSupportsOf, DataProviderBounds, Debug, ElectionBounds, ElectionBoundsBuilder, + ElectionDataProvider, ElectionProvider, ElectionProviderBase, InstantElectionProvider, + NposSolver, WeightInfo, }; use frame_support::{dispatch::DispatchClass, traits::Get}; use sp_npos_elections::{ @@ -52,8 +53,8 @@ impl From for Error { /// This implements both `ElectionProvider` and `InstantElectionProvider`. /// /// This type has some utilities to make it safe. Nonetheless, it should be used with utmost care. A -/// thoughtful value must be set as [`Config::VotersBound`] and [`Config::TargetsBound`] to ensure -/// the size of the input is sensible. +/// thoughtful value must be set as [`Config::ElectionBounds`] to ensure the size of the input is +/// sensible. pub struct OnChainExecution(PhantomData); #[deprecated(note = "use OnChainExecution, which is bounded by default")] @@ -85,13 +86,9 @@ pub trait Config { /// always be more than `DataProvider::desired_target`. type MaxWinners: Get; - /// Bounds the number of voters, when calling into [`Config::DataProvider`]. It might be - /// overwritten in the `InstantElectionProvider` impl. - type VotersBounds: Get; - - /// Bounds the number of targets, when calling into [`Config::DataProvider`]. It might be - /// overwritten in the `InstantElectionProvider` impl. - type TargetsBounds: Get; + /// Elections bounds, to use when calling into + /// [`Config::DataProvider`]. It might be overwritten in the `InstantElectionProvider` impl. + type ElectionBounds: Get; } /// Same as `BoundedSupportsOf` but for `onchain::Config`. @@ -101,11 +98,11 @@ pub type OnChainBoundedSupportsOf = BoundedSupports< >; fn elect_with_input_bounds( - voter_bounds: ElectionBounds, - target_bounds: ElectionBounds, + bounds: ElectionBounds, ) -> Result, Error> { - let voters = T::DataProvider::electing_voters(voter_bounds).map_err(Error::DataProvider)?; - let targets = T::DataProvider::electable_targets(target_bounds).map_err(Error::DataProvider)?; + let voters = T::DataProvider::electing_voters(bounds.voters).map_err(Error::DataProvider)?; + let targets = + T::DataProvider::electable_targets(bounds.targets).map_err(Error::DataProvider)?; let desired_targets = T::DataProvider::desired_targets().map_err(Error::DataProvider)?; if desired_targets > T::MaxWinners::get() { @@ -158,13 +155,14 @@ impl ElectionProviderBase for OnChainExecution { impl InstantElectionProvider for OnChainExecution { fn instant_elect( - voters_bounds: ElectionBounds, - targets_bounds: ElectionBounds, + voters_bounds: DataProviderBounds, + targets_bounds: DataProviderBounds, ) -> Result, Self::Error> { - elect_with_input_bounds::( - T::VotersBounds::get().min(voters_bounds), - T::TargetsBounds::get().min(targets_bounds), - ) + let elections_bounds = ElectionBoundsBuilder::from(T::ElectionBounds::get()) + .max_voters(voters_bounds) + .max_targets(targets_bounds) + .build(); + elect_with_input_bounds::(elections_bounds) } } @@ -174,7 +172,8 @@ impl ElectionProvider for OnChainExecution { } fn elect() -> Result, Self::Error> { - elect_with_input_bounds::(T::VotersBounds::get(), T::TargetsBounds::get()) + let election_bounds = ElectionBoundsBuilder::from(T::ElectionBounds::get()).build(); + elect_with_input_bounds::(election_bounds) } } @@ -182,7 +181,7 @@ impl ElectionProvider for OnChainExecution { mod tests { use super::*; use crate::{ElectionProvider, PhragMMS, SequentialPhragmen}; - use frame_support::{assert_noop, parameter_types, traits::ConstU32}; + use frame_support::{assert_noop, parameter_types}; use sp_npos_elections::Support; use sp_runtime::Perbill; type AccountId = u64; @@ -235,6 +234,7 @@ mod tests { parameter_types! { pub static MaxWinners: u32 = 10; pub static DesiredTargets: u32 = 2; + pub static ElectionBounds: crate::ElectionBounds = ElectionBoundsBuilder::new().voters_count(Some(600)).targets_count(Some(400)).build(); } impl Config for PhragmenParams { @@ -243,8 +243,7 @@ mod tests { type DataProvider = mock_data_provider::DataProvider; type WeightInfo = (); type MaxWinners = MaxWinners; - type VotersBound = ConstU32<600>; - type TargetsBound = ConstU32<400>; + type ElectionBounds = ElectionBounds; } impl Config for PhragMMSParams { @@ -253,8 +252,7 @@ mod tests { type DataProvider = mock_data_provider::DataProvider; type WeightInfo = (); type MaxWinners = MaxWinners; - type VotersBound = ConstU32<600>; - type TargetsBound = ConstU32<400>; + type ElectionBounds = ElectionBounds; } mod mock_data_provider { @@ -268,7 +266,7 @@ mod tests { type AccountId = AccountId; type BlockNumber = BlockNumber; type MaxVotesPerVoter = ConstU32<2>; - fn electing_voters(_: ElectionBounds) -> data_provider::Result>> { + fn electing_voters(_: DataProviderBounds) -> data_provider::Result>> { Ok(vec![ (1, 10, bounded_vec![10, 20]), (2, 20, bounded_vec![30, 20]), @@ -276,7 +274,7 @@ mod tests { ]) } - fn electable_targets(_: ElectionBounds) -> data_provider::Result> { + fn electable_targets(_: DataProviderBounds) -> data_provider::Result> { Ok(vec![10, 20, 30]) } diff --git a/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index 6d7baba2a0afc..9e364c2c69b0e 100644 --- a/frame/staking/src/mock.rs +++ b/frame/staking/src/mock.rs @@ -18,7 +18,9 @@ //! Test utilities use crate::{self as pallet_staking, *}; -use frame_election_provider_support::{onchain, ElectionBounds, SequentialPhragmen, VoteWeight}; +use frame_election_provider_support::{ + onchain, ElectionBounds, ElectionBoundsBuilder, SequentialPhragmen, VoteWeight, +}; use frame_support::{ assert_ok, parameter_types, traits::{ @@ -238,8 +240,7 @@ parameter_types! { pub static RewardOnUnbalanceWasCalled: bool = false; pub static LedgerSlashPerEra: (BalanceOf, BTreeMap>) = (Zero::zero(), BTreeMap::new()); pub static MaxWinners: u32 = 100; - pub static VotersBounds: ElectionBounds = ElectionBounds::new_unbounded(); - pub static TargetsBounds: ElectionBounds = ElectionBounds::new_unbounded(); + pub static ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::new().build(); } type VoterBagsListInstance = pallet_bags_list::Instance1; @@ -259,8 +260,7 @@ impl onchain::Config for OnChainSeqPhragmen { type DataProvider = Staking; type WeightInfo = (); type MaxWinners = MaxWinners; - type VotersBounds = VotersBounds; - type TargetsBounds = TargetsBounds; + type ElectionBounds = ElectionsBounds; } pub struct MockReward {} diff --git a/frame/staking/src/pallet/impls.rs b/frame/staking/src/pallet/impls.rs index 86d2d7faa26fb..a7e749bd733bd 100644 --- a/frame/staking/src/pallet/impls.rs +++ b/frame/staking/src/pallet/impls.rs @@ -18,8 +18,8 @@ //! Implementations for the Staking FRAME Pallet. use frame_election_provider_support::{ - data_provider, BoundedSupportsOf, ElectionBounds, ElectionDataProvider, ElectionProvider, - ScoreProvider, SortedListProvider, VoteWeight, VoterOf, + data_provider, BoundedSupportsOf, DataProviderBounds, ElectionBounds, ElectionDataProvider, + ElectionProvider, ScoreProvider, SortedListProvider, VoteWeight, VoterOf, }; use frame_support::{ dispatch::WithPostDispatchInfo, @@ -748,7 +748,7 @@ impl Pallet { /// nominators. /// /// This function is self-weighing as [`DispatchClass::Mandatory`]. - pub fn get_npos_voters(voter_bounds: ElectionBounds) -> Vec> { + pub fn get_npos_voters(voter_bounds: DataProviderBounds) -> Vec> { let mut voters_size_tracker: ElectionSizeTracker = ElectionSizeTracker::new(); let max_allowed_len = { @@ -858,7 +858,7 @@ impl Pallet { /// Get the targets for an upcoming npos election. /// /// This function is self-weighing as [`DispatchClass::Mandatory`]. - pub fn get_npos_targets(target_bounds: ElectionBounds) -> Vec { + pub fn get_npos_targets(target_bounds: DataProviderBounds) -> Vec { let max_allowed_len = { let all_target_count = T::TargetList::count(); target_bounds.count.unwrap_or(all_target_count).min(all_target_count) @@ -1003,7 +1003,7 @@ impl ElectionDataProvider for Pallet { Ok(Self::validator_count()) } - fn electing_voters(bounds: ElectionBounds) -> data_provider::Result>> { + fn electing_voters(bounds: DataProviderBounds) -> data_provider::Result>> { // This can never fail -- if `maybe_max_len` is `Some(_)` we handle it. let voters = Self::get_npos_voters(bounds); @@ -1014,7 +1014,7 @@ impl ElectionDataProvider for Pallet { Ok(voters) } - fn electable_targets(bounds: ElectionBounds) -> data_provider::Result> { + fn electable_targets(bounds: DataProviderBounds) -> data_provider::Result> { let target_count = T::TargetList::count(); // We can't handle this case yet -- return an error. From cdaeb7cdf8e0794404aa98c16fa22a0e375b8c77 Mon Sep 17 00:00:00 2001 From: gpestana Date: Tue, 27 Dec 2022 11:23:43 +0000 Subject: [PATCH 10/80] Finishes conversions - tests passing --- frame/staking/src/lib.rs | 4 ++-- frame/staking/src/tests.rs | 49 ++++++++++++++++++++++++-------------- 2 files changed, 33 insertions(+), 20 deletions(-) diff --git a/frame/staking/src/lib.rs b/frame/staking/src/lib.rs index ffeeaa6b678ed..a9896e016b1af 100644 --- a/frame/staking/src/lib.rs +++ b/frame/staking/src/lib.rs @@ -300,7 +300,7 @@ pub mod weights; mod pallet; use codec::{Decode, Encode, HasCompact, MaxEncodedLen}; -use frame_election_provider_support::{ElectionBounds, VoteWeight}; +use frame_election_provider_support::{DataProviderBounds, ElectionBounds, VoteWeight}; use frame_support::{ traits::{Currency, Defensive, Get}, weights::Weight, @@ -833,7 +833,7 @@ impl ElectionSizeTracker { pub(crate) fn try_register_voter( &mut self, votes: usize, - bounds: ElectionBounds, + bounds: DataProviderBounds, ) -> Result<(), ()> { let voter_size = Self::voter_size(votes); let size_after = self.size.saturating_add(voter_size); diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index a63f12f5b517a..fdc74d1b474fd 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -4506,14 +4506,14 @@ mod election_data_provider { .add_staker(81, 80, 50, StakerStatus::::Nominator(vec![21])) .build_and_execute(|| { assert_ok!(::electing_voters( - ElectionBounds::new_unbounded() + DataProviderBounds::new_unbounded() )); assert_eq!(MinimumActiveStake::::get(), 10); // remove staker with lower bond by limiting the number of voters and check // `MinimumActiveStake` again after electing voters. - let bounds = ElectionBoundsBuilder::new().count(Some(5)).build(); - assert_ok!(::electing_voters(bounds)); + let bounds = ElectionBoundsBuilder::new().voters_count(Some(5)).build(); + assert_ok!(::electing_voters(bounds.voters)); assert_eq!(MinimumActiveStake::::get(), 50); }); } @@ -4522,7 +4522,7 @@ mod election_data_provider { fn set_minimum_active_stake_zero_correct() { ExtBuilder::default().has_stakers(false).build_and_execute(|| { assert_ok!(::electing_voters( - ElectionBounds::new_unbounded() + DataProviderBounds::new_unbounded() )); assert_eq!(MinimumActiveStake::::get(), 0); }); @@ -4532,7 +4532,7 @@ mod election_data_provider { fn voters_include_self_vote() { ExtBuilder::default().nominate(false).build_and_execute(|| { assert!(>::iter().map(|(x, _)| x).all(|v| Staking::electing_voters( - ElectionBounds::new_unbounded() + DataProviderBounds::new_unbounded() ) .unwrap() .into_iter() @@ -4552,39 +4552,52 @@ mod election_data_provider { // if limits is less.. assert_eq!( - Staking::electing_voters(bounds_builder.count(Some(1)).build()).unwrap().len(), + Staking::electing_voters(bounds_builder.voters_count(Some(1)).build().voters) + .unwrap() + .len(), 1 ); // if limit is equal.. assert_eq!( - Staking::electing_voters(bounds_builder.count(Some(5)).build()).unwrap().len(), + Staking::electing_voters(bounds_builder.voters_count(Some(5)).build().voters) + .unwrap() + .len(), 5 ); // if limit is more. assert_eq!( - Staking::electing_voters(bounds_builder.count(Some(55)).build()).unwrap().len(), + Staking::electing_voters(bounds_builder.voters_count(Some(55)).build().voters) + .unwrap() + .len(), 5 ); // if target limit is more.. assert_eq!( - Staking::electable_targets(bounds_builder.count(Some(6)).build()) - .unwrap() - .len(), + Staking::electable_targets( + bounds_builder.targets_count(Some(6)).build().targets + ) + .unwrap() + .len(), 4 ); assert_eq!( - Staking::electable_targets(bounds_builder.count(Some(4)).build()) - .unwrap() - .len(), + Staking::electable_targets( + bounds_builder.targets_count(Some(4)).build().targets + ) + .unwrap() + .len(), 4 ); // if target limit is less, then we return an error. assert_eq!( - Staking::electable_targets(bounds_builder.count(Some(1)).build()).unwrap_err(), + Staking::electable_targets( + bounds_builder.targets_count(Some(1)).build().targets + ) + .unwrap_err(), "Target snapshot too big" ); }); @@ -4602,7 +4615,7 @@ mod election_data_provider { ) .build_and_execute(|| { assert_eq!( - Staking::electing_voters(ElectionBounds::new_unbounded()) + Staking::electing_voters(DataProviderBounds::new_unbounded()) .unwrap() .iter() .map(|(stash, _, targets)| (*stash, targets.len())) @@ -4638,7 +4651,7 @@ mod election_data_provider { ) .build_and_execute(|| { assert_eq!( - Staking::electing_voters(ElectionBounds::new_unbounded()) + Staking::electing_voters(DataProviderBounds::new_unbounded()) .unwrap() .iter() .map(|(stash, _, targets)| (*stash, targets.len())) @@ -5097,7 +5110,7 @@ fn nomination_quota_max_changes_decoding() { // pre-condition assert_eq!(AbsoluteMaxNominationsOf::::get(), 16); - let unbonded_election = ElectionBounds::new_unbounded(); + let unbonded_election = DataProviderBounds::new_unbounded(); assert_eq!( Nominators::::iter() From 4e38839e1df7c3cd0ab9a3e27e146a7578b81a16 Mon Sep 17 00:00:00 2001 From: gpestana Date: Tue, 27 Dec 2022 11:43:06 +0000 Subject: [PATCH 11/80] Refactor staking in babe mocks --- frame/babe/src/mock.rs | 9 +++++---- frame/staking/src/lib.rs | 2 +- frame/staking/src/pallet/impls.rs | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/frame/babe/src/mock.rs b/frame/babe/src/mock.rs index 855bd873a3f0d..49a9d10da8647 100644 --- a/frame/babe/src/mock.rs +++ b/frame/babe/src/mock.rs @@ -19,12 +19,13 @@ use crate::{self as pallet_babe, Config, CurrentSlot}; use codec::Encode; -use frame_election_provider_support::{onchain, SequentialPhragmen}; +use frame_election_provider_support::{onchain, SequentialPhragmen, ElectionBoundsBuilder, ElectionBounds}; use frame_support::{ parameter_types, traits::{ConstU128, ConstU32, ConstU64, GenesisBuild, KeyOwnerProofSystem, OnInitialize}, }; use pallet_session::historical as pallet_session_historical; +use pallet_staking::FixedNominationsQuota; use sp_consensus_babe::{AuthorityId, AuthorityPair, Slot}; use sp_consensus_vrf::schnorrkel::{VRFOutput, VRFProof}; use sp_core::{ @@ -170,6 +171,7 @@ parameter_types! { pub const SlashDeferDuration: EraIndex = 0; pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE; pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(16); + pub static ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::new().build(); } pub struct OnChainSeqPhragmen; @@ -179,12 +181,10 @@ impl onchain::Config for OnChainSeqPhragmen { type DataProvider = Staking; type WeightInfo = (); type MaxWinners = ConstU32<100>; - type VotersBounds = ElectionBounds::new_unbounded(); - type TargetsBounds = ElectionBounds::new_unbounded(); + type ElectionBounds = ElectionsBounds; } impl pallet_staking::Config for Test { - type MaxNominations = ConstU32<16>; type RewardRemainder = (); type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote; type RuntimeEvent = RuntimeEvent; @@ -211,6 +211,7 @@ impl pallet_staking::Config for Test { type OnStakerSlash = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; type WeightInfo = (); + type NominationsQuota = FixedNominationsQuota<16>; } impl pallet_offences::Config for Test { diff --git a/frame/staking/src/lib.rs b/frame/staking/src/lib.rs index a9896e016b1af..fd504df668e11 100644 --- a/frame/staking/src/lib.rs +++ b/frame/staking/src/lib.rs @@ -300,7 +300,7 @@ pub mod weights; mod pallet; use codec::{Decode, Encode, HasCompact, MaxEncodedLen}; -use frame_election_provider_support::{DataProviderBounds, ElectionBounds, VoteWeight}; +use frame_election_provider_support::{DataProviderBounds, VoteWeight}; use frame_support::{ traits::{Currency, Defensive, Get}, weights::Weight, diff --git a/frame/staking/src/pallet/impls.rs b/frame/staking/src/pallet/impls.rs index a7e749bd733bd..c9f368f8cc90b 100644 --- a/frame/staking/src/pallet/impls.rs +++ b/frame/staking/src/pallet/impls.rs @@ -18,7 +18,7 @@ //! Implementations for the Staking FRAME Pallet. use frame_election_provider_support::{ - data_provider, BoundedSupportsOf, DataProviderBounds, ElectionBounds, ElectionDataProvider, + data_provider, BoundedSupportsOf, DataProviderBounds, ElectionDataProvider, ElectionProvider, ScoreProvider, SortedListProvider, VoteWeight, VoterOf, }; use frame_support::{ From 11bd646a975446dbd55cb0af5c1d66f42260c678 Mon Sep 17 00:00:00 2001 From: gpestana Date: Tue, 27 Dec 2022 20:27:30 +0000 Subject: [PATCH 12/80] Replaces MaxElectableTargets and MaxElectingVoters with ElectionBounds; Adds more tests --- bin/node/runtime/src/lib.rs | 15 ++--- .../election-provider-multi-phase/src/lib.rs | 34 +++++----- .../election-provider-multi-phase/src/mock.rs | 7 +- .../src/signed.rs | 6 +- frame/election-provider-support/src/lib.rs | 27 ++++---- .../election-provider-support/src/onchain.rs | 4 +- frame/election-provider-support/src/tests.rs | 55 +++++++++++++++ frame/staking/src/lib.rs | 2 +- frame/staking/src/pallet/impls.rs | 17 +++-- frame/staking/src/pallet/mod.rs | 2 + frame/staking/src/tests.rs | 67 ++++++++++++++++++- 11 files changed, 180 insertions(+), 56 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 0e3bee8821fc2..84f4c61e24199 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -24,7 +24,8 @@ use codec::{Decode, Encode, MaxEncodedLen}; use frame_election_provider_support::{ - onchain, BalancingConfig, ElectionDataProvider, SequentialPhragmen, VoteWeight, + onchain, BalancingConfig, ElectionBounds, ElectionBoundsBuilder, ElectionDataProvider, + SequentialPhragmen, VoteWeight, }; use frame_support::{ construct_runtime, @@ -632,12 +633,10 @@ frame_election_provider_support::generate_solution_type!( ); parameter_types! { + pub ElectionBounds: ElectionBounds = ElectionBoundsBuilder::new().voters_count(40_000).targets_count(10_000.into()).build(); pub MaxNominations: u32 = ::LIMIT as u32; - pub MaxElectingVoters: u32 = 40_000; - pub MaxElectableTargets: u16 = 10_000; // OnChain values are lower. - pub MaxOnChainElectingVoters: u32 = 5000; - pub MaxOnChainElectableTargets: u16 = 1250; + pub ElectionBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::new().voters_count(5_000).targets_count(1_250.into()).build(); // The maximum winners that can be elected by the Election pallet which is equivalent to the // maximum active validators the staking pallet can have. pub MaxActiveValidators: u32 = 1000; @@ -692,8 +691,7 @@ impl onchain::Config for OnChainSeqPhragmen { type DataProvider = ::DataProvider; type WeightInfo = frame_election_provider_support::weights::SubstrateWeight; type MaxWinners = ::MaxWinners; - type VotersBound = MaxOnChainElectingVoters; - type TargetsBound = MaxOnChainElectableTargets; + type ElectionBounds = ElectionBoundsOnChain; } impl pallet_election_provider_multi_phase::MinerConfig for Runtime { @@ -740,9 +738,8 @@ impl pallet_election_provider_multi_phase::Config for Runtime { type GovernanceFallback = onchain::OnChainExecution; type Solver = SequentialPhragmen, OffchainRandomBalancing>; type ForceOrigin = EnsureRootOrHalfCouncil; - type MaxElectableTargets = MaxElectableTargets; type MaxWinners = MaxActiveValidators; - type MaxElectingVoters = MaxElectingVoters; + type ElectionBounds = ElectionBounds; type BenchmarkingConfig = ElectionProviderBenchmarkConfig; type WeightInfo = pallet_election_provider_multi_phase::weights::SubstrateWeight; } diff --git a/frame/election-provider-multi-phase/src/lib.rs b/frame/election-provider-multi-phase/src/lib.rs index a338ba517f6c4..13c8e79a9b1e7 100644 --- a/frame/election-provider-multi-phase/src/lib.rs +++ b/frame/election-provider-multi-phase/src/lib.rs @@ -654,16 +654,6 @@ pub mod pallet { #[pallet::constant] type SignedDepositWeight: Get>; - /// The maximum number of electing voters to put in the snapshot. At the moment, snapshots - /// are only over a single block, but once multi-block elections are introduced they will - /// take place over multiple blocks. - #[pallet::constant] - type MaxElectingVoters: Get>; - - /// The maximum number of electable targets to put in the snapshot. - #[pallet::constant] - type MaxElectableTargets: Get>; - /// The maximum number of winners that can be elected by this `ElectionProvider` /// implementation. /// @@ -671,6 +661,10 @@ pub mod pallet { #[pallet::constant] type MaxWinners: Get; + /// The maximum number of electing voters and electable targets to put in the snapshot. + /// At the moment, snapshots + /// are only over a single block, but once multi-block elections are introduced they will + /// take place over multiple blocks. type ElectionBounds: Get; /// Handler for the slashed deposits. @@ -1407,10 +1401,11 @@ impl Pallet { /// Extracted for easier weight calculation. fn create_snapshot_external( ) -> Result<(Vec, Vec>, u32), ElectionError> { - let target_limit = T::MaxElectableTargets::get().saturated_into::(); - let voter_limit = T::MaxElectingVoters::get().saturated_into::(); - let election_bounds = T::ElectionBounds::get(); + let target_limit = + election_bounds.targets.count.unwrap_or(u32::MAX).saturated_into::(); + let voter_limit = + election_bounds.voters.count.unwrap_or(u32::MAX).saturated_into::(); let targets = T::DataProvider::electable_targets(election_bounds.targets) .map_err(ElectionError::DataProvider)?; @@ -2370,6 +2365,10 @@ mod tests { fn snapshot_too_big_failure_onchain_fallback() { // the `MockStaking` is designed such that if it has too many targets, it simply fails. ExtBuilder::default().build_and_execute(|| { + // sets bounds on number of targets. + let new_bounds = ElectionBoundsBuilder::new().targets_count(1_000.into()).build(); + crate::mock::ElectionsBounds::set(new_bounds); + Targets::set((0..(TargetIndex::max_value() as AccountId) + 1).collect::>()); // Signed phase failed to open. @@ -2398,6 +2397,10 @@ mod tests { fn snapshot_too_big_failure_no_fallback() { // and if the backup mode is nothing, we go into the emergency mode.. ExtBuilder::default().onchain_fallback(false).build_and_execute(|| { + // sets bounds on number of targets. + let new_bounds = ElectionBoundsBuilder::new().targets_count(1_000.into()).build(); + crate::mock::ElectionsBounds::set(new_bounds); + crate::mock::Targets::set( (0..(TargetIndex::max_value() as AccountId) + 1).collect::>(), ); @@ -2426,7 +2429,8 @@ mod tests { // we have 8 voters in total. assert_eq!(crate::mock::Voters::get().len(), 8); // but we want to take 2. - crate::mock::MaxElectingVoters::set(2); + let new_bounds = ElectionBoundsBuilder::new().voters_count(2.into()).build(); + crate::mock::ElectionsBounds::set(new_bounds); // Signed phase opens just fine. roll_to_signed(); @@ -2437,7 +2441,7 @@ mod tests { SolutionOrSnapshotSize { voters: 2, targets: 4 } ); }) - } + } #[test] fn untrusted_score_verification_is_respected() { diff --git a/frame/election-provider-multi-phase/src/mock.rs b/frame/election-provider-multi-phase/src/mock.rs index 1486528e661b8..450b428522bd8 100644 --- a/frame/election-provider-multi-phase/src/mock.rs +++ b/frame/election-provider-multi-phase/src/mock.rs @@ -295,10 +295,9 @@ parameter_types! { pub static MinerMaxWeight: Weight = BlockWeights::get().max_block; pub static MinerMaxLength: u32 = 256; pub static MockWeightInfo: MockedWeightInfo = MockedWeightInfo::Real; - pub static MaxElectingVoters: VoterIndex = u32::max_value(); - pub static MaxElectableTargets: TargetIndex = TargetIndex::max_value(); pub static MaxWinners: u32 = 200; pub static ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::new().build(); + pub static ElectionsBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::new().build(); pub static EpochLength: u64 = 30; pub static OnChainFallback: bool = true; @@ -311,7 +310,7 @@ impl onchain::Config for OnChainSeqPhragmen { type DataProvider = StakingMock; type WeightInfo = (); type MaxWinners = MaxWinners; - type ElectionBounds = ElectionsBounds; + type ElectionBounds = ElectionsBoundsOnChain; } pub struct MockFallback; @@ -403,8 +402,6 @@ impl crate::Config for Runtime { type GovernanceFallback = frame_election_provider_support::onchain::OnChainExecution; type ForceOrigin = frame_system::EnsureRoot; - type MaxElectingVoters = MaxElectingVoters; - type MaxElectableTargets = MaxElectableTargets; type MaxWinners = MaxWinners; type MinerConfig = Self; type Solver = SequentialPhragmen, Balancing>; diff --git a/frame/election-provider-multi-phase/src/signed.rs b/frame/election-provider-multi-phase/src/signed.rs index 12d39e83b6c09..e90d33d97b8a4 100644 --- a/frame/election-provider-multi-phase/src/signed.rs +++ b/frame/election-provider-multi-phase/src/signed.rs @@ -561,7 +561,8 @@ mod tests { fn data_provider_should_respect_target_limits() { ExtBuilder::default().build_and_execute(|| { // given a reduced expectation of maximum electable targets - MaxElectableTargets::set(2); + let new_bounds = crate::ElectionBoundsBuilder::new().targets_count(2.into()).build(); + ElectionsBounds::set(new_bounds); // and a data provider that does not respect limits DataProviderAllowBadData::set(true); @@ -576,7 +577,8 @@ mod tests { fn data_provider_should_respect_voter_limits() { ExtBuilder::default().build_and_execute(|| { // given a reduced expectation of maximum electing voters - MaxElectingVoters::set(2); + let new_bounds = crate::ElectionBoundsBuilder::new().voters_count(2.into()).build(); + ElectionsBounds::set(new_bounds); // and a data provider that does not respect limits DataProviderAllowBadData::set(true); diff --git a/frame/election-provider-support/src/lib.rs b/frame/election-provider-support/src/lib.rs index 3926df90de807..d1e48669fee62 100644 --- a/frame/election-provider-support/src/lib.rs +++ b/frame/election-provider-support/src/lib.rs @@ -675,7 +675,7 @@ pub type BoundedSupportsOf = BoundedSupports< sp_core::generate_feature_enabled_macro!(runtime_benchmarks_enabled, feature = "runtime-benchmarks", $); sp_core::generate_feature_enabled_macro!(runtime_benchmarks_or_fuzz_enabled, any(feature = "runtime-benchmarks", feature = "fuzzing"), $); -#[derive(Clone, Copy, Eq, Default)] +#[derive(Clone, Copy, Eq, Default, Debug)] pub struct DataProviderBounds { pub count: Option, pub size: Option, @@ -732,7 +732,7 @@ impl Ord for DataProviderBounds { /// /// Ordering: when comparing two instances of `ElectionBounds`, the `count` has priority over the /// `size`, ie. if `A.count > B.count`, then `A > B` regardless of their relative `size`. -#[derive(Eq, PartialEq, Ord, PartialOrd, Clone)] +#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Debug)] pub struct ElectionBounds { pub voters: DataProviderBounds, pub targets: DataProviderBounds, @@ -815,23 +815,25 @@ impl ElectionBoundsBuilder { self } - /// Caps the maximum number of voters. - pub fn max_voters(mut self, voters: DataProviderBounds) -> Self { + /// Caps the maximum number of the voters bounds to `voters`. If `voters` bounds are less than + /// the current value, keeps it. + pub fn clamp_voters(mut self, voters: DataProviderBounds) -> Self { self.voters = self.voters.map_or(None, |v| { Some(DataProviderBounds { - count: v.count.max(voters.count), - size: v.size.max(voters.size), + count: v.count.map(|c| c.clamp(0, voters.count.unwrap_or(u32::MAX)).into()), + size: v.size.map(|c| c.clamp(0, voters.size.unwrap_or(u32::MAX)).into()), }) }); self } - /// Caps the maximum number of targets. - pub fn max_targets(mut self, targets: DataProviderBounds) -> Self { + /// Caps the maximum number of the targets to `targets`. If `targets` bounds are less than the + /// current value, keeps it. + pub fn clamp_targets(mut self, targets: DataProviderBounds) -> Self { self.targets = self.targets.map_or(None, |t| { Some(DataProviderBounds { - count: t.count.max(targets.count), - size: t.size.max(targets.size), + count: t.count.map(|c| c.clamp(0, targets.count.unwrap_or(u32::MAX)).into()), + size: t.size.map(|c| c.clamp(0, targets.size.unwrap_or(u32::MAX)).into()), }) }); self @@ -845,8 +847,3 @@ impl ElectionBoundsBuilder { } } } - -#[cfg(test)] -mod elections_bounds { - // TODO(gpestana) -} diff --git a/frame/election-provider-support/src/onchain.rs b/frame/election-provider-support/src/onchain.rs index aa8e03890d4b5..952a6013b7656 100644 --- a/frame/election-provider-support/src/onchain.rs +++ b/frame/election-provider-support/src/onchain.rs @@ -159,8 +159,8 @@ impl InstantElectionProvider for OnChainExecution { targets_bounds: DataProviderBounds, ) -> Result, Self::Error> { let elections_bounds = ElectionBoundsBuilder::from(T::ElectionBounds::get()) - .max_voters(voters_bounds) - .max_targets(targets_bounds) + .clamp_voters(voters_bounds) + .clamp_targets(targets_bounds) .build(); elect_with_input_bounds::(elections_bounds) } diff --git a/frame/election-provider-support/src/tests.rs b/frame/election-provider-support/src/tests.rs index 1ccff79f3efd4..140d02e3fa59f 100644 --- a/frame/election-provider-support/src/tests.rs +++ b/frame/election-provider-support/src/tests.rs @@ -452,3 +452,58 @@ fn index_assignments_generate_same_solution_as_plain_assignments() { assert_eq!(solution, index_compact); } + +#[cfg(test)] +mod elections_bounds { + use crate::*; + + #[test] + fn data_provider_bounds_unbounded() { + let bounds = DataProviderBounds::new_unbounded(); + assert!(!bounds.exhausted(None, None)); + assert!(!bounds.exhausted(Some(10_000), Some(10_000))); + } + + #[test] + fn election_bounds_builder_and_exhausted_bounds() { + // voter bounds exhausts if count > 100 or size > 1_000; target bounds exhausts if count > + // 200 or size > 2_000. + let bounds = ElectionBoundsBuilder::new() + .voters_count(100.into()) + .voters_size(1_000.into()) + .targets_count(200.into()) + .targets_size(2_000.into()) + .build(); + + assert!(!bounds.voters.exhausted(None, None)); + assert!(!bounds.voters.exhausted(10.into(), 10.into())); + assert!(!bounds.voters.exhausted(None, 100.into())); + assert!(!bounds.voters.exhausted(1_000.into(), None)); + assert!(bounds.voters.exhausted(None, 101.into())); + assert!(bounds.voters.exhausted(1_001.into(), None)); + + assert!(!bounds.targets.exhausted(None, None)); + assert!(!bounds.targets.exhausted(20.into(), 20.into())); + assert!(!bounds.targets.exhausted(None, 200.into())); + assert!(!bounds.targets.exhausted(2_000.into(), None)); + assert!(bounds.targets.exhausted(None, 201.into())); + assert!(bounds.targets.exhausted(2_001.into(), None)); + } + + #[test] + fn election_bounds_clamp_works() { + let bounds = ElectionBoundsBuilder::new() + .voters_count(10.into()) + .voters_size(10.into()) + .clamp_voters(DataProviderBounds { count: 5.into(), size: 20.into() }) + .targets_count(20.into()) + .targets_size(None) + .clamp_targets(DataProviderBounds { count: 30.into(), size: 30.into() }) + .build(); + + assert_eq!(bounds.voters.count, 5.into()); + assert_eq!(bounds.voters.size, 10.into()); + assert_eq!(bounds.targets.count, 20.into()); + assert_eq!(bounds.targets.size, None); + } +} diff --git a/frame/staking/src/lib.rs b/frame/staking/src/lib.rs index fd504df668e11..3a94b7cfbe374 100644 --- a/frame/staking/src/lib.rs +++ b/frame/staking/src/lib.rs @@ -819,7 +819,7 @@ impl Get for FixedNominationsQuota { /// length prefix of the outer `Vec`. To get the final size at any point, use /// [`final_byte_size_of`]. pub(crate) struct ElectionSizeTracker { - size: usize, + pub size: usize, _marker: sp_std::marker::PhantomData, } diff --git a/frame/staking/src/pallet/impls.rs b/frame/staking/src/pallet/impls.rs index c9f368f8cc90b..d9a85ebef324c 100644 --- a/frame/staking/src/pallet/impls.rs +++ b/frame/staking/src/pallet/impls.rs @@ -18,8 +18,8 @@ //! Implementations for the Staking FRAME Pallet. use frame_election_provider_support::{ - data_provider, BoundedSupportsOf, DataProviderBounds, ElectionDataProvider, - ElectionProvider, ScoreProvider, SortedListProvider, VoteWeight, VoterOf, + data_provider, BoundedSupportsOf, DataProviderBounds, ElectionDataProvider, ElectionProvider, + ScoreProvider, SortedListProvider, VoteWeight, VoterOf, }; use frame_support::{ dispatch::WithPostDispatchInfo, @@ -795,6 +795,9 @@ impl Pallet { if voters_size_tracker.try_register_voter(targets.len(), voter_bounds).is_err() { // no more space left for the election result, stop iterating. + Self::deposit_event(Event::::SnapshotVotersSizeExceeded { + size: voters_size_tracker.size as u32, + }); break } @@ -809,6 +812,9 @@ impl Pallet { // if this voter is a validator: if voters_size_tracker.try_register_voter(1, voter_bounds).is_err() { // no more space left for the election result, stop iterating over. + Self::deposit_event(Event::::SnapshotVotersSizeExceeded { + size: voters_size_tracker.size as u32, + }); break } let self_vote = ( @@ -1007,9 +1013,10 @@ impl ElectionDataProvider for Pallet { // This can never fail -- if `maybe_max_len` is `Some(_)` we handle it. let voters = Self::get_npos_voters(bounds); - debug_assert!( - !bounds.exhausted(Some(voters.encoded_size() as u32), Some(voters.len() as u32)) - ); + debug_assert!(!bounds.exhausted( + (voters.encoded_size().saturating_sub(1) as u32).into(), + (voters.len() as u32).into() + )); Ok(voters) } diff --git a/frame/staking/src/pallet/mod.rs b/frame/staking/src/pallet/mod.rs index 830e40ba6ee99..9a644702e77e4 100644 --- a/frame/staking/src/pallet/mod.rs +++ b/frame/staking/src/pallet/mod.rs @@ -721,6 +721,8 @@ pub mod pallet { NominationsQuotaExceeded { staker: T::AccountId, exceeded_by: BalanceOf }, /// Encapsulates the nomination quota for a given balance. NominationsQuotaForBalance { balance: BalanceOf, nominations_quota: u32 }, + /// Voters size limit reached due to too many nominations. + SnapshotVotersSizeExceeded { size: u32 }, } #[pallet::error] diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index fdc74d1b474fd..ac163aab00a92 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -19,7 +19,7 @@ use super::{ConfigOp, Event, *}; use frame_election_provider_support::{ - ElectionBounds, ElectionBoundsBuilder, ElectionProvider, SortedListProvider, Support, + ElectionBoundsBuilder, ElectionProvider, SortedListProvider, Support, }; use frame_support::{ assert_noop, assert_ok, assert_storage_noop, bounded_vec, @@ -4603,6 +4603,19 @@ mod election_data_provider { }); } + #[test] + fn respects_snapshot_size_limits() { + ExtBuilder::default().build_and_execute(|| { + let bounds_builder = ElectionBoundsBuilder::new(); + assert_eq!( + Staking::electing_voters(bounds_builder.voters_size(Some(25)).build().voters) + .unwrap() + .len(), + 1 + ); + }); + } + #[test] fn nominations_quota_truncates() { ExtBuilder::default() @@ -4630,7 +4643,7 @@ mod election_data_provider { } #[test] - fn nominations_quota_limits() { + fn nominations_quota_limits_count() { ExtBuilder::default() .nominate(false) .add_staker( @@ -4661,6 +4674,35 @@ mod election_data_provider { }); } + #[test] + fn nominations_quota_limits_size() { + ExtBuilder::default() + .nominate(false) + .add_staker( + 71, + 70, + 333, + StakerStatus::::Nominator(vec![16, 15, 14, 13, 12, 11, 10]), + ) + .build_and_execute(|| { + // nominations of controller 70 won't be added due to voter size limit exceeded. + let bounds = ElectionBoundsBuilder::new().voters_size(100.into()).build(); + assert_eq!( + Staking::electing_voters(bounds.voters) + .unwrap() + .iter() + .map(|(stash, _, targets)| (*stash, targets.len())) + .collect::>(), + vec![(11, 1), (21, 1), (31, 1)], + ); + + assert_eq!( + *staking_events().last().unwrap(), + Event::SnapshotVotersSizeExceeded { size: 75 } + ); + }); + } + #[test] fn estimate_next_election_works() { ExtBuilder::default().session_per_era(5).period(5).build_and_execute(|| { @@ -5706,3 +5748,24 @@ fn scale_validator_count_errors() { ); }) } + +#[cfg(test)] +mod election_size_tracker { + use super::*; + + #[test] + pub fn election_size_tracker_works() { + let mut size_tracker = ElectionSizeTracker::::new(); + let voter_bounds = ElectionBoundsBuilder::new().voters_size(1_00.into()).build().voters; + + assert!(size_tracker.try_register_voter(1, voter_bounds).is_ok()); + assert!(size_tracker.try_register_voter(2, voter_bounds).is_ok()); + assert!(size_tracker.size > 0 && size_tracker.size < 1_00); + let size_before_overflow = size_tracker.size; + + // try many voters that will overflow the tracker's buffer. + assert!(size_tracker.try_register_voter(10, voter_bounds).is_err()); + assert!(size_tracker.size > 0 && size_tracker.size < 1_00); + assert_eq!(size_tracker.size, size_before_overflow); + } +} From a1f77adfde3d13e1a85797cbbcb4c3f130910723 Mon Sep 17 00:00:00 2001 From: gpestana Date: Wed, 28 Dec 2022 11:33:13 +0000 Subject: [PATCH 13/80] Fixes nits; node compiling --- bin/node/runtime/src/lib.rs | 13 +++++---- frame/bags-list/remote-tests/src/snapshot.rs | 20 +++++++------ frame/election-provider-support/src/lib.rs | 30 ++------------------ 3 files changed, 22 insertions(+), 41 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 8fb98c33f292b..7ad739e81c300 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -548,6 +548,9 @@ parameter_types! { pub HistoryDepth: u32 = 84; } +/// Upper limit on the number of NPOS nominations. +const MAX_QUOTA_NOMINATIONS: u32 = 16; + pub struct StakingBenchmarkingConfig; impl pallet_staking::BenchmarkingConfig for StakingBenchmarkingConfig { type MaxNominators = ConstU32<1000>; @@ -555,7 +558,6 @@ impl pallet_staking::BenchmarkingConfig for StakingBenchmarkingConfig { } impl pallet_staking::Config for Runtime { - type MaxNominations = MaxNominations; type Currency = Balances; type CurrencyBalance = Balance; type UnixTime = Timestamp; @@ -580,6 +582,7 @@ impl pallet_staking::Config for Runtime { type ElectionProvider = ElectionProviderMultiPhase; type GenesisElectionProvider = onchain::OnChainExecution; type VoterList = VoterList; + type NominationsQuota = pallet_staking::FixedNominationsQuota; // This a placeholder, to be introduced in the next PR as an instance of bags-list type TargetList = pallet_staking::UseValidatorsMap; type MaxUnlockingChunks = ConstU32<32>; @@ -630,15 +633,15 @@ frame_election_provider_support::generate_solution_type!( VoterIndex = u32, TargetIndex = u16, Accuracy = sp_runtime::PerU16, - MaxVoters = MaxElectingVoters, + MaxVoters = MaxNominations, >(16) ); parameter_types! { - pub ElectionBounds: ElectionBounds = ElectionBoundsBuilder::new().voters_count(40_000).targets_count(10_000.into()).build(); + pub ElectionBoundsMultiPhase: ElectionBounds = ElectionBoundsBuilder::new().voters_count(40_000.into()).targets_count(10_000.into()).build(); pub MaxNominations: u32 = ::LIMIT as u32; // OnChain values are lower. - pub ElectionBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::new().voters_count(5_000).targets_count(1_250.into()).build(); + pub ElectionBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::new().voters_count(5_000.into()).targets_count(1_250.into()).build(); // The maximum winners that can be elected by the Election pallet which is equivalent to the // maximum active validators the staking pallet can have. pub MaxActiveValidators: u32 = 1000; @@ -741,7 +744,7 @@ impl pallet_election_provider_multi_phase::Config for Runtime { type Solver = SequentialPhragmen, OffchainRandomBalancing>; type ForceOrigin = EnsureRootOrHalfCouncil; type MaxWinners = MaxActiveValidators; - type ElectionBounds = ElectionBounds; + type ElectionBounds = ElectionBoundsMultiPhase; type BenchmarkingConfig = ElectionProviderBenchmarkConfig; type WeightInfo = pallet_election_provider_multi_phase::weights::SubstrateWeight; } diff --git a/frame/bags-list/remote-tests/src/snapshot.rs b/frame/bags-list/remote-tests/src/snapshot.rs index 0163ca200a15d..69b39bfe073b9 100644 --- a/frame/bags-list/remote-tests/src/snapshot.rs +++ b/frame/bags-list/remote-tests/src/snapshot.rs @@ -16,14 +16,17 @@ //! Test to execute the snapshot using the voter bag. -use frame_election_provider_support::SortedListProvider; +use frame_election_provider_support::{ElectionBounds, SortedListProvider}; use frame_support::traits::PalletInfoAccess; use remote_externalities::{Builder, Mode, OnlineConfig}; use sp_runtime::{traits::Block as BlockT, DeserializeOwned}; /// Execute create a snapshot from pallet-staking. -pub async fn execute(voter_limit: Option, currency_unit: u64, ws_url: String) -where +pub async fn execute( + election_bounds: ElectionBounds, + currency_unit: u64, + ws_url: String, +) where Runtime: crate::RuntimeT, Block: BlockT + DeserializeOwned, Block::Header: DeserializeOwned, @@ -62,9 +65,10 @@ where ::VoterList::count(), ); - let voters = - as ElectionDataProvider>::electing_voters(voter_limit) - .unwrap(); + let voters = as ElectionDataProvider>::electing_voters( + election_bounds.voters, + ) + .unwrap(); let mut voters_nominator_only = voters .iter() @@ -82,8 +86,8 @@ where .map(|(x, y, _)| (x.clone(), *y as f64 / currency_unit)); log::info!( target: crate::LOG_TARGET, - "a snapshot with limit {:?} has been created, {} voters are taken. min nominator: {:?}, max: {:?}", - voter_limit, + "a snapshot with limits {:?} has been created, {} voters are taken. min nominator: {:?}, max: {:?}", + election_bounds, voters.len(), min_voter, max_voter diff --git a/frame/election-provider-support/src/lib.rs b/frame/election-provider-support/src/lib.rs index d1e48669fee62..dfe25959eeb8e 100644 --- a/frame/election-provider-support/src/lib.rs +++ b/frame/election-provider-support/src/lib.rs @@ -675,7 +675,7 @@ pub type BoundedSupportsOf = BoundedSupports< sp_core::generate_feature_enabled_macro!(runtime_benchmarks_enabled, feature = "runtime-benchmarks", $); sp_core::generate_feature_enabled_macro!(runtime_benchmarks_or_fuzz_enabled, any(feature = "runtime-benchmarks", feature = "fuzzing"), $); -#[derive(Clone, Copy, Eq, Default, Debug)] +#[derive(Clone, Copy, Default, Debug)] pub struct DataProviderBounds { pub count: Option, pub size: Option, @@ -704,35 +704,9 @@ impl DataProviderBounds { } } -impl PartialEq for DataProviderBounds { - fn eq(&self, other: &Self) -> bool { - self.count == other.count && self.size == self.size - } -} - -impl PartialOrd for DataProviderBounds { - fn partial_cmp(&self, other: &Self) -> Option { - Some(self.cmp(other)) - } -} - -// TODO(gpestana): is this correct? -impl Ord for DataProviderBounds { - fn cmp(&self, other: &Self) -> std::cmp::Ordering { - if self.count == other.count { - self.size.cmp(&other.size) - } else { - self.count.cmp(&other.count) - } - } -} - /// The limits of an election result. The bounds are defined over the count of element of the /// election (voters or targets) or the overall datastructure size. -/// -/// Ordering: when comparing two instances of `ElectionBounds`, the `count` has priority over the -/// `size`, ie. if `A.count > B.count`, then `A > B` regardless of their relative `size`. -#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Debug)] +#[derive(Clone, Debug)] pub struct ElectionBounds { pub voters: DataProviderBounds, pub targets: DataProviderBounds, From 905b8e0a78df471b508fbcc045b26711242be195 Mon Sep 17 00:00:00 2001 From: gpestana Date: Thu, 29 Dec 2022 12:46:43 +0000 Subject: [PATCH 14/80] bechmarks --- .../src/benchmarking.rs | 5 ++-- .../nomination-pools/benchmarking/src/lib.rs | 5 ++-- frame/offences/benchmarking/src/lib.rs | 10 +++---- frame/session/benchmarking/src/lib.rs | 10 +++---- frame/staking/src/benchmarking.rs | 26 +++++++++---------- frame/staking/src/lib.rs | 2 +- 6 files changed, 30 insertions(+), 28 deletions(-) diff --git a/frame/election-provider-multi-phase/src/benchmarking.rs b/frame/election-provider-multi-phase/src/benchmarking.rs index 10041f6aec07c..7632dfbbd911c 100644 --- a/frame/election-provider-multi-phase/src/benchmarking.rs +++ b/frame/election-provider-multi-phase/src/benchmarking.rs @@ -20,6 +20,7 @@ use super::*; use crate::{unsigned::IndexAssignmentOf, Pallet as MultiPhase}; use frame_benchmarking::account; +use frame_election_provider_support::DataProviderBounds; use frame_support::{ assert_ok, traits::{Hooks, TryCollect}, @@ -267,8 +268,8 @@ frame_benchmarking::benchmarks! { // we don't directly need the data-provider to be populated, but it is just easy to use it. set_up_data_provider::(v, t); - let targets = T::DataProvider::electable_targets(None)?; - let voters = T::DataProvider::electing_voters(None)?; + let targets = T::DataProvider::electable_targets(DataProviderBounds::new_unbounded())?; + let voters = T::DataProvider::electing_voters(DataProviderBounds::new_unbounded())?; let desired_targets = T::DataProvider::desired_targets()?; assert!(>::snapshot().is_none()); }: { diff --git a/frame/nomination-pools/benchmarking/src/lib.rs b/frame/nomination-pools/benchmarking/src/lib.rs index 9b063539152b7..60588bb30c792 100644 --- a/frame/nomination-pools/benchmarking/src/lib.rs +++ b/frame/nomination-pools/benchmarking/src/lib.rs @@ -32,6 +32,7 @@ use pallet_nomination_pools::{ MaxPoolMembersPerPool, MaxPools, Metadata, MinCreateBond, MinJoinBond, Pallet as Pools, PoolMembers, PoolRoles, PoolState, RewardPools, SubPoolsStorage, }; +use pallet_staking::AbsoluteMaxNominationsOf; use sp_runtime::traits::{Bounded, StaticLookup, Zero}; use sp_staking::{EraIndex, StakingInterface}; // `frame_benchmarking::benchmarks!` macro needs this @@ -527,7 +528,7 @@ frame_benchmarking::benchmarks! { } nominate { - let n in 1 .. T::MaxNominations::get(); + let n in 1 .. AbsoluteMaxNominationsOf::::get(); // Create a pool let min_create_bond = Pools::::depositor_min_bond() * 2u32.into(); @@ -639,7 +640,7 @@ frame_benchmarking::benchmarks! { let (depositor, pool_account) = create_pool_account::(0, Pools::::depositor_min_bond() * 2u32.into()); // Nominate with the pool. - let validators: Vec<_> = (0..T::MaxNominations::get()) + let validators: Vec<_> = (0..AbsoluteMaxNominationsOf::::get()) .map(|i| account("stash", USER_SEED, i)) .collect(); diff --git a/frame/offences/benchmarking/src/lib.rs b/frame/offences/benchmarking/src/lib.rs index e5ec2952f8114..8275eea16c076 100644 --- a/frame/offences/benchmarking/src/lib.rs +++ b/frame/offences/benchmarking/src/lib.rs @@ -44,8 +44,8 @@ use pallet_session::{ Config as SessionConfig, SessionManager, }; use pallet_staking::{ - Config as StakingConfig, Event as StakingEvent, Exposure, IndividualExposure, - Pallet as Staking, RewardDestination, ValidatorPrefs, + AbsoluteMaxNominationsOf, Config as StakingConfig, Event as StakingEvent, Exposure, + IndividualExposure, Pallet as Staking, RewardDestination, ValidatorPrefs, }; const SEED: u32 = 0; @@ -274,7 +274,7 @@ benchmarks! { let r in 1 .. MAX_REPORTERS; // we skip 1 offender, because in such case there is no slashing let o in 2 .. MAX_OFFENDERS; - let n in 0 .. MAX_NOMINATORS.min(::MaxNominations::get()); + let n in 0 .. MAX_NOMINATORS.min(AbsoluteMaxNominationsOf::::get()); // Make r reporters let mut reporters = vec![]; @@ -382,7 +382,7 @@ benchmarks! { } report_offence_grandpa { - let n in 0 .. MAX_NOMINATORS.min(::MaxNominations::get()); + let n in 0 .. MAX_NOMINATORS.min(AbsoluteMaxNominationsOf::::get()); // for grandpa equivocation reports the number of reporters // and offenders is always 1 @@ -419,7 +419,7 @@ benchmarks! { } report_offence_babe { - let n in 0 .. MAX_NOMINATORS.min(::MaxNominations::get()); + let n in 0 .. MAX_NOMINATORS.min(AbsoluteMaxNominationsOf::::get()); // for babe equivocation reports the number of reporters // and offenders is always 1 diff --git a/frame/session/benchmarking/src/lib.rs b/frame/session/benchmarking/src/lib.rs index 9e478ada53cf2..d52d3e02b51ce 100644 --- a/frame/session/benchmarking/src/lib.rs +++ b/frame/session/benchmarking/src/lib.rs @@ -35,7 +35,7 @@ use frame_system::RawOrigin; use pallet_session::{historical::Pallet as Historical, Pallet as Session, *}; use pallet_staking::{ benchmarking::create_validator_with_nominators, testing_utils::create_validators, - RewardDestination, + AbsoluteMaxNominationsOf, RewardDestination, }; const MAX_VALIDATORS: u32 = 1000; @@ -54,10 +54,10 @@ impl OnInitialize for Pallet { benchmarks! { set_keys { - let n = ::MaxNominations::get(); + let n = AbsoluteMaxNominationsOf::::get(); let (v_stash, _) = create_validator_with_nominators::( n, - ::MaxNominations::get(), + AbsoluteMaxNominationsOf::::get(), false, RewardDestination::Staked, )?; @@ -71,10 +71,10 @@ benchmarks! { }: _(RawOrigin::Signed(v_controller), keys, proof) purge_keys { - let n = ::MaxNominations::get(); + let n = AbsoluteMaxNominationsOf::::get(); let (v_stash, _) = create_validator_with_nominators::( n, - ::MaxNominations::get(), + AbsoluteMaxNominationsOf::::get(), false, RewardDestination::Staked )?; diff --git a/frame/staking/src/benchmarking.rs b/frame/staking/src/benchmarking.rs index b3d32b26ec1f7..1a93914d965c7 100644 --- a/frame/staking/src/benchmarking.rs +++ b/frame/staking/src/benchmarking.rs @@ -22,7 +22,7 @@ use crate::{ConfigOp, Pallet as Staking}; use testing_utils::*; use codec::Decode; -use frame_election_provider_support::SortedListProvider; +use frame_election_provider_support::{DataProviderBounds, SortedListProvider}; use frame_support::{ dispatch::UnfilteredDispatchable, pallet_prelude::*, @@ -334,7 +334,7 @@ benchmarks! { validate { let (stash, controller) = create_stash_controller::( - T::MaxNominations::get() - 1, + AbsoluteMaxNominationsOf::::get() - 1, 100, Default::default(), )?; @@ -358,11 +358,11 @@ benchmarks! { // these are the other validators; there are `T::MaxNominations::get() - 1` of them, so // there are a total of `T::MaxNominations::get()` validators in the system. - let rest_of_validators = create_validators_with_seed::(T::MaxNominations::get() - 1, 100, 415)?; + let rest_of_validators = create_validators_with_seed::(AbsoluteMaxNominationsOf::::get() - 1, 100, 415)?; // this is the validator that will be kicking. let (stash, controller) = create_stash_controller::( - T::MaxNominations::get() - 1, + AbsoluteMaxNominationsOf::::get() - 1, 100, Default::default(), )?; @@ -377,7 +377,7 @@ benchmarks! { for i in 0 .. k { // create a nominator stash. let (n_stash, n_controller) = create_stash_controller::( - T::MaxNominations::get() + i, + AbsoluteMaxNominationsOf::::get() + i, 100, Default::default(), )?; @@ -414,7 +414,7 @@ benchmarks! { // Worst case scenario, T::MaxNominations::get() nominate { - let n in 1 .. T::MaxNominations::get(); + let n in 1 .. AbsoluteMaxNominationsOf::::get(); // clean up any existing state. clear_validators_and_nominators::(); @@ -425,7 +425,7 @@ benchmarks! { // we are just doing an insert into the origin position. let scenario = ListScenario::::new(origin_weight, true)?; let (stash, controller) = create_stash_controller_with_balance::( - SEED + T::MaxNominations::get() + 1, // make sure the account does not conflict with others + SEED + AbsoluteMaxNominationsOf::::get() + 1, // make sure the account does not conflict with others origin_weight, Default::default(), ).unwrap(); @@ -702,7 +702,7 @@ benchmarks! { create_validators_with_nominators_for_era::( v, n, - ::MaxNominations::get() as usize, + AbsoluteMaxNominationsOf::::get() as usize, false, None, )?; @@ -720,7 +720,7 @@ benchmarks! { create_validators_with_nominators_for_era::( v, n, - ::MaxNominations::get() as usize, + AbsoluteMaxNominationsOf::::get() as usize, false, None, )?; @@ -799,7 +799,7 @@ benchmarks! { let n in (MaxNominators::::get() / 2) .. MaxNominators::::get(); let validators = create_validators_with_nominators_for_era::( - v, n, T::MaxNominations::get() as usize, false, None + v, n, AbsoluteMaxNominationsOf::::get() as usize, false, None )? .into_iter() .map(|v| T::Lookup::lookup(v).unwrap()) @@ -810,7 +810,7 @@ benchmarks! { let num_voters = (v + n) as usize; }: { - let voters = >::get_npos_voters(None); + let voters = >::get_npos_voters(DataProviderBounds::new_unbounded()); assert_eq!(voters.len(), num_voters); } @@ -821,10 +821,10 @@ benchmarks! { let n = MaxNominators::::get(); let _ = create_validators_with_nominators_for_era::( - v, n, T::MaxNominations::get() as usize, false, None + v, n, AbsoluteMaxNominationsOf::::get() as usize, false, None )?; }: { - let targets = >::get_npos_targets(None); + let targets = >::get_npos_targets(DataProviderBounds::new_unbounded()); assert_eq!(targets.len() as u32, v); } diff --git a/frame/staking/src/lib.rs b/frame/staking/src/lib.rs index 3a94b7cfbe374..f309fee10a596 100644 --- a/frame/staking/src/lib.rs +++ b/frame/staking/src/lib.rs @@ -340,7 +340,7 @@ macro_rules! log { pub type MaxWinnersOf = <::ElectionProvider as frame_election_provider_support::ElectionProviderBase>::MaxWinners; /// Absolute maximum number of nominations per nominator. -type AbsoluteMaxNominationsOf = +pub type AbsoluteMaxNominationsOf = <::NominationsQuota as NominationsQuota>>::AbsoluteMaxNominations; /// Counter for the number of "reward" points earned by a given validator. From 775fe25b8a76019d694808a403e1bc9ddb7a7bac Mon Sep 17 00:00:00 2001 From: gpestana Date: Tue, 3 Jan 2023 15:42:08 +0100 Subject: [PATCH 15/80] removes nomination_quota extrinsic to request the nomination quota --- frame/staking/src/pallet/mod.rs | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/frame/staking/src/pallet/mod.rs b/frame/staking/src/pallet/mod.rs index 07d9223c60bdd..98421f207d624 100644 --- a/frame/staking/src/pallet/mod.rs +++ b/frame/staking/src/pallet/mod.rs @@ -721,8 +721,6 @@ pub mod pallet { ValidatorPrefsSet { stash: T::AccountId, prefs: ValidatorPrefs }, /// The number of nominations has exceeded the allowed by the voter's nomination quota. NominationsQuotaExceeded { staker: T::AccountId, exceeded_by: BalanceOf }, - /// Encapsulates the nomination quota for a given balance. - NominationsQuotaForBalance { balance: BalanceOf, nominations_quota: u32 }, /// Voters size limit reached due to too many nominations. SnapshotVotersSizeExceeded { size: u32 }, } @@ -1823,23 +1821,6 @@ pub mod pallet { MinCommission::::put(new); Ok(()) } - - /// Emits an event with the nominations quota for a given balance. - #[pallet::call_index(26)] - #[pallet::weight(1)] // TODO(gpestana): finish - pub fn nominations_quota( - origin: OriginFor, - #[pallet::compact] balance: BalanceOf, - ) -> DispatchResult { - ensure_signed(origin)?; - - Self::deposit_event(Event::::NominationsQuotaForBalance { - balance, - nominations_quota: - >>::get_quota_safe(balance), - }); - Ok(()) - } } } From eb2456bd1ad8d56ae67dfdacfa6bef6004d7481d Mon Sep 17 00:00:00 2001 From: gpestana Date: Tue, 3 Jan 2023 23:32:27 +0100 Subject: [PATCH 16/80] Lazy quota check, ie. at nominate time only --- frame/staking/src/pallet/impls.rs | 3 +- frame/staking/src/pallet/mod.rs | 3 +- frame/staking/src/tests.rs | 65 ++++++++++++++----------------- 3 files changed, 33 insertions(+), 38 deletions(-) diff --git a/frame/staking/src/pallet/impls.rs b/frame/staking/src/pallet/impls.rs index a138bc3fac0a9..95a1f869a1e1c 100644 --- a/frame/staking/src/pallet/impls.rs +++ b/frame/staking/src/pallet/impls.rs @@ -776,7 +776,7 @@ impl Pallet { None => break, }; - if let Some(Nominations { mut targets, .. }) = >::get(&voter) { + if let Some(Nominations { targets, .. }) = >::get(&voter) { // if this voter is a nominator: let voter_weight = weight_of(&voter); if !targets.is_empty() { @@ -791,7 +791,6 @@ impl Pallet { }); } - targets.truncate(nominations_quota as usize); if voters_size_tracker.try_register_voter(targets.len(), voter_bounds).is_err() { // no more space left for the election result, stop iterating. diff --git a/frame/staking/src/pallet/mod.rs b/frame/staking/src/pallet/mod.rs index 98421f207d624..6a8adb0c30401 100644 --- a/frame/staking/src/pallet/mod.rs +++ b/frame/staking/src/pallet/mod.rs @@ -1175,7 +1175,8 @@ pub mod pallet { ensure!(!targets.is_empty(), Error::::EmptyTargets); ensure!( - targets.len() <= AbsoluteMaxNominationsOf::::get() as usize, + targets.len() <= + T::NominationsQuota::get_quota_safe(Self::weight_of(&stash).into()) as usize, Error::::TooManyTargets ); diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index 838b8d70aec88..647594bdbf278 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -4617,24 +4617,51 @@ mod election_data_provider { } #[test] - fn nominations_quota_truncates() { + fn nominate_above_quota_fails() { + ExtBuilder::default().nominate(false).build_and_execute(|| { + // stash bond of 222 has a nomination quota of 2 targets. + bond(61, 60, 222); + + // nominating with targets below the nomination quota works. + assert_ok!(Staking::nominate(RuntimeOrigin::signed(60), vec![11])); + assert_ok!(Staking::nominate(RuntimeOrigin::signed(60), vec![11, 12])); + + // nominating with targets above the nomination quota returns error. + assert_noop!( + Staking::nominate(RuntimeOrigin::signed(60), vec![11, 12, 13]), + Error::::TooManyTargets + ); + }); + } + + #[test] + fn lazy_quota_npos_voters_works_above_quota() { ExtBuilder::default() .nominate(false) .add_staker( 61, 60, - 222, // voters with balance == 222 have nomination quota of 2 nominations. + 100, // voters with balance == 100 have nomination quota of 16 targets. StakerStatus::::Nominator(vec![21, 22, 23, 24, 25]), ) .build_and_execute(|| { + // set stash balance to 222, where the nomination quota is 2 targets. + let _ = Balances::make_free_balance_be(&60, 100); + let _ = Balances::make_free_balance_be(&61, 100); + + // even through 61 has nomination quota of 2, all the nominations (5) will be + // accepted and an event `NominationsQuotaExceeded` emitted. assert_eq!( Staking::electing_voters(DataProviderBounds::new_unbounded()) .unwrap() .iter() .map(|(stash, _, targets)| (*stash, targets.len())) .collect::>(), - vec![(11, 1), (21, 1), (31, 1), (61, 2)], + vec![(11, 1), (21, 1), (31, 1), (61, 5)], ); + + // `Event::NominationsQuotaExceeded` is emitted, even though all votes are + // are considered. assert_eq!( *staking_events().last().unwrap(), Event::NominationsQuotaExceeded { staker: 61, exceeded_by: 3 } @@ -4642,38 +4669,6 @@ mod election_data_provider { }); } - #[test] - fn nominations_quota_limits_count() { - ExtBuilder::default() - .nominate(false) - .add_staker( - 61, - 60, - 111, /* voters with balance == 111 have nomination quota of 0 nominations, - * should be rounded to 1. */ - StakerStatus::::Nominator(vec![21, 22, 23, 24, 25]), - ) - .add_staker( - 71, - 70, - 333, /* voters with balance == 333 have nomination quota of MAX + 10 - * nominations, should be rounded to MAX. */ - StakerStatus::::Nominator(vec![ - 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, - ]), - ) - .build_and_execute(|| { - assert_eq!( - Staking::electing_voters(DataProviderBounds::new_unbounded()) - .unwrap() - .iter() - .map(|(stash, _, targets)| (*stash, targets.len())) - .collect::>(), - vec![(11, 1), (21, 1), (31, 1), (61, 1), (71, 16)], - ); - }); - } - #[test] fn nominations_quota_limits_size() { ExtBuilder::default() From b0b21a429505e5bb98cf48694876ff0a19f046cc Mon Sep 17 00:00:00 2001 From: gpestana Date: Tue, 3 Jan 2023 23:39:13 +0100 Subject: [PATCH 17/80] remove non-working test (for now) --- frame/staking/src/tests.rs | 35 ----------------------------------- 1 file changed, 35 deletions(-) diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index 647594bdbf278..397146ee1162a 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -4634,41 +4634,6 @@ mod election_data_provider { }); } - #[test] - fn lazy_quota_npos_voters_works_above_quota() { - ExtBuilder::default() - .nominate(false) - .add_staker( - 61, - 60, - 100, // voters with balance == 100 have nomination quota of 16 targets. - StakerStatus::::Nominator(vec![21, 22, 23, 24, 25]), - ) - .build_and_execute(|| { - // set stash balance to 222, where the nomination quota is 2 targets. - let _ = Balances::make_free_balance_be(&60, 100); - let _ = Balances::make_free_balance_be(&61, 100); - - // even through 61 has nomination quota of 2, all the nominations (5) will be - // accepted and an event `NominationsQuotaExceeded` emitted. - assert_eq!( - Staking::electing_voters(DataProviderBounds::new_unbounded()) - .unwrap() - .iter() - .map(|(stash, _, targets)| (*stash, targets.len())) - .collect::>(), - vec![(11, 1), (21, 1), (31, 1), (61, 5)], - ); - - // `Event::NominationsQuotaExceeded` is emitted, even though all votes are - // are considered. - assert_eq!( - *staking_events().last().unwrap(), - Event::NominationsQuotaExceeded { staker: 61, exceeded_by: 3 } - ); - }); - } - #[test] fn nominations_quota_limits_size() { ExtBuilder::default() From 82ac2db3a3b1fe7b445b167066bab716969e1d7a Mon Sep 17 00:00:00 2001 From: gpestana Date: Wed, 4 Jan 2023 19:00:38 +0100 Subject: [PATCH 18/80] tests lazy nominations quota when quota is lower than current number of nominated targets --- frame/staking/src/tests.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index 397146ee1162a..3614304992292 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -4634,6 +4634,39 @@ mod election_data_provider { }); } + #[test] + fn lazy_quota_npos_voters_works_above_quota() { + ExtBuilder::default() + .nominate(false) + .add_staker( + 61, + 60, + 300, // 300 bond has 16 nomination quota. + StakerStatus::::Nominator(vec![21, 22, 23, 24, 25]), + ) + .build_and_execute(|| { + // unbond 78 from stash 60 so that it's bonded balance is 222, which has a lower + // nomination quota than at nomination time (max 2 targets). + assert_ok!(Staking::unbond(RuntimeOrigin::signed(60), 78)); + + // even through 61 has nomination quota of 2 at the time of the election, all the + // nominations (5) will be used and an `Event::NominationsQuotaExceeded` emitted. + assert_eq!( + Staking::electing_voters(DataProviderBounds::new_unbounded()) + .unwrap() + .iter() + .map(|(stash, _, targets)| (*stash, targets.len())) + .collect::>(), + vec![(11, 1), (21, 1), (31, 1), (61, 5)], + ); + + assert_eq!( + *staking_events().last().unwrap(), + Event::NominationsQuotaExceeded { staker: 61, exceeded_by: 3 } + ); + }); + } + #[test] fn nominations_quota_limits_size() { ExtBuilder::default() From 8218e17c6ff092f2842d5d81a62e3fa210dc0065 Mon Sep 17 00:00:00 2001 From: gpestana Date: Wed, 4 Jan 2023 21:20:30 +0100 Subject: [PATCH 19/80] Adds runtime API and custom RPC call for clients to query the nominations quota for a given balance --- Cargo.lock | 28 ++++++++ Cargo.toml | 2 + bin/node/rpc/Cargo.toml | 1 + bin/node/rpc/src/lib.rs | 3 + bin/node/runtime/Cargo.toml | 1 + bin/node/runtime/src/lib.rs | 6 ++ frame/staking/rpc/Cargo.toml | 24 +++++++ frame/staking/rpc/README.md | 3 + frame/staking/rpc/runtime-api/Cargo.toml | 30 ++++++++ frame/staking/rpc/runtime-api/README.md | 3 + frame/staking/rpc/runtime-api/src/lib.rs | 32 +++++++++ frame/staking/rpc/src/lib.rs | 90 ++++++++++++++++++++++++ frame/staking/src/pallet/impls.rs | 5 ++ 13 files changed, 228 insertions(+) create mode 100644 frame/staking/rpc/Cargo.toml create mode 100644 frame/staking/rpc/README.md create mode 100644 frame/staking/rpc/runtime-api/Cargo.toml create mode 100644 frame/staking/rpc/runtime-api/README.md create mode 100644 frame/staking/rpc/runtime-api/src/lib.rs create mode 100644 frame/staking/rpc/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index c93a0b7fdd28a..f0d9a9cb374e1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3129,6 +3129,7 @@ dependencies = [ "pallet-society", "pallet-staking", "pallet-staking-reward-curve", + "pallet-staking-rpc-runtime-api", "pallet-state-trie-migration", "pallet-sudo", "pallet-timestamp", @@ -4380,6 +4381,7 @@ dependencies = [ "jsonrpsee", "mmr-rpc", "node-primitives", + "pallet-staking-rpc", "pallet-transaction-payment-rpc", "sc-chain-spec", "sc-client-api", @@ -5900,6 +5902,32 @@ dependencies = [ "sp-arithmetic", ] +[[package]] +name = "pallet-staking-rpc" +version = "4.0.0-dev" +dependencies = [ + "jsonrpsee", + "pallet-staking-rpc-runtime-api", + "parity-scale-codec", + "sp-api", + "sp-blockchain", + "sp-core", + "sp-rpc", + "sp-runtime", + "sp-weights", +] + +[[package]] +name = "pallet-staking-rpc-runtime-api" +version = "4.0.0-dev" +dependencies = [ + "pallet-staking", + "parity-scale-codec", + "sp-api", + "sp-runtime", + "sp-weights", +] + [[package]] name = "pallet-state-trie-migration" version = "4.0.0-dev" diff --git a/Cargo.toml b/Cargo.toml index 8f55d8e527ecd..4ab4e4cf340ce 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -141,6 +141,8 @@ members = [ "frame/staking", "frame/staking/reward-curve", "frame/staking/reward-fn", + "frame/staking/rpc", + "frame/staking/rpc/runtime-api", "frame/state-trie-migration", "frame/sudo", "frame/root-offences", diff --git a/bin/node/rpc/Cargo.toml b/bin/node/rpc/Cargo.toml index f34922a287dfe..48252c722ddb7 100644 --- a/bin/node/rpc/Cargo.toml +++ b/bin/node/rpc/Cargo.toml @@ -16,6 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"] jsonrpsee = { version = "0.16.2", features = ["server"] } node-primitives = { version = "2.0.0", path = "../primitives" } pallet-transaction-payment-rpc = { version = "4.0.0-dev", path = "../../../frame/transaction-payment/rpc/" } +pallet-staking-rpc = { version = "4.0.0-dev", path = "../../../frame/staking/rpc/" } mmr-rpc = { version = "4.0.0-dev", path = "../../../client/merkle-mountain-range/rpc/" } sc-chain-spec = { version = "4.0.0-dev", path = "../../../client/chain-spec" } sc-client-api = { version = "4.0.0-dev", path = "../../../client/api" } diff --git a/bin/node/rpc/src/lib.rs b/bin/node/rpc/src/lib.rs index 0dc5ba4039b00..1bd2b26445a60 100644 --- a/bin/node/rpc/src/lib.rs +++ b/bin/node/rpc/src/lib.rs @@ -110,6 +110,7 @@ where C::Api: substrate_frame_rpc_system::AccountNonceApi, C::Api: mmr_rpc::MmrRuntimeApi::Hash, BlockNumber>, C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi, + C::Api: pallet_staking_rpc::StakingRuntimeApi, C::Api: BabeApi, C::Api: BlockBuilder, P: TransactionPool + 'static, @@ -118,6 +119,7 @@ where B::State: sc_client_api::backend::StateBackend>, { use mmr_rpc::{Mmr, MmrApiServer}; + use pallet_staking_rpc::{Staking, StakingApiServer}; use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer}; use sc_consensus_babe_rpc::{Babe, BabeApiServer}; use sc_finality_grandpa_rpc::{Grandpa, GrandpaApiServer}; @@ -150,6 +152,7 @@ where // These RPCs should use an asynchronous caller instead. io.merge(Mmr::new(client.clone()).into_rpc())?; io.merge(TransactionPayment::new(client.clone()).into_rpc())?; + io.merge(Staking::new(client.clone()).into_rpc())?; io.merge( Babe::new( client.clone(), diff --git a/bin/node/runtime/Cargo.toml b/bin/node/runtime/Cargo.toml index 201e3a85f8941..ec01c16a70ba0 100644 --- a/bin/node/runtime/Cargo.toml +++ b/bin/node/runtime/Cargo.toml @@ -96,6 +96,7 @@ pallet-session = { version = "4.0.0-dev", features = [ "historical" ], path = ". pallet-session-benchmarking = { version = "4.0.0-dev", path = "../../../frame/session/benchmarking", default-features = false, optional = true } pallet-staking = { version = "4.0.0-dev", default-features = false, path = "../../../frame/staking" } pallet-staking-reward-curve = { version = "4.0.0-dev", default-features = false, path = "../../../frame/staking/reward-curve" } +pallet-staking-rpc-runtime-api = { version = "4.0.0-dev", default-features = false, path = "../../../frame/staking/rpc/runtime-api/" } pallet-state-trie-migration = { version = "4.0.0-dev", default-features = false, path = "../../../frame/state-trie-migration" } pallet-scheduler = { version = "4.0.0-dev", default-features = false, path = "../../../frame/scheduler" } pallet-society = { version = "4.0.0-dev", default-features = false, path = "../../../frame/society" } diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 7ad739e81c300..df6c072dea871 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -2133,6 +2133,12 @@ impl_runtime_apis! { } } + impl pallet_staking_rpc_runtime_api::StakingApi for Runtime { + fn query_nominations_quota(balance: Balance) -> u32 { + Staking::query_nominations_quota(balance) + } + } + impl pallet_mmr::primitives::MmrApi< Block, mmr::Hash, diff --git a/frame/staking/rpc/Cargo.toml b/frame/staking/rpc/Cargo.toml new file mode 100644 index 0000000000000..cf9c192456355 --- /dev/null +++ b/frame/staking/rpc/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "pallet-staking-rpc" +version = "4.0.0-dev" +authors = ["Parity Technologies "] +edition = "2021" +license = "Apache-2.0" +homepage = "https://substrate.io" +repository = "https://github.com/paritytech/substrate/" +description = "RPC interface for the staking pallet." +readme = "README.md" + +[package.metadata.docs.rs] +targets = ["x86_64-unknown-linux-gnu"] + +[dependencies] +codec = { package = "parity-scale-codec", version = "3.0.0" } +jsonrpsee = { version = "0.16.2", features = ["client-core", "server", "macros"] } +pallet-staking-rpc-runtime-api = { version = "4.0.0-dev", path = "./runtime-api" } +sp-api = { version = "4.0.0-dev", path = "../../../primitives/api" } +sp-blockchain = { version = "4.0.0-dev", path = "../../../primitives/blockchain" } +sp-core = { version = "7.0.0", path = "../../../primitives/core" } +sp-rpc = { version = "6.0.0", path = "../../../primitives/rpc" } +sp-runtime = { version = "7.0.0", path = "../../../primitives/runtime" } +sp-weights = { version = "4.0.0", path = "../../../primitives/weights" } diff --git a/frame/staking/rpc/README.md b/frame/staking/rpc/README.md new file mode 100644 index 0000000000000..8a5a617d1a370 --- /dev/null +++ b/frame/staking/rpc/README.md @@ -0,0 +1,3 @@ +RPC interface for the staking pallet. + +License: Apache-2.0 diff --git a/frame/staking/rpc/runtime-api/Cargo.toml b/frame/staking/rpc/runtime-api/Cargo.toml new file mode 100644 index 0000000000000..351cd37b0991c --- /dev/null +++ b/frame/staking/rpc/runtime-api/Cargo.toml @@ -0,0 +1,30 @@ +[package] +name = "pallet-staking-rpc-runtime-api" +version = "4.0.0-dev" +authors = ["Parity Technologies "] +edition = "2021" +license = "Apache-2.0" +homepage = "https://substrate.io" +repository = "https://github.com/paritytech/substrate/" +description = "RPC runtime API for transaction payment FRAME pallet" +readme = "README.md" + +[package.metadata.docs.rs] +targets = ["x86_64-unknown-linux-gnu"] + +[dependencies] +codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +pallet-staking = { version = "4.0.0-dev", default-features = false, path = "../../../staking" } +sp-api = { version = "4.0.0-dev", default-features = false, path = "../../../../primitives/api" } +sp-runtime = { version = "7.0.0", default-features = false, path = "../../../../primitives/runtime" } +sp-weights = { version = "4.0.0", default-features = false, path = "../../../../primitives/weights" } + +[features] +default = ["std"] +std = [ + "codec/std", + "pallet-staking/std", + "sp-api/std", + "sp-runtime/std", + "sp-weights/std", +] diff --git a/frame/staking/rpc/runtime-api/README.md b/frame/staking/rpc/runtime-api/README.md new file mode 100644 index 0000000000000..a999e519f8cbf --- /dev/null +++ b/frame/staking/rpc/runtime-api/README.md @@ -0,0 +1,3 @@ +Runtime API definition for the staking pallet. + +License: Apache-2.0 diff --git a/frame/staking/rpc/runtime-api/src/lib.rs b/frame/staking/rpc/runtime-api/src/lib.rs new file mode 100644 index 0000000000000..0c563b0b2abc0 --- /dev/null +++ b/frame/staking/rpc/runtime-api/src/lib.rs @@ -0,0 +1,32 @@ +// This file is part of Substrate. + +// Copyright (C) 2019-2022 Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! Runtime API definition for the staking pallet. + +#![cfg_attr(not(feature = "std"), no_std)] + +use codec::Codec; +use sp_runtime::traits::MaybeDisplay; + +sp_api::decl_runtime_apis! { + #[api_version(1)] + pub trait StakingApi where + Balance: Codec + MaybeDisplay, + { + fn query_nominations_quota(balance: Balance) -> u32; + } +} diff --git a/frame/staking/rpc/src/lib.rs b/frame/staking/rpc/src/lib.rs new file mode 100644 index 0000000000000..b4db85bcbfe54 --- /dev/null +++ b/frame/staking/rpc/src/lib.rs @@ -0,0 +1,90 @@ +// This file is part of Substrate. + +// Copyright (C) 2019-2022 Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! RPC interface for the staking pallet. + +use std::sync::Arc; + +use codec::Codec; +use jsonrpsee::{ + core::RpcResult, + proc_macros::rpc, + types::error::{CallError, ErrorObject}, +}; +use sp_api::ProvideRuntimeApi; +use sp_blockchain::HeaderBackend; +use sp_rpc::number::NumberOrHex; +use sp_runtime::{ + generic::BlockId, + traits::{Block as BlockT, MaybeDisplay}, +}; + +pub use pallet_staking_rpc_runtime_api::StakingApi as StakingRuntimeApi; + +#[rpc(client, server)] +pub trait StakingApi { + #[method(name = "staking_nominationsQuota")] + fn query_nominations_quota(&self, balance: Balance) -> RpcResult; +} + +pub struct Staking { + client: Arc, + _marker: std::marker::PhantomData

, +} + +impl Staking { + pub fn new(client: Arc) -> Self { + Self { client, _marker: Default::default() } + } +} + +/// Error type of this RPC api. +pub enum Error { + /// The call to runtime failed. + RuntimeError, +} + +impl From for i32 { + fn from(e: Error) -> i32 { + match e { + Error::RuntimeError => 1, + } + } +} + +impl StakingApiServer for Staking +where + Block: BlockT, + C: ProvideRuntimeApi + HeaderBackend + Send + Sync + 'static, + C::Api: StakingRuntimeApi, + Balance: Codec + MaybeDisplay + Copy + TryInto + Send + Sync + 'static, +{ + fn query_nominations_quota(&self, balance: Balance) -> RpcResult { + let api = self.client.runtime_api(); + let at = BlockId::hash(self.client.info().best_hash); + + let runtime_api_result = api.query_nominations_quota(&at, balance); + + Ok(runtime_api_result.map_err(|e| { + CallError::Custom(ErrorObject::owned( + Error::RuntimeError.into(), + "Unable to query the nominations quota.", + Some(e.to_string()), + )) + })?) + } +} diff --git a/frame/staking/src/pallet/impls.rs b/frame/staking/src/pallet/impls.rs index 95a1f869a1e1c..4419dae1b8ee0 100644 --- a/frame/staking/src/pallet/impls.rs +++ b/frame/staking/src/pallet/impls.rs @@ -60,6 +60,11 @@ use super::{pallet::*, STAKING_ID}; const NPOS_MAX_ITERATIONS_COEFFICIENT: u32 = 2; impl Pallet { + /// Query nominations quota for a given balance. + pub fn query_nominations_quota(balance: BalanceOf) -> u32 { + T::NominationsQuota::get_quota_safe(balance) + } + /// The total balance that can be slashed from a stash account as of right now. pub fn slashable_balance_of(stash: &T::AccountId) -> BalanceOf { // Weight note: consider making the stake accessible through stash. From af0c52b80069d7bf421b3d43b434c8f1bbba26a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Tue, 28 Feb 2023 10:38:13 +0100 Subject: [PATCH 20/80] removes old rpc --- Cargo.lock | 2120 ++++++++++++---------- Cargo.toml | 2 - bin/node/rpc/Cargo.toml | 1 - bin/node/rpc/src/lib.rs | 3 - bin/node/runtime/Cargo.toml | 1 - bin/node/runtime/src/lib.rs | 6 - frame/staking/rpc/Cargo.toml | 24 - frame/staking/rpc/README.md | 3 - frame/staking/rpc/runtime-api/Cargo.toml | 30 - frame/staking/rpc/runtime-api/README.md | 3 - frame/staking/rpc/runtime-api/src/lib.rs | 32 - frame/staking/rpc/src/lib.rs | 90 - 12 files changed, 1115 insertions(+), 1200 deletions(-) delete mode 100644 frame/staking/rpc/Cargo.toml delete mode 100644 frame/staking/rpc/README.md delete mode 100644 frame/staking/rpc/runtime-api/Cargo.toml delete mode 100644 frame/staking/rpc/runtime-api/README.md delete mode 100644 frame/staking/rpc/runtime-api/src/lib.rs delete mode 100644 frame/staking/rpc/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index f0d9a9cb374e1..d53e7f54f409a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -18,7 +18,7 @@ version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b" dependencies = [ - "gimli 0.26.1", + "gimli 0.26.2", ] [[package]] @@ -27,7 +27,7 @@ version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97" dependencies = [ - "gimli 0.27.0", + "gimli 0.27.2", ] [[package]] @@ -42,7 +42,7 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b613b8e1e3cf911a086f53f03bf286f52fd7a7258e4fa606f0ef220d39d8877" dependencies = [ - "generic-array 0.14.4", + "generic-array 0.14.6", ] [[package]] @@ -77,20 +77,29 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" dependencies = [ - "getrandom 0.2.3", + "getrandom 0.2.8", "once_cell", "version_check", ] [[package]] name = "aho-corasick" -version = "0.7.18" +version = "0.7.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" +checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" dependencies = [ "memchr", ] +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "ansi_term" version = "0.12.1" @@ -102,30 +111,30 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.66" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6" +checksum = "224afbd727c3d6e4b90103ece64b8d1b67fbb1973b1046c2281eed3f3803f800" [[package]] name = "approx" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "072df7202e63b127ab55acfe16ce97013d5b97bf160489336d3f1840fd78e99e" +checksum = "cab112f0a86d568ea0e627cc1d6be74a1e9cd55214684db5561995f6dad897c6" dependencies = [ "num-traits", ] [[package]] name = "arbitrary" -version = "1.0.0" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "698b65a961a9d730fb45b6b0327e20207810c9f61ee421b082b27ba003f49e2b" +checksum = "3e90af4de65aa7b293ef2d09daff88501eb254f58edde2e1ac02c82d873eadad" [[package]] name = "array-bytes" -version = "4.1.0" +version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a913633b0c922e6b745072795f50d90ebea78ba31a57e2ac8c2fc7b50950949" +checksum = "f52f63c5c1316a16a4b35eaac8b76a98248961a533f061684cb2a7cb0eafb6c6" [[package]] name = "arrayref" @@ -147,17 +156,17 @@ checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" [[package]] name = "asn1_der" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d6e24d2cce90c53b948c46271bfb053e4bdc2db9b5d3f65e20f8cf28a1b7fc3" +checksum = "e22d1f4b888c298a027c99dc9048015fac177587de20fc30232a057dfbe24a21" [[package]] name = "assert_cmd" -version = "2.0.6" +version = "2.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba45b8163c49ab5f972e59a8a5a03b6d2972619d486e19ec9fe744f7c2753d3c" +checksum = "9834fcc22e0874394a010230586367d4a3e9f11b560f469262678547e1d2575e" dependencies = [ - "bstr 1.0.1", + "bstr", "doc-comment", "predicates", "predicates-core", @@ -173,9 +182,9 @@ checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" [[package]] name = "async-channel" -version = "1.6.1" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2114d64672151c0c5eaa5e131ec84a74f06e1e559830dabba01ca30605d66319" +checksum = "cf46fee83e5ccffc220104713af3292ff9bc7c64c7de289f66dae8e38d826833" dependencies = [ "concurrent-queue", "event-listener", @@ -184,86 +193,79 @@ dependencies = [ [[package]] name = "async-executor" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb877970c7b440ead138f6321a3b5395d6061183af779340b65e20c0fede9146" +checksum = "17adb73da160dfb475c183343c8cccd80721ea5a605d3eb57125f0a7b7a92d0b" dependencies = [ + "async-lock", "async-task", "concurrent-queue", "fastrand", "futures-lite", - "once_cell", - "vec-arena", + "slab", ] [[package]] name = "async-global-executor" -version = "2.0.2" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9586ec52317f36de58453159d48351bc244bc24ced3effc1fce22f3d48664af6" +checksum = "f1b6f5d7df27bd294849f8eec66ecfc63d11814df7a4f5d74168a2394467b776" dependencies = [ "async-channel", "async-executor", "async-io", - "async-mutex", + "async-lock", "blocking", "futures-lite", - "num_cpus", "once_cell", ] [[package]] name = "async-io" -version = "1.6.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a811e6a479f2439f0c04038796b5cfb3d2ad56c230e0f2d3f7b04d68cfee607b" +checksum = "8c374dda1ed3e7d8f0d9ba58715f924862c63eae6849c92d3a18e7fbde9e2794" dependencies = [ + "async-lock", + "autocfg", "concurrent-queue", "futures-lite", "libc", "log", - "once_cell", "parking", "polling", "slab", "socket2", "waker-fn", - "winapi", + "windows-sys 0.42.0", ] [[package]] name = "async-lock" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e97a171d191782fba31bb902b14ad94e24a68145032b7eedf871ab0bc0d077b6" -dependencies = [ - "event-listener", -] - -[[package]] -name = "async-mutex" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479db852db25d9dbf6204e6cb6253698f175c15726470f78af0d918e99d6156e" +checksum = "c8101efe8695a6c17e02911402145357e718ac92d3ff88ae8419e84b1707b685" dependencies = [ "event-listener", + "futures-lite", ] [[package]] name = "async-stream" -version = "0.3.2" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "171374e7e3b2504e0e5236e3b59260560f9fe94bfe9ac39ba5e4e929c5590625" +checksum = "ad445822218ce64be7a341abfb0b1ea43b5c23aa83902542a4542e78309d8e5e" dependencies = [ "async-stream-impl", "futures-core", + "pin-project-lite 0.2.9", ] [[package]] name = "async-stream-impl" -version = "0.3.2" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "648ed8c8d2ce5409ccd57453d9d1b214b342a0d69376a6feda1fd6cae3299308" +checksum = "e4655ae1a7b0cdf149156f780c5bf3f1352bc53cbd9e0a361a7ef7b22947e965" dependencies = [ "proc-macro2", "quote", @@ -272,15 +274,15 @@ dependencies = [ [[package]] name = "async-task" -version = "4.0.3" +version = "4.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91831deabf0d6d7ec49552e489aed63b7456a7a3c46cff62adad428110b0af0" +checksum = "7a40729d2133846d9ed0ea60a8b9541bccddab49cd30f0715a1da672fe9a2524" [[package]] name = "async-trait" -version = "0.1.59" +version = "0.1.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e6e93155431f3931513b243d371981bb2770112b370c82745a1d19d2f99364" +checksum = "1cd7fce9ba8c3c042128ce72d8b2ddbf3a05747efb67ea0313c635e10bda47a2" dependencies = [ "proc-macro2", "quote", @@ -289,9 +291,9 @@ dependencies = [ [[package]] name = "asynchronous-codec" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0de5164e5edbf51c45fb8c2d9664ae1c095cce1b265ecf7569093c0d66ef690" +checksum = "06a0daa378f5fd10634e44b0a29b2a87b890657658e072a30d6f26e57ddee182" dependencies = [ "bytes", "futures-sink", @@ -302,9 +304,9 @@ dependencies = [ [[package]] name = "atomic-waker" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "065374052e7df7ee4047b1160cca5e1467a12351a40b3da123c870ba0b8eda2a" +checksum = "debc29dde2e69f9e47506b525f639ed42300fc014a3e007832592448fa8e4599" [[package]] name = "atty" @@ -312,7 +314,7 @@ version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" dependencies = [ - "hermit-abi", + "hermit-abi 0.1.19", "libc", "winapi", ] @@ -333,16 +335,16 @@ dependencies = [ "cc", "cfg-if", "libc", - "miniz_oxide 0.6.2", - "object 0.30.0", + "miniz_oxide", + "object 0.30.3", "rustc-demangle", ] [[package]] name = "base-x" -version = "0.2.8" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4521f3e3d031370679b3b140beb36dfe4801b09ac77e30c61941f97df3ef28b" +checksum = "4cbbc9d0964165b47557570cce6c952866c2678457aca742aafc9fb771d30270" [[package]] name = "base16ct" @@ -358,21 +360,36 @@ checksum = "6107fe1be6682a68940da878d9e9f5e90ca5745b3dec9fd1bb393c8777d4f581" [[package]] name = "base64" -version = "0.13.0" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + +[[package]] +name = "base64" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" +checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" [[package]] name = "base64ct" -version = "1.5.1" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bdca834647821e0b13d9539a8634eb62d3501b6b6c2cec1722786ee6671b851" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" + +[[package]] +name = "basic-toml" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e819b667739967cd44d308b8c7b71305d8bb0729ac44a248aa08f33d01950b4" +dependencies = [ + "serde", +] [[package]] name = "beef" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bed554bd50246729a1ec158d08aa3235d1b69d94ad120ebe187e28894787e736" +checksum = "3a8241f3ebb85c056b509d4327ad0358fbbba6ffb340bf388f26350aeda225b1" dependencies = [ "serde", ] @@ -446,7 +463,7 @@ name = "beefy-merkle-tree" version = "4.0.0-dev" dependencies = [ "array-bytes", - "env_logger", + "env_logger 0.9.3", "log", "sp-api", "sp-beefy", @@ -464,9 +481,9 @@ dependencies = [ [[package]] name = "bindgen" -version = "0.60.1" +version = "0.64.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "062dddbc1ba4aca46de6338e2bf87771414c335f7b2f2036e8f3e9befebf88e6" +checksum = "c4243e6031260db77ede97ad86c27e501d646a27ab57b59a574f725d98ab1fb4" dependencies = [ "bitflags", "cexpr", @@ -479,6 +496,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", + "syn", ] [[package]] @@ -489,9 +507,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitvec" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1489fcb93a5bb47da0462ca93ad252ad6af2145cce58d10d46a83931ba9f016b" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" dependencies = [ "funty", "radium", @@ -501,18 +519,18 @@ dependencies = [ [[package]] name = "blake2" -version = "0.10.4" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9cf849ee05b2ee5fba5e36f97ff8ec2533916700fc0758d40d92136a42f3388" +checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" dependencies = [ - "digest 0.10.3", + "digest 0.10.6", ] [[package]] name = "blake2b_simd" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72936ee4afc7f8f736d1c38383b56480b5497b4617b4a77bdbf1d2ababc76127" +checksum = "3c2f0dc9a68c6317d884f97cc36cf5a3d20ba14ce404227df55e1af708ab04bc" dependencies = [ "arrayref", "arrayvec 0.7.2", @@ -521,9 +539,9 @@ dependencies = [ [[package]] name = "blake2s_simd" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db539cc2b5f6003621f1cd9ef92d7ded8ea5232c7de0f9faa2de251cd98730d4" +checksum = "6637f448b9e61dfadbdcbae9a885fadee1f3eaffb1f8d3c1965d3ade8bdfd44f" dependencies = [ "arrayref", "arrayvec 0.7.2", @@ -532,9 +550,9 @@ dependencies = [ [[package]] name = "blake3" -version = "1.3.1" +version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a08e53fc5a564bb15bfe6fae56bd71522205f1f91893f9c0116edad6496c183f" +checksum = "42ae2468a89544a466886840aa467a25b766499f4f04bf7d9fcd10ecee9fccef" dependencies = [ "arrayref", "arrayvec 0.7.2", @@ -561,16 +579,16 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "generic-array 0.14.4", + "generic-array 0.14.6", ] [[package]] name = "block-buffer" -version = "0.10.0" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1d36a02058e76b040de25a4464ba1c80935655595b661505c8b39b664828b95" +checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" dependencies = [ - "generic-array 0.14.4", + "generic-array 0.14.6", ] [[package]] @@ -584,16 +602,16 @@ dependencies = [ [[package]] name = "blocking" -version = "1.0.2" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5e170dbede1f740736619b776d7251cb1b9095c435c34d8ca9f57fcd2f335e9" +checksum = "3c67b173a56acffd6d2326fb7ab938ba0b00a71480e14902b2591c87bc5741e8" dependencies = [ "async-channel", + "async-lock", "async-task", "atomic-waker", "fastrand", "futures-lite", - "once_cell", ] [[package]] @@ -604,21 +622,9 @@ checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" [[package]] name = "bstr" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a40b47ad93e1a5404e6c18dec46b628214fee441c70f4ab5d6942142cc268a3d" -dependencies = [ - "lazy_static", - "memchr", - "regex-automata", - "serde", -] - -[[package]] -name = "bstr" -version = "1.0.1" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fca0852af221f458706eb0725c03e4ed6c46af9ac98e6a689d5e634215d594dd" +checksum = "5ffdb39cb703212f3c11973452c2861b972f757b021158f3516ba10f2fa8b2c1" dependencies = [ "memchr", "once_cell", @@ -637,15 +643,15 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.6.1" +version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63396b8a4b9de3f4fdfb320ab6080762242f66a8ef174c49d8e19b674db4cdbe" +checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" [[package]] name = "byte-slice-cast" -version = "1.0.0" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65c1bf4a04a88c54f589125563643d773f3254b5c38571395e2b591c693bbc81" +checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" [[package]] name = "byte-tools" @@ -661,9 +667,9 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "bytes" -version = "1.1.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" +checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" [[package]] name = "bzip2-sys" @@ -676,26 +682,20 @@ dependencies = [ "pkg-config", ] -[[package]] -name = "cache-padded" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "631ae5198c9be5e753e5cc215e1bd73c2b466a3565173db433f52bb9d3e66dba" - [[package]] name = "camino" -version = "1.0.4" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4648c6d00a709aa069a236adcaae4f605a6241c72bf5bee79331a4b625921a9" +checksum = "6031a462f977dd38968b6f23378356512feeace69cef817e1a4475108093cec3" dependencies = [ "serde", ] [[package]] name = "cargo-platform" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0226944a63d1bf35a3b5f948dd7c59e263db83695c9e8bffc4037de02e30f1d7" +checksum = "cbdb825da8a5df079a43676dbe042702f1707b1109f713a01420fbb4cc71fa27" dependencies = [ "serde", ] @@ -708,25 +708,22 @@ checksum = "4acbb09d9ee8e23699b9634375c72795d095bf268439da88562cf9b501f181fa" dependencies = [ "camino", "cargo-platform", - "semver 1.0.4", + "semver 1.0.16", "serde", "serde_json", ] [[package]] name = "cast" -version = "0.2.3" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b9434b9a5aa1450faa3f9cb14ea0e8c53bb5d2b3c1bfd1ab4fc03e9f33fbfb0" -dependencies = [ - "rustc_version 0.2.3", -] +checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.0.73" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" +checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" dependencies = [ "jobserver", ] @@ -791,7 +788,7 @@ name = "chain-spec-builder" version = "2.0.0" dependencies = [ "ansi_term", - "clap 4.0.11", + "clap 4.1.7", "node-cli", "rand 0.8.5", "sc-chain-spec", @@ -802,14 +799,16 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.19" +version = "0.4.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" +checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" dependencies = [ - "libc", + "iana-time-zone", + "js-sys", "num-integer", "num-traits", "time", + "wasm-bindgen", "winapi", ] @@ -832,7 +831,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" dependencies = [ - "generic-array 0.14.4", + "generic-array 0.14.6", ] [[package]] @@ -846,9 +845,9 @@ dependencies = [ [[package]] name = "clang-sys" -version = "1.2.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "853eda514c284c2287f4bf20ae614f8781f40a81d32ecda6e91449304dfe077c" +checksum = "77ed9a53e5d4d9c573ae844bfac6872b159cb1d1585a83b29e7a64b7eef7332a" dependencies = [ "glob", "libc", @@ -868,14 +867,14 @@ dependencies = [ [[package]] name = "clap" -version = "4.0.11" +version = "4.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ed45cc2c62a3eff523e718d8576ba762c83a3146151093283ac62ae11933a73" +checksum = "2f3061d6db6d8fcbbd4b05e057f2acace52e64e96b498c08c2d7a4e65addd340" dependencies = [ - "atty", "bitflags", "clap_derive", "clap_lex", + "is-terminal", "once_cell", "strsim", "termcolor", @@ -883,18 +882,18 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.0.5" +version = "4.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96b0fba905b035a30d25c1b585bf1171690712fbb0ad3ac47214963aa4acc36c" +checksum = "501ff0a401473ea1d4c3b125ff95506b62c5bc5768d818634195fbb7c4ad5ff4" dependencies = [ - "clap 4.0.11", + "clap 4.1.7", ] [[package]] name = "clap_derive" -version = "4.0.10" +version = "4.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db342ce9fda24fb191e2ed4e102055a4d381c1086a06630174cd8da8d5d917ce" +checksum = "34d122164198950ba84a918270a3bb3f7ededd25e15f7451673d986f55bd2667" dependencies = [ "heck", "proc-macro-error", @@ -905,9 +904,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.3.0" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d4198f73e42b4936b35b5bb248d81d2b595ecb170da0bac7655c54eedfa8da8" +checksum = "350b9cf31731f9957399229e9b2adc51eeabdfbe9d71d9a0552275fd12710d09" dependencies = [ "os_str_bytes", ] @@ -924,9 +923,9 @@ dependencies = [ [[package]] name = "comfy-table" -version = "6.0.0" +version = "6.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "121d8a5b0346092c18a4b2fd6f620d7a06f0eb7ac0a45860939a0884bc579c56" +checksum = "6e7b787b0dc42e8111badfdbe4c3059158ccb2db8780352fa1b01e8ccf45cc4d" dependencies = [ "strum", "strum_macros", @@ -935,24 +934,24 @@ dependencies = [ [[package]] name = "concurrent-queue" -version = "1.2.2" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30ed07550be01594c6026cff2a1d7fe9c8f683caa798e12b68694ac9e88286a3" +checksum = "c278839b831783b70278b14df4d45e1beb1aad306c07bb796637de9a0e323e8e" dependencies = [ - "cache-padded", + "crossbeam-utils", ] [[package]] name = "const-oid" -version = "0.9.0" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "722e23542a15cea1f65d4a1419c4cfd7a26706c70871a13a04238ca3f40f1661" +checksum = "520fbf3c07483f94e3e3ca9d0cfd913d7718ef2483d2cfd91c0d9e91474ab913" [[package]] name = "constant_time_eq" -version = "0.1.5" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" +checksum = "f3ad85c1f65dc7b37604eb0e89748faf0b9653065f2a8ef69f96a687ec1e9279" [[package]] name = "core-foundation" @@ -981,43 +980,36 @@ dependencies = [ [[package]] name = "cpp_demangle" -version = "0.3.2" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44919ecaf6f99e8e737bc239408931c9a01e9a6c74814fee8242dd2506b65390" +checksum = "eeaa953eaad386a53111e47172c2fedba671e5684c8dd601a5f474f4f118710f" dependencies = [ "cfg-if", - "glob", ] [[package]] name = "cpufeatures" -version = "0.2.1" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95059428f66df56b63431fdb4e1947ed2190586af5c5a8a8b71122bdf5a7f469" +checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" dependencies = [ "libc", ] -[[package]] -name = "cpuid-bool" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" - [[package]] name = "cranelift-bforest" -version = "0.88.0" +version = "0.88.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b27bbd3e6c422cf6282b047bcdd51ecd9ca9f3497a3be0132ffa08e509b824b0" +checksum = "52056f6d0584484b57fa6c1a65c1fcb15f3780d8b6a758426d9e3084169b2ddd" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.88.0" +version = "0.88.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "872f5d4557a411b087bd731df6347c142ae1004e6467a144a7e33662e5715a01" +checksum = "18fed94c8770dc25d01154c3ffa64ed0b3ba9d583736f305fed7beebe5d9cf74" dependencies = [ "arrayvec 0.7.2", "bumpalo", @@ -1026,7 +1018,7 @@ dependencies = [ "cranelift-codegen-shared", "cranelift-entity", "cranelift-isle", - "gimli 0.26.1", + "gimli 0.26.2", "log", "regalloc2", "smallvec", @@ -1035,33 +1027,33 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.88.0" +version = "0.88.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21b49fdebb29c62c1fc4da1eeebd609e9d530ecde24a9876def546275f73a244" +checksum = "1c451b81faf237d11c7e4f3165eeb6bac61112762c5cfe7b4c0fb7241474358f" dependencies = [ "cranelift-codegen-shared", ] [[package]] name = "cranelift-codegen-shared" -version = "0.88.0" +version = "0.88.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fc0c091e2db055d4d7f6b7cec2d2ead286bcfaea3357c6a52c2a2613a8cb5ac" +checksum = "e7c940133198426d26128f08be2b40b0bd117b84771fd36798969c4d712d81fc" [[package]] name = "cranelift-entity" -version = "0.88.0" +version = "0.88.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "354a9597be87996c9b278655e68b8447f65dd907256855ad773864edee8d985c" +checksum = "87a0f1b2fdc18776956370cf8d9b009ded3f855350c480c1c52142510961f352" dependencies = [ "serde", ] [[package]] name = "cranelift-frontend" -version = "0.88.0" +version = "0.88.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cd8dd3fb8b82c772f4172e87ae1677b971676fffa7c4e3398e3047e650a266b" +checksum = "34897538b36b216cc8dd324e73263596d51b8cf610da6498322838b2546baf8a" dependencies = [ "cranelift-codegen", "log", @@ -1071,15 +1063,15 @@ dependencies = [ [[package]] name = "cranelift-isle" -version = "0.88.0" +version = "0.88.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b82527802b1f7d8da288adc28f1dc97ea52943f5871c041213f7b5035ac698a7" +checksum = "1b2629a569fae540f16a76b70afcc87ad7decb38dc28fa6c648ac73b51e78470" [[package]] name = "cranelift-native" -version = "0.88.0" +version = "0.88.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c30ba8b910f1be023af0c39109cb28a8809734942a6b3eecbf2de8993052ea5e" +checksum = "20937dab4e14d3e225c5adfc9c7106bafd4ac669bdb43027b911ff794c6fb318" dependencies = [ "cranelift-codegen", "libc", @@ -1088,9 +1080,9 @@ dependencies = [ [[package]] name = "cranelift-wasm" -version = "0.88.0" +version = "0.88.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "776a8916d201894aca9637a20814f1e11abc62acd5cfbe0b4eb2e63922756971" +checksum = "80fc2288957a94fd342a015811479de1837850924166d1f1856d8406e6f3609b" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -1104,18 +1096,18 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.2.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" dependencies = [ "cfg-if", ] [[package]] name = "criterion" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1604dafd25fba2fe2d5895a9da139f8dc9b319a5fe5354ca137cbbce4e178d10" +checksum = "b01d6de93b2b6c65e17c634a26653a29d107b3c98c607c765bf38d041531cd8f" dependencies = [ "atty", "cast", @@ -1141,9 +1133,9 @@ dependencies = [ [[package]] name = "criterion-plot" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d00996de9f2f7559f7f4dc286073197f83e92256a59ed395f9aac01fe717da57" +checksum = "2673cc8207403546f45f5fd319a974b1e6983ad1a3ee7e6041650013be041876" dependencies = [ "cast", "itertools", @@ -1151,9 +1143,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.0" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dca26ee1f8d361640700bde38b2c37d8c22b3ce2d360e1fc1c74ea4b0aa7d775" +checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521" dependencies = [ "cfg-if", "crossbeam-utils", @@ -1161,9 +1153,9 @@ dependencies = [ [[package]] name = "crossbeam-deque" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" +checksum = "715e8152b692bba2d374b53d4875445368fdf21a94751410af607a5ac677d1fc" dependencies = [ "cfg-if", "crossbeam-epoch", @@ -1172,25 +1164,24 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.5" +version = "0.9.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec02e091aa634e2c3ada4a392989e7c3116673ef0ac5b72232439094d73b7fd" +checksum = "01a9af1f4c2ef74bb8aa1f7e19706bc72d03598c8a570bb5de72243c7a9d9d5a" dependencies = [ + "autocfg", "cfg-if", "crossbeam-utils", - "lazy_static", - "memoffset", + "memoffset 0.7.1", "scopeguard", ] [[package]] name = "crossbeam-utils" -version = "0.8.8" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bf124c720b7686e3c2663cf54062ab0f68a88af2fb6a030e87e30bf721fcb38" +checksum = "4fb766fa798726286dbbb842f174001dab8abc7b627a1dd86e0b7222a95d929f" dependencies = [ "cfg-if", - "lazy_static", ] [[package]] @@ -1201,23 +1192,23 @@ checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" [[package]] name = "crypto-bigint" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f2b443d17d49dad5ef0ede301c3179cc923b8822f3393b4d2c28c269dd4a122" +checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" dependencies = [ - "generic-array 0.14.4", - "rand_core 0.6.2", + "generic-array 0.14.6", + "rand_core 0.6.4", "subtle", "zeroize", ] [[package]] name = "crypto-common" -version = "0.1.3" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57952ca27b5e3606ff4dd79b0020231aaf9d6aa76dc05fd30137538c50bd3ce8" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ - "generic-array 0.14.4", + "generic-array 0.14.6", "typenum", ] @@ -1227,7 +1218,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" dependencies = [ - "generic-array 0.14.4", + "generic-array 0.14.6", "subtle", ] @@ -1237,19 +1228,18 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" dependencies = [ - "generic-array 0.14.4", + "generic-array 0.14.6", "subtle", ] [[package]] name = "csv" -version = "1.1.6" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22813a6dc45b335f9bade10bf7271dc477e81113e89eb251a0bc2a8a81c536e1" +checksum = "af91f40b7355f82b0a891f50e70399475945bb0b0da4f1700ce60761c9d3e359" dependencies = [ - "bstr 0.2.15", "csv-core", - "itoa 0.4.8", + "itoa", "ryu", "serde", ] @@ -1265,9 +1255,9 @@ dependencies = [ [[package]] name = "ctor" -version = "0.1.19" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8f45d9ad417bcef4817d614a501ab55cdd96a6fdb24f49aab89a54acfd66b19" +checksum = "6d2301688392eb071b0bf1a37be05c469d3cc4dbbd95df672fe28ab021e6a096" dependencies = [ "quote", "syn", @@ -1284,9 +1274,9 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "2.1.2" +version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "434e1720189a637d44fe464f4df1e6eb900b4835255b14354497c78af37d9bb8" +checksum = "4a9b85542f99a2dfa2a1b8e192662741c9859a846b296bef1c92ef9b58b5a216" dependencies = [ "byteorder", "digest 0.8.1", @@ -1297,9 +1287,9 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "3.0.2" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f627126b946c25a4638eec0ea634fc52506dea98db118aae985118ce7c3d723f" +checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" dependencies = [ "byteorder", "digest 0.9.0", @@ -1310,22 +1300,23 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "4.0.0-pre.1" +version = "4.0.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4033478fbf70d6acf2655ac70da91ee65852d69daf7a67bf7a2f518fb47aafcf" +checksum = "8da00a7a9a4eb92a0a0f8e75660926d48f0d0f3c537e455c457bcdaa1e16b1ac" dependencies = [ - "byteorder", - "digest 0.9.0", - "rand_core 0.6.2", + "cfg-if", + "fiat-crypto", + "packed_simd_2", + "platforms 3.0.2", "subtle", "zeroize", ] [[package]] name = "cxx" -version = "1.0.80" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b7d4e43b25d3c994662706a1d4fcfc32aaa6afd287502c111b237093bb23f3a" +checksum = "86d3488e7665a7a483b57e25bdd90d0aeb2bc7608c8d0346acf2ad3f1caf1d62" dependencies = [ "cc", "cxxbridge-flags", @@ -1335,9 +1326,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.80" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84f8829ddc213e2c1368e51a2564c552b65a8cb6a28f31e576270ac81d5e5827" +checksum = "48fcaf066a053a41a81dfb14d57d99738b767febb8b735c3016e469fac5da690" dependencies = [ "cc", "codespan-reporting", @@ -1350,15 +1341,15 @@ dependencies = [ [[package]] name = "cxxbridge-flags" -version = "1.0.80" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e72537424b474af1460806647c41d4b6d35d09ef7fe031c5c2fa5766047cc56a" +checksum = "a2ef98b8b717a829ca5603af80e1f9e2e48013ab227b68ef37872ef84ee479bf" [[package]] name = "cxxbridge-macro" -version = "1.0.80" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "309e4fb93eed90e1e14bea0da16b209f81813ba9fc7830c20ed151dd7bc0a4d7" +checksum = "086c685979a698443656e5cf7856c95c642295a38599f12fb1ff76fb28d19892" dependencies = [ "proc-macro2", "quote", @@ -1367,15 +1358,15 @@ dependencies = [ [[package]] name = "data-encoding" -version = "2.3.2" +version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ee2393c4a91429dffb4bedf19f4d6abf27d8a732c8ce4980305d782e5426d57" +checksum = "23d8666cb01533c39dde32bcbab8e227b4ed6679b2c925eba05feabea39508fb" [[package]] name = "data-encoding-macro" -version = "0.1.10" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a94feec3d2ba66c0b6621bca8bc6f68415b1e5c69af3586fdd0af9fd9f29b17" +checksum = "86927b7cd2fe88fa698b87404b287ab98d1a0063a34071d92e575b72d3029aca" dependencies = [ "data-encoding", "data-encoding-macro-internal", @@ -1383,9 +1374,9 @@ dependencies = [ [[package]] name = "data-encoding-macro-internal" -version = "0.1.9" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f83e699727abca3c56e187945f303389590305ab2f0185ea445aa66e8d5f2a" +checksum = "a5bbed42daaa95e780b60a50546aa345b8413a1e46f9a40a12907d3598f038db" dependencies = [ "data-encoding", "syn", @@ -1393,9 +1384,9 @@ dependencies = [ [[package]] name = "der" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13dd2ae565c0a381dde7fade45fce95984c568bdcb4700a4fdbe3175e0380b2f" +checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de" dependencies = [ "const-oid", "zeroize", @@ -1414,9 +1405,9 @@ dependencies = [ [[package]] name = "diff" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e25ea47919b1560c4e3b7fe0aaab9becf5b84a10325ddf7db0f0ba5e1026499" +checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" [[package]] name = "difflib" @@ -1439,16 +1430,16 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" dependencies = [ - "generic-array 0.14.4", + "generic-array 0.14.6", ] [[package]] name = "digest" -version = "0.10.3" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2fb860ca6fafa5552fb6d0e816a69c8e49f0908bf524e30a90d97c85892d506" +checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" dependencies = [ - "block-buffer 0.10.0", + "block-buffer 0.10.3", "crypto-common", "subtle", ] @@ -1474,9 +1465,9 @@ dependencies = [ [[package]] name = "dirs-sys" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03d86534ed367a67548dc68113a0f5db55432fdfbb6e6f9d77704397d95d5780" +checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" dependencies = [ "libc", "redox_users", @@ -1496,9 +1487,9 @@ dependencies = [ [[package]] name = "dissimilar" -version = "1.0.2" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc4b29f4b9bb94bf267d57269fd0706d343a160937108e9619fe380645428abb" +checksum = "210ec60ae7d710bed8683e333e9d2855a8a56a3e9892b38bad3bb0d4d29b0d5e" [[package]] name = "dns-parser" @@ -1530,9 +1521,9 @@ checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" [[package]] name = "dtoa" -version = "1.0.2" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5caaa75cbd2b960ff1e5392d2cfb1f44717fffe12fc1f32b7b5d1267f99732a6" +checksum = "c00704156a7de8df8da0911424e30c2049957b0a714542a44e05fe693dd85313" [[package]] name = "dyn-clonable" @@ -1557,15 +1548,15 @@ dependencies = [ [[package]] name = "dyn-clone" -version = "1.0.5" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21e50f3adc76d6a43f5ed73b698a87d0760ca74617f60f7c3b879003536fdd28" +checksum = "68b0cf012f1230e43cd00ebb729c6bb58707ecfa8ad08b52ef3a4ccd2697fc30" [[package]] name = "ecdsa" -version = "0.14.7" +version = "0.14.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85789ce7dfbd0f0624c07ef653a08bb2ebf43d3e16531361f46d36dd54334fed" +checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" dependencies = [ "der", "elliptic-curve", @@ -1575,9 +1566,9 @@ dependencies = [ [[package]] name = "ed25519" -version = "1.5.2" +version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e9c280362032ea4203659fc489832d0204ef09f247a0506f170dafcac08c369" +checksum = "91cff35c70bba8a626e3185d8cd48cc11b5437e1a5bcd15b9b5fa3c64b6dfee7" dependencies = [ "signature", ] @@ -1588,11 +1579,11 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" dependencies = [ - "curve25519-dalek 3.0.2", + "curve25519-dalek 3.2.0", "ed25519", "rand 0.7.3", "serde", - "sha2 0.9.8", + "sha2 0.9.9", "zeroize", ] @@ -1602,19 +1593,19 @@ version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c24f403d068ad0b359e577a77f92392118be3f3c927538f2bb544a5ecd828c6" dependencies = [ - "curve25519-dalek 3.0.2", - "hashbrown 0.12.3", + "curve25519-dalek 3.2.0", + "hashbrown", "hex", - "rand_core 0.6.2", - "sha2 0.9.8", + "rand_core 0.6.4", + "sha2 0.9.9", "zeroize", ] [[package]] name = "either" -version = "1.6.1" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" +checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" [[package]] name = "elliptic-curve" @@ -1625,11 +1616,11 @@ dependencies = [ "base16ct", "crypto-bigint", "der", - "digest 0.10.3", + "digest 0.10.6", "ff", - "generic-array 0.14.4", + "generic-array 0.14.6", "group", - "rand_core 0.6.2", + "rand_core 0.6.4", "sec1", "subtle", "zeroize", @@ -1669,9 +1660,9 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.9.0" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b2cf0344971ee6c64c31be0d530793fba457d322dfec2810c453d0ef228f9c3" +checksum = "a12e6657c4c97ebab115a42dcee77225f7f482cdd841cf7088c657a42e9e00e7" dependencies = [ "atty", "humantime", @@ -1680,11 +1671,24 @@ dependencies = [ "termcolor", ] +[[package]] +name = "env_logger" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" +dependencies = [ + "humantime", + "is-terminal", + "log", + "regex", + "termcolor", +] + [[package]] name = "environmental" -version = "1.1.3" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b91989ae21441195d7d9b9993a2f9295c7e1a8c96255d8b729accddc124797" +checksum = "e48c92028aaa870e83d51c64e5d4e0b6981b360c522198c23959f219a4e1b15b" [[package]] name = "errno" @@ -1699,19 +1703,19 @@ dependencies = [ [[package]] name = "errno-dragonfly" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" dependencies = [ - "gcc", + "cc", "libc", ] [[package]] name = "event-listener" -version = "2.5.1" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7531096570974c3a9dcf9e4b8e1cede1ec26cf5046219fb3b9d897503b9be59" +checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "exit-future" @@ -1736,9 +1740,9 @@ checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" [[package]] name = "fastrand" -version = "1.7.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3fcf0cee53519c866c09b5de1f6c56ff9d647101f81c1964fa632e148896cdf" +checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" dependencies = [ "instant", ] @@ -1754,41 +1758,47 @@ dependencies = [ [[package]] name = "ff" -version = "0.12.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df689201f395c6b90dfe87127685f8dbfc083a5e779e613575d8bd7314300c3e" +checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" dependencies = [ - "rand_core 0.6.2", + "rand_core 0.6.4", "subtle", ] +[[package]] +name = "fiat-crypto" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a214f5bb88731d436478f3ae1f8a277b62124089ba9fb67f4f93fb100ef73c90" + [[package]] name = "file-per-thread-logger" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21e16290574b39ee41c71aeb90ae960c504ebaf1e2a1c87bd52aa56ed6e1a02f" +checksum = "84f2e425d9790201ba4af4630191feac6dcc98765b118d4d18e91d23c2353866" dependencies = [ - "env_logger", + "env_logger 0.10.0", "log", ] [[package]] name = "filetime" -version = "0.2.16" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0408e2626025178a6a7f7ffc05a25bc47103229f19c113755de7bf63816290c" +checksum = "8a3de6e8d11b22ff9edc6d916f890800597d60f8b2da1caf2955c274638d6412" dependencies = [ "cfg-if", "libc", "redox_syscall", - "winapi", + "windows-sys 0.45.0", ] [[package]] name = "finality-grandpa" -version = "0.16.0" +version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b22349c6a11563a202d95772a68e0fcf56119e74ea8a2a19cf2301460fcd0df5" +checksum = "e24e6c429951433ccb7c87fd528c60084834dcd14763182c1f83291bcde24c34" dependencies = [ "either", "futures", @@ -1815,21 +1825,19 @@ dependencies = [ [[package]] name = "fixedbitset" -version = "0.4.0" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "398ea4fabe40b9b0d885340a2a991a44c8a645624075ad966d21f88688e2b69e" +checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flate2" -version = "1.0.20" +version = "1.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd3aec53de10fe96d7d8c565eb17f2c687bb5518a2ec453b5b1252964526abe0" +checksum = "a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841" dependencies = [ - "cfg-if", "crc32fast", - "libc", "libz-sys", - "miniz_oxide 0.4.4", + "miniz_oxide", ] [[package]] @@ -1856,19 +1864,18 @@ dependencies = [ [[package]] name = "form_urlencoded" -version = "1.0.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" +checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" dependencies = [ - "matches", "percent-encoding", ] [[package]] name = "fragile" -version = "1.2.1" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85dcb89d2b10c5f6133de2efd8c11959ce9dbb46a2f7a4cab208c4eeda6ce1ab" +checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" [[package]] name = "frame-benchmarking" @@ -1902,7 +1909,7 @@ dependencies = [ "Inflector", "array-bytes", "chrono", - "clap 4.0.11", + "clap 4.1.7", "comfy-table", "frame-benchmarking", "frame-support", @@ -1979,7 +1986,7 @@ dependencies = [ name = "frame-election-solution-type-fuzzer" version = "2.0.0-alpha.5" dependencies = [ - "clap 4.0.11", + "clap 4.1.7", "frame-election-provider-solution-type", "frame-election-provider-support", "frame-support", @@ -2222,9 +2229,9 @@ dependencies = [ [[package]] name = "fs_extra" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2022715d62ab30faffd124d40b76f4134a550a87792276512b18d63272333394" +checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" [[package]] name = "funty" @@ -2234,9 +2241,9 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "futures" -version = "0.3.21" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f73fe65f54d1e12b726f517d3e2135ca3125a437b6d998caf1962961f7172d9e" +checksum = "13e2792b0ff0340399d58445b88fd9770e3489eff258a4cbc1523418f12abf84" dependencies = [ "futures-channel", "futures-core", @@ -2249,9 +2256,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.21" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3083ce4b914124575708913bca19bfe887522d6e2e6d0952943f5eac4a74010" +checksum = "2e5317663a9089767a1ec00a487df42e0ca174b61b4483213ac24448e4664df5" dependencies = [ "futures-core", "futures-sink", @@ -2259,15 +2266,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.21" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c09fd04b7e4073ac7156a9539b57a484a8ea920f79c7c675d05d289ab6110d3" +checksum = "ec90ff4d0fe1f57d600049061dc6bb68ed03c7d2fbd697274c41805dcb3f8608" [[package]] name = "futures-executor" -version = "0.3.21" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9420b90cfa29e327d0429f19be13e7ddb68fa1cccb09d65e5706b8c7a749b8a6" +checksum = "e8de0a35a6ab97ec8869e32a2473f4b1324459e14c29275d14b10cb1fd19b50e" dependencies = [ "futures-core", "futures-task", @@ -2277,15 +2284,15 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.21" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc4045962a5a5e935ee2fdedaa4e08284547402885ab326734432bed5d12966b" +checksum = "bfb8371b6fb2aeb2d280374607aeabfc99d95c72edfe51692e42d3d7f0d08531" [[package]] name = "futures-lite" -version = "1.11.3" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4481d0cd0de1d204a4fa55e7d45f07b1d958abcb06714b3446438e2eff695fb" +checksum = "7694489acd39452c77daa48516b894c153f192c3578d5a839b62c58099fcbf48" dependencies = [ "fastrand", "futures-core", @@ -2298,9 +2305,9 @@ dependencies = [ [[package]] name = "futures-macro" -version = "0.3.21" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33c1e13800337f4d4d7a316bf45a567dbcb6ffe087f16424852d97e97a91f512" +checksum = "95a73af87da33b5acf53acfebdc339fe592ecf5357ac7c0a7734ab9d8c876a70" dependencies = [ "proc-macro2", "quote", @@ -2309,9 +2316,9 @@ dependencies = [ [[package]] name = "futures-rustls" -version = "0.22.1" +version = "0.22.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e01fe9932a224b72b45336d96040aa86386d674a31d0af27d800ea7bc8ca97fe" +checksum = "d2411eed028cdf8c8034eaf21f9915f956b6c3abec4d4c7949ee67f0721127bd" dependencies = [ "futures-io", "rustls", @@ -2320,15 +2327,15 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.21" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21163e139fa306126e6eedaf49ecdb4588f939600f0b1e770f4205ee4b7fa868" +checksum = "f310820bb3e8cfd46c80db4d7fb8353e15dfff853a127158425f31e0be6c8364" [[package]] name = "futures-task" -version = "0.3.21" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57c66a976bf5909d801bbef33416c41372779507e7a6b3a5e25e4749c58f776a" +checksum = "dcf79a1bf610b10f42aea489289c5a2c478a786509693b80cd39c44ccd936366" [[package]] name = "futures-timer" @@ -2338,9 +2345,9 @@ checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" [[package]] name = "futures-util" -version = "0.3.21" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8b7abd5d659d9b90c8cba917f6ec750a74e2dc23902ef9cd4cc8c8b22e6036a" +checksum = "9c1d6de3acfef38d2be4b1f543f553131788603495be83da675e180c8d6b7bd1" dependencies = [ "futures-channel", "futures-core", @@ -2363,12 +2370,6 @@ dependencies = [ "byteorder", ] -[[package]] -name = "gcc" -version = "0.3.55" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" - [[package]] name = "generate-bags" version = "4.0.0-dev" @@ -2393,9 +2394,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.14.4" +version = "0.14.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" +checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" dependencies = [ "typenum", "version_check", @@ -2424,13 +2425,13 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.3" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" +checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" dependencies = [ "cfg-if", "libc", - "wasi 0.10.0+wasi-snapshot-preview1", + "wasi 0.11.0+wasi-snapshot-preview1", ] [[package]] @@ -2445,9 +2446,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.26.1" +version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4" +checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" dependencies = [ "fallible-iterator", "indexmap", @@ -2456,15 +2457,15 @@ dependencies = [ [[package]] name = "gimli" -version = "0.27.0" +version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dec7af912d60cdbd3677c1af9352ebae6fb8394d165568a2234df0fa00f87793" +checksum = "ad0a93d233ebf96623465aad4046a8d3aa4da22d4f4beba5388838c8a434bbb4" [[package]] name = "git2" -version = "0.14.2" +version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3826a6e0e2215d7a41c2bfc7c9244123969273f3476b939a226aac0ab56e9e3c" +checksum = "d0155506aab710a86160ddb504a480d2964d7ab5b9e62419be69e0032bc5931c" dependencies = [ "bitflags", "libc", @@ -2475,18 +2476,18 @@ dependencies = [ [[package]] name = "glob" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "globset" -version = "0.4.6" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c152169ef1e421390738366d2f796655fec62621dabbd0fd476f905934061e4a" +checksum = "029d74589adefde59de1a0c4f4732695c32805624aec7b68d91503d4dba79afc" dependencies = [ "aho-corasick", - "bstr 0.2.15", + "bstr", "fnv", "log", "regex", @@ -2494,20 +2495,20 @@ dependencies = [ [[package]] name = "group" -version = "0.12.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7391856def869c1c81063a03457c676fbcd419709c3dfb33d8d319de484b154d" +checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" dependencies = [ "ff", - "rand_core 0.6.2", + "rand_core 0.6.4", "subtle", ] [[package]] name = "h2" -version = "0.3.13" +version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37a82c6d637fc9515a4694bbf1cb2457b79d81ce52b3108bdeea58b07dd34a57" +checksum = "5be7b54589b581f624f566bf5d8eb2bab1db736c51528720b6bd36b96b55924d" dependencies = [ "bytes", "fnv", @@ -2518,21 +2519,21 @@ dependencies = [ "indexmap", "slab", "tokio", - "tokio-util 0.7.4", + "tokio-util", "tracing", ] [[package]] name = "half" -version = "1.7.1" +version = "1.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62aca2aba2d62b4a7f5b33f3712cb1b0692779a56fb510499d5c0aa594daeaf3" +checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" [[package]] name = "handlebars" -version = "4.3.5" +version = "4.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "433e4ab33f1213cdc25b5fa45c76881240cfe79284cf2b395e8b9e312a30a2fd" +checksum = "035ef95d03713f2c347a72547b7cd38cbc9af7cd51e6099fb62d586d4a6dee3a" dependencies = [ "log", "pest", @@ -2557,12 +2558,6 @@ dependencies = [ "crunchy", ] -[[package]] -name = "hashbrown" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" - [[package]] name = "hashbrown" version = "0.12.3" @@ -2574,19 +2569,34 @@ dependencies = [ [[package]] name = "heck" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.1.18" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" dependencies = [ "libc", ] +[[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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" + [[package]] name = "hex" version = "0.4.3" @@ -2619,7 +2629,7 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" dependencies = [ - "digest 0.10.3", + "digest 0.10.6", ] [[package]] @@ -2629,7 +2639,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17ea0a1394df5b6574da6e0c1ade9e78868c9fb0a4e5ef4428e32da4676b85b1" dependencies = [ "digest 0.9.0", - "generic-array 0.14.4", + "generic-array 0.14.6", "hmac 0.8.1", ] @@ -2658,13 +2668,13 @@ dependencies = [ [[package]] name = "http" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" +checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" dependencies = [ "bytes", "fnv", - "itoa 1.0.4", + "itoa", ] [[package]] @@ -2692,9 +2702,9 @@ checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" [[package]] name = "httpdate" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6456b8a6c8f33fee7d958fcd1b60d55b11940a79e63ae87013e6d22e26034440" +checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" [[package]] name = "humantime" @@ -2704,9 +2714,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.14.22" +version = "0.14.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abfba89e19b959ca163c7752ba59d737c1ceea53a5d31a149c805446fc958064" +checksum = "5e011372fa0b68db8350aa7a248930ecc7839bf46d8485577d69f117a75f164c" dependencies = [ "bytes", "futures-channel", @@ -2717,7 +2727,7 @@ dependencies = [ "http-body", "httparse", "httpdate", - "itoa 1.0.4", + "itoa", "pin-project-lite 0.2.9", "socket2", "tokio", @@ -2728,9 +2738,9 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.23.0" +version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d87c48c02e0dc5e3b849a2041db3029fd066650f8f717c07bf8ed78ccb895cac" +checksum = "1788965e61b367cd03a62950836d5cd41560c3577d90e40e0819373194d1661c" dependencies = [ "http", "hyper", @@ -2741,6 +2751,30 @@ dependencies = [ "tokio-rustls", ] +[[package]] +name = "iana-time-zone" +version = "0.1.53" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "winapi", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" +dependencies = [ + "cxx", + "cxx-build", +] + [[package]] name = "idna" version = "0.2.3" @@ -2752,6 +2786,16 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "idna" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + [[package]] name = "if-addrs" version = "0.7.0" @@ -2811,12 +2855,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.8.0" +version = "1.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223" +checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" dependencies = [ "autocfg", - "hashbrown 0.11.2", + "hashbrown", "serde", ] @@ -2846,9 +2890,19 @@ dependencies = [ [[package]] name = "io-lifetimes" -version = "0.7.2" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24c3f4eff5495aee4c0399d7b6a0dc2b6e81be84242ffbfcf253ebacccc1d0cb" +checksum = "59ce5ef949d49ee85593fc4d3f3f95ad61657076395cbbce23e2121fc5542074" + +[[package]] +name = "io-lifetimes" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1abeb7a0dd0f8181267ff8adc397075586500b81b28a73e8a0208b00fc170fb3" +dependencies = [ + "libc", + "windows-sys 0.45.0", +] [[package]] name = "ip_network" @@ -2858,9 +2912,9 @@ checksum = "aa2f047c0a98b2f299aa5d6d7088443570faae494e9ae1305e48be000c9e0eb1" [[package]] name = "ipconfig" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "723519edce41262b05d4143ceb95050e4c614f483e78e9fd9e39a8275a84ad98" +checksum = "bd302af1b90f2463a98fa5ad469fc212c8e3175a41c3068601bfa2727591c5be" dependencies = [ "socket2", "widestring", @@ -2870,9 +2924,21 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.5.0" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "879d54834c8c76457ef4293a689b2a8c59b076067ad77b15efafbb05f92a592b" +checksum = "30e22bd8629359895450b59ea7a776c850561b96a3b1d31321c1949d9e6c9146" + +[[package]] +name = "is-terminal" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b6b32576413a8e69b90e952e4a026476040d81017b80445deda5f2d3921857" +dependencies = [ + "hermit-abi 0.3.1", + "io-lifetimes 1.0.5", + "rustix 0.36.8", + "windows-sys 0.45.0", +] [[package]] name = "itertools" @@ -2885,30 +2951,24 @@ dependencies = [ [[package]] name = "itoa" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" - -[[package]] -name = "itoa" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" +checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" [[package]] name = "jobserver" -version = "0.1.21" +version = "0.1.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c71313ebb9439f74b00d9d2dcec36440beaf57a6aa0623068441dd7cd81a7f2" +checksum = "068b1ee6743e4d11fb9c6a1e6064b3693a1b600e7f5f5988047d98b3dc9fb90b" dependencies = [ "libc", ] [[package]] name = "js-sys" -version = "0.3.54" +version = "0.3.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1866b355d9c878e5e607473cbe3f63282c0b7aad2db1dbebf55076c686918254" +checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" dependencies = [ "wasm-bindgen", ] @@ -2943,7 +3003,7 @@ dependencies = [ "thiserror", "tokio", "tokio-rustls", - "tokio-util 0.7.4", + "tokio-util", "tracing", "webpki-roots", ] @@ -3006,7 +3066,7 @@ dependencies = [ "soketto", "tokio", "tokio-stream", - "tokio-util 0.7.4", + "tokio-util", "tower", "tracing", ] @@ -3039,21 +3099,24 @@ dependencies = [ [[package]] name = "k256" -version = "0.11.5" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3636d281d46c3b64182eb3a0a42b7b483191a2ecc3f05301fa67403f7c9bc949" +checksum = "72c1e0b51e7ec0a97369623508396067a486bd0cbed95a2659a4b863d28cfc8b" dependencies = [ "cfg-if", "ecdsa", "elliptic-curve", - "sha2 0.10.2", + "sha2 0.10.6", ] [[package]] name = "keccak" -version = "0.1.0" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7" +checksum = "3afef3b6eff9ce9d8ff9b3601125eec7f0c8cbac7abd14f355d053fa56c98768" +dependencies = [ + "cpufeatures", +] [[package]] name = "keccak-hasher" @@ -3129,7 +3192,6 @@ dependencies = [ "pallet-society", "pallet-staking", "pallet-staking-reward-curve", - "pallet-staking-rpc-runtime-api", "pallet-state-trie-migration", "pallet-sudo", "pallet-timestamp", @@ -3209,21 +3271,21 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "leb128" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3576a87f2ba00f6f106fdfcd16db1d698d648a26ad8e0573cad8537c3c362d2a" +checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.126" +version = "0.2.139" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" +checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" [[package]] name = "libgit2-sys" -version = "0.13.2+1.4.2" +version = "0.13.5+1.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a42de9a51a5c12e00fc0e4ca6bc2ea43582fc6418488e8f615e905d886f258b" +checksum = "51e5ea06c26926f1002dd553fded6cfcdc9784c1f60feeb58368b4d9b07b6dba" dependencies = [ "cc", "libc", @@ -3233,9 +3295,9 @@ dependencies = [ [[package]] name = "libloading" -version = "0.7.0" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f84d96438c15fcd6c3f244c8fce01d1e2b9c6b5623e9c711dc9286d8fc92d6a" +checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" dependencies = [ "cfg-if", "winapi", @@ -3243,9 +3305,15 @@ dependencies = [ [[package]] name = "libm" -version = "0.2.1" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7d73b3f436185384286bd8098d17ec07c9a7d2388a6599f824d8502b529702a" +checksum = "7fc7aa29613bd6a620df431842069224d8bc9011086b1db4c0e0cd47fa03ec9a" + +[[package]] +name = "libm" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "348108ab3fba42ec82ff6e9564fc4ca0247bdccdc68dd8af9764bbc79c3c8ffb" [[package]] name = "libp2p" @@ -3256,7 +3324,7 @@ dependencies = [ "bytes", "futures", "futures-timer", - "getrandom 0.2.3", + "getrandom 0.2.8", "instant", "lazy_static", "libp2p-core", @@ -3306,7 +3374,7 @@ dependencies = [ "prost-build", "rand 0.8.5", "rw-stream-sink", - "sha2 0.10.2", + "sha2 0.10.6", "smallvec", "thiserror", "unsigned-varint", @@ -3369,7 +3437,7 @@ dependencies = [ "prost", "prost-build", "rand 0.8.5", - "sha2 0.10.2", + "sha2 0.10.6", "smallvec", "thiserror", "uint", @@ -3436,7 +3504,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "048155686bd81fe6cb5efdef0c6290f25ad32a0a42e8f4f72625cf6a505a206f" dependencies = [ "bytes", - "curve25519-dalek 3.0.2", + "curve25519-dalek 3.2.0", "futures", "lazy_static", "libp2p-core", @@ -3444,7 +3512,7 @@ dependencies = [ "prost", "prost-build", "rand 0.8.5", - "sha2 0.10.2", + "sha2 0.10.6", "snow", "static_assertions", "x25519-dalek", @@ -3567,9 +3635,9 @@ dependencies = [ [[package]] name = "libp2p-yamux" -version = "0.41.0" +version = "0.41.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30f079097a21ad017fc8139460630286f02488c8c13b26affb46623aa20d8845" +checksum = "0d6874d66543c4f7e26e3b8ca9a6bead351563a13ab4fafd43c7927f7c0d6c12" dependencies = [ "futures", "libp2p-core", @@ -3581,9 +3649,9 @@ dependencies = [ [[package]] name = "librocksdb-sys" -version = "0.8.0+7.4.4" +version = "0.8.3+7.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "611804e4666a25136fcc5f8cf425ab4d26c7f74ea245ffe92ea23b85b6420b5d" +checksum = "557b255ff04123fcc176162f56ed0c9cd42d8f357cf55b3fabeb60f7413741b3" dependencies = [ "bindgen", "bzip2-sys", @@ -3596,12 +3664,12 @@ dependencies = [ [[package]] name = "libsecp256k1" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0452aac8bab02242429380e9b2f94ea20cea2b37e2c1777a1358799bbe97f37" +checksum = "95b09eff1b35ed3b33b877ced3a691fc7a481919c7e29c53c906226fcf55e2a1" dependencies = [ "arrayref", - "base64", + "base64 0.13.1", "digest 0.9.0", "hmac-drbg", "libsecp256k1-core", @@ -3609,7 +3677,7 @@ dependencies = [ "libsecp256k1-gen-genmult", "rand 0.8.5", "serde", - "sha2 0.9.8", + "sha2 0.9.9", "typenum", ] @@ -3644,9 +3712,9 @@ dependencies = [ [[package]] name = "libz-sys" -version = "1.1.2" +version = "1.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "602113192b08db8f38796c4e85c39e960c145965140e918018bcde1952429655" +checksum = "9702761c3935f8cc2f101793272e202c72b99da8f4224a19ddcf1279a6450bbf" dependencies = [ "cc", "libc", @@ -3656,18 +3724,18 @@ dependencies = [ [[package]] name = "link-cplusplus" -version = "1.0.7" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9272ab7b96c9046fbc5bc56c06c117cb639fe2d509df0c421cad82d2915cf369" +checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5" dependencies = [ "cc", ] [[package]] name = "linked-hash-map" -version = "0.5.4" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" +checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" [[package]] name = "linked_hash_set" @@ -3694,6 +3762,12 @@ version = "0.0.46" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4d2456c373231a208ad294c33dc5bff30051eafd954cd4caae83a712b12854d" +[[package]] +name = "linux-raw-sys" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" + [[package]] name = "lite-json" version = "0.2.0" @@ -3714,10 +3788,11 @@ dependencies = [ [[package]] name = "lock_api" -version = "0.4.6" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88943dd7ef4a2e5a4bfa2753aaab3013e34ce2533d1996fb18ef591e315e2b3b" +checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" dependencies = [ + "autocfg", "scopeguard", ] @@ -3736,7 +3811,7 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6e8aaa3f231bb4bd57b84b2d5dc3ae7f350265df8aa96492e0bc394a1571909" dependencies = [ - "hashbrown 0.12.3", + "hashbrown", ] [[package]] @@ -3803,48 +3878,57 @@ dependencies = [ [[package]] name = "matches" -version = "0.1.8" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" +checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" [[package]] name = "matrixmultiply" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a8a15b776d9dfaecd44b03c5828c2199cddff5247215858aac14624f8d6b741" +checksum = "add85d4dd35074e6fedc608f8c8f513a3548619a9024b751949ef0e8e45a4d84" dependencies = [ "rawpointer", ] [[package]] name = "memchr" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "memfd" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "480b5a5de855d11ff13195950bdc8b98b5e942ef47afc447f6615cdcc4e15d80" +checksum = "b20a59d985586e4a5aef64564ac77299f8586d8be6cf9106a5a40207e8908efb" dependencies = [ - "rustix", + "rustix 0.36.8", ] [[package]] name = "memmap2" -version = "0.5.0" +version = "0.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4647a11b578fead29cdbb34d4adef8dd3dc35b876c9c6d5240d83f205abfe96e" +checksum = "83faa42c0a078c393f6b29d5db232d8be22776a891f8f56e5284faee4a20b327" dependencies = [ "libc", ] [[package]] name = "memoffset" -version = "0.6.4" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +dependencies = [ + "autocfg", +] + +[[package]] +name = "memoffset" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" +checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" dependencies = [ "autocfg", ] @@ -3856,7 +3940,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e0c7cba9ce19ac7ffd2053ac9f49843bbd3f4318feedfd74e85c19d5fb0ba66" dependencies = [ "hash-db", - "hashbrown 0.12.3", + "hashbrown", ] [[package]] @@ -3883,16 +3967,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" -[[package]] -name = "miniz_oxide" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" -dependencies = [ - "adler", - "autocfg", -] - [[package]] name = "miniz_oxide" version = "0.6.2" @@ -3904,14 +3978,14 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.4" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57ee1c23c7c63b0c9250c339ffdc69255f110b298b901b9f6c82547b7b87caaf" +checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" dependencies = [ "libc", "log", "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.36.1", + "windows-sys 0.45.0", ] [[package]] @@ -3955,9 +4029,9 @@ dependencies = [ [[package]] name = "mockall" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2be9a9090bc1cac2930688fa9478092a64c6a92ddc6ae0692d46b37d9cab709" +checksum = "50e4a1c770583dac7ab5e2f6c139153b783a53a1bbee9729613f193e59828326" dependencies = [ "cfg-if", "downcast", @@ -3970,9 +4044,9 @@ dependencies = [ [[package]] name = "mockall_derive" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86d702a0530a0141cf4ed147cf5ec7be6f2c187d4e37fcbefc39cf34116bfe8f" +checksum = "832663583d5fa284ca8810bf7015e46c9fff9622d3cf34bd1eea5003fec06dd0" dependencies = [ "cfg-if", "proc-macro2", @@ -4011,26 +4085,26 @@ dependencies = [ [[package]] name = "multihash" -version = "0.16.2" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3db354f401db558759dfc1e568d010a5d4146f4d3f637be1275ec4a3cf09689" +checksum = "1c346cf9999c631f002d8f977c4eaeaa0e6386f16007202308d0b3757522c2cc" dependencies = [ "blake2b_simd", "blake2s_simd", "blake3", "core2", - "digest 0.10.3", + "digest 0.10.6", "multihash-derive", - "sha2 0.10.2", + "sha2 0.10.6", "sha3", "unsigned-varint", ] [[package]] name = "multihash-derive" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc076939022111618a5026d3be019fd8b366e76314538ff9a1b59ffbcbf98bcd" +checksum = "1d6d4752e6230d8ef7adf7bd5d8c4b1f6561c1014c5ba9a37445ccefe18aa1db" dependencies = [ "proc-macro-crate", "proc-macro-error", @@ -4042,15 +4116,15 @@ dependencies = [ [[package]] name = "multimap" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1255076139a83bb467426e7f8d0134968a8118844faa755985e077cf31850333" +checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" [[package]] name = "multistream-select" -version = "0.12.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bc41247ec209813e2fd414d6e16b9d94297dacf3cd613fa6ef09cd4d9755c10" +checksum = "c8552ab875c1313b97b8d20cb857b9fd63e2d1d6a0a1b53ce9821e575405f27a" dependencies = [ "bytes", "futures", @@ -4126,9 +4200,9 @@ dependencies = [ [[package]] name = "netlink-packet-utils" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25af9cf0dc55498b7bd94a1508af7a78706aa0ab715a73c5169273e03c84845e" +checksum = "0ede8a08c71ad5a95cdd0e4e52facd37190977039a4704eb82a283f713747d34" dependencies = [ "anyhow", "byteorder", @@ -4153,9 +4227,9 @@ dependencies = [ [[package]] name = "netlink-sys" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92b654097027250401127914afb37cb1f311df6610a9891ff07a757e94199027" +checksum = "260e21fbb6f3d253a14df90eb0000a6066780a15dd901a7519ce02d77a94985b" dependencies = [ "async-io", "bytes", @@ -4166,22 +4240,22 @@ dependencies = [ [[package]] name = "nix" -version = "0.23.1" +version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f866317acbd3a240710c63f065ffb1e4fd466259045ccb504130b7f668f35c6" +checksum = "8f3790c00a0150112de0f4cd161e3d7fc4b2d8a5542ffc35f099a2562aecb35c" dependencies = [ "bitflags", "cc", "cfg-if", "libc", - "memoffset", + "memoffset 0.6.5", ] [[package]] name = "nix" -version = "0.24.2" +version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "195cdbc1741b8134346d515b3a56a1c94b0912758009cfd53f99ea0f57b065fc" +checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" dependencies = [ "bitflags", "cfg-if", @@ -4193,7 +4267,7 @@ name = "node-bench" version = "0.9.0-dev" dependencies = [ "array-bytes", - "clap 4.0.11", + "clap 4.1.7", "derive_more", "fs_extra", "futures", @@ -4230,7 +4304,7 @@ version = "3.0.0-dev" dependencies = [ "array-bytes", "assert_cmd", - "clap 4.0.11", + "clap 4.1.7", "clap_complete", "criterion", "frame-benchmarking-cli", @@ -4240,7 +4314,7 @@ dependencies = [ "jsonrpsee", "kitchensink-runtime", "log", - "nix 0.23.1", + "nix 0.23.2", "node-executor", "node-inspect", "node-primitives", @@ -4252,7 +4326,7 @@ dependencies = [ "pallet-timestamp", "pallet-transaction-payment", "parity-scale-codec", - "platforms", + "platforms 2.0.0", "rand 0.8.5", "regex", "sc-authority-discovery", @@ -4305,7 +4379,7 @@ dependencies = [ "substrate-rpc-client", "tempfile", "tokio", - "tokio-util 0.7.4", + "tokio-util", "try-runtime-cli", "wait-timeout", ] @@ -4350,7 +4424,7 @@ dependencies = [ name = "node-inspect" version = "0.9.0-dev" dependencies = [ - "clap 4.0.11", + "clap 4.1.7", "parity-scale-codec", "sc-cli", "sc-client-api", @@ -4381,7 +4455,6 @@ dependencies = [ "jsonrpsee", "mmr-rpc", "node-primitives", - "pallet-staking-rpc", "pallet-transaction-payment-rpc", "sc-chain-spec", "sc-client-api", @@ -4410,7 +4483,7 @@ dependencies = [ name = "node-runtime-generate-bags" version = "3.0.0" dependencies = [ - "clap 4.0.11", + "clap 4.1.7", "generate-bags", "kitchensink-runtime", ] @@ -4419,7 +4492,7 @@ dependencies = [ name = "node-template" version = "4.0.0-dev" dependencies = [ - "clap 4.0.11", + "clap 4.1.7", "frame-benchmarking", "frame-benchmarking-cli", "frame-system", @@ -4538,13 +4611,12 @@ checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" [[package]] name = "nom" -version = "7.1.0" +version = "7.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b1d11e1ef389c76fe5b81bcaf2ea32cf88b62bc494e19f493d0b30e7a930109" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" dependencies = [ "memchr", "minimal-lexical", - "version_check", ] [[package]] @@ -4576,28 +4648,28 @@ dependencies = [ [[package]] name = "num-complex" -version = "0.4.0" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26873667bbbb7c5182d4a37c1add32cdf09f841af72da53318fdb81543c15085" +checksum = "02e0d21255c828d6f128a1e41534206671e8c3ea0c62f32291e808dc82cff17d" dependencies = [ "num-traits", ] [[package]] name = "num-format" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54b862ff8df690cf089058c98b183676a7ed0f974cc08b426800093227cbff3b" +checksum = "a652d9771a63711fd3c3deb670acfbe5c30a4072e664d7a3bf5a9e1056ac72c3" dependencies = [ "arrayvec 0.7.2", - "itoa 1.0.4", + "itoa", ] [[package]] name = "num-integer" -version = "0.1.44" +version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" dependencies = [ "autocfg", "num-traits", @@ -4617,21 +4689,21 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" dependencies = [ "autocfg", - "libm", + "libm 0.2.6", ] [[package]] name = "num_cpus" -version = "1.13.1" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" +checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" dependencies = [ - "hermit-abi", + "hermit-abi 0.2.6", "libc", ] @@ -4642,25 +4714,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53" dependencies = [ "crc32fast", - "hashbrown 0.12.3", + "hashbrown", "indexmap", "memchr", ] [[package]] name = "object" -version = "0.30.0" +version = "0.30.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "239da7f290cfa979f43f85a8efeee9a8a76d0827c356d37f9d3d7254d6b537fb" +checksum = "ea86265d3d3dcb6a27fc51bd29a4bf387fae9d2986b823079d4986af253eb439" dependencies = [ "memchr", ] [[package]] name = "once_cell" -version = "1.16.0" +version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" +checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" [[package]] name = "oorandom" @@ -4682,21 +4754,21 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "openssl-probe" -version = "0.1.2" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "os_str_bytes" -version = "6.0.0" +version = "6.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64" +checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee" [[package]] name = "output_vt100" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53cdc5b785b7a58c5aad8216b3dfa114df64b0b06ae6e1501cef91df2fbdf8f9" +checksum = "628223faebab4e3e40667ee0b2336d34a5b960ff60ea743ddfdbcf7770bcfb66" dependencies = [ "winapi", ] @@ -4707,6 +4779,16 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" +[[package]] +name = "packed_simd_2" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1914cd452d8fccd6f9db48147b29fd4ae05bea9dc5d9ad578509f72415de282" +dependencies = [ + "cfg-if", + "libm 0.1.4", +] + [[package]] name = "pallet-alliance" version = "4.0.0-dev" @@ -4721,7 +4803,7 @@ dependencies = [ "pallet-identity", "parity-scale-codec", "scale-info", - "sha2 0.10.2", + "sha2 0.10.6", "sp-core", "sp-io", "sp-runtime", @@ -5025,7 +5107,7 @@ dependencies = [ "array-bytes", "assert_matches", "bitflags", - "env_logger", + "env_logger 0.9.3", "frame-benchmarking", "frame-support", "frame-system", @@ -5374,7 +5456,7 @@ name = "pallet-mmr" version = "4.0.0-dev" dependencies = [ "array-bytes", - "env_logger", + "env_logger 0.9.3", "frame-benchmarking", "frame-support", "frame-system", @@ -5902,32 +5984,6 @@ dependencies = [ "sp-arithmetic", ] -[[package]] -name = "pallet-staking-rpc" -version = "4.0.0-dev" -dependencies = [ - "jsonrpsee", - "pallet-staking-rpc-runtime-api", - "parity-scale-codec", - "sp-api", - "sp-blockchain", - "sp-core", - "sp-rpc", - "sp-runtime", - "sp-weights", -] - -[[package]] -name = "pallet-staking-rpc-runtime-api" -version = "4.0.0-dev" -dependencies = [ - "pallet-staking", - "parity-scale-codec", - "sp-api", - "sp-runtime", - "sp-weights", -] - [[package]] name = "pallet-state-trie-migration" version = "4.0.0-dev" @@ -6174,9 +6230,9 @@ dependencies = [ [[package]] name = "parity-db" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a7511a0bec4a336b5929999d02b560d2439c993cccf98c26481484e811adc43" +checksum = "dd684a725651d9588ef21f140a328b6b4f64e646b2e931f3e6f14f75eedf9980" dependencies = [ "blake2", "crc32fast", @@ -6193,9 +6249,9 @@ dependencies = [ [[package]] name = "parity-scale-codec" -version = "3.1.3" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04bc9583b5e01cc8c70d89acc9af14ef9b1c29ee3a0074b2a9eea8c0fa396690" +checksum = "637935964ff85a605d114591d4d2c13c5d1ba2806dae97cea6bf180238a749ac" dependencies = [ "arrayvec 0.7.2", "bitvec", @@ -6208,9 +6264,9 @@ dependencies = [ [[package]] name = "parity-scale-codec-derive" -version = "3.1.3" +version = "3.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9299338969a3d2f491d65f140b00ddec470858402f888af98e8642fb5e8965cd" +checksum = "86b26a931f824dd4eca30b3e43bb4f31cd5f0d3a403c5f5ff27106b805bfde7b" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -6244,7 +6300,7 @@ checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" dependencies = [ "instant", "lock_api", - "parking_lot_core 0.8.5", + "parking_lot_core 0.8.6", ] [[package]] @@ -6254,14 +6310,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ "lock_api", - "parking_lot_core 0.9.1", + "parking_lot_core 0.9.7", ] [[package]] name = "parking_lot_core" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" +checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc" dependencies = [ "cfg-if", "instant", @@ -6273,22 +6329,22 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.1" +version = "0.9.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28141e0cc4143da2443301914478dc976a61ffdb3f043058310c70df2fed8954" +checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", - "windows-sys 0.32.0", + "windows-sys 0.45.0", ] [[package]] name = "paste" -version = "1.0.9" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1de2e551fb905ac83f73f7aedf2f0cb4a0da7e35efa24a202a936269f1f18e1" +checksum = "d01a5bd0424d00070b0098dd17ebca6f961a959dead1dbcbbbc1d1cd8d3deeba" [[package]] name = "pbkdf2" @@ -6305,7 +6361,7 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" dependencies = [ - "digest 0.10.3", + "digest 0.10.6", ] [[package]] @@ -6316,15 +6372,15 @@ checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" [[package]] name = "percent-encoding" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" +checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" [[package]] name = "pest" -version = "2.4.0" +version = "2.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbc7bc69c062e492337d74d59b120c274fd3d261b6bf6d3207d499b4b379c41a" +checksum = "028accff104c4e513bad663bbcd2ad7cfd5304144404c31ed0a77ac103d00660" dependencies = [ "thiserror", "ucd-trie", @@ -6332,9 +6388,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.4.0" +version = "2.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60b75706b9642ebcb34dab3bc7750f811609a0eb1dd8b88c2d15bf628c1c65b2" +checksum = "2ac3922aac69a40733080f53c1ce7f91dcf57e1a5f6c52f421fadec7fbdc4b69" dependencies = [ "pest", "pest_generator", @@ -6342,9 +6398,9 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.4.0" +version = "2.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f9272122f5979a6511a749af9db9bfc810393f63119970d7085fed1c4ea0db" +checksum = "d06646e185566b5961b4058dd107e0a7f56e77c3f484549fb119867773c0f202" dependencies = [ "pest", "pest_meta", @@ -6355,20 +6411,20 @@ dependencies = [ [[package]] name = "pest_meta" -version = "2.4.0" +version = "2.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8717927f9b79515e565a64fe46c38b8cd0427e64c40680b14a7365ab09ac8d" +checksum = "e6f60b2ba541577e2a0c307c8f39d1439108120eb7903adeb6497fa880c59616" dependencies = [ "once_cell", "pest", - "sha1", + "sha2 0.10.6", ] [[package]] name = "petgraph" -version = "0.6.0" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a13a2fa9d0b63e5f22328828741e523766fff0ee9e779316902290dff3f824f" +checksum = "4dd7d28ee937e54fe3080c91faa1c3a46c06de6252988a7f4592ba2310ef22a4" dependencies = [ "fixedbitset", "indexmap", @@ -6424,9 +6480,9 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.19" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" +checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" [[package]] name = "platforms" @@ -6434,11 +6490,17 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8d0eef3571242013a0d5dc84861c3ae4a652e56e12adf8bdc26ff5f8cb34c94" +[[package]] +name = "platforms" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3d7ddaed09e0eb771a79ab0fd64609ba0afb0a8366421957936ad14cbd13630" + [[package]] name = "plotters" -version = "0.3.1" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a3fd9ec30b9749ce28cd91f255d569591cdf937fe280c312143e3c4bad6f2a" +checksum = "2538b639e642295546c50fcd545198c9d64ee2a38620a628724a3b266d5fbf97" dependencies = [ "num-traits", "plotters-backend", @@ -6449,31 +6511,31 @@ dependencies = [ [[package]] name = "plotters-backend" -version = "0.3.0" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b07fffcddc1cb3a1de753caa4e4df03b79922ba43cf882acc1bdd7e8df9f4590" +checksum = "193228616381fecdc1224c62e96946dfbc73ff4384fba576e052ff8c1bea8142" [[package]] name = "plotters-svg" -version = "0.3.0" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b38a02e23bd9604b842a812063aec4ef702b57989c37b655254bb61c471ad211" +checksum = "f9a81d2759aae1dae668f783c308bc5c8ebd191ff4184aaa1b37f65a6ae5a56f" dependencies = [ "plotters-backend", ] [[package]] name = "polling" -version = "2.4.0" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab4609a838d88b73d8238967b60dd115cc08d38e2bbaf51ee1e4b695f89122e2" +checksum = "22122d5ec4f9fe1b3916419b76be1e80bcb93f618d071d2edf841b137b2a2bd6" dependencies = [ "autocfg", "cfg-if", "libc", "log", "wepoll-ffi", - "winapi", + "windows-sys 0.42.0", ] [[package]] @@ -6501,15 +6563,15 @@ dependencies = [ [[package]] name = "ppv-lite86" -version = "0.2.10" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "predicates" -version = "2.1.3" +version = "2.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed6bd09a7f7e68f3f0bf710fb7ab9c4615a488b58b5f653382a687701e458c92" +checksum = "59230a63c37f3e18569bdb90e4a89cbf5bf8b06fea0b84e65ea10cc4df47addd" dependencies = [ "difflib", "float-cmp", @@ -6521,37 +6583,47 @@ dependencies = [ [[package]] name = "predicates-core" -version = "1.0.2" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57e35a3326b75e49aa85f5dc6ec15b41108cf5aee58eabb1f274dd18b73c2451" +checksum = "72f883590242d3c6fc5bf50299011695fa6590c2c70eac95ee1bdb9a733ad1a2" [[package]] name = "predicates-tree" -version = "1.0.2" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15f553275e5721409451eb85e15fd9a860a6e5ab4496eb215987502b5f5391f2" +checksum = "54ff541861505aabf6ea722d2131ee980b8276e10a1297b94e896dd8b621850d" dependencies = [ "predicates-core", - "treeline", + "termtree", ] [[package]] name = "pretty_assertions" -version = "1.2.1" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c89f989ac94207d048d92db058e4f6ec7342b0971fc58d1271ca148b799b3563" +checksum = "a25e9bcb20aa780fd0bb16b72403a9064d6b3f22f026946029acb941a50af755" dependencies = [ - "ansi_term", "ctor", "diff", "output_vt100", + "yansi", +] + +[[package]] +name = "prettyplease" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e97e3215779627f01ee256d2fad52f3d95e8e1c11e9fc6fd08f7cd455d5d5c78" +dependencies = [ + "proc-macro2", + "syn", ] [[package]] name = "primitive-types" -version = "0.12.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cfd65aea0c5fa0bfcc7c9e7ca828c921ef778f43d325325ec84bda371bfa75a" +checksum = "9f3486ccba82358b11a77516035647c34ba167dfa53312630de83b12bd4f3d66" dependencies = [ "fixed-hash", "impl-codec", @@ -6596,35 +6668,35 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.46" +version = "1.0.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94e2ef8dbfc347b10c094890f778ee2e36ca9bb4262e86dc99cd217e35f3470b" +checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6" dependencies = [ "unicode-ident", ] [[package]] name = "prometheus" -version = "0.13.0" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7f64969ffd5dd8f39bd57a68ac53c163a095ed9d0fb707146da1b27025a3504" +checksum = "449811d15fbdf5ceb5c1144416066429cf82316e2ec8ce0c1f6f8a02e7bbcf8c" dependencies = [ "cfg-if", "fnv", "lazy_static", "memchr", - "parking_lot 0.11.2", + "parking_lot 0.12.1", "thiserror", ] [[package]] name = "prometheus-client" -version = "0.18.0" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c473049631c233933d6286c88bbb7be30e62ec534cf99a9ae0079211f7fa603" +checksum = "83cd1b99916654a69008fd66b4f9397fbe08e6e51dfe23d4417acf5d3b8cb87c" dependencies = [ "dtoa", - "itoa 1.0.4", + "itoa", "parking_lot 0.12.1", "prometheus-client-derive-text-encode", ] @@ -6642,9 +6714,9 @@ dependencies = [ [[package]] name = "prost" -version = "0.11.0" +version = "0.11.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "399c3c31cdec40583bb68f0b18403400d01ec4289c383aa047560439952c4dd7" +checksum = "e48e50df39172a3e7eb17e14642445da64996989bc212b583015435d39a58537" dependencies = [ "bytes", "prost-derive", @@ -6652,9 +6724,9 @@ dependencies = [ [[package]] name = "prost-build" -version = "0.11.1" +version = "0.11.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f835c582e6bd972ba8347313300219fed5bfa52caf175298d860b61ff6069bb" +checksum = "2c828f93f5ca4826f97fedcbd3f9a536c16b12cff3dbbb4a007f932bbad95b12" dependencies = [ "bytes", "heck", @@ -6663,9 +6735,11 @@ dependencies = [ "log", "multimap", "petgraph", + "prettyplease", "prost", "prost-types", "regex", + "syn", "tempfile", "which", ] @@ -6685,9 +6759,9 @@ dependencies = [ [[package]] name = "prost-derive" -version = "0.11.0" +version = "0.11.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7345d5f0e08c0536d7ac7229952590239e77abf0a0100a1b1d890add6ea96364" +checksum = "4ea9b0f8cbe5e15a8a042d030bd96668db28ecb567ec37d691971ff5731d2b1b" dependencies = [ "anyhow", "itertools", @@ -6698,19 +6772,18 @@ dependencies = [ [[package]] name = "prost-types" -version = "0.11.1" +version = "0.11.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dfaa718ad76a44b3415e6c4d53b17c8f99160dcb3a99b10470fce8ad43f6e3e" +checksum = "379119666929a1afd7a043aa6cf96fa67a6dce9af60c88095a4686dbce4c9c88" dependencies = [ - "bytes", "prost", ] [[package]] name = "psm" -version = "0.1.12" +version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3abf49e5417290756acfd26501536358560c4a5cc4a0934d390939acb3e7083a" +checksum = "5787f7cda34e3033a72192c018bc5883100330f362ef279a8cbccfce8bb4e874" dependencies = [ "cc", ] @@ -6743,9 +6816,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.18" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1" +checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" dependencies = [ "proc-macro2", ] @@ -6777,7 +6850,7 @@ checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", "rand_chacha 0.3.1", - "rand_core 0.6.2", + "rand_core 0.6.4", ] [[package]] @@ -6797,7 +6870,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core 0.6.2", + "rand_core 0.6.4", ] [[package]] @@ -6811,11 +6884,11 @@ dependencies = [ [[package]] name = "rand_core" -version = "0.6.2" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34cf66eb183df1c5876e2dcf6b13d57340741e8dc255b48e40a26de954d06ae7" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.3", + "getrandom 0.2.8", ] [[package]] @@ -6843,7 +6916,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "59cad018caf63deb318e5a4586d99a24424a364f40f1e5778c29aca23f4fc73e" dependencies = [ - "rand_core 0.6.2", + "rand_core 0.6.4", ] [[package]] @@ -6854,62 +6927,60 @@ checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" [[package]] name = "rayon" -version = "1.5.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b0d8e0819fadc20c74ea8373106ead0600e3a67ef1fe8da56e39b9ae7275674" +checksum = "6db3a213adf02b3bcfd2d3846bb41cb22857d131789e01df434fb7e7bc0759b7" dependencies = [ - "autocfg", - "crossbeam-deque", "either", "rayon-core", ] [[package]] name = "rayon-core" -version = "1.9.0" +version = "1.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ab346ac5921dc62ffa9f89b7a773907511cdfa5490c572ae9be1be33e8afa4a" +checksum = "356a0625f1954f730c0201cdab48611198dc6ce21f4acff55089b5a78e6e835b" dependencies = [ "crossbeam-channel", "crossbeam-deque", "crossbeam-utils", - "lazy_static", "num_cpus", ] [[package]] name = "redox_syscall" -version = "0.2.10" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ "bitflags", ] [[package]] name = "redox_users" -version = "0.4.0" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" +checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ - "getrandom 0.2.3", + "getrandom 0.2.8", "redox_syscall", + "thiserror", ] [[package]] name = "ref-cast" -version = "1.0.6" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "300f2a835d808734ee295d45007adacb9ebb29dd3ae2424acfa17930cae541da" +checksum = "8c78fb8c9293bcd48ef6fce7b4ca950ceaf21210de6e105a883ee280c0f7b9ed" dependencies = [ "ref-cast-impl", ] [[package]] name = "ref-cast-impl" -version = "1.0.6" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c38e3aecd2b21cb3959637b883bb3714bc7e43f0268b9a29d3743ee3e55cdd2" +checksum = "9f9c0c92af03644e4806106281fe2e068ac5bc0ae74a707266d06ea27bccee5f" dependencies = [ "proc-macro2", "quote", @@ -6930,9 +7001,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.6.0" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" +checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" dependencies = [ "aho-corasick", "memchr", @@ -6941,28 +7012,18 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.1.9" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae1ded71d66a4a97f5e961fd0cb25a5f366a42a41570d16a763a69c092c26ae4" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" dependencies = [ - "byteorder", "regex-syntax", ] [[package]] name = "regex-syntax" -version = "0.6.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" - -[[package]] -name = "remove_dir_all" -version = "0.5.3" +version = "0.6.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" -dependencies = [ - "winapi", -] +checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" [[package]] name = "resolv-conf" @@ -6976,9 +7037,9 @@ dependencies = [ [[package]] name = "rfc6979" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88c86280f057430a52f4861551b092a01b419b8eacefc7c995eacb9dc132fe32" +checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" dependencies = [ "crypto-bigint", "hmac 0.12.1", @@ -7012,11 +7073,12 @@ dependencies = [ [[package]] name = "rpassword" -version = "7.0.0" +version = "7.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b763cb66df1c928432cc35053f8bd4cec3335d8559fc16010017d16b3c1680" +checksum = "6678cf63ab3491898c0d021b493c94c9b221d91295294a2a5746eacbe5928322" dependencies = [ "libc", + "rtoolbox", "winapi", ] @@ -7031,15 +7093,25 @@ dependencies = [ "log", "netlink-packet-route", "netlink-proto", - "nix 0.24.2", + "nix 0.24.3", "thiserror", ] +[[package]] +name = "rtoolbox" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "034e22c514f5c0cb8a10ff341b9b048b5ceb21591f31c8f44c43b960f9b3524a" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "rustc-demangle" -version = "0.1.18" +version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e3bad0ee36814ca07d7968269dd4b7ec89ec2da10c4bb613928d3077083c232" +checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" [[package]] name = "rustc-hash" @@ -7068,28 +7140,42 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver 1.0.4", + "semver 1.0.16", ] [[package]] name = "rustix" -version = "0.35.9" +version = "0.35.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72c825b8aa8010eb9ee99b75f05e10180b9278d161583034d7574c9d617aeada" +checksum = "727a1a6d65f786ec22df8a81ca3121107f235970dc1705ed681d3e6e8b9cd5f9" dependencies = [ "bitflags", "errno", - "io-lifetimes", + "io-lifetimes 0.7.5", "libc", - "linux-raw-sys", - "windows-sys 0.36.1", + "linux-raw-sys 0.0.46", + "windows-sys 0.42.0", +] + +[[package]] +name = "rustix" +version = "0.36.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f43abb88211988493c1abb44a70efa56ff0ce98f233b7b276146f1f3f7ba9644" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes 1.0.5", + "libc", + "linux-raw-sys 0.1.4", + "windows-sys 0.45.0", ] [[package]] name = "rustls" -version = "0.20.2" +version = "0.20.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d37e5e2290f3e040b594b1a9e04377c2c671f1a1cfd9bfdef82106ac1c113f84" +checksum = "fff78fc74d175294f4e83b28343315ffcfb114b156f0185e9741cb5570f50e2f" dependencies = [ "log", "ring", @@ -7099,9 +7185,9 @@ dependencies = [ [[package]] name = "rustls-native-certs" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ca9ebdfa27d3fc180e42879037b5338ab1c040c06affd00d8338598e7800943" +checksum = "0167bac7a9f490495f3c33013e7722b53cb087ecbe082fb0c6387c96f634ea50" dependencies = [ "openssl-probe", "rustls-pemfile", @@ -7111,18 +7197,18 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "0.2.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5eebeaeb360c87bfb72e84abdb3447159c0eaececf1bef2aecd65a8be949d1c9" +checksum = "d194b56d58803a43635bdc398cd17e383d6f71f9182b9a192c127ca42494a59b" dependencies = [ - "base64", + "base64 0.21.0", ] [[package]] name = "rustversion" -version = "1.0.6" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2cc38e8fa666e2de3c4aba7edeb5ffc5246c1c2ed0e3d17e560aeeba736b23f" +checksum = "5583e89e108996506031660fe09baa5011b9dd0341b89029313006d1fb508d70" [[package]] name = "rusty-fork" @@ -7148,9 +7234,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.5" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" +checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde" [[package]] name = "safe-mix" @@ -7280,7 +7366,7 @@ version = "0.10.0-dev" dependencies = [ "array-bytes", "chrono", - "clap 4.0.11", + "clap 4.1.7", "fdlimit", "futures", "futures-timer", @@ -7623,7 +7709,7 @@ version = "0.10.0-dev" dependencies = [ "array-bytes", "criterion", - "env_logger", + "env_logger 0.9.3", "lru", "num_cpus", "parity-scale-codec", @@ -7651,7 +7737,7 @@ dependencies = [ "tempfile", "tracing", "tracing-subscriber 0.2.25", - "wasmi 0.13.0", + "wasmi 0.13.2", "wat", ] @@ -7664,7 +7750,7 @@ dependencies = [ "sp-wasm-interface", "thiserror", "wasm-instrument 0.3.0", - "wasmi 0.13.0", + "wasmi 0.13.2", ] [[package]] @@ -7676,7 +7762,7 @@ dependencies = [ "sc-executor-common", "sp-runtime-interface", "sp-wasm-interface", - "wasmi 0.13.0", + "wasmi 0.13.2", ] [[package]] @@ -7689,7 +7775,7 @@ dependencies = [ "once_cell", "parity-scale-codec", "paste", - "rustix", + "rustix 0.35.13", "sc-allocator", "sc-executor-common", "sc-runtime-test", @@ -7846,7 +7932,7 @@ dependencies = [ "tempfile", "thiserror", "tokio", - "tokio-util 0.7.4", + "tokio-util", "unsigned-varint", "zeroize", ] @@ -8090,7 +8176,7 @@ name = "sc-rpc" version = "4.0.0-dev" dependencies = [ "assert_matches", - "env_logger", + "env_logger 0.9.3", "futures", "jsonrpsee", "log", @@ -8468,9 +8554,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.2.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "333af15b02563b8182cd863f925bd31ef8fa86a0e095d30c091956057d436153" +checksum = "001cf62ece89779fd16105b5f515ad0e5cedcd5440d3dd806bb067978e7c3608" dependencies = [ "bitvec", "cfg-if", @@ -8482,9 +8568,9 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.2.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53f56acbd0743d29ffa08f911ab5397def774ad01bab3786804cf6ee057fb5e1" +checksum = "303959cf613a6f6efd19ed4b4ad5bf79966a13352716299ad532cfb115f4205c" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -8494,12 +8580,11 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.19" +version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75" +checksum = "713cfb06c7059f3588fb8044c0fad1d09e3c01d225e25b9220dbfdcf16dbb1b3" dependencies = [ - "lazy_static", - "winapi", + "windows-sys 0.42.0", ] [[package]] @@ -8510,7 +8595,7 @@ checksum = "021b403afe70d81eea68f6ea12f6b3c9588e5d536a94c3bf80f15e7faa267862" dependencies = [ "arrayref", "arrayvec 0.5.2", - "curve25519-dalek 2.1.2", + "curve25519-dalek 2.1.3", "getrandom 0.1.16", "merlin", "rand 0.7.3", @@ -8528,9 +8613,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "scratch" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898" +checksum = "ddccb15bcce173023b3fedd9436f882a0739b8dfb45e4f6b6002bee5929f61b2" [[package]] name = "sct" @@ -8550,7 +8635,7 @@ checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" dependencies = [ "base16ct", "der", - "generic-array 0.14.4", + "generic-array 0.14.6", "pkcs8", "subtle", "zeroize", @@ -8558,18 +8643,18 @@ dependencies = [ [[package]] name = "secp256k1" -version = "0.24.0" +version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7649a0b3ffb32636e60c7ce0d70511eda9c52c658cd0634e194d5a19943aeff" +checksum = "6b1629c9c557ef9b293568b338dddfc8208c98a18c59d722a9d53f859d9c9b62" dependencies = [ "secp256k1-sys", ] [[package]] name = "secp256k1-sys" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7058dc8eaf3f2810d7828680320acda0b25a288f6d288e19278e249bbf74226b" +checksum = "83080e2c2fc1006e625be82e5d1eb6a43b7fd9578b617fcc55814daf286bba4b" dependencies = [ "cc", ] @@ -8585,9 +8670,9 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.3.0" +version = "2.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b239a3d5db51252f6f48f42172c65317f37202f4a21021bf5f9d40a408f4592c" +checksum = "a332be01508d814fed64bf28f798a146d73792121129962fdf335bb3c49a4254" dependencies = [ "bitflags", "core-foundation", @@ -8598,9 +8683,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.3.0" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e4effb91b4b8b6fb7732e670b6cee160278ff8e6bf485c7805d9e319d76e284" +checksum = "31c9bb296072e961fcbd8853511dd39c2d8be2deb1e17c6860b1d30732b323b4" dependencies = [ "core-foundation-sys", "libc", @@ -8626,9 +8711,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.4" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "568a8e6258aa33c13358f81fd834adb854c6f7c9468520910a9b1e8fac068012" +checksum = "58bc9567378fc7690d6b2addae4e60ac2eeea07becb2c64b9f218b53865cba2a" dependencies = [ "serde", ] @@ -8641,18 +8726,18 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.145" +version = "1.0.152" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "728eb6351430bccb993660dfffc5a72f91ccc1295abaa8ce19b27ebe4f75568b" +checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" dependencies = [ "serde_derive", ] [[package]] name = "serde_cbor" -version = "0.11.1" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e18acfa2f90e8b735b2836ab8d538de304cbb6729a7360729ea5a895d15a622" +checksum = "2bef2ebfde456fb76bbcf9f59315333decc4fda0b2b44b420243c11e0f5ec1f5" dependencies = [ "half", "serde", @@ -8660,9 +8745,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.145" +version = "1.0.152" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81fa1584d3d1bcacd84c277a0dfe21f5b0f6accf4a23d04d4c6d61f1af522b4c" +checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" dependencies = [ "proc-macro2", "quote", @@ -8671,39 +8756,28 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.85" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e55a28e3aaef9d5ce0506d0a14dbba8054ddc7e499ef522dd8b26859ec9d4a44" +checksum = "cad406b69c91885b5107daf2c29572f6c8cdb3c66826821e286c533490c0bc76" dependencies = [ - "itoa 1.0.4", + "itoa", "ryu", "serde", ] [[package]] name = "sha-1" -version = "0.9.4" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfebf75d25bd900fd1e7d11501efab59bc846dbc76196839663e6637bba9f25f" +checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6" dependencies = [ "block-buffer 0.9.0", "cfg-if", - "cpuid-bool", + "cpufeatures", "digest 0.9.0", "opaque-debug 0.3.0", ] -[[package]] -name = "sha1" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "006769ba83e921b3085caa8334186b00cf92b4cb1a6cf4632fbccc8eff5c7549" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest 0.10.3", -] - [[package]] name = "sha2" version = "0.8.2" @@ -8718,9 +8792,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.9.8" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b69f9a4c9740d74c5baa3fd2e547f9525fa8088a8a958e0ca2409a514e33f5fa" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" dependencies = [ "block-buffer 0.9.0", "cfg-if", @@ -8731,22 +8805,22 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.2" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55deaec60f81eefe3cce0dc50bda92d6d8e88f2a27df7c5033b42afeb1ed2676" +checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" dependencies = [ "cfg-if", "cpufeatures", - "digest 0.10.3", + "digest 0.10.6", ] [[package]] name = "sha3" -version = "0.10.0" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31f935e31cf406e8c0e96c2815a5516181b7004ae8c5f296293221e9b1e356bd" +checksum = "bdf0c33fae925bdc080598b84bc15c55e7b9a4a43b3c704da051f977469691c9" dependencies = [ - "digest 0.10.3", + "digest 0.10.6", "keccak", ] @@ -8761,27 +8835,27 @@ dependencies = [ [[package]] name = "shlex" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42a568c8f2cd051a4d283bd6eb0343ac214c1b0f1ac19f93e1175b2dee38c73d" +checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" [[package]] name = "signal-hook-registry" -version = "1.3.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16f1d0fef1604ba8f7a073c7e701f213e056707210e9020af4528e0101ce11a6" +checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" dependencies = [ "libc", ] [[package]] name = "signature" -version = "1.6.3" +version = "1.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "deb766570a2825fa972bceff0d195727876a9cdf2460ab2e52d455dc2de47fd9" +checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" dependencies = [ - "digest 0.10.3", - "rand_core 0.6.2", + "digest 0.10.6", + "rand_core 0.6.4", ] [[package]] @@ -8798,9 +8872,12 @@ dependencies = [ [[package]] name = "slab" -version = "0.4.2" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" +checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" +dependencies = [ + "autocfg", +] [[package]] name = "slice-group-by" @@ -8816,32 +8893,32 @@ checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" [[package]] name = "snap" -version = "1.0.5" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45456094d1983e2ee2a18fdfebce3189fa451699d0502cb8e3b49dba5ba41451" +checksum = "5e9f0ab6ef7eb7353d9119c170a436d1bf248eea575ac42d19d12f4e34130831" [[package]] name = "snow" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "774d05a3edae07ce6d68ea6984f3c05e9bba8927e3dd591e3b479e5b03213d0d" +checksum = "12ba5f4d4ff12bdb6a169ed51b7c48c0e0ac4b0b4b31012b2571e97d78d3201d" dependencies = [ "aes-gcm", "blake2", "chacha20poly1305", - "curve25519-dalek 4.0.0-pre.1", - "rand_core 0.6.2", + "curve25519-dalek 4.0.0-rc.0", + "rand_core 0.6.4", "ring", "rustc_version 0.4.0", - "sha2 0.10.2", + "sha2 0.10.6", "subtle", ] [[package]] name = "socket2" -version = "0.4.4" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66d72b759436ae32898a2af0a14218dbf55efde3feeb170eb623637db85ee1e0" +checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" dependencies = [ "libc", "winapi", @@ -8853,7 +8930,7 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41d1c5305e39e09653383c2c7244f2f78b3bcae37cf50c64cb4789c9f5096ec2" dependencies = [ - "base64", + "base64 0.13.1", "bytes", "flate2", "futures", @@ -9176,8 +9253,8 @@ version = "5.0.0" dependencies = [ "blake2", "byteorder", - "digest 0.10.3", - "sha2 0.10.2", + "digest 0.10.6", + "sha2 0.10.6", "sha3", "sp-std", "twox-hash", @@ -9348,7 +9425,7 @@ dependencies = [ name = "sp-npos-elections-fuzzer" version = "2.0.0-alpha.5" dependencies = [ - "clap 4.0.11", + "clap 4.1.7", "honggfuzz", "parity-scale-codec", "rand 0.8.5", @@ -9624,7 +9701,7 @@ dependencies = [ "array-bytes", "criterion", "hash-db", - "hashbrown 0.12.3", + "hashbrown", "lazy_static", "lru", "memory-db", @@ -9678,7 +9755,7 @@ dependencies = [ "log", "parity-scale-codec", "sp-std", - "wasmi 0.13.0", + "wasmi 0.13.2", "wasmtime", ] @@ -9704,9 +9781,9 @@ checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" [[package]] name = "spin" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f6002a767bff9e83f8eeecf883ecb8011875a21ae8da43bffb817a57e78cc09" +checksum = "7dccf47db1b41fa1573ed27ccf5e08e3ca771cb994f776668c5ebda893b248fc" [[package]] name = "spki" @@ -9720,9 +9797,9 @@ dependencies = [ [[package]] name = "ss58-registry" -version = "1.34.0" +version = "1.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37a9821878e1f13aba383aa40a86fb1b33c7265774ec91e32563cb1dd1577496" +checksum = "ecf0bd63593ef78eca595a7fc25e9a443ca46fe69fd472f8f09f5245cdcd769d" dependencies = [ "Inflector", "num-format", @@ -9755,7 +9832,7 @@ dependencies = [ "cfg_aliases", "libc", "parking_lot 0.11.2", - "parking_lot_core 0.8.5", + "parking_lot_core 0.8.6", "static_init_macro", "winapi", ] @@ -9803,9 +9880,9 @@ dependencies = [ [[package]] name = "strum_macros" -version = "0.24.2" +version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4faebde00e8ff94316c01800f9054fd2ba77d30d9e922541913051d1d978918b" +checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" dependencies = [ "heck", "proc-macro2", @@ -9818,7 +9895,7 @@ dependencies = [ name = "subkey" version = "2.0.2" dependencies = [ - "clap 4.0.11", + "clap 4.1.7", "sc-cli", ] @@ -9831,7 +9908,7 @@ dependencies = [ "hmac 0.11.0", "pbkdf2 0.8.0", "schnorrkel", - "sha2 0.9.8", + "sha2 0.9.9", "zeroize", ] @@ -9839,14 +9916,14 @@ dependencies = [ name = "substrate-build-script-utils" version = "3.0.0" dependencies = [ - "platforms", + "platforms 2.0.0", ] [[package]] name = "substrate-frame-cli" version = "4.0.0-dev" dependencies = [ - "clap 4.0.11", + "clap 4.1.7", "frame-support", "frame-system", "sc-cli", @@ -10091,15 +10168,15 @@ dependencies = [ [[package]] name = "subtle" -version = "2.4.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e81da0851ada1f3e9d4312c704aa4f8806f0f9d69faaf8df2f3464b4a9437c2" +checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "syn" -version = "1.0.98" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ "proc-macro2", "quote", @@ -10108,9 +10185,9 @@ dependencies = [ [[package]] name = "synstructure" -version = "0.12.4" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701" +checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" dependencies = [ "proc-macro2", "quote", @@ -10147,33 +10224,38 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "target-lexicon" -version = "0.12.3" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7fa7e55043acb85fca6b3c01485a2eeb6b69c5d21002e273c79e465f43b7ac1" +checksum = "8ae9980cab1db3fceee2f6c6f643d5d8de2997c58ee8d25fb0cc8a9e9e7348e5" [[package]] name = "tempfile" -version = "3.3.0" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" +checksum = "af18f7ae1acd354b992402e9ec5864359d693cd8a79dcbef59f76891701c1e95" dependencies = [ "cfg-if", "fastrand", - "libc", "redox_syscall", - "remove_dir_all", - "winapi", + "rustix 0.36.8", + "windows-sys 0.42.0", ] [[package]] name = "termcolor" -version = "1.1.2" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" +checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" dependencies = [ "winapi-util", ] +[[package]] +name = "termtree" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95059e91184749cb66be6dc994f67f182b6d897cb3df74a5bf66b5e709295fd8" + [[package]] name = "textwrap" version = "0.11.0" @@ -10185,18 +10267,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.37" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e" +checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.37" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" +checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" dependencies = [ "proc-macro2", "quote", @@ -10211,10 +10293,11 @@ checksum = "3bf63baf9f5039dadc247375c29eb13706706cfde997d0330d05aa63a77d8820" [[package]] name = "thread_local" -version = "1.1.4" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180" +checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" dependencies = [ + "cfg-if", "once_cell", ] @@ -10229,20 +10312,19 @@ dependencies = [ [[package]] name = "tikv-jemalloc-sys" -version = "0.5.1+5.3.0-patched" +version = "0.5.3+5.3.0-patched" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "931e876f91fed0827f863a2d153897790da0b24d882c721a79cb3beb0b903261" +checksum = "a678df20055b43e57ef8cddde41cdfda9a3c1a060b67f4c5836dfb1d78543ba8" dependencies = [ "cc", - "fs_extra", "libc", ] [[package]] name = "time" -version = "0.1.44" +version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" +checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" dependencies = [ "libc", "wasi 0.10.0+wasi-snapshot-preview1", @@ -10261,7 +10343,7 @@ dependencies = [ "pbkdf2 0.11.0", "rand 0.8.5", "rustc-hash", - "sha2 0.10.2", + "sha2 0.10.6", "thiserror", "unicode-normalization", "wasm-bindgen", @@ -10289,24 +10371,24 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.1.1" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "317cca572a0e89c3ce0ca1f1bdc9369547fe318a683418e42ac8f59d14701023" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" dependencies = [ "tinyvec_macros", ] [[package]] name = "tinyvec_macros" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.22.0" +version = "1.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d76ce4a75fb488c605c54bf610f221cea8b0dafb53333c1a67e8ee199dcd2ae3" +checksum = "c8e00990ebabbe4c14c08aca901caed183ecd5c09562a12c824bb53d3c3fd3af" dependencies = [ "autocfg", "bytes", @@ -10319,14 +10401,14 @@ dependencies = [ "signal-hook-registry", "socket2", "tokio-macros", - "winapi", + "windows-sys 0.42.0", ] [[package]] name = "tokio-macros" -version = "1.7.0" +version = "1.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b557f72f448c511a979e2564e55d74e6c4432fc96ff4f6241bc6bded342643b7" +checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8" dependencies = [ "proc-macro2", "quote", @@ -10335,9 +10417,9 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.23.2" +version = "0.23.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a27d5f2b839802bd8267fa19b0530f5a08b9c08cd417976be2a65d130fe1c11b" +checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59" dependencies = [ "rustls", "tokio", @@ -10346,14 +10428,14 @@ dependencies = [ [[package]] name = "tokio-stream" -version = "0.1.7" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b2f3f698253f03119ac0102beaa64f67a67e08074d03a22d18784104543727f" +checksum = "8fb52b74f05dbf495a8fba459fdc331812b96aa086d9eb78101fa0d4569c3313" dependencies = [ "futures-core", "pin-project-lite 0.2.9", "tokio", - "tokio-util 0.6.10", + "tokio-util", ] [[package]] @@ -10371,23 +10453,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.6.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36943ee01a6d67977dd3f84a5a1d2efeb4ada3a1ae771cadfaa535d9d9fc6507" -dependencies = [ - "bytes", - "futures-core", - "futures-sink", - "log", - "pin-project-lite 0.2.9", - "tokio", -] - -[[package]] -name = "tokio-util" -version = "0.7.4" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bb2e075f03b3d66d8d8785356224ba688d2906a371015e225beeb65ca92c740" +checksum = "5427d89453009325de0d8f342c9490009f76e999cb7672d77e46267448f7e6b2" dependencies = [ "bytes", "futures-core", @@ -10400,9 +10468,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.5.8" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" dependencies = [ "serde", ] @@ -10444,15 +10512,15 @@ checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" [[package]] name = "tower-service" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" [[package]] name = "tracing" -version = "0.1.35" +version = "0.1.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a400e31aa60b9d44a52a8ee0343b5b18566b03a8321e0d321f695cf56e940160" +checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" dependencies = [ "cfg-if", "log", @@ -10463,9 +10531,9 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.22" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11c75893af559bc8e10716548bdef5cb2b983f8e637db9d0e15126b61b484ee2" +checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" dependencies = [ "proc-macro2", "quote", @@ -10505,9 +10573,9 @@ dependencies = [ [[package]] name = "tracing-serde" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb65ea441fbb84f9f6748fd496cf7f63ec9af5bca94dd86456978d055e8eb28b" +checksum = "bc6b213177105856957181934e4920de57730fc69bf42c37ee5bb664d406d9e1" dependencies = [ "serde", "tracing-core", @@ -10554,12 +10622,6 @@ dependencies = [ "tracing-log", ] -[[package]] -name = "treeline" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7f741b240f1a48843f9b8e0444fb55fb2a4ff67293b50a9179dfd5ea67f8d41" - [[package]] name = "trie-bench" version = "0.33.0" @@ -10583,7 +10645,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "004e1e8f92535694b4cb1444dc5a8073ecf0815e3357f729638b9f8fc4062908" dependencies = [ "hash-db", - "hashbrown 0.12.3", + "hashbrown", "log", "rustc-hex", "smallvec", @@ -10621,7 +10683,7 @@ dependencies = [ "futures-channel", "futures-io", "futures-util", - "idna", + "idna 0.2.3", "ipnet", "lazy_static", "rand 0.8.5", @@ -10655,15 +10717,15 @@ dependencies = [ [[package]] name = "try-lock" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" +checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" [[package]] name = "try-runtime-cli" version = "0.10.0-dev" dependencies = [ - "clap 4.0.11", + "clap 4.1.7", "frame-remote-externalities", "frame-try-runtime", "hex", @@ -10691,10 +10753,11 @@ dependencies = [ [[package]] name = "trybuild" -version = "1.0.60" +version = "1.0.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0da18123d1316f5a65fc9b94e30a0fcf58afb1daff1b8e18f41dc30f5bfc38c8" +checksum = "a44da5a6f2164c8e14d3bbc0657d69c5966af9f5f6930d4f600b1f5c4a673413" dependencies = [ + "basic-toml", "dissimilar", "glob", "once_cell", @@ -10702,14 +10765,13 @@ dependencies = [ "serde_derive", "serde_json", "termcolor", - "toml", ] [[package]] name = "tt-call" -version = "1.0.8" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e66dcbec4290c69dd03c57e76c2469ea5c7ce109c6dd4351c13055cf71ea055" +checksum = "f4f195fd851901624eee5a58c4bb2b4f06399148fcd0ed336e6f1cb60a9881df" [[package]] name = "twox-hash" @@ -10718,28 +10780,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ "cfg-if", - "digest 0.10.3", + "digest 0.10.6", "rand 0.8.5", "static_assertions", ] [[package]] name = "typenum" -version = "1.15.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" +checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" [[package]] name = "ucd-trie" -version = "0.1.3" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" +checksum = "9e79c4d996edb816c91e4308506774452e55e95c3c9de07b6729e17e15a5ef81" [[package]] name = "uint" -version = "0.9.0" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e11fe9a9348741cf134085ad57c249508345fe16411b3d7fb4ff2da2f1d6382e" +checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" dependencies = [ "byteorder", "crunchy", @@ -10749,18 +10811,15 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.4" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" -dependencies = [ - "matches", -] +checksum = "d54675592c1dbefd78cbd98db9bacd89886e1ca50692a0692baefffdeb92dd58" [[package]] name = "unicode-ident" -version = "1.0.1" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c" +checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" [[package]] name = "unicode-normalization" @@ -10773,15 +10832,15 @@ dependencies = [ [[package]] name = "unicode-width" -version = "0.1.8" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" +checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" [[package]] name = "unicode-xid" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" [[package]] name = "universal-hash" @@ -10789,7 +10848,7 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f214e8f697e925001e66ec2c6e37a4ef93f0f78c2eed7814394e10c62025b05" dependencies = [ - "generic-array 0.14.4", + "generic-array 0.14.6", "subtle", ] @@ -10813,13 +10872,12 @@ checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" [[package]] name = "url" -version = "2.2.1" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ccd964113622c8e9322cfac19eb1004a07e636c545f325da085d5cdde6f1f8b" +checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" dependencies = [ "form_urlencoded", - "idna", - "matches", + "idna 0.3.0", "percent-encoding", ] @@ -10831,21 +10889,15 @@ checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" [[package]] name = "vcpkg" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00bca6106a5e23f3eee943593759b7fcddb00554332e856d990c893966879fb" - -[[package]] -name = "vec-arena" -version = "1.0.0" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eafc1b9b2dfc6f5529177b62cf806484db55b32dc7c9658a118e11bbeb33061d" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "version_check" -version = "0.9.2" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "void" @@ -10909,9 +10961,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.77" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e68338db6becec24d3c7977b5bf8a48be992c934b5d07177e3931f5dc9b076c" +checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -10919,13 +10971,13 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.77" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f34c405b4f0658583dba0c1c7c9b694f3cac32655db463b56c254a1c75269523" +checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" dependencies = [ "bumpalo", - "lazy_static", "log", + "once_cell", "proc-macro2", "quote", "syn", @@ -10934,9 +10986,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.20" +version = "0.4.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3de431a2910c86679c34283a33f66f4e4abd7e0aec27b6669060148872aadf94" +checksum = "f219e0d211ba40266969f6dbdd90636da12f75bee4fc9d6c23d1260dadb51454" dependencies = [ "cfg-if", "js-sys", @@ -10946,9 +10998,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.77" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9d5a6580be83b19dc570a8f9c324251687ab2184e57086f71625feb57ec77c8" +checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -10956,9 +11008,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.77" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3775a030dc6f5a0afd8a84981a21cc92a781eb429acef9ecce476d0c9113e92" +checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" dependencies = [ "proc-macro2", "quote", @@ -10969,9 +11021,18 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.77" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" + +[[package]] +name = "wasm-encoder" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c279e376c7a8e8752a8f1eaa35b7b0bee6bb9fb0cdacfa97cc3f1f289c87e2b4" +checksum = "68f7d56227d910901ce12dfd19acc40c12687994dfb3f57c90690f80be946ec5" +dependencies = [ + "leb128", +] [[package]] name = "wasm-instrument" @@ -11049,13 +11110,13 @@ dependencies = [ [[package]] name = "wasmi" -version = "0.13.0" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc13b3c219ca9aafeec59150d80d89851df02e0061bc357b4d66fc55a8d38787" +checksum = "06c326c93fbf86419608361a2c925a31754cf109da1b8b55737070b4d6669422" dependencies = [ "parity-wasm", "wasmi-validation", - "wasmi_core 0.2.0", + "wasmi_core 0.2.1", ] [[package]] @@ -11064,7 +11125,7 @@ version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "01bf50edb2ea9d922aa75a7bf3c15e26a6c9e2d18c56e862b49737a582901729" dependencies = [ - "spin 0.9.4", + "spin 0.9.5", "wasmi_arena", "wasmi_core 0.5.0", "wasmparser-nostd", @@ -11087,12 +11148,12 @@ checksum = "a1ea379cbb0b41f3a9f0bf7b47036d036aae7f43383d8cc487d4deccf40dee0a" [[package]] name = "wasmi_core" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a088e8c4c59c6f2b9eae169bf86328adccc477c00b56d3661e3e9fb397b184" +checksum = "57d20cb3c59b788653d99541c646c561c9dd26506f25c0cebfe810659c54c6d7" dependencies = [ "downcast-rs", - "libm", + "libm 0.2.6", "memory_units", "num-rational", "num-traits", @@ -11105,7 +11166,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c5bf998ab792be85e20e771fe14182b4295571ad1d4f89d3da521c1bef5f597a" dependencies = [ "downcast-rs", - "libm", + "libm 0.2.6", "num-traits", ] @@ -11129,9 +11190,9 @@ dependencies = [ [[package]] name = "wasmtime" -version = "1.0.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a10dc9784d8c3a33c970e3939180424955f08af2e7f20368ec02685a0e8f065" +checksum = "4ad5af6ba38311282f2a21670d96e78266e8c8e2f38cbcd52c254df6ccbc7731" dependencies = [ "anyhow", "bincode", @@ -11157,28 +11218,28 @@ dependencies = [ [[package]] name = "wasmtime-asm-macros" -version = "1.0.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee4dbdc6daf68528cad1275ac91e3f51848ce9824385facc94c759f529decdf8" +checksum = "45de63ddfc8b9223d1adc8f7b2ee5f35d1f6d112833934ad7ea66e4f4339e597" dependencies = [ "cfg-if", ] [[package]] name = "wasmtime-cache" -version = "1.0.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f507f3fa1ee1b2f9a83644e2514242b1dfe580782c0eb042f1ef70255bc4ffe" +checksum = "bcd849399d17d2270141cfe47fa0d91ee52d5f8ea9b98cf7ddde0d53e5f79882" dependencies = [ "anyhow", - "base64", + "base64 0.13.1", "bincode", "directories-next", "file-per-thread-logger", "log", - "rustix", + "rustix 0.35.13", "serde", - "sha2 0.9.8", + "sha2 0.9.9", "toml", "windows-sys 0.36.1", "zstd", @@ -11186,9 +11247,9 @@ dependencies = [ [[package]] name = "wasmtime-cranelift" -version = "1.0.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f03cf79d982fc68e94ba0bea6a300a3b94621c4eb9705eece0a4f06b235a3b5" +checksum = "4bd91339b742ff20bfed4532a27b73c86b5bcbfedd6bea2dcdf2d64471e1b5c6" dependencies = [ "anyhow", "cranelift-codegen", @@ -11196,7 +11257,7 @@ dependencies = [ "cranelift-frontend", "cranelift-native", "cranelift-wasm", - "gimli 0.26.1", + "gimli 0.26.2", "log", "object 0.29.0", "target-lexicon", @@ -11207,13 +11268,13 @@ dependencies = [ [[package]] name = "wasmtime-environ" -version = "1.0.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c587c62e91c5499df62012b87b88890d0eb470b2ffecc5964e9da967b70c77c" +checksum = "ebb881c61f4f627b5d45c54e629724974f8a8890d455bcbe634330cc27309644" dependencies = [ "anyhow", "cranelift-entity", - "gimli 0.26.1", + "gimli 0.26.2", "indexmap", "log", "object 0.29.0", @@ -11226,20 +11287,20 @@ dependencies = [ [[package]] name = "wasmtime-jit" -version = "1.0.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "047839b5dabeae5424a078c19b8cc897e5943a7fadc69e3d888b9c9a897666b3" +checksum = "1985c628011fe26adf5e23a5301bdc79b245e0e338f14bb58b39e4e25e4d8681" dependencies = [ "addr2line 0.17.0", "anyhow", "bincode", "cfg-if", "cpp_demangle", - "gimli 0.26.1", + "gimli 0.26.2", "log", "object 0.29.0", "rustc-demangle", - "rustix", + "rustix 0.35.13", "serde", "target-lexicon", "thiserror", @@ -11251,20 +11312,20 @@ dependencies = [ [[package]] name = "wasmtime-jit-debug" -version = "1.0.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b299569abf6f99b7b8e020afaf84a700e8636c6a42e242069267322cd5818235" +checksum = "f671b588486f5ccec8c5a3dba6b4c07eac2e66ab8c60e6f4e53717c77f709731" dependencies = [ "object 0.29.0", "once_cell", - "rustix", + "rustix 0.35.13", ] [[package]] name = "wasmtime-runtime" -version = "1.0.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae79e0515160bd5abee5df50a16c4eb8db9f71b530fc988ae1d9ce34dcb8dd01" +checksum = "ee8f92ad4b61736339c29361da85769ebc200f184361959d1792832e592a1afd" dependencies = [ "anyhow", "cc", @@ -11274,10 +11335,10 @@ dependencies = [ "log", "mach", "memfd", - "memoffset", + "memoffset 0.6.5", "paste", "rand 0.8.5", - "rustix", + "rustix 0.35.13", "thiserror", "wasmtime-asm-macros", "wasmtime-environ", @@ -11287,9 +11348,9 @@ dependencies = [ [[package]] name = "wasmtime-types" -version = "1.0.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "790cf43ee8e2d5dad1780af30f00d7a972b74725fb1e4f90c28d62733819b185" +checksum = "d23d61cb4c46e837b431196dd06abb11731541021916d03476a178b54dc07aeb" dependencies = [ "cranelift-entity", "serde", @@ -11299,27 +11360,30 @@ dependencies = [ [[package]] name = "wast" -version = "38.0.0" +version = "54.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ebc29df4629f497e0893aacd40f13a4a56b85ef6eb4ab6d603f07244f1a7bf2" +checksum = "3d48d9d731d835f4f8dacbb8de7d47be068812cb9877f5c60d408858778d8d2a" dependencies = [ "leb128", + "memchr", + "unicode-width", + "wasm-encoder", ] [[package]] name = "wat" -version = "1.0.40" +version = "1.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adcfaeb27e2578d2c6271a45609f4a055e6d7ba3a12eff35b1fd5ba147bdf046" +checksum = "d1db2e3ed05ea31243761439194bec3af6efbbaf87c4c8667fb879e4f23791a0" dependencies = [ "wast", ] [[package]] name = "web-sys" -version = "0.3.54" +version = "0.3.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a84d70d1ec7d2da2d26a5bd78f4bca1b8c3254805363ce743b7a05bc30d195a" +checksum = "e33b99f4b23ba3eec1a53ac264e35a755f00e966e0065077d6027c0f575b0b97" dependencies = [ "js-sys", "wasm-bindgen", @@ -11337,9 +11401,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.22.2" +version = "0.22.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "552ceb903e957524388c4d3475725ff2c8b7960922063af6ce53c9a43da07449" +checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87" dependencies = [ "webpki", ] @@ -11355,12 +11419,13 @@ dependencies = [ [[package]] name = "which" -version = "4.0.2" +version = "4.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87c14ef7e1b8b8ecfc75d5eca37949410046e66f15d185c01d70824f1f8111ef" +checksum = "2441c784c52b289a054b7201fc93253e288f094e2f4be9058343127c4226a269" dependencies = [ + "either", "libc", - "thiserror", + "once_cell", ] [[package]] @@ -11413,19 +11478,6 @@ dependencies = [ "windows_x86_64_msvc 0.34.0", ] -[[package]] -name = "windows-sys" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3df6e476185f92a12c072be4a189a0210dcdcf512a1891d6dff9edb874deadc6" -dependencies = [ - "windows_aarch64_msvc 0.32.0", - "windows_i686_gnu 0.32.0", - "windows_i686_msvc 0.32.0", - "windows_x86_64_gnu 0.32.0", - "windows_x86_64_msvc 0.32.0", -] - [[package]] name = "windows-sys" version = "0.36.1" @@ -11440,10 +11492,49 @@ dependencies = [ ] [[package]] -name = "windows_aarch64_msvc" -version = "0.32.0" +name = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc 0.42.1", + "windows_i686_gnu 0.42.1", + "windows_i686_msvc 0.42.1", + "windows_x86_64_gnu 0.42.1", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc 0.42.1", +] + +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc 0.42.1", + "windows_i686_gnu 0.42.1", + "windows_i686_msvc 0.42.1", + "windows_x86_64_gnu 0.42.1", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc 0.42.1", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8e92753b1c443191654ec532f14c199742964a061be25d77d7a96f09db20bf5" +checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" [[package]] name = "windows_aarch64_msvc" @@ -11458,10 +11549,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" [[package]] -name = "windows_i686_gnu" -version = "0.32.0" +name = "windows_aarch64_msvc" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a711c68811799e017b6038e0922cb27a5e2f43a2ddb609fe0b6f3eeda9de615" +checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" [[package]] name = "windows_i686_gnu" @@ -11476,10 +11567,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" [[package]] -name = "windows_i686_msvc" -version = "0.32.0" +name = "windows_i686_gnu" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "146c11bb1a02615db74680b32a68e2d61f553cc24c4eb5b4ca10311740e44172" +checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" [[package]] name = "windows_i686_msvc" @@ -11494,10 +11585,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" [[package]] -name = "windows_x86_64_gnu" -version = "0.32.0" +name = "windows_i686_msvc" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c912b12f7454c6620635bbff3450962753834be2a594819bd5e945af18ec64bc" +checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" [[package]] name = "windows_x86_64_gnu" @@ -11512,10 +11603,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" [[package]] -name = "windows_x86_64_msvc" -version = "0.32.0" +name = "windows_x86_64_gnu" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "504a2476202769977a040c6364301a3f65d0cc9e3fb08600b2bda150a0488316" +checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" [[package]] name = "windows_x86_64_msvc" @@ -11529,20 +11626,26 @@ version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" + [[package]] name = "winreg" -version = "0.7.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0120db82e8a1e0b9fb3345a539c478767c0048d842860994d96113d5b667bd69" +checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" dependencies = [ "winapi", ] [[package]] name = "wyz" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30b31594f29d27036c383b53b59ed3476874d518f0efb151b27a4c275141390e" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" dependencies = [ "tap", ] @@ -11553,7 +11656,7 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a0c105152107e3b96f6a00a65e86ce82d9b125230e1c4302940eca58ff71f4f" dependencies = [ - "curve25519-dalek 3.0.2", + "curve25519-dalek 3.2.0", "rand_core 0.5.1", "zeroize", ] @@ -11572,6 +11675,12 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "yansi" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" + [[package]] name = "zeroize" version = "1.5.7" @@ -11583,9 +11692,9 @@ dependencies = [ [[package]] name = "zeroize_derive" -version = "1.3.2" +version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f8f187641dad4f680d25c4bfc4225b418165984179f26ca76ec4fb6441d3a17" +checksum = "44bf07cb3e50ea2003396695d58bf46bc9887a1f362260446fad6bc4e79bd36c" dependencies = [ "proc-macro2", "quote", @@ -11614,10 +11723,11 @@ dependencies = [ [[package]] name = "zstd-sys" -version = "2.0.1+zstd.1.5.2" +version = "2.0.7+zstd.1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fd07cbbc53846d9145dbffdf6dd09a7a0aa52be46741825f5c97bdd4f73f12b" +checksum = "94509c3ba2fe55294d752b79842c530ccfab760192521df74a081a78d2b3c7f5" dependencies = [ "cc", "libc", + "pkg-config", ] diff --git a/Cargo.toml b/Cargo.toml index 4ab4e4cf340ce..8f55d8e527ecd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -141,8 +141,6 @@ members = [ "frame/staking", "frame/staking/reward-curve", "frame/staking/reward-fn", - "frame/staking/rpc", - "frame/staking/rpc/runtime-api", "frame/state-trie-migration", "frame/sudo", "frame/root-offences", diff --git a/bin/node/rpc/Cargo.toml b/bin/node/rpc/Cargo.toml index 48252c722ddb7..f34922a287dfe 100644 --- a/bin/node/rpc/Cargo.toml +++ b/bin/node/rpc/Cargo.toml @@ -16,7 +16,6 @@ targets = ["x86_64-unknown-linux-gnu"] jsonrpsee = { version = "0.16.2", features = ["server"] } node-primitives = { version = "2.0.0", path = "../primitives" } pallet-transaction-payment-rpc = { version = "4.0.0-dev", path = "../../../frame/transaction-payment/rpc/" } -pallet-staking-rpc = { version = "4.0.0-dev", path = "../../../frame/staking/rpc/" } mmr-rpc = { version = "4.0.0-dev", path = "../../../client/merkle-mountain-range/rpc/" } sc-chain-spec = { version = "4.0.0-dev", path = "../../../client/chain-spec" } sc-client-api = { version = "4.0.0-dev", path = "../../../client/api" } diff --git a/bin/node/rpc/src/lib.rs b/bin/node/rpc/src/lib.rs index 1bd2b26445a60..0dc5ba4039b00 100644 --- a/bin/node/rpc/src/lib.rs +++ b/bin/node/rpc/src/lib.rs @@ -110,7 +110,6 @@ where C::Api: substrate_frame_rpc_system::AccountNonceApi, C::Api: mmr_rpc::MmrRuntimeApi::Hash, BlockNumber>, C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi, - C::Api: pallet_staking_rpc::StakingRuntimeApi, C::Api: BabeApi, C::Api: BlockBuilder, P: TransactionPool + 'static, @@ -119,7 +118,6 @@ where B::State: sc_client_api::backend::StateBackend>, { use mmr_rpc::{Mmr, MmrApiServer}; - use pallet_staking_rpc::{Staking, StakingApiServer}; use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer}; use sc_consensus_babe_rpc::{Babe, BabeApiServer}; use sc_finality_grandpa_rpc::{Grandpa, GrandpaApiServer}; @@ -152,7 +150,6 @@ where // These RPCs should use an asynchronous caller instead. io.merge(Mmr::new(client.clone()).into_rpc())?; io.merge(TransactionPayment::new(client.clone()).into_rpc())?; - io.merge(Staking::new(client.clone()).into_rpc())?; io.merge( Babe::new( client.clone(), diff --git a/bin/node/runtime/Cargo.toml b/bin/node/runtime/Cargo.toml index ec01c16a70ba0..201e3a85f8941 100644 --- a/bin/node/runtime/Cargo.toml +++ b/bin/node/runtime/Cargo.toml @@ -96,7 +96,6 @@ pallet-session = { version = "4.0.0-dev", features = [ "historical" ], path = ". pallet-session-benchmarking = { version = "4.0.0-dev", path = "../../../frame/session/benchmarking", default-features = false, optional = true } pallet-staking = { version = "4.0.0-dev", default-features = false, path = "../../../frame/staking" } pallet-staking-reward-curve = { version = "4.0.0-dev", default-features = false, path = "../../../frame/staking/reward-curve" } -pallet-staking-rpc-runtime-api = { version = "4.0.0-dev", default-features = false, path = "../../../frame/staking/rpc/runtime-api/" } pallet-state-trie-migration = { version = "4.0.0-dev", default-features = false, path = "../../../frame/state-trie-migration" } pallet-scheduler = { version = "4.0.0-dev", default-features = false, path = "../../../frame/scheduler" } pallet-society = { version = "4.0.0-dev", default-features = false, path = "../../../frame/society" } diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index df6c072dea871..7ad739e81c300 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -2133,12 +2133,6 @@ impl_runtime_apis! { } } - impl pallet_staking_rpc_runtime_api::StakingApi for Runtime { - fn query_nominations_quota(balance: Balance) -> u32 { - Staking::query_nominations_quota(balance) - } - } - impl pallet_mmr::primitives::MmrApi< Block, mmr::Hash, diff --git a/frame/staking/rpc/Cargo.toml b/frame/staking/rpc/Cargo.toml deleted file mode 100644 index cf9c192456355..0000000000000 --- a/frame/staking/rpc/Cargo.toml +++ /dev/null @@ -1,24 +0,0 @@ -[package] -name = "pallet-staking-rpc" -version = "4.0.0-dev" -authors = ["Parity Technologies "] -edition = "2021" -license = "Apache-2.0" -homepage = "https://substrate.io" -repository = "https://github.com/paritytech/substrate/" -description = "RPC interface for the staking pallet." -readme = "README.md" - -[package.metadata.docs.rs] -targets = ["x86_64-unknown-linux-gnu"] - -[dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0" } -jsonrpsee = { version = "0.16.2", features = ["client-core", "server", "macros"] } -pallet-staking-rpc-runtime-api = { version = "4.0.0-dev", path = "./runtime-api" } -sp-api = { version = "4.0.0-dev", path = "../../../primitives/api" } -sp-blockchain = { version = "4.0.0-dev", path = "../../../primitives/blockchain" } -sp-core = { version = "7.0.0", path = "../../../primitives/core" } -sp-rpc = { version = "6.0.0", path = "../../../primitives/rpc" } -sp-runtime = { version = "7.0.0", path = "../../../primitives/runtime" } -sp-weights = { version = "4.0.0", path = "../../../primitives/weights" } diff --git a/frame/staking/rpc/README.md b/frame/staking/rpc/README.md deleted file mode 100644 index 8a5a617d1a370..0000000000000 --- a/frame/staking/rpc/README.md +++ /dev/null @@ -1,3 +0,0 @@ -RPC interface for the staking pallet. - -License: Apache-2.0 diff --git a/frame/staking/rpc/runtime-api/Cargo.toml b/frame/staking/rpc/runtime-api/Cargo.toml deleted file mode 100644 index 351cd37b0991c..0000000000000 --- a/frame/staking/rpc/runtime-api/Cargo.toml +++ /dev/null @@ -1,30 +0,0 @@ -[package] -name = "pallet-staking-rpc-runtime-api" -version = "4.0.0-dev" -authors = ["Parity Technologies "] -edition = "2021" -license = "Apache-2.0" -homepage = "https://substrate.io" -repository = "https://github.com/paritytech/substrate/" -description = "RPC runtime API for transaction payment FRAME pallet" -readme = "README.md" - -[package.metadata.docs.rs] -targets = ["x86_64-unknown-linux-gnu"] - -[dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -pallet-staking = { version = "4.0.0-dev", default-features = false, path = "../../../staking" } -sp-api = { version = "4.0.0-dev", default-features = false, path = "../../../../primitives/api" } -sp-runtime = { version = "7.0.0", default-features = false, path = "../../../../primitives/runtime" } -sp-weights = { version = "4.0.0", default-features = false, path = "../../../../primitives/weights" } - -[features] -default = ["std"] -std = [ - "codec/std", - "pallet-staking/std", - "sp-api/std", - "sp-runtime/std", - "sp-weights/std", -] diff --git a/frame/staking/rpc/runtime-api/README.md b/frame/staking/rpc/runtime-api/README.md deleted file mode 100644 index a999e519f8cbf..0000000000000 --- a/frame/staking/rpc/runtime-api/README.md +++ /dev/null @@ -1,3 +0,0 @@ -Runtime API definition for the staking pallet. - -License: Apache-2.0 diff --git a/frame/staking/rpc/runtime-api/src/lib.rs b/frame/staking/rpc/runtime-api/src/lib.rs deleted file mode 100644 index 0c563b0b2abc0..0000000000000 --- a/frame/staking/rpc/runtime-api/src/lib.rs +++ /dev/null @@ -1,32 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) 2019-2022 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -//! Runtime API definition for the staking pallet. - -#![cfg_attr(not(feature = "std"), no_std)] - -use codec::Codec; -use sp_runtime::traits::MaybeDisplay; - -sp_api::decl_runtime_apis! { - #[api_version(1)] - pub trait StakingApi where - Balance: Codec + MaybeDisplay, - { - fn query_nominations_quota(balance: Balance) -> u32; - } -} diff --git a/frame/staking/rpc/src/lib.rs b/frame/staking/rpc/src/lib.rs deleted file mode 100644 index b4db85bcbfe54..0000000000000 --- a/frame/staking/rpc/src/lib.rs +++ /dev/null @@ -1,90 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) 2019-2022 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -//! RPC interface for the staking pallet. - -use std::sync::Arc; - -use codec::Codec; -use jsonrpsee::{ - core::RpcResult, - proc_macros::rpc, - types::error::{CallError, ErrorObject}, -}; -use sp_api::ProvideRuntimeApi; -use sp_blockchain::HeaderBackend; -use sp_rpc::number::NumberOrHex; -use sp_runtime::{ - generic::BlockId, - traits::{Block as BlockT, MaybeDisplay}, -}; - -pub use pallet_staking_rpc_runtime_api::StakingApi as StakingRuntimeApi; - -#[rpc(client, server)] -pub trait StakingApi { - #[method(name = "staking_nominationsQuota")] - fn query_nominations_quota(&self, balance: Balance) -> RpcResult; -} - -pub struct Staking { - client: Arc, - _marker: std::marker::PhantomData

, -} - -impl Staking { - pub fn new(client: Arc) -> Self { - Self { client, _marker: Default::default() } - } -} - -/// Error type of this RPC api. -pub enum Error { - /// The call to runtime failed. - RuntimeError, -} - -impl From for i32 { - fn from(e: Error) -> i32 { - match e { - Error::RuntimeError => 1, - } - } -} - -impl StakingApiServer for Staking -where - Block: BlockT, - C: ProvideRuntimeApi + HeaderBackend + Send + Sync + 'static, - C::Api: StakingRuntimeApi, - Balance: Codec + MaybeDisplay + Copy + TryInto + Send + Sync + 'static, -{ - fn query_nominations_quota(&self, balance: Balance) -> RpcResult { - let api = self.client.runtime_api(); - let at = BlockId::hash(self.client.info().best_hash); - - let runtime_api_result = api.query_nominations_quota(&at, balance); - - Ok(runtime_api_result.map_err(|e| { - CallError::Custom(ErrorObject::owned( - Error::RuntimeError.into(), - "Unable to query the nominations quota.", - Some(e.to_string()), - )) - })?) - } -} From 8e7ecbb28573a696fbf33d18539e5a1044e50e6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Tue, 28 Feb 2023 12:41:57 +0100 Subject: [PATCH 21/80] Cosmetic touches --- bin/node/runtime/src/lib.rs | 4 +- .../election-provider-multi-phase/src/lib.rs | 12 +- .../src/signed.rs | 4 +- frame/election-provider-support/src/lib.rs | 120 +++++++++--------- .../election-provider-support/src/onchain.rs | 6 +- frame/election-provider-support/src/tests.rs | 19 ++- frame/staking/src/lib.rs | 4 +- frame/staking/src/tests.rs | 36 +++--- 8 files changed, 99 insertions(+), 106 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 0468659f71a98..9ef419072be2a 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -638,10 +638,10 @@ frame_election_provider_support::generate_solution_type!( ); parameter_types! { - pub ElectionBoundsMultiPhase: ElectionBounds = ElectionBoundsBuilder::new().voters_count(40_000.into()).targets_count(10_000.into()).build(); + pub ElectionBoundsMultiPhase: ElectionBounds = ElectionBoundsBuilder::new().voters_count(40_000).targets_count(10_000).build(); pub MaxNominations: u32 = ::LIMIT as u32; // OnChain values are lower. - pub ElectionBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::new().voters_count(5_000.into()).targets_count(1_250.into()).build(); + pub ElectionBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::new().voters_count(5_000).targets_count(1_250).build(); // The maximum winners that can be elected by the Election pallet which is equivalent to the // maximum active validators the staking pallet can have. pub MaxActiveValidators: u32 = 1000; diff --git a/frame/election-provider-multi-phase/src/lib.rs b/frame/election-provider-multi-phase/src/lib.rs index 8307de18db84f..dc8d0e479c21c 100644 --- a/frame/election-provider-multi-phase/src/lib.rs +++ b/frame/election-provider-multi-phase/src/lib.rs @@ -1078,8 +1078,8 @@ pub mod pallet { T::ForceOrigin::ensure_origin(origin)?; ensure!(Self::current_phase().is_emergency(), >::CallNotAllowed); let election_bounds = ElectionBoundsBuilder::new() - .voters_count(maybe_max_voters) - .targets_count(maybe_max_targets) + .voters_count(maybe_max_voters.unwrap_or(0)) + .targets_count(maybe_max_targets.unwrap_or(0)) .build(); let supports = T::GovernanceFallback::instant_elect( election_bounds.voters, @@ -2486,7 +2486,7 @@ mod tests { // the `MockStaking` is designed such that if it has too many targets, it simply fails. ExtBuilder::default().build_and_execute(|| { // sets bounds on number of targets. - let new_bounds = ElectionBoundsBuilder::new().targets_count(1_000.into()).build(); + let new_bounds = ElectionBoundsBuilder::new().targets_count(1_000).build(); crate::mock::ElectionsBounds::set(new_bounds); Targets::set((0..(TargetIndex::max_value() as AccountId) + 1).collect::>()); @@ -2525,7 +2525,7 @@ mod tests { // and if the backup mode is nothing, we go into the emergency mode.. ExtBuilder::default().onchain_fallback(false).build_and_execute(|| { // sets bounds on number of targets. - let new_bounds = ElectionBoundsBuilder::new().targets_count(1_000.into()).build(); + let new_bounds = ElectionBoundsBuilder::new().targets_count(1_000).build(); crate::mock::ElectionsBounds::set(new_bounds); crate::mock::Targets::set( @@ -2562,7 +2562,7 @@ mod tests { // we have 8 voters in total. assert_eq!(crate::mock::Voters::get().len(), 8); // but we want to take 2. - let new_bounds = ElectionBoundsBuilder::new().voters_count(2.into()).build(); + let new_bounds = ElectionBoundsBuilder::new().voters_count(2).build(); crate::mock::ElectionsBounds::set(new_bounds); // Signed phase opens just fine. @@ -2574,7 +2574,7 @@ mod tests { SolutionOrSnapshotSize { voters: 2, targets: 4 } ); }) - } + } #[test] fn untrusted_score_verification_is_respected() { diff --git a/frame/election-provider-multi-phase/src/signed.rs b/frame/election-provider-multi-phase/src/signed.rs index e965e79c7ed8e..70d2873d74aed 100644 --- a/frame/election-provider-multi-phase/src/signed.rs +++ b/frame/election-provider-multi-phase/src/signed.rs @@ -561,7 +561,7 @@ mod tests { fn data_provider_should_respect_target_limits() { ExtBuilder::default().build_and_execute(|| { // given a reduced expectation of maximum electable targets - let new_bounds = crate::ElectionBoundsBuilder::new().targets_count(2.into()).build(); + let new_bounds = crate::ElectionBoundsBuilder::new().targets_count(2).build(); ElectionsBounds::set(new_bounds); // and a data provider that does not respect limits DataProviderAllowBadData::set(true); @@ -577,7 +577,7 @@ mod tests { fn data_provider_should_respect_voter_limits() { ExtBuilder::default().build_and_execute(|| { // given a reduced expectation of maximum electing voters - let new_bounds = crate::ElectionBoundsBuilder::new().voters_count(2.into()).build(); + let new_bounds = crate::ElectionBoundsBuilder::new().voters_count(2).build(); ElectionsBounds::set(new_bounds); // and a data provider that does not respect limits DataProviderAllowBadData::set(true); diff --git a/frame/election-provider-support/src/lib.rs b/frame/election-provider-support/src/lib.rs index c8a67445a2590..a8347b34e18ea 100644 --- a/frame/election-provider-support/src/lib.rs +++ b/frame/election-provider-support/src/lib.rs @@ -283,9 +283,6 @@ pub trait ElectionDataProvider { /// All possible targets for the election, i.e. the targets that could become elected, thus /// "electable". /// - /// If `bounds` are defined, then the resulting vector MUST NOT be longer or larger in MB than - /// `v` items long. - /// /// This should be implemented as a self-weighing function. The implementor should register its /// appropriate weight at the end of execution with the system pallet directly. fn electable_targets(bounds: DataProviderBounds) @@ -295,9 +292,6 @@ pub trait ElectionDataProvider { /// /// Note that if a notion of self-vote exists, it should be represented here. /// - /// If `bounds` are defined, then the resulting vector MUST NOT be longer or larger in bytes - /// than `v` items long. - /// /// This should be implemented as a self-weighing function. The implementor should register its /// appropriate weight at the end of execution with the system pallet directly. fn electing_voters(bounds: DataProviderBounds) -> data_provider::Result>>; @@ -662,24 +656,26 @@ impl = (AccountId, VoteWeight, BoundedVec); - /// Same as [`Voter`], but parameterized by an [`ElectionDataProvider`]. pub type VoterOf = Voter<::AccountId, ::MaxVotesPerVoter>; - /// Same as `BoundedSupports` but parameterized by a `ElectionProviderBase`. pub type BoundedSupportsOf = BoundedSupports< ::AccountId, ::MaxWinners, >; +/// Count bound of data provider bounds. +pub type CountBound = u32; +/// Size bound of data provider bounds. +pub type SizeBound = u32; sp_core::generate_feature_enabled_macro!(runtime_benchmarks_enabled, feature = "runtime-benchmarks", $); sp_core::generate_feature_enabled_macro!(runtime_benchmarks_or_fuzz_enabled, any(feature = "runtime-benchmarks", feature = "fuzzing"), $); #[derive(Clone, Copy, Default, Debug)] pub struct DataProviderBounds { - pub count: Option, - pub size: Option, + pub count: Option, + pub size: Option, } impl DataProviderBounds { @@ -689,24 +685,34 @@ impl DataProviderBounds { } /// Returns true if `given_count` exhausts `self.count`. - pub fn count_exhausted(self, given_count: Option) -> bool { - self.count.map_or(false, |count| given_count.unwrap_or(0) > count) + pub fn count_exhausted(self, given_count: CountBound) -> bool { + self.count.map_or(false, |count| given_count > count) } /// Returns true if `given_size` exhausts `self.size`. - pub fn size_exhausted(self, given_size: Option) -> bool { - self.size.map_or(false, |size| given_size.unwrap_or(0) > size) + pub fn size_exhausted(self, given_size: SizeBound) -> bool { + self.size.map_or(false, |size| given_size > size) } - /// Returns true if `given_size` or `given_count` exhausts `self.size` or `self_count` + /// Returns true if `given_size` or `given_count` exhausts `self.size` or `self_count`, /// respectively. - pub fn exhausted(self, given_size: Option, given_count: Option) -> bool { - self.count_exhausted(given_count) || self.size_exhausted(given_size) + pub fn exhausted(self, given_size: Option, given_count: Option) -> bool { + self.count_exhausted(given_count.unwrap_or(0)) || + self.size_exhausted(given_size.unwrap_or(0)) + } + + /// Returns an instance of `Self` that is constructed by capping both the `count` and `size` + /// fields. + pub fn max(self, bounds: DataProviderBounds) -> Self { + DataProviderBounds { + count: self.count.map(|c| c.clamp(0, bounds.count.unwrap_or(u32::MAX)).into()), + size: self.size.map(|c| c.clamp(0, bounds.size.unwrap_or(u32::MAX)).into()), + } } } /// The limits of an election result. The bounds are defined over the count of element of the -/// election (voters or targets) or the overall datastructure size. +/// election (voters or targets) or the overall size of the elements in MB. #[derive(Clone, Debug)] pub struct ElectionBounds { pub voters: DataProviderBounds, @@ -735,46 +741,50 @@ impl ElectionBoundsBuilder { } // Sets the voters count bounds. - pub fn voters_count(mut self, count: Option) -> Self { - self.voters = - self.voters - .map_or(Some(DataProviderBounds { count, size: None }), |mut bounds| { - bounds.count = count; - Some(bounds) - }); + pub fn voters_count(mut self, count: CountBound) -> Self { + self.voters = self.voters.map_or( + Some(DataProviderBounds { count: Some(count), size: None }), + |mut bounds| { + bounds.count = Some(count); + Some(bounds) + }, + ); self } // Sets the voters size bounds. - pub fn voters_size(mut self, size: Option) -> Self { - self.voters = - self.voters - .map_or(Some(DataProviderBounds { count: None, size }), |mut bounds| { - bounds.size = size; - Some(bounds) - }); + pub fn voters_size(mut self, size: SizeBound) -> Self { + self.voters = self.voters.map_or( + Some(DataProviderBounds { count: None, size: Some(size) }), + |mut bounds| { + bounds.size = Some(size); + Some(bounds) + }, + ); self } // Sets the targets count bounds. - pub fn targets_count(mut self, count: Option) -> Self { - self.targets = - self.targets - .map_or(Some(DataProviderBounds { count, size: None }), |mut bounds| { - bounds.count = count; - Some(bounds) - }); + pub fn targets_count(mut self, count: CountBound) -> Self { + self.targets = self.targets.map_or( + Some(DataProviderBounds { count: Some(count), size: None }), + |mut bounds| { + bounds.count = Some(count); + Some(bounds) + }, + ); self } // Sets the targets size bounds. - pub fn targets_size(mut self, size: Option) -> Self { - self.targets = - self.targets - .map_or(Some(DataProviderBounds { count: None, size }), |mut bounds| { - bounds.size = size; - Some(bounds) - }); + pub fn targets_size(mut self, size: SizeBound) -> Self { + self.targets = self.targets.map_or( + Some(DataProviderBounds { count: None, size: Some(size) }), + |mut bounds| { + bounds.size = Some(size); + Some(bounds) + }, + ); self } @@ -792,25 +802,15 @@ impl ElectionBoundsBuilder { /// Caps the maximum number of the voters bounds to `voters`. If `voters` bounds are less than /// the current value, keeps it. - pub fn clamp_voters(mut self, voters: DataProviderBounds) -> Self { - self.voters = self.voters.map_or(None, |v| { - Some(DataProviderBounds { - count: v.count.map(|c| c.clamp(0, voters.count.unwrap_or(u32::MAX)).into()), - size: v.size.map(|c| c.clamp(0, voters.size.unwrap_or(u32::MAX)).into()), - }) - }); + pub fn max_voters(mut self, voters: DataProviderBounds) -> Self { + self.voters = self.voters.map_or(None, |v| Some(v.max(voters))); self } /// Caps the maximum number of the targets to `targets`. If `targets` bounds are less than the /// current value, keeps it. - pub fn clamp_targets(mut self, targets: DataProviderBounds) -> Self { - self.targets = self.targets.map_or(None, |t| { - Some(DataProviderBounds { - count: t.count.map(|c| c.clamp(0, targets.count.unwrap_or(u32::MAX)).into()), - size: t.size.map(|c| c.clamp(0, targets.size.unwrap_or(u32::MAX)).into()), - }) - }); + pub fn max_targets(mut self, targets: DataProviderBounds) -> Self { + self.targets = self.targets.map_or(None, |t| Some(t.max(targets))); self } diff --git a/frame/election-provider-support/src/onchain.rs b/frame/election-provider-support/src/onchain.rs index 080605499b822..e48493d597ff8 100644 --- a/frame/election-provider-support/src/onchain.rs +++ b/frame/election-provider-support/src/onchain.rs @@ -159,8 +159,8 @@ impl InstantElectionProvider for OnChainExecution { targets_bounds: DataProviderBounds, ) -> Result, Self::Error> { let elections_bounds = ElectionBoundsBuilder::from(T::ElectionBounds::get()) - .clamp_voters(voters_bounds) - .clamp_targets(targets_bounds) + .max_voters(voters_bounds) + .max_targets(targets_bounds) .build(); elect_with_input_bounds::(elections_bounds) } @@ -234,7 +234,7 @@ mod tests { parameter_types! { pub static MaxWinners: u32 = 10; pub static DesiredTargets: u32 = 2; - pub static ElectionBounds: crate::ElectionBounds = ElectionBoundsBuilder::new().voters_count(Some(600)).targets_count(Some(400)).build(); + pub static ElectionBounds: crate::ElectionBounds = ElectionBoundsBuilder::new().voters_count(600).targets_count(400).build(); } impl Config for PhragmenParams { diff --git a/frame/election-provider-support/src/tests.rs b/frame/election-provider-support/src/tests.rs index bf39164c0c6d3..cb778075a7452 100644 --- a/frame/election-provider-support/src/tests.rs +++ b/frame/election-provider-support/src/tests.rs @@ -469,10 +469,10 @@ mod elections_bounds { // voter bounds exhausts if count > 100 or size > 1_000; target bounds exhausts if count > // 200 or size > 2_000. let bounds = ElectionBoundsBuilder::new() - .voters_count(100.into()) - .voters_size(1_000.into()) - .targets_count(200.into()) - .targets_size(2_000.into()) + .voters_count(100) + .voters_size(1_000) + .targets_count(200) + .targets_size(2_000) .build(); assert!(!bounds.voters.exhausted(None, None)); @@ -493,12 +493,11 @@ mod elections_bounds { #[test] fn election_bounds_clamp_works() { let bounds = ElectionBoundsBuilder::new() - .voters_count(10.into()) - .voters_size(10.into()) - .clamp_voters(DataProviderBounds { count: 5.into(), size: 20.into() }) - .targets_count(20.into()) - .targets_size(None) - .clamp_targets(DataProviderBounds { count: 30.into(), size: 30.into() }) + .voters_count(10) + .voters_size(10) + .max_voters(DataProviderBounds { count: 5.into(), size: 20.into() }) + .targets_count(20) + .max_targets(DataProviderBounds { count: 30.into(), size: 30.into() }) .build(); assert_eq!(bounds.voters.count, 5.into()); diff --git a/frame/staking/src/lib.rs b/frame/staking/src/lib.rs index 6be7c74541434..8f0316d8de7db 100644 --- a/frame/staking/src/lib.rs +++ b/frame/staking/src/lib.rs @@ -300,7 +300,7 @@ pub mod weights; mod pallet; use codec::{Decode, Encode, HasCompact, MaxEncodedLen}; -use frame_election_provider_support::{DataProviderBounds, VoteWeight}; +use frame_election_provider_support::{DataProviderBounds, SizeBound, VoteWeight}; use frame_support::{ traits::{Currency, Defensive, Get}, weights::Weight, @@ -838,7 +838,7 @@ impl ElectionSizeTracker { let voter_size = Self::voter_size(votes); let size_after = self.size.saturating_add(voter_size); - match bounds.size_exhausted(Some(size_after as u32)) { + match bounds.size_exhausted(size_after as SizeBound) { true => Err(()), false => { self.size = size_after; diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index db6988846df31..b2e1bcb30f97a 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -4514,7 +4514,7 @@ mod election_data_provider { // remove staker with lower bond by limiting the number of voters and check // `MinimumActiveStake` again after electing voters. - let bounds = ElectionBoundsBuilder::new().voters_count(Some(5)).build(); + let bounds = ElectionBoundsBuilder::new().voters_count(5).build(); assert_ok!(::electing_voters(bounds.voters)); assert_eq!(MinimumActiveStake::::get(), 50); }); @@ -4554,7 +4554,7 @@ mod election_data_provider { // if limits is less.. assert_eq!( - Staking::electing_voters(bounds_builder.voters_count(Some(1)).build().voters) + Staking::electing_voters(bounds_builder.voters_count(1).build().voters) .unwrap() .len(), 1 @@ -4562,7 +4562,7 @@ mod election_data_provider { // if limit is equal.. assert_eq!( - Staking::electing_voters(bounds_builder.voters_count(Some(5)).build().voters) + Staking::electing_voters(bounds_builder.voters_count(5).build().voters) .unwrap() .len(), 5 @@ -4570,7 +4570,7 @@ mod election_data_provider { // if limit is more. assert_eq!( - Staking::electing_voters(bounds_builder.voters_count(Some(55)).build().voters) + Staking::electing_voters(bounds_builder.voters_count(55).build().voters) .unwrap() .len(), 5 @@ -4578,28 +4578,22 @@ mod election_data_provider { // if target limit is more.. assert_eq!( - Staking::electable_targets( - bounds_builder.targets_count(Some(6)).build().targets - ) - .unwrap() - .len(), + Staking::electable_targets(bounds_builder.targets_count(6).build().targets) + .unwrap() + .len(), 4 ); assert_eq!( - Staking::electable_targets( - bounds_builder.targets_count(Some(4)).build().targets - ) - .unwrap() - .len(), + Staking::electable_targets(bounds_builder.targets_count(4).build().targets) + .unwrap() + .len(), 4 ); // if target limit is less, then we return an error. assert_eq!( - Staking::electable_targets( - bounds_builder.targets_count(Some(1)).build().targets - ) - .unwrap_err(), + Staking::electable_targets(bounds_builder.targets_count(1).build().targets) + .unwrap_err(), "Target snapshot too big" ); }); @@ -4610,7 +4604,7 @@ mod election_data_provider { ExtBuilder::default().build_and_execute(|| { let bounds_builder = ElectionBoundsBuilder::new(); assert_eq!( - Staking::electing_voters(bounds_builder.voters_size(Some(25)).build().voters) + Staking::electing_voters(bounds_builder.voters_size(25).build().voters) .unwrap() .len(), 1 @@ -4681,7 +4675,7 @@ mod election_data_provider { ) .build_and_execute(|| { // nominations of controller 70 won't be added due to voter size limit exceeded. - let bounds = ElectionBoundsBuilder::new().voters_size(100.into()).build(); + let bounds = ElectionBoundsBuilder::new().voters_size(100).build(); assert_eq!( Staking::electing_voters(bounds.voters) .unwrap() @@ -5797,7 +5791,7 @@ mod election_size_tracker { #[test] pub fn election_size_tracker_works() { let mut size_tracker = ElectionSizeTracker::::new(); - let voter_bounds = ElectionBoundsBuilder::new().voters_size(1_00.into()).build().voters; + let voter_bounds = ElectionBoundsBuilder::new().voters_size(1_00).build().voters; assert!(size_tracker.try_register_voter(1, voter_bounds).is_ok()); assert!(size_tracker.try_register_voter(2, voter_bounds).is_ok()); From bfbb91b2743b91ff074841636bf42671d4c25a1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Tue, 28 Feb 2023 13:28:56 +0100 Subject: [PATCH 22/80] All mocks working --- frame/babe/src/mock.rs | 6 +++-- frame/beefy/src/mock.rs | 10 +++++---- frame/fast-unstake/src/mock.rs | 2 +- frame/grandpa/src/mock.rs | 6 ++--- .../nomination-pools/benchmarking/src/lib.rs | 6 ++--- frame/offences/benchmarking/src/lib.rs | 10 ++++----- frame/session/benchmarking/src/lib.rs | 10 ++++----- frame/staking/src/benchmarking.rs | 20 ++++++++--------- frame/staking/src/lib.rs | 22 ++++++++----------- frame/staking/src/mock.rs | 10 ++------- frame/staking/src/pallet/impls.rs | 10 ++++----- frame/staking/src/pallet/mod.rs | 14 ++++++------ frame/staking/src/tests.rs | 2 +- 13 files changed, 61 insertions(+), 67 deletions(-) diff --git a/frame/babe/src/mock.rs b/frame/babe/src/mock.rs index 2c2f56562921b..81e54833cf9b6 100644 --- a/frame/babe/src/mock.rs +++ b/frame/babe/src/mock.rs @@ -19,7 +19,9 @@ use crate::{self as pallet_babe, Config, CurrentSlot}; use codec::Encode; -use frame_election_provider_support::{onchain, SequentialPhragmen, ElectionBoundsBuilder, ElectionBounds}; +use frame_election_provider_support::{ + onchain, ElectionBounds, ElectionBoundsBuilder, SequentialPhragmen, +}; use frame_support::{ parameter_types, traits::{ConstU128, ConstU32, ConstU64, GenesisBuild, KeyOwnerProofSystem, OnInitialize}, @@ -199,12 +201,12 @@ impl pallet_staking::Config for Test { type GenesisElectionProvider = Self::ElectionProvider; type VoterList = pallet_staking::UseNominatorsAndValidatorsMap; type TargetList = pallet_staking::UseValidatorsMap; + type NominationsQuota = FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; type HistoryDepth = ConstU32<84>; type OnStakerSlash = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; type WeightInfo = (); - type NominationsQuota = FixedNominationsQuota<16>; } impl pallet_offences::Config for Test { diff --git a/frame/beefy/src/mock.rs b/frame/beefy/src/mock.rs index 74dba2a01b81d..621b81dcdb1e9 100644 --- a/frame/beefy/src/mock.rs +++ b/frame/beefy/src/mock.rs @@ -17,7 +17,9 @@ use std::vec; -use frame_election_provider_support::{onchain, SequentialPhragmen}; +use frame_election_provider_support::{ + onchain, ElectionBounds, ElectionBoundsBuilder, SequentialPhragmen, +}; use frame_support::{ construct_runtime, parameter_types, sp_io::TestExternalities, @@ -192,6 +194,7 @@ parameter_types! { pub const BondingDuration: EraIndex = 3; pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE; pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17); + pub const ElectionsBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::new().build(); } pub struct OnChainSeqPhragmen; @@ -201,12 +204,10 @@ impl onchain::Config for OnChainSeqPhragmen { type DataProvider = Staking; type WeightInfo = (); type MaxWinners = ConstU32<100>; - type VotersBound = ConstU32<{ u32::MAX }>; - type TargetsBound = ConstU32<{ u32::MAX }>; + type ElectionBounds = ElectionsBoundsOnChain; } impl pallet_staking::Config for Test { - type MaxNominations = ConstU32<16>; type RewardRemainder = (); type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote; type RuntimeEvent = RuntimeEvent; @@ -228,6 +229,7 @@ impl pallet_staking::Config for Test { type GenesisElectionProvider = Self::ElectionProvider; type VoterList = pallet_staking::UseNominatorsAndValidatorsMap; type TargetList = pallet_staking::UseValidatorsMap; + type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; type HistoryDepth = ConstU32<84>; type OnStakerSlash = (); diff --git a/frame/fast-unstake/src/mock.rs b/frame/fast-unstake/src/mock.rs index b20ba43ab3758..77366039a70d5 100644 --- a/frame/fast-unstake/src/mock.rs +++ b/frame/fast-unstake/src/mock.rs @@ -129,7 +129,6 @@ impl frame_election_provider_support::ElectionProvider for MockElection { } impl pallet_staking::Config for Runtime { - type MaxNominations = ConstU32<16>; type Currency = Balances; type CurrencyBalance = Balance; type UnixTime = pallet_timestamp::Pallet; @@ -152,6 +151,7 @@ impl pallet_staking::Config for Runtime { type GenesisElectionProvider = Self::ElectionProvider; type VoterList = pallet_staking::UseNominatorsAndValidatorsMap; type TargetList = pallet_staking::UseValidatorsMap; + type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; type OnStakerSlash = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; diff --git a/frame/grandpa/src/mock.rs b/frame/grandpa/src/mock.rs index a33fbb22d6ff8..25f99ce68aa7d 100644 --- a/frame/grandpa/src/mock.rs +++ b/frame/grandpa/src/mock.rs @@ -167,6 +167,7 @@ parameter_types! { pub const BondingDuration: EraIndex = 3; pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE; pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17); + pub const ElectionsBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::new().build(); } pub struct OnChainSeqPhragmen; @@ -176,12 +177,10 @@ impl onchain::Config for OnChainSeqPhragmen { type DataProvider = Staking; type WeightInfo = (); type MaxWinners = ConstU32<100>; - type VotersBound = ConstU32<{ u32::MAX }>; - type TargetsBound = ConstU32<{ u32::MAX }>; + type ElectionBounds = ElectionsBoundsOnChain; } impl pallet_staking::Config for Test { - type MaxNominations = ConstU32<16>; type RewardRemainder = (); type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote; type RuntimeEvent = RuntimeEvent; @@ -203,6 +202,7 @@ impl pallet_staking::Config for Test { type GenesisElectionProvider = Self::ElectionProvider; type VoterList = pallet_staking::UseNominatorsAndValidatorsMap; type TargetList = pallet_staking::UseValidatorsMap; + type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; type HistoryDepth = ConstU32<84>; type OnStakerSlash = (); diff --git a/frame/nomination-pools/benchmarking/src/lib.rs b/frame/nomination-pools/benchmarking/src/lib.rs index 5e0fa57f1abc9..2229965e7bdca 100644 --- a/frame/nomination-pools/benchmarking/src/lib.rs +++ b/frame/nomination-pools/benchmarking/src/lib.rs @@ -34,7 +34,7 @@ use pallet_nomination_pools::{ ConfigOp, MaxPoolMembers, MaxPoolMembersPerPool, MaxPools, Metadata, MinCreateBond, MinJoinBond, Pallet as Pools, PoolMembers, PoolRoles, PoolState, RewardPools, SubPoolsStorage, }; -use pallet_staking::AbsoluteMaxNominationsOf; +use pallet_staking::MaxNominationsOf; use sp_runtime::traits::{Bounded, StaticLookup, Zero}; use sp_staking::{EraIndex, StakingInterface}; // `frame_benchmarking::benchmarks!` macro needs this @@ -542,7 +542,7 @@ frame_benchmarking::benchmarks! { } nominate { - let n in 1 .. AbsoluteMaxNominationsOf::::get(); + let n in 1 .. MaxNominationsOf::::get(); // Create a pool let min_create_bond = Pools::::depositor_min_bond() * 2u32.into(); @@ -654,7 +654,7 @@ frame_benchmarking::benchmarks! { let (depositor, pool_account) = create_pool_account::(0, Pools::::depositor_min_bond() * 2u32.into()); // Nominate with the pool. - let validators: Vec<_> = (0..AbsoluteMaxNominationsOf::::get()) + let validators: Vec<_> = (0..MaxNominationsOf::::get()) .map(|i| account("stash", USER_SEED, i)) .collect(); diff --git a/frame/offences/benchmarking/src/lib.rs b/frame/offences/benchmarking/src/lib.rs index 0829bca026210..18193595f5eb5 100644 --- a/frame/offences/benchmarking/src/lib.rs +++ b/frame/offences/benchmarking/src/lib.rs @@ -48,8 +48,8 @@ use pallet_session::{ #[cfg(test)] use pallet_staking::Event as StakingEvent; use pallet_staking::{ - AbsoluteMaxNominationsOf, Config as StakingConfig, Event as StakingEvent, Exposure, - IndividualExposure, Pallet as Staking, RewardDestination, ValidatorPrefs, + Config as StakingConfig, Event as StakingEvent, Exposure, IndividualExposure, NominationsOf, + Pallet as Staking, RewardDestination, ValidatorPrefs, }; const SEED: u32 = 0; @@ -288,7 +288,7 @@ benchmarks! { let r in 1 .. MAX_REPORTERS; // we skip 1 offender, because in such case there is no slashing let o in 2 .. MAX_OFFENDERS; - let n in 0 .. MAX_NOMINATORS.min(AbsoluteMaxNominationsOf::::get()); + let n in 0 .. MAX_NOMINATORS.min(MaxNominationsOf::::get()); // Make r reporters let mut reporters = vec![]; @@ -395,7 +395,7 @@ benchmarks! { } report_offence_grandpa { - let n in 0 .. MAX_NOMINATORS.min(AbsoluteMaxNominationsOf::::get()); + let n in 0 .. MAX_NOMINATORS.min(MaxNominationsOf::::get()); // for grandpa equivocation reports the number of reporters // and offenders is always 1 @@ -432,7 +432,7 @@ benchmarks! { } report_offence_babe { - let n in 0 .. MAX_NOMINATORS.min(AbsoluteMaxNominationsOf::::get()); + let n in 0 .. MAX_NOMINATORS.min(MaxNominationsOf::::get()); // for babe equivocation reports the number of reporters // and offenders is always 1 diff --git a/frame/session/benchmarking/src/lib.rs b/frame/session/benchmarking/src/lib.rs index aaa9ad3a48f9b..24ce81ad72096 100644 --- a/frame/session/benchmarking/src/lib.rs +++ b/frame/session/benchmarking/src/lib.rs @@ -35,7 +35,7 @@ use frame_system::RawOrigin; use pallet_session::{historical::Pallet as Historical, Pallet as Session, *}; use pallet_staking::{ benchmarking::create_validator_with_nominators, testing_utils::create_validators, - AbsoluteMaxNominationsOf, RewardDestination, + MaxNominationsOf, RewardDestination, }; const MAX_VALIDATORS: u32 = 1000; @@ -54,10 +54,10 @@ impl OnInitialize for Pallet { benchmarks! { set_keys { - let n = AbsoluteMaxNominationsOf::::get(); + let n = MaxNominationsOf::::get(); let (v_stash, _) = create_validator_with_nominators::( n, - AbsoluteMaxNominationsOf::::get(), + MaxNominationsOf::::get(), false, RewardDestination::Staked, )?; @@ -71,10 +71,10 @@ benchmarks! { }: _(RawOrigin::Signed(v_controller), keys, proof) purge_keys { - let n = AbsoluteMaxNominationsOf::::get(); + let n = MaxNominationsOf::::get(); let (v_stash, _) = create_validator_with_nominators::( n, - AbsoluteMaxNominationsOf::::get(), + MaxNominationsOf::::get(), false, RewardDestination::Staked )?; diff --git a/frame/staking/src/benchmarking.rs b/frame/staking/src/benchmarking.rs index cf49eb85669fb..cf4b8fd1ff0db 100644 --- a/frame/staking/src/benchmarking.rs +++ b/frame/staking/src/benchmarking.rs @@ -334,7 +334,7 @@ benchmarks! { validate { let (stash, controller) = create_stash_controller::( - AbsoluteMaxNominationsOf::::get() - 1, + MaxNominationsOf::::get() - 1, 100, Default::default(), )?; @@ -358,11 +358,11 @@ benchmarks! { // these are the other validators; there are `T::MaxNominations::get() - 1` of them, so // there are a total of `T::MaxNominations::get()` validators in the system. - let rest_of_validators = create_validators_with_seed::(AbsoluteMaxNominationsOf::::get() - 1, 100, 415)?; + let rest_of_validators = create_validators_with_seed::(MaxNominationsOf::::get() - 1, 100, 415)?; // this is the validator that will be kicking. let (stash, controller) = create_stash_controller::( - AbsoluteMaxNominationsOf::::get() - 1, + MaxNominationsOf::::get() - 1, 100, Default::default(), )?; @@ -377,7 +377,7 @@ benchmarks! { for i in 0 .. k { // create a nominator stash. let (n_stash, n_controller) = create_stash_controller::( - AbsoluteMaxNominationsOf::::get() + i, + MaxNominationsOf::::get() + i, 100, Default::default(), )?; @@ -414,7 +414,7 @@ benchmarks! { // Worst case scenario, T::MaxNominations::get() nominate { - let n in 1 .. AbsoluteMaxNominationsOf::::get(); + let n in 1 .. MaxNominationsOf::::get(); // clean up any existing state. clear_validators_and_nominators::(); @@ -425,7 +425,7 @@ benchmarks! { // we are just doing an insert into the origin position. let scenario = ListScenario::::new(origin_weight, true)?; let (stash, controller) = create_stash_controller_with_balance::( - SEED + AbsoluteMaxNominationsOf::::get() + 1, // make sure the account does not conflict with others + SEED + MaxNominationsOf::::get() + 1, // make sure the account does not conflict with others origin_weight, Default::default(), ).unwrap(); @@ -702,7 +702,7 @@ benchmarks! { create_validators_with_nominators_for_era::( v, n, - AbsoluteMaxNominationsOf::::get() as usize, + MaxNominationsOf::::get() as usize, false, None, )?; @@ -720,7 +720,7 @@ benchmarks! { create_validators_with_nominators_for_era::( v, n, - AbsoluteMaxNominationsOf::::get() as usize, + MaxNominationsOf::::get() as usize, false, None, )?; @@ -799,7 +799,7 @@ benchmarks! { let n in (MaxNominators::::get() / 2) .. MaxNominators::::get(); let validators = create_validators_with_nominators_for_era::( - v, n, AbsoluteMaxNominationsOf::::get() as usize, false, None + v, n, MaxNominationsOf::::get() as usize, false, None )? .into_iter() .map(|v| T::Lookup::lookup(v).unwrap()) @@ -821,7 +821,7 @@ benchmarks! { let n = MaxNominators::::get(); let _ = create_validators_with_nominators_for_era::( - v, n, AbsoluteMaxNominationsOf::::get() as usize, false, None + v, n, MaxNominationsOf::::get() as usize, false, None )?; }: { let targets = >::get_npos_targets(DataProviderBounds::new_unbounded()); diff --git a/frame/staking/src/lib.rs b/frame/staking/src/lib.rs index 8f0316d8de7db..bf5ad34c2f47d 100644 --- a/frame/staking/src/lib.rs +++ b/frame/staking/src/lib.rs @@ -339,9 +339,9 @@ macro_rules! log { /// pallet. pub type MaxWinnersOf = <::ElectionProvider as frame_election_provider_support::ElectionProviderBase>::MaxWinners; -/// Absolute maximum number of nominations per nominator. -pub type AbsoluteMaxNominationsOf = - <::NominationsQuota as NominationsQuota>>::AbsoluteMaxNominations; +/// Maximum number of nominations per nominator. +pub type MaxNominationsOf = + <::NominationsQuota as NominationsQuota>>::MaxNominations; /// Counter for the number of "reward" points earned by a given validator. pub type RewardPoint = u32; @@ -697,7 +697,7 @@ impl StakingLedger { #[scale_info(skip_type_params(T))] pub struct Nominations { /// The targets of nomination. - pub targets: BoundedVec>, + pub targets: BoundedVec>, /// The era the nominations were submitted. /// /// Except for initial nominations which are considered submitted at era 0. @@ -769,17 +769,15 @@ impl UnappliedSlash { /// Something that defines the maximum number of nominations per nominator. pub trait NominationsQuota { - const ABSOLUTE_MAX_NOMINATIONS: u32; - /// Maximum number of nominations. The method `get_quota` may return a larger number of - /// nominations than `ABSOLUTE_MAX_NOMINATIONS`. However, `get_quota_safe` returns the bounded + /// nominations than `Self::MaxNominations`. However, `get_quota_safe` returns the bounded /// maximum number of nominations. - type AbsoluteMaxNominations: Get; + type MaxNominations: Get; /// Returns the voter's nomination quota within reasonable bounds [`min`, `max`], where `min` - /// is 1 and `max` is ABSOLUTE_MAX_NOMINATIONS. + /// is 1 and `max` is `Self::MaxNominations`. fn get_quota_safe(balance: Balance) -> u32 { - Self::get_quota(balance).max(1).min(Self::ABSOLUTE_MAX_NOMINATIONS) + Self::get_quota(balance).max(1).min(Self::MaxNominations::get()) } // Returns the voter's nomination quota based on the quota implementation. @@ -789,9 +787,7 @@ pub trait NominationsQuota { /// A nomination quota that allows up to MAX nominations for all validators. pub struct FixedNominationsQuota; impl NominationsQuota for FixedNominationsQuota { - const ABSOLUTE_MAX_NOMINATIONS: u32 = MAX; - - type AbsoluteMaxNominations = Self; + type MaxNominations = Self; fn get_quota(_: Balance) -> u32 { MAX diff --git a/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index 134220cb3fe22..27e2acd311ab1 100644 --- a/frame/staking/src/mock.rs +++ b/frame/staking/src/mock.rs @@ -236,6 +236,7 @@ parameter_types! { pub static LedgerSlashPerEra: (BalanceOf, BTreeMap>) = (Zero::zero(), BTreeMap::new()); pub static MaxWinners: u32 = 100; pub static ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::new().build(); + pub static MaxNominations: u32 = 16; } type VoterBagsListInstance = pallet_bags_list::Instance1; @@ -312,8 +313,7 @@ impl NominationsQuota for WeightedNominationsQ where u128: From, { - const ABSOLUTE_MAX_NOMINATIONS: u32 = MAX; - type AbsoluteMaxNominations = Self; + type MaxNominations = MaxNominations; fn get_quota(balance: Balance) -> u32 { match balance.into() { @@ -327,12 +327,6 @@ where } } -impl Get for WeightedNominationsQuota { - fn get() -> u32 { - MAX - } -} - pub(crate) type StakingCall = crate::Call; pub(crate) type TestCall = ::RuntimeCall; diff --git a/frame/staking/src/pallet/impls.rs b/frame/staking/src/pallet/impls.rs index 8949b79623a4d..31849091415cf 100644 --- a/frame/staking/src/pallet/impls.rs +++ b/frame/staking/src/pallet/impls.rs @@ -43,10 +43,10 @@ use sp_staking::{ use sp_std::prelude::*; use crate::{ - log, slashing, weights::WeightInfo, AbsoluteMaxNominationsOf, ActiveEraInfo, BalanceOf, - ElectionSizeTracker, EraPayout, Exposure, ExposureOf, Forcing, IndividualExposure, - MaxWinnersOf, Nominations, NominationsQuota, PositiveImbalanceOf, RewardDestination, - SessionInterface, StakingLedger, ValidatorPrefs, + log, slashing, weights::WeightInfo, ActiveEraInfo, BalanceOf, ElectionSizeTracker, EraPayout, + Exposure, ExposureOf, Forcing, IndividualExposure, MaxNominationsOf, MaxWinnersOf, Nominations, + NominationsQuota, PositiveImbalanceOf, RewardDestination, SessionInterface, StakingLedger, + ValidatorPrefs, }; use super::{pallet::*, STAKING_ID}; @@ -1022,7 +1022,7 @@ impl Pallet { impl ElectionDataProvider for Pallet { type AccountId = T::AccountId; type BlockNumber = BlockNumberFor; - type MaxVotesPerVoter = AbsoluteMaxNominationsOf; + type MaxVotesPerVoter = MaxNominationsOf; fn desired_targets() -> data_provider::Result { Self::register_weight(T::DbWeight::get().reads(1)); diff --git a/frame/staking/src/pallet/mod.rs b/frame/staking/src/pallet/mod.rs index a49089a704d7d..0c0a19e7cc73e 100644 --- a/frame/staking/src/pallet/mod.rs +++ b/frame/staking/src/pallet/mod.rs @@ -44,8 +44,8 @@ mod impls; pub use impls::*; use crate::{ - slashing, weights::WeightInfo, AbsoluteMaxNominationsOf, AccountIdLookupOf, ActiveEraInfo, - BalanceOf, EraPayout, EraRewardPoints, Exposure, Forcing, NegativeImbalanceOf, Nominations, + slashing, weights::WeightInfo, AccountIdLookupOf, ActiveEraInfo, BalanceOf, EraPayout, + EraRewardPoints, Exposure, Forcing, MaxNominationsOf, NegativeImbalanceOf, Nominations, NominationsQuota, PositiveImbalanceOf, RewardDestination, SessionInterface, StakingLedger, UnappliedSlash, UnlockChunk, ValidatorPrefs, }; @@ -275,9 +275,9 @@ pub mod pallet { /// Maximum limit of nominations per nominator, regardless of `T::NominationsQuota`. #[pallet::extra_constants] impl Pallet { - #[pallet::constant_name(AbsoluteMaxNominations)] + #[pallet::constant_name(MaxNominations)] fn absolute_max_nominations() -> u32 { - >>::AbsoluteMaxNominations::get() + >>::MaxNominations::get() } } @@ -355,7 +355,7 @@ pub mod pallet { /// they wish to support. /// /// Note that the keys of this storage map might become non-decodable in case the - /// account's [`NominationsQuota::ABSOLUTE_MAX_NOMINATIONS`] configuration is decreased. + /// account's [`NominationsQuota::MaxNominations`] configuration is decreased. /// In this rare case, these nominators /// are still existent in storage, their key is correct and retrievable (i.e. `contains_key` /// indicates that they exist), but their value cannot be decoded. Therefore, the non-decodable @@ -813,11 +813,11 @@ pub mod pallet { fn integrity_test() { // ensure that we funnel the correct value to the `DataProvider::MaxVotesPerVoter`; assert_eq!( - AbsoluteMaxNominationsOf::::get(), + MaxNominationsOf::::get(), ::MaxVotesPerVoter::get() ); // and that MaxNominations is always greater than 1, since we count on this. - assert!(!AbsoluteMaxNominationsOf::::get().is_zero()); + assert!(!MaxNominationsOf::::get().is_zero()); // ensure election results are always bounded with the same value assert!( diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index b2e1bcb30f97a..56bed6451bd71 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -5146,7 +5146,7 @@ fn nomination_quota_max_changes_decoding() { .balance_factor(10) .build_and_execute(|| { // pre-condition - assert_eq!(AbsoluteMaxNominationsOf::::get(), 16); + assert_eq!(MaxNominationsOf::::get(), 16); let unbonded_election = DataProviderBounds::new_unbounded(); From 2c44857f46edbc8ebf9d155a0a474ad50f9e265f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Tue, 28 Feb 2023 14:14:52 +0100 Subject: [PATCH 23/80] Fixes benchmarking mocks --- frame/beefy/src/mock.rs | 2 +- frame/grandpa/src/mock.rs | 4 ++-- frame/nomination-pools/benchmarking/src/mock.rs | 2 +- frame/nomination-pools/test-staking/src/mock.rs | 2 +- frame/offences/benchmarking/src/lib.rs | 4 ++-- frame/offences/benchmarking/src/mock.rs | 8 ++++---- frame/root-offences/src/mock.rs | 13 +++++++++---- frame/session/benchmarking/src/mock.rs | 8 ++++---- frame/staking/src/benchmarking.rs | 2 +- 9 files changed, 25 insertions(+), 20 deletions(-) diff --git a/frame/beefy/src/mock.rs b/frame/beefy/src/mock.rs index 621b81dcdb1e9..e39c4d948c862 100644 --- a/frame/beefy/src/mock.rs +++ b/frame/beefy/src/mock.rs @@ -194,7 +194,7 @@ parameter_types! { pub const BondingDuration: EraIndex = 3; pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE; pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17); - pub const ElectionsBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::new().build(); + pub static ElectionsBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::new().build(); } pub struct OnChainSeqPhragmen; diff --git a/frame/grandpa/src/mock.rs b/frame/grandpa/src/mock.rs index 25f99ce68aa7d..8c80e0c894aff 100644 --- a/frame/grandpa/src/mock.rs +++ b/frame/grandpa/src/mock.rs @@ -22,7 +22,7 @@ use crate::{self as pallet_grandpa, AuthorityId, AuthorityList, Config, ConsensusLog}; use ::grandpa as finality_grandpa; use codec::Encode; -use frame_election_provider_support::{onchain, SequentialPhragmen}; +use frame_election_provider_support::{onchain, SequentialPhragmen, ElectionBounds, ElectionBoundsBuilder}; use frame_support::{ parameter_types, traits::{ @@ -167,7 +167,7 @@ parameter_types! { pub const BondingDuration: EraIndex = 3; pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE; pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17); - pub const ElectionsBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::new().build(); + pub static ElectionsBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::new().build(); } pub struct OnChainSeqPhragmen; diff --git a/frame/nomination-pools/benchmarking/src/mock.rs b/frame/nomination-pools/benchmarking/src/mock.rs index 4e188ea7ef189..b6cb795e806b0 100644 --- a/frame/nomination-pools/benchmarking/src/mock.rs +++ b/frame/nomination-pools/benchmarking/src/mock.rs @@ -91,7 +91,6 @@ parameter_types! { pub const RewardCurve: &'static sp_runtime::curve::PiecewiseLinear<'static> = &I_NPOS; } impl pallet_staking::Config for Runtime { - type MaxNominations = ConstU32<16>; type Currency = Balances; type CurrencyBalance = Balance; type UnixTime = pallet_timestamp::Pallet; @@ -114,6 +113,7 @@ impl pallet_staking::Config for Runtime { type GenesisElectionProvider = Self::ElectionProvider; type VoterList = VoterList; type TargetList = pallet_staking::UseValidatorsMap; + type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; type HistoryDepth = ConstU32<84>; type OnStakerSlash = Pools; diff --git a/frame/nomination-pools/test-staking/src/mock.rs b/frame/nomination-pools/test-staking/src/mock.rs index 3d0ab2c6f35f3..a7375fb9edfbc 100644 --- a/frame/nomination-pools/test-staking/src/mock.rs +++ b/frame/nomination-pools/test-staking/src/mock.rs @@ -105,7 +105,6 @@ parameter_types! { } impl pallet_staking::Config for Runtime { - type MaxNominations = ConstU32<16>; type Currency = Balances; type CurrencyBalance = Balance; type UnixTime = pallet_timestamp::Pallet; @@ -128,6 +127,7 @@ impl pallet_staking::Config for Runtime { type GenesisElectionProvider = Self::ElectionProvider; type VoterList = VoterList; type TargetList = pallet_staking::UseValidatorsMap; + type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; type HistoryDepth = ConstU32<84>; type OnStakerSlash = Pools; diff --git a/frame/offences/benchmarking/src/lib.rs b/frame/offences/benchmarking/src/lib.rs index 18193595f5eb5..35d827b067fcd 100644 --- a/frame/offences/benchmarking/src/lib.rs +++ b/frame/offences/benchmarking/src/lib.rs @@ -48,8 +48,8 @@ use pallet_session::{ #[cfg(test)] use pallet_staking::Event as StakingEvent; use pallet_staking::{ - Config as StakingConfig, Event as StakingEvent, Exposure, IndividualExposure, NominationsOf, - Pallet as Staking, RewardDestination, ValidatorPrefs, + Config as StakingConfig, Exposure, IndividualExposure, MaxNominationsOf, Pallet as Staking, + RewardDestination, ValidatorPrefs, }; const SEED: u32 = 0; diff --git a/frame/offences/benchmarking/src/mock.rs b/frame/offences/benchmarking/src/mock.rs index 233aa449d391c..1647c28f8c095 100644 --- a/frame/offences/benchmarking/src/mock.rs +++ b/frame/offences/benchmarking/src/mock.rs @@ -20,7 +20,7 @@ #![cfg(test)] use super::*; -use frame_election_provider_support::{onchain, SequentialPhragmen}; +use frame_election_provider_support::{onchain, SequentialPhragmen, ElectionBounds, ElectionBoundsBuilder}; use frame_support::{ parameter_types, traits::{ConstU32, ConstU64}, @@ -138,6 +138,7 @@ pallet_staking_reward_curve::build! { } parameter_types! { pub const RewardCurve: &'static sp_runtime::curve::PiecewiseLinear<'static> = &I_NPOS; + pub static ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::new().build(); } pub type Extrinsic = sp_runtime::testing::TestXt; @@ -149,12 +150,10 @@ impl onchain::Config for OnChainSeqPhragmen { type DataProvider = Staking; type WeightInfo = (); type MaxWinners = ConstU32<100>; - type VotersBound = ConstU32<{ u32::MAX }>; - type TargetsBound = ConstU32<{ u32::MAX }>; + type ElectionBounds = ElectionsBounds; } impl pallet_staking::Config for Test { - type MaxNominations = ConstU32<16>; type Currency = Balances; type CurrencyBalance = ::Balance; type UnixTime = pallet_timestamp::Pallet; @@ -176,6 +175,7 @@ impl pallet_staking::Config for Test { type GenesisElectionProvider = Self::ElectionProvider; type VoterList = pallet_staking::UseNominatorsAndValidatorsMap; type TargetList = pallet_staking::UseValidatorsMap; + type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; type HistoryDepth = ConstU32<84>; type OnStakerSlash = (); diff --git a/frame/root-offences/src/mock.rs b/frame/root-offences/src/mock.rs index 0937c43d6e519..3b39e1ffeb630 100644 --- a/frame/root-offences/src/mock.rs +++ b/frame/root-offences/src/mock.rs @@ -18,7 +18,9 @@ use super::*; use crate as root_offences; -use frame_election_provider_support::{onchain, SequentialPhragmen}; +use frame_election_provider_support::{ + onchain, ElectionBounds, ElectionBoundsBuilder, SequentialPhragmen, +}; use frame_support::{ parameter_types, traits::{ConstU32, ConstU64, GenesisBuild, Hooks, OneSessionHandler}, @@ -134,6 +136,10 @@ pallet_staking_reward_curve::build! { ); } +parameter_types! { + pub static ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::new().build(); +} + pub struct OnChainSeqPhragmen; impl onchain::Config for OnChainSeqPhragmen { type System = Test; @@ -141,8 +147,7 @@ impl onchain::Config for OnChainSeqPhragmen { type DataProvider = Staking; type WeightInfo = (); type MaxWinners = ConstU32<100>; - type VotersBound = ConstU32<{ u32::MAX }>; - type TargetsBound = ConstU32<{ u32::MAX }>; + type ElectionBounds = ElectionsBounds; } pub struct OnStakerSlashMock(core::marker::PhantomData); @@ -168,7 +173,6 @@ parameter_types! { } impl pallet_staking::Config for Test { - type MaxNominations = ConstU32<16>; type Currency = Balances; type CurrencyBalance = ::Balance; type UnixTime = Timestamp; @@ -189,6 +193,7 @@ impl pallet_staking::Config for Test { type ElectionProvider = onchain::OnChainExecution; type GenesisElectionProvider = Self::ElectionProvider; type TargetList = pallet_staking::UseValidatorsMap; + type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type MaxUnlockingChunks = ConstU32<32>; type HistoryDepth = ConstU32<84>; type VoterList = pallet_staking::UseNominatorsAndValidatorsMap; diff --git a/frame/session/benchmarking/src/mock.rs b/frame/session/benchmarking/src/mock.rs index 4ab77ceb89314..e6317c63a4dfe 100644 --- a/frame/session/benchmarking/src/mock.rs +++ b/frame/session/benchmarking/src/mock.rs @@ -19,7 +19,7 @@ #![cfg(test)] -use frame_election_provider_support::{onchain, SequentialPhragmen}; +use frame_election_provider_support::{onchain, SequentialPhragmen, ElectionBounds, ElectionBoundsBuilder}; use frame_support::{ parameter_types, traits::{ConstU32, ConstU64}, @@ -142,6 +142,7 @@ pallet_staking_reward_curve::build! { } parameter_types! { pub const RewardCurve: &'static sp_runtime::curve::PiecewiseLinear<'static> = &I_NPOS; + pub static ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::new().build(); } pub struct OnChainSeqPhragmen; @@ -151,12 +152,10 @@ impl onchain::Config for OnChainSeqPhragmen { type DataProvider = Staking; type WeightInfo = (); type MaxWinners = ConstU32<100>; - type VotersBounds = ElectionsBounds::new_unbounded(); - type TargetsBounds = ElectionsBounds::new_unbounded(); + type ElectionBounds = ElectionsBounds; } impl pallet_staking::Config for Test { - type MaxNominations = ConstU32<16>; type Currency = Balances; type CurrencyBalance = ::Balance; type UnixTime = pallet_timestamp::Pallet; @@ -180,6 +179,7 @@ impl pallet_staking::Config for Test { type HistoryDepth = ConstU32<84>; type VoterList = pallet_staking::UseNominatorsAndValidatorsMap; type TargetList = pallet_staking::UseValidatorsMap; + type NominationsQuota = pallet_staking::FixedNominationsQuota<16>; type OnStakerSlash = (); type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig; type WeightInfo = (); diff --git a/frame/staking/src/benchmarking.rs b/frame/staking/src/benchmarking.rs index cf4b8fd1ff0db..2034909248e13 100644 --- a/frame/staking/src/benchmarking.rs +++ b/frame/staking/src/benchmarking.rs @@ -952,7 +952,7 @@ mod tests { create_validators_with_nominators_for_era::( v, n, - ::MaxNominations::get() as usize, + MaxNominationsOf::::get() as usize, false, None, ) From 1bf29f7ce3160f5942de6d4db67bbfd116b23331 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Tue, 28 Feb 2023 23:15:08 +0100 Subject: [PATCH 24/80] nits --- frame/election-provider-multi-phase/src/lib.rs | 9 +++++---- frame/election-provider-support/src/lib.rs | 5 +---- frame/staking/src/lib.rs | 10 +++++----- frame/staking/src/mock.rs | 2 +- frame/staking/src/pallet/impls.rs | 10 ++++------ frame/staking/src/tests.rs | 2 ++ 6 files changed, 18 insertions(+), 20 deletions(-) diff --git a/frame/election-provider-multi-phase/src/lib.rs b/frame/election-provider-multi-phase/src/lib.rs index dc8d0e479c21c..23dd67f44a1b3 100644 --- a/frame/election-provider-multi-phase/src/lib.rs +++ b/frame/election-provider-multi-phase/src/lib.rs @@ -231,8 +231,9 @@ use codec::{Decode, Encode}; use frame_election_provider_support::{ - BoundedSupportsOf, ElectionBounds, ElectionBoundsBuilder, ElectionDataProvider, - ElectionProvider, ElectionProviderBase, InstantElectionProvider, NposSolution, + BoundedSupportsOf, DataProviderBounds, ElectionBounds, ElectionBoundsBuilder, + ElectionDataProvider, ElectionProvider, ElectionProviderBase, InstantElectionProvider, + NposSolution, }; use frame_support::{ dispatch::DispatchClass, @@ -1596,8 +1597,8 @@ impl Pallet { .ok_or(ElectionError::::NothingQueued) .or_else(|_| { T::Fallback::instant_elect( - ElectionBoundsBuilder::new().build().voters, - ElectionBoundsBuilder::new().build().targets, + DataProviderBounds::new_unbounded(), + DataProviderBounds::new_unbounded(), ) .map_err(|fe| ElectionError::Fallback(fe)) .and_then(|supports| { diff --git a/frame/election-provider-support/src/lib.rs b/frame/election-provider-support/src/lib.rs index a8347b34e18ea..57e5bcd356b9d 100644 --- a/frame/election-provider-support/src/lib.rs +++ b/frame/election-provider-support/src/lib.rs @@ -720,9 +720,6 @@ pub struct ElectionBounds { } /// Utility builder for [`ElectionBounds`]. -/// -/// The main purpose of this is to prevent mixing the order of similarly typed arguments (e.g. u32 -/// size and count). #[derive(Copy, Clone)] pub struct ElectionBoundsBuilder { voters: Option, @@ -730,7 +727,7 @@ pub struct ElectionBoundsBuilder { } impl ElectionBoundsBuilder { - /// Returns a new election bounds builder + /// Returns a new election bounds builder, initialized with unbounded voter and target limits. pub fn new() -> Self { ElectionBoundsBuilder { voters: None, targets: None } } diff --git a/frame/staking/src/lib.rs b/frame/staking/src/lib.rs index bf5ad34c2f47d..5fc5c71a8a404 100644 --- a/frame/staking/src/lib.rs +++ b/frame/staking/src/lib.rs @@ -780,7 +780,7 @@ pub trait NominationsQuota { Self::get_quota(balance).max(1).min(Self::MaxNominations::get()) } - // Returns the voter's nomination quota based on the quota implementation. + // Returns the voter's nomination quota based on the quota curve. fn get_quota(balance: Balance) -> u32; } @@ -807,9 +807,9 @@ impl Get for FixedNominationsQuota { /// /// ## Details /// -/// The snapshot has a the form `Vec` where `Voter = (Account, u64, Vec)`. For each -/// voter added to the snapshot, [`try_register_voter`] should be called, with the number of votes -/// (length of the internal `Vec`). +/// The snapshot has the form of `Vec` where `Voter = (Account, u64, Vec)`. For +/// each voter added to the snapshot, [`try_register_voter`] should be called, with the number +/// of votes (length of the internal `Vec`). /// /// Whilst doing this, [`size`] will track the entire size of the `Vec`, except for the /// length prefix of the outer `Vec`. To get the final size at any point, use @@ -825,7 +825,7 @@ impl ElectionSizeTracker { } /// Attempts to register a new voter with `votes` for a given election `bounds`. Returns an - /// error if the size of the new votes exceed the capacity of the tracker. + /// error if the new size exceeds the capacity of the tracker. pub(crate) fn try_register_voter( &mut self, votes: usize, diff --git a/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index 27e2acd311ab1..4dc855a0af997 100644 --- a/frame/staking/src/mock.rs +++ b/frame/staking/src/mock.rs @@ -317,7 +317,7 @@ where fn get_quota(balance: Balance) -> u32 { match balance.into() { - // random quota per balance for testing + // random curve for testing. 0..=110 => MAX, 111 => 0, 222 => 2, diff --git a/frame/staking/src/pallet/impls.rs b/frame/staking/src/pallet/impls.rs index 31849091415cf..45906678f97c0 100644 --- a/frame/staking/src/pallet/impls.rs +++ b/frame/staking/src/pallet/impls.rs @@ -60,11 +60,6 @@ use super::{pallet::*, STAKING_ID}; const NPOS_MAX_ITERATIONS_COEFFICIENT: u32 = 2; impl Pallet { - /// Query nominations quota for a given balance. - pub fn query_nominations_quota(balance: BalanceOf) -> u32 { - T::NominationsQuota::get_quota_safe(balance) - } - /// The total balance that can be slashed from a stash account as of right now. pub fn slashable_balance_of(stash: &T::AccountId) -> BalanceOf { // Weight note: consider making the stake accessible through stash. @@ -792,10 +787,13 @@ impl Pallet { // if this voter is a nominator: let voter_weight = weight_of(&voter); if !targets.is_empty() { - // select only targets allowed by voter's nomination quota + // select only targets allowed by voter's nomination quota. let nominations_quota = T::NominationsQuota::get_quota_safe(voter_weight.into()); + // if the current number of targets exceeds the nomination quota, emit an event + // but proceed without truncating or failing. The nomination quota checks are + // lazy and only fail when setting/updating the nominations. if targets.len() > nominations_quota as usize { Self::deposit_event(Event::::NominationsQuotaExceeded { staker: voter.clone(), diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index 56bed6451bd71..576a0f3055128 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -5165,6 +5165,8 @@ fn nomination_quota_max_changes_decoding() { }); } +// TOOD(gpestana): test runtime api call `api_nominations_quota` + mod sorted_list_provider { use super::*; use frame_election_provider_support::SortedListProvider; From 125ff54a5a9f4442b28b57868f71f73a8dddaefe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Wed, 1 Mar 2023 11:21:05 +0100 Subject: [PATCH 25/80] more tests --- .../election-provider-multi-phase/src/lib.rs | 8 +- frame/staking/src/tests.rs | 129 ++++++++++++++++-- 2 files changed, 124 insertions(+), 13 deletions(-) diff --git a/frame/election-provider-multi-phase/src/lib.rs b/frame/election-provider-multi-phase/src/lib.rs index 23dd67f44a1b3..39d69c39fa4e7 100644 --- a/frame/election-provider-multi-phase/src/lib.rs +++ b/frame/election-provider-multi-phase/src/lib.rs @@ -1883,7 +1883,7 @@ mod tests { mock::{ multi_phase_events, raw_solution, roll_to, roll_to_signed, roll_to_unsigned, AccountId, ExtBuilder, MockWeightInfo, MockedWeightInfo, MultiPhase, Runtime, RuntimeOrigin, - SignedMaxSubmissions, System, TargetIndex, Targets, + SignedMaxSubmissions, System, }, Phase, }; @@ -2490,7 +2490,7 @@ mod tests { let new_bounds = ElectionBoundsBuilder::new().targets_count(1_000).build(); crate::mock::ElectionsBounds::set(new_bounds); - Targets::set((0..(TargetIndex::max_value() as AccountId) + 1).collect::>()); + crate::mock::Targets::set((0..(1_000 as AccountId) + 1).collect::>()); // Signed phase failed to open. roll_to(15); @@ -2529,9 +2529,7 @@ mod tests { let new_bounds = ElectionBoundsBuilder::new().targets_count(1_000).build(); crate::mock::ElectionsBounds::set(new_bounds); - crate::mock::Targets::set( - (0..(TargetIndex::max_value() as AccountId) + 1).collect::>(), - ); + crate::mock::Targets::set((0..(1_000 as AccountId) + 1).collect::>()); // Signed phase failed to open. roll_to(15); diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index 576a0f3055128..2915755daa204 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -4613,7 +4613,7 @@ mod election_data_provider { } #[test] - fn nominate_above_quota_fails() { + fn nomination_quota_checks_at_nominate_works() { ExtBuilder::default().nominate(false).build_and_execute(|| { // stash bond of 222 has a nomination quota of 2 targets. bond(61, 60, 222); @@ -4664,7 +4664,7 @@ mod election_data_provider { } #[test] - fn nominations_quota_limits_size() { + fn nominations_quota_limits_size_work() { ExtBuilder::default() .nominate(false) .add_staker( @@ -4689,6 +4689,18 @@ mod election_data_provider { *staking_events().last().unwrap(), Event::SnapshotVotersSizeExceeded { size: 75 } ); + + // however, if the election voter size bounds were largers, the snapshot would + // include the electing voters of 70. + let bounds = ElectionBoundsBuilder::new().voters_size(1_000).build(); + assert_eq!( + Staking::electing_voters(bounds.voters) + .unwrap() + .iter() + .map(|(stash, _, targets)| (*stash, targets.len())) + .collect::>(), + vec![(11, 1), (21, 1), (31, 1), (71, 7)], + ); }); } @@ -5135,6 +5147,103 @@ fn min_commission_works() { }) } +#[test] +fn change_of_max_nominations() { + use frame_election_provider_support::ElectionDataProvider; + ExtBuilder::default() + .add_staker(60, 61, 10, StakerStatus::Nominator(vec![1])) + .add_staker(70, 71, 10, StakerStatus::Nominator(vec![1, 2, 3])) + .balance_factor(10) + .build_and_execute(|| { + // pre-condition + assert_eq!(MaxNominations::get(), 16); + + assert_eq!( + Nominators::::iter() + .map(|(k, n)| (k, n.targets.len())) + .collect::>(), + vec![(70, 3), (101, 2), (60, 1)] + ); + + let bounds = DataProviderBounds::new_unbounded(); + + // 3 validators and 3 nominators + assert_eq!(Staking::electing_voters(bounds).unwrap().len(), 3 + 3); + + // abrupt change from 16 to 4, everyone should be fine. + MaxNominations::set(4); + + assert_eq!( + Nominators::::iter() + .map(|(k, n)| (k, n.targets.len())) + .collect::>(), + vec![(70, 3), (101, 2), (60, 1)] + ); + assert_eq!(Staking::electing_voters(bounds).unwrap().len(), 3 + 3); + + // abrupt change from 4 to 3, everyone should be fine. + MaxNominations::set(3); + + assert_eq!( + Nominators::::iter() + .map(|(k, n)| (k, n.targets.len())) + .collect::>(), + vec![(70, 3), (101, 2), (60, 1)] + ); + assert_eq!(Staking::electing_voters(bounds).unwrap().len(), 3 + 3); + + // abrupt change from 3 to 2, this should cause some nominators to be non-decodable, and + // thus non-existent unless if they update. + MaxNominations::set(2); + + assert_eq!( + Nominators::::iter() + .map(|(k, n)| (k, n.targets.len())) + .collect::>(), + vec![(101, 2), (60, 1)] + ); + // 70 is still in storage.. + assert!(Nominators::::contains_key(70)); + // but its value cannot be decoded and default is returned. + assert!(Nominators::::get(70).is_none()); + + assert_eq!(Staking::electing_voters(bounds).unwrap().len(), 3 + 2); + assert!(Nominators::::contains_key(101)); + + // abrupt change from 2 to 1, this should cause some nominators to be non-decodable, and + // thus non-existent unless if they update. + MaxNominations::set(1); + + assert_eq!( + Nominators::::iter() + .map(|(k, n)| (k, n.targets.len())) + .collect::>(), + vec![(60, 1)] + ); + assert!(Nominators::::contains_key(70)); + assert!(Nominators::::contains_key(60)); + assert!(Nominators::::get(70).is_none()); + assert!(Nominators::::get(60).is_some()); + assert_eq!(Staking::electing_voters(bounds).unwrap().len(), 3 + 1); + + // now one of them can revive themselves by re-nominating to a proper value. + assert_ok!(Staking::nominate(RuntimeOrigin::signed(71), vec![1])); + assert_eq!( + Nominators::::iter() + .map(|(k, n)| (k, n.targets.len())) + .collect::>(), + vec![(70, 1), (60, 1)] + ); + + // or they can be chilled by any account. + assert!(Nominators::::contains_key(101)); + assert!(Nominators::::get(101).is_none()); + assert_ok!(Staking::chill_other(RuntimeOrigin::signed(70), 100)); + assert!(!Nominators::::contains_key(101)); + assert!(Nominators::::get(101).is_none()); + }) +} + #[test] fn nomination_quota_max_changes_decoding() { use frame_election_provider_support::ElectionDataProvider; @@ -5145,7 +5254,7 @@ fn nomination_quota_max_changes_decoding() { .add_staker(50, 550, 10, StakerStatus::Nominator(vec![1, 2, 3, 4])) .balance_factor(10) .build_and_execute(|| { - // pre-condition + // pre-condition. assert_eq!(MaxNominationsOf::::get(), 16); let unbonded_election = DataProviderBounds::new_unbounded(); @@ -5158,14 +5267,18 @@ fn nomination_quota_max_changes_decoding() { ); // 4 validators and 4 nominators assert_eq!(Staking::electing_voters(unbonded_election).unwrap().len(), 4 + 4); - - // TODO(gpestana): test decoding error when Nominations_quota::ABSOLUTE_MAX_NOMINATIONS - // decreases and test the chilling in those cases too (see old test and [`Nominators`] - // comments) }); } -// TOOD(gpestana): test runtime api call `api_nominations_quota` +#[test] +fn api_nominations_quota_works() { + ExtBuilder::default().build_and_execute(|| { + assert_eq!(Staking::api_nominations_quota(10), MaxNominationsOf::::get()); + assert_eq!(Staking::api_nominations_quota(333), MaxNominationsOf::::get()); + assert_eq!(Staking::api_nominations_quota(222), 2); + assert_eq!(Staking::api_nominations_quota(111), 1); + }) +} mod sorted_list_provider { use super::*; From 7d9fdfcdde411dfdffdcb5fea6c7de91cfe67f85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Wed, 1 Mar 2023 12:17:23 +0100 Subject: [PATCH 26/80] renames trait methods --- frame/staking/src/lib.rs | 18 +++++++++--------- frame/staking/src/mock.rs | 2 +- frame/staking/src/pallet/impls.rs | 5 ++--- frame/staking/src/pallet/mod.rs | 2 +- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/frame/staking/src/lib.rs b/frame/staking/src/lib.rs index 5fc5c71a8a404..4c0a408b6c7cd 100644 --- a/frame/staking/src/lib.rs +++ b/frame/staking/src/lib.rs @@ -767,21 +767,21 @@ impl UnappliedSlash { } } -/// Something that defines the maximum number of nominations per nominator. +/// Something that defines the maximum number of nominations per nominator based on a curve. pub trait NominationsQuota { - /// Maximum number of nominations. The method `get_quota` may return a larger number of - /// nominations than `Self::MaxNominations`. However, `get_quota_safe` returns the bounded - /// maximum number of nominations. + /// Maximum number of nominations. The method `curve` implements the nomination quota curve and + /// should not be used directly. However, `get_quota` returns the bounded maximum number of + // nominations based on `fn curve` and the nominator's balance. type MaxNominations: Get; /// Returns the voter's nomination quota within reasonable bounds [`min`, `max`], where `min` /// is 1 and `max` is `Self::MaxNominations`. - fn get_quota_safe(balance: Balance) -> u32 { - Self::get_quota(balance).max(1).min(Self::MaxNominations::get()) + fn get_quota(balance: Balance) -> u32 { + Self::curve(balance).max(1).min(Self::MaxNominations::get()) } - // Returns the voter's nomination quota based on the quota curve. - fn get_quota(balance: Balance) -> u32; + // Returns the voter's nomination quota based on its balance and a curve. + fn curve(balance: Balance) -> u32; } /// A nomination quota that allows up to MAX nominations for all validators. @@ -789,7 +789,7 @@ pub struct FixedNominationsQuota; impl NominationsQuota for FixedNominationsQuota { type MaxNominations = Self; - fn get_quota(_: Balance) -> u32 { + fn curve(_: Balance) -> u32 { MAX } } diff --git a/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index 4dc855a0af997..fd3a9928e6ebe 100644 --- a/frame/staking/src/mock.rs +++ b/frame/staking/src/mock.rs @@ -315,7 +315,7 @@ where { type MaxNominations = MaxNominations; - fn get_quota(balance: Balance) -> u32 { + fn curve(balance: Balance) -> u32 { match balance.into() { // random curve for testing. 0..=110 => MAX, diff --git a/frame/staking/src/pallet/impls.rs b/frame/staking/src/pallet/impls.rs index 45906678f97c0..5c17ec67dcf7e 100644 --- a/frame/staking/src/pallet/impls.rs +++ b/frame/staking/src/pallet/impls.rs @@ -788,8 +788,7 @@ impl Pallet { let voter_weight = weight_of(&voter); if !targets.is_empty() { // select only targets allowed by voter's nomination quota. - let nominations_quota = - T::NominationsQuota::get_quota_safe(voter_weight.into()); + let nominations_quota = T::NominationsQuota::get_quota(voter_weight.into()); // if the current number of targets exceeds the nomination quota, emit an event // but proceed without truncating or failing. The nomination quota checks are @@ -1013,7 +1012,7 @@ impl Pallet { /// /// Used by the runtime API. pub fn api_nominations_quota(balance: BalanceOf) -> u32 { - T::NominationsQuota::get_quota_safe(balance) + T::NominationsQuota::get_quota(balance) } } diff --git a/frame/staking/src/pallet/mod.rs b/frame/staking/src/pallet/mod.rs index 0c0a19e7cc73e..b5cfd0dd199bc 100644 --- a/frame/staking/src/pallet/mod.rs +++ b/frame/staking/src/pallet/mod.rs @@ -1177,7 +1177,7 @@ pub mod pallet { ensure!(!targets.is_empty(), Error::::EmptyTargets); ensure!( targets.len() <= - T::NominationsQuota::get_quota_safe(Self::weight_of(&stash).into()) as usize, + T::NominationsQuota::get_quota(Self::weight_of(&stash).into()) as usize, Error::::TooManyTargets ); From 8fddf4175c24d34b131b1a2a4bdd8a9706e27355 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Wed, 1 Mar 2023 12:27:31 +0100 Subject: [PATCH 27/80] nit --- frame/election-provider-multi-phase/src/mock.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/frame/election-provider-multi-phase/src/mock.rs b/frame/election-provider-multi-phase/src/mock.rs index f30bb46c64a8d..a7e3b875f4df1 100644 --- a/frame/election-provider-multi-phase/src/mock.rs +++ b/frame/election-provider-multi-phase/src/mock.rs @@ -470,7 +470,6 @@ impl ElectionDataProvider for StakingMock { voters: Vec>, targets: Vec, _target_stake: Option, - /* TODO(gpestana): this is the absolute max nomination, make it more explicit */ ) { Targets::set(targets); Voters::set(voters); From 805e3f795cb63da8f5011f76bd73d7c2749685f6 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Wed, 1 Mar 2023 11:35:19 +0000 Subject: [PATCH 28/80] ".git/.scripts/commands/fmt/fmt.sh" --- frame/grandpa/src/mock.rs | 4 +++- frame/offences/benchmarking/src/mock.rs | 4 +++- frame/session/benchmarking/src/mock.rs | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/frame/grandpa/src/mock.rs b/frame/grandpa/src/mock.rs index 8c80e0c894aff..c4d1aff411bb2 100644 --- a/frame/grandpa/src/mock.rs +++ b/frame/grandpa/src/mock.rs @@ -22,7 +22,9 @@ use crate::{self as pallet_grandpa, AuthorityId, AuthorityList, Config, ConsensusLog}; use ::grandpa as finality_grandpa; use codec::Encode; -use frame_election_provider_support::{onchain, SequentialPhragmen, ElectionBounds, ElectionBoundsBuilder}; +use frame_election_provider_support::{ + onchain, ElectionBounds, ElectionBoundsBuilder, SequentialPhragmen, +}; use frame_support::{ parameter_types, traits::{ diff --git a/frame/offences/benchmarking/src/mock.rs b/frame/offences/benchmarking/src/mock.rs index 1647c28f8c095..5484cb95101cc 100644 --- a/frame/offences/benchmarking/src/mock.rs +++ b/frame/offences/benchmarking/src/mock.rs @@ -20,7 +20,9 @@ #![cfg(test)] use super::*; -use frame_election_provider_support::{onchain, SequentialPhragmen, ElectionBounds, ElectionBoundsBuilder}; +use frame_election_provider_support::{ + onchain, ElectionBounds, ElectionBoundsBuilder, SequentialPhragmen, +}; use frame_support::{ parameter_types, traits::{ConstU32, ConstU64}, diff --git a/frame/session/benchmarking/src/mock.rs b/frame/session/benchmarking/src/mock.rs index e6317c63a4dfe..cf211b3cdb5f3 100644 --- a/frame/session/benchmarking/src/mock.rs +++ b/frame/session/benchmarking/src/mock.rs @@ -19,7 +19,9 @@ #![cfg(test)] -use frame_election_provider_support::{onchain, SequentialPhragmen, ElectionBounds, ElectionBoundsBuilder}; +use frame_election_provider_support::{ + onchain, ElectionBounds, ElectionBoundsBuilder, SequentialPhragmen, +}; use frame_support::{ parameter_types, traits::{ConstU32, ConstU64}, From 3317bd7b5544d1a6d3eebe3539a5f9c1187f7f9c Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Tue, 28 Feb 2023 14:47:36 +0100 Subject: [PATCH 29/80] Fix V2 PoV benchmarking (#13485) * Bump default 'additional_trie_layers' to two The default here only works for extremely small runtimes, which have no more than 16 storage prefices. This is changed to a "sane" default of 2, which is save for runtimes with up to 4096 storage prefices (eg StorageValue). Signed-off-by: Oliver Tale-Yazdi * Update tests and test weights Signed-off-by: Oliver Tale-Yazdi * Fix PoV weights Signed-off-by: Oliver Tale-Yazdi * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_balances * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_message_queue * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_glutton * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_glutton * Fix sanity check >0 would also do as a check, but let's try this. Signed-off-by: Oliver Tale-Yazdi --------- Signed-off-by: Oliver Tale-Yazdi Co-authored-by: command-bot <> --- frame/balances/src/weights.rs | 139 ++--- frame/benchmarking/pov/src/benchmarking.rs | 11 + frame/benchmarking/pov/src/weights.rs | 508 ++++++++++-------- frame/glutton/src/tests.rs | 2 +- frame/glutton/src/weights.rs | 184 +++---- frame/message-queue/src/weights.rs | 194 +++---- frame/support/procedural/src/benchmark.rs | 13 +- .../frame/benchmarking-cli/src/pallet/mod.rs | 2 +- 8 files changed, 576 insertions(+), 477 deletions(-) diff --git a/frame/balances/src/weights.rs b/frame/balances/src/weights.rs index 6bd7d7548c637..8c307ff90924d 100644 --- a/frame/balances/src/weights.rs +++ b/frame/balances/src/weights.rs @@ -18,25 +18,26 @@ //! Autogenerated weights for pallet_balances //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-02-27, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `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_balances // --extrinsic=* // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --output=./frame/balances/src/weights.rs +// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/substrate/.git/.artifacts/bench.json +// --pallet=pallet_balances +// --chain=dev // --header=./HEADER-APACHE2 +// --output=./frame/balances/src/weights.rs // --template=./.maintain/frame-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -64,10 +65,11 @@ impl WeightInfo for SubstrateWeight { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn transfer() -> Weight { // Proof Size summary in bytes: - // Measured: `1723` - // Estimated: `2603` - // Minimum execution time: 47_557 nanoseconds. - Weight::from_parts(48_314_000, 2603) + // Measured: `0` + // Estimated: `3593` + // Minimum execution time: 37_815 nanoseconds. + Weight::from_ref_time(38_109_000) + .saturating_add(Weight::from_proof_size(3593)) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -75,10 +77,11 @@ impl WeightInfo for SubstrateWeight { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn transfer_keep_alive() -> Weight { // Proof Size summary in bytes: - // Measured: `1607` - // Estimated: `2603` - // Minimum execution time: 36_372 nanoseconds. - Weight::from_parts(37_432_000, 2603) + // Measured: `0` + // Estimated: `3593` + // Minimum execution time: 28_184 nanoseconds. + Weight::from_ref_time(49_250_000) + .saturating_add(Weight::from_proof_size(3593)) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -86,10 +89,11 @@ impl WeightInfo for SubstrateWeight { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn set_balance_creating() -> Weight { // Proof Size summary in bytes: - // Measured: `1757` - // Estimated: `2603` - // Minimum execution time: 26_671 nanoseconds. - Weight::from_parts(28_287_000, 2603) + // Measured: `206` + // Estimated: `3593` + // Minimum execution time: 17_474 nanoseconds. + Weight::from_ref_time(17_777_000) + .saturating_add(Weight::from_proof_size(3593)) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -97,10 +101,11 @@ impl WeightInfo for SubstrateWeight { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn set_balance_killing() -> Weight { // Proof Size summary in bytes: - // Measured: `1757` - // Estimated: `2603` - // Minimum execution time: 30_122 nanoseconds. - Weight::from_parts(30_615_000, 2603) + // Measured: `206` + // Estimated: `3593` + // Minimum execution time: 20_962 nanoseconds. + Weight::from_ref_time(21_419_000) + .saturating_add(Weight::from_proof_size(3593)) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -108,10 +113,11 @@ impl WeightInfo for SubstrateWeight { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn force_transfer() -> Weight { // Proof Size summary in bytes: - // Measured: `1719` - // Estimated: `5206` - // Minimum execution time: 47_891 nanoseconds. - Weight::from_parts(48_496_000, 5206) + // Measured: `135` + // Estimated: `6196` + // Minimum execution time: 39_713 nanoseconds. + Weight::from_ref_time(40_360_000) + .saturating_add(Weight::from_proof_size(6196)) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -119,10 +125,11 @@ impl WeightInfo for SubstrateWeight { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn transfer_all() -> Weight { // Proof Size summary in bytes: - // Measured: `1607` - // Estimated: `2603` - // Minimum execution time: 42_470 nanoseconds. - Weight::from_parts(42_950_000, 2603) + // Measured: `0` + // Estimated: `3593` + // Minimum execution time: 34_878 nanoseconds. + Weight::from_ref_time(35_121_000) + .saturating_add(Weight::from_proof_size(3593)) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -130,10 +137,11 @@ impl WeightInfo for SubstrateWeight { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn force_unreserve() -> Weight { // Proof Size summary in bytes: - // Measured: `1641` - // Estimated: `2603` - // Minimum execution time: 23_230 nanoseconds. - Weight::from_parts(23_951_000, 2603) + // Measured: `206` + // Estimated: `3593` + // Minimum execution time: 16_790 nanoseconds. + Weight::from_ref_time(17_029_000) + .saturating_add(Weight::from_proof_size(3593)) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -145,10 +153,11 @@ impl WeightInfo for () { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn transfer() -> Weight { // Proof Size summary in bytes: - // Measured: `1723` - // Estimated: `2603` - // Minimum execution time: 47_557 nanoseconds. - Weight::from_parts(48_314_000, 2603) + // Measured: `0` + // Estimated: `3593` + // Minimum execution time: 37_815 nanoseconds. + Weight::from_ref_time(38_109_000) + .saturating_add(Weight::from_proof_size(3593)) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -156,10 +165,11 @@ impl WeightInfo for () { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn transfer_keep_alive() -> Weight { // Proof Size summary in bytes: - // Measured: `1607` - // Estimated: `2603` - // Minimum execution time: 36_372 nanoseconds. - Weight::from_parts(37_432_000, 2603) + // Measured: `0` + // Estimated: `3593` + // Minimum execution time: 28_184 nanoseconds. + Weight::from_ref_time(49_250_000) + .saturating_add(Weight::from_proof_size(3593)) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -167,10 +177,11 @@ impl WeightInfo for () { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn set_balance_creating() -> Weight { // Proof Size summary in bytes: - // Measured: `1757` - // Estimated: `2603` - // Minimum execution time: 26_671 nanoseconds. - Weight::from_parts(28_287_000, 2603) + // Measured: `206` + // Estimated: `3593` + // Minimum execution time: 17_474 nanoseconds. + Weight::from_ref_time(17_777_000) + .saturating_add(Weight::from_proof_size(3593)) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -178,10 +189,11 @@ impl WeightInfo for () { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn set_balance_killing() -> Weight { // Proof Size summary in bytes: - // Measured: `1757` - // Estimated: `2603` - // Minimum execution time: 30_122 nanoseconds. - Weight::from_parts(30_615_000, 2603) + // Measured: `206` + // Estimated: `3593` + // Minimum execution time: 20_962 nanoseconds. + Weight::from_ref_time(21_419_000) + .saturating_add(Weight::from_proof_size(3593)) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -189,10 +201,11 @@ impl WeightInfo for () { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn force_transfer() -> Weight { // Proof Size summary in bytes: - // Measured: `1719` - // Estimated: `5206` - // Minimum execution time: 47_891 nanoseconds. - Weight::from_parts(48_496_000, 5206) + // Measured: `135` + // Estimated: `6196` + // Minimum execution time: 39_713 nanoseconds. + Weight::from_ref_time(40_360_000) + .saturating_add(Weight::from_proof_size(6196)) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -200,10 +213,11 @@ impl WeightInfo for () { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn transfer_all() -> Weight { // Proof Size summary in bytes: - // Measured: `1607` - // Estimated: `2603` - // Minimum execution time: 42_470 nanoseconds. - Weight::from_parts(42_950_000, 2603) + // Measured: `0` + // Estimated: `3593` + // Minimum execution time: 34_878 nanoseconds. + Weight::from_ref_time(35_121_000) + .saturating_add(Weight::from_proof_size(3593)) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -211,10 +225,11 @@ impl WeightInfo for () { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn force_unreserve() -> Weight { // Proof Size summary in bytes: - // Measured: `1641` - // Estimated: `2603` - // Minimum execution time: 23_230 nanoseconds. - Weight::from_parts(23_951_000, 2603) + // Measured: `206` + // Estimated: `3593` + // Minimum execution time: 16_790 nanoseconds. + Weight::from_ref_time(17_029_000) + .saturating_add(Weight::from_proof_size(3593)) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } diff --git a/frame/benchmarking/pov/src/benchmarking.rs b/frame/benchmarking/pov/src/benchmarking.rs index 331570ad28fce..ebe9b241416ad 100644 --- a/frame/benchmarking/pov/src/benchmarking.rs +++ b/frame/benchmarking/pov/src/benchmarking.rs @@ -39,6 +39,17 @@ frame_benchmarking::benchmarks! { assert_eq!(Value::::get(), Some(123)); } + #[pov_mode = MaxEncodedLen { + Pov::Value2: Ignored + }] + storage_single_value_ignored_some_read { + Value::::put(123); + Value2::::put(123); + }: { + assert_eq!(Value::::get(), Some(123)); + assert_eq!(Value2::::get(), Some(123)); + } + storage_single_value_read_twice { Value::::put(123); }: { diff --git a/frame/benchmarking/pov/src/weights.rs b/frame/benchmarking/pov/src/weights.rs index e890e9b2ef88a..948d268cf7a4b 100644 --- a/frame/benchmarking/pov/src/weights.rs +++ b/frame/benchmarking/pov/src/weights.rs @@ -2,9 +2,9 @@ //! Autogenerated weights for frame_benchmarking_pallet_pov //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-01-23, STEPS: `50`, REPEAT: `1`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-02-27, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `oty-parity`, CPU: `11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz` +//! HOSTNAME: `i9`, CPU: `13th Gen Intel(R) Core(TM) i9-13900K` //! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024 // Executed Command: @@ -19,7 +19,7 @@ // --steps // 50 // --repeat -// 1 +// 20 // --template=.maintain/frame-weight-template.hbs // --output=frame/benchmarking/pov/src/weights.rs @@ -71,9 +71,10 @@ impl WeightInfo for SubstrateWeight { fn storage_single_value_read() -> Weight { // Proof Size summary in bytes: // Measured: `136` - // Estimated: `499` - // Minimum execution time: 3_291 nanoseconds. - Weight::from_parts(3_291_000, 499) + // Estimated: `1489` + // Minimum execution time: 1_968 nanoseconds. + Weight::from_ref_time(2_060_000) + .saturating_add(Weight::from_proof_size(1489)) .saturating_add(T::DbWeight::get().reads(1_u64)) } /// Storage: Pov Value (r:1 w:0) @@ -82,8 +83,9 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `136` // Estimated: `0` - // Minimum execution time: 2_918 nanoseconds. - Weight::from_ref_time(2_918_000) + // Minimum execution time: 1_934 nanoseconds. + Weight::from_ref_time(2_092_000) + .saturating_add(Weight::from_proof_size(0)) .saturating_add(T::DbWeight::get().reads(1_u64)) } /// Storage: Pov Value (r:1 w:0) @@ -93,9 +95,10 @@ impl WeightInfo for SubstrateWeight { fn storage_single_value_ignored_some_read() -> Weight { // Proof Size summary in bytes: // Measured: `160` - // Estimated: `659` - // Minimum execution time: 4_056 nanoseconds. - Weight::from_parts(4_056_000, 659) + // Estimated: `1649` + // Minimum execution time: 2_605 nanoseconds. + Weight::from_ref_time(2_786_000) + .saturating_add(Weight::from_proof_size(1649)) .saturating_add(T::DbWeight::get().reads(2_u64)) } /// Storage: Pov Value (r:1 w:0) @@ -103,9 +106,10 @@ impl WeightInfo for SubstrateWeight { fn storage_single_value_read_twice() -> Weight { // Proof Size summary in bytes: // Measured: `136` - // Estimated: `499` - // Minimum execution time: 3_552 nanoseconds. - Weight::from_parts(3_552_000, 499) + // Estimated: `1489` + // Minimum execution time: 2_019 nanoseconds. + Weight::from_ref_time(2_214_000) + .saturating_add(Weight::from_proof_size(1489)) .saturating_add(T::DbWeight::get().reads(1_u64)) } /// Storage: Pov Value (r:0 w:1) @@ -114,8 +118,9 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 795 nanoseconds. - Weight::from_ref_time(795_000) + // Minimum execution time: 279 nanoseconds. + Weight::from_ref_time(357_000) + .saturating_add(Weight::from_proof_size(0)) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: Pov Value (r:0 w:1) @@ -124,8 +129,9 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 865 nanoseconds. - Weight::from_ref_time(865_000) + // Minimum execution time: 291 nanoseconds. + Weight::from_ref_time(378_000) + .saturating_add(Weight::from_proof_size(0)) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: Pov Map1M (r:1 w:0) @@ -133,9 +139,10 @@ impl WeightInfo for SubstrateWeight { fn storage_1m_map_read_one_value_two_additional_layers() -> Weight { // Proof Size summary in bytes: // Measured: `1275` - // Estimated: `3750` - // Minimum execution time: 9_571 nanoseconds. - Weight::from_parts(9_571_000, 3750) + // Estimated: `4740` + // Minimum execution time: 5_077 nanoseconds. + Weight::from_ref_time(5_400_000) + .saturating_add(Weight::from_proof_size(4740)) .saturating_add(T::DbWeight::get().reads(1_u64)) } /// Storage: Pov Map1M (r:1 w:0) @@ -143,9 +150,10 @@ impl WeightInfo for SubstrateWeight { fn storage_1m_map_read_one_value_three_additional_layers() -> Weight { // Proof Size summary in bytes: // Measured: `1544` - // Estimated: `4019` - // Minimum execution time: 14_597 nanoseconds. - Weight::from_parts(14_597_000, 4019) + // Estimated: `5009` + // Minimum execution time: 5_878 nanoseconds. + Weight::from_ref_time(6_239_000) + .saturating_add(Weight::from_proof_size(5009)) .saturating_add(T::DbWeight::get().reads(1_u64)) } /// Storage: Pov Map1M (r:1 w:0) @@ -153,9 +161,10 @@ impl WeightInfo for SubstrateWeight { fn storage_1m_map_read_one_value_four_additional_layers() -> Weight { // Proof Size summary in bytes: // Measured: `2044` - // Estimated: `4519` - // Minimum execution time: 19_793 nanoseconds. - Weight::from_parts(19_793_000, 4519) + // Estimated: `5509` + // Minimum execution time: 7_282 nanoseconds. + Weight::from_ref_time(8_022_000) + .saturating_add(Weight::from_proof_size(5509)) .saturating_add(T::DbWeight::get().reads(1_u64)) } /// Storage: Pov Map1M (r:100 w:0) @@ -167,13 +176,14 @@ impl WeightInfo for SubstrateWeight { fn storage_map_read_per_component(n: u32, m: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `515 + n * (188 ±0) + m * (188 ±0)` - // Estimated: `0 + n * (3006 ±0) + m * (2511 ±0)` - // Minimum execution time: 266_160 nanoseconds. - Weight::from_ref_time(190_477_747) - // Standard Error: 96_405 - .saturating_add(Weight::from_ref_time(1_049_993).saturating_mul(n.into())) - // Standard Error: 96_405 - .saturating_add(Weight::from_ref_time(1_202_546).saturating_mul(m.into())) + // Estimated: `1980 + n * (3006 ±0) + m * (2511 ±0)` + // Minimum execution time: 195_406 nanoseconds. + Weight::from_ref_time(129_093_464) + .saturating_add(Weight::from_proof_size(1980)) + // Standard Error: 12_134 + .saturating_add(Weight::from_ref_time(855_330).saturating_mul(n.into())) + // Standard Error: 12_134 + .saturating_add(Weight::from_ref_time(870_523).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(m.into()))) .saturating_add(Weight::from_proof_size(3006).saturating_mul(n.into())) @@ -188,13 +198,14 @@ impl WeightInfo for SubstrateWeight { fn storage_map_read_per_component_one_ignored(n: u32, m: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `515 + n * (188 ±0) + m * (188 ±0)` - // Estimated: `695 + n * (3195 ±2) + m * (189 ±2)` - // Minimum execution time: 265_113 nanoseconds. - Weight::from_parts(215_943_973, 695) - // Standard Error: 199_907 - .saturating_add(Weight::from_ref_time(988_371).saturating_mul(n.into())) - // Standard Error: 199_907 - .saturating_add(Weight::from_ref_time(1_145_693).saturating_mul(m.into())) + // Estimated: `1685 + n * (3195 ±0) + m * (189 ±0)` + // Minimum execution time: 195_053 nanoseconds. + Weight::from_ref_time(131_322_479) + .saturating_add(Weight::from_proof_size(1685)) + // Standard Error: 12_161 + .saturating_add(Weight::from_ref_time(843_047).saturating_mul(n.into())) + // Standard Error: 12_161 + .saturating_add(Weight::from_ref_time(858_668).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(m.into()))) .saturating_add(Weight::from_proof_size(3195).saturating_mul(n.into())) @@ -206,11 +217,12 @@ impl WeightInfo for SubstrateWeight { fn storage_1m_map_one_entry_repeated_read(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `170` - // Estimated: `2511` - // Minimum execution time: 119 nanoseconds. - Weight::from_parts(3_649_405, 2511) - // Standard Error: 4_472 - .saturating_add(Weight::from_ref_time(432_147).saturating_mul(n.into())) + // Estimated: `3501` + // Minimum execution time: 22 nanoseconds. + Weight::from_ref_time(2_334_945) + .saturating_add(Weight::from_proof_size(3501)) + // Standard Error: 624 + .saturating_add(Weight::from_ref_time(282_046).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) } /// Storage: Pov Map1M (r:100 w:0) @@ -219,11 +231,12 @@ impl WeightInfo for SubstrateWeight { fn storage_1m_map_multiple_entry_repeated_read(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `147 + n * (40 ±0)` - // Estimated: `0 + n * (2511 ±0)` - // Minimum execution time: 106 nanoseconds. - Weight::from_ref_time(59_892_609) - // Standard Error: 418_004 - .saturating_add(Weight::from_ref_time(5_919_793).saturating_mul(n.into())) + // Estimated: `990 + n * (2511 ±0)` + // Minimum execution time: 20 nanoseconds. + Weight::from_ref_time(525_027) + .saturating_add(Weight::from_proof_size(990)) + // Standard Error: 2_767 + .saturating_add(Weight::from_ref_time(3_887_350).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(Weight::from_proof_size(2511).saturating_mul(n.into())) } @@ -233,11 +246,12 @@ impl WeightInfo for SubstrateWeight { fn storage_1m_double_map_read_per_component(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `21938 + n * (57 ±0)` - // Estimated: `0 + n * (2543 ±0)` - // Minimum execution time: 550 nanoseconds. - Weight::from_ref_time(65_431_603) - // Standard Error: 66_935 - .saturating_add(Weight::from_ref_time(2_825_371).saturating_mul(n.into())) + // Estimated: `990 + n * (2543 ±0)` + // Minimum execution time: 34 nanoseconds. + Weight::from_ref_time(18_341_393) + .saturating_add(Weight::from_proof_size(990)) + // Standard Error: 1_312 + .saturating_add(Weight::from_ref_time(2_053_135).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(Weight::from_proof_size(2543).saturating_mul(n.into())) } @@ -246,9 +260,10 @@ impl WeightInfo for SubstrateWeight { fn storage_value_bounded_read() -> Weight { // Proof Size summary in bytes: // Measured: `109` - // Estimated: `528` - // Minimum execution time: 2_541 nanoseconds. - Weight::from_parts(2_541_000, 528) + // Estimated: `1518` + // Minimum execution time: 1_163 nanoseconds. + Weight::from_ref_time(1_274_000) + .saturating_add(Weight::from_proof_size(1518)) .saturating_add(T::DbWeight::get().reads(1_u64)) } /// Storage: Pov UnboundedValue (r:1 w:0) @@ -256,9 +271,10 @@ impl WeightInfo for SubstrateWeight { fn storage_value_unbounded_read() -> Weight { // Proof Size summary in bytes: // Measured: `109` - // Estimated: `604` - // Minimum execution time: 2_226 nanoseconds. - Weight::from_parts(2_226_000, 604) + // Estimated: `1594` + // Minimum execution time: 1_167 nanoseconds. + Weight::from_ref_time(1_367_000) + .saturating_add(Weight::from_proof_size(1594)) .saturating_add(T::DbWeight::get().reads(1_u64)) } /// Storage: Pov UnboundedValue (r:1 w:0) @@ -267,8 +283,9 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `109` // Estimated: `0` - // Minimum execution time: 2_100 nanoseconds. - Weight::from_ref_time(2_100_000) + // Minimum execution time: 1_155 nanoseconds. + Weight::from_ref_time(1_248_000) + .saturating_add(Weight::from_proof_size(0)) .saturating_add(T::DbWeight::get().reads(1_u64)) } /// Storage: Pov UnboundedValue (r:1 w:0) @@ -278,9 +295,10 @@ impl WeightInfo for SubstrateWeight { fn storage_value_bounded_and_unbounded_read() -> Weight { // Proof Size summary in bytes: // Measured: `109` - // Estimated: `1132` - // Minimum execution time: 2_808 nanoseconds. - Weight::from_parts(2_808_000, 1132) + // Estimated: `3112` + // Minimum execution time: 1_424 nanoseconds. + Weight::from_ref_time(1_601_000) + .saturating_add(Weight::from_proof_size(3112)) .saturating_add(T::DbWeight::get().reads(2_u64)) } /// Storage: Pov LargeValue (r:1 w:0) @@ -289,11 +307,12 @@ impl WeightInfo for SubstrateWeight { fn measured_storage_value_read_linear_size(l: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `174 + l * (1 ±0)` - // Estimated: `666 + l * (1 ±0)` - // Minimum execution time: 3_385 nanoseconds. - Weight::from_parts(3_385_000, 666) - // Standard Error: 10 - .saturating_add(Weight::from_ref_time(356).saturating_mul(l.into())) + // Estimated: `1656 + l * (1 ±0)` + // Minimum execution time: 1_744 nanoseconds. + Weight::from_ref_time(1_800_000) + .saturating_add(Weight::from_proof_size(1656)) + // Standard Error: 4 + .saturating_add(Weight::from_ref_time(443).saturating_mul(l.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(Weight::from_proof_size(1).saturating_mul(l.into())) } @@ -303,11 +322,12 @@ impl WeightInfo for SubstrateWeight { fn mel_storage_value_read_linear_size(l: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `174 + l * (1 ±0)` - // Estimated: `4194803` - // Minimum execution time: 3_342 nanoseconds. - Weight::from_parts(3_342_000, 4194803) + // Estimated: `4195793` + // Minimum execution time: 1_770 nanoseconds. + Weight::from_ref_time(1_813_000) + .saturating_add(Weight::from_proof_size(4195793)) // Standard Error: 6 - .saturating_add(Weight::from_ref_time(345).saturating_mul(l.into())) + .saturating_add(Weight::from_ref_time(495).saturating_mul(l.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) } /// Storage: Pov LargeValue (r:1 w:0) @@ -318,11 +338,12 @@ impl WeightInfo for SubstrateWeight { fn measured_storage_double_value_read_linear_size(l: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `235 + l * (2 ±0)` - // Estimated: `1448 + l * (4 ±0)` - // Minimum execution time: 4_519 nanoseconds. - Weight::from_parts(4_519_000, 1448) - // Standard Error: 9 - .saturating_add(Weight::from_ref_time(560).saturating_mul(l.into())) + // Estimated: `3428 + l * (4 ±0)` + // Minimum execution time: 2_349 nanoseconds. + Weight::from_ref_time(2_423_000) + .saturating_add(Weight::from_proof_size(3428)) + // Standard Error: 11 + .saturating_add(Weight::from_ref_time(950).saturating_mul(l.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(Weight::from_proof_size(4).saturating_mul(l.into())) } @@ -334,11 +355,12 @@ impl WeightInfo for SubstrateWeight { fn mel_storage_double_value_read_linear_size(l: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `235 + l * (2 ±0)` - // Estimated: `8389606` - // Minimum execution time: 4_462 nanoseconds. - Weight::from_parts(4_462_000, 8389606) - // Standard Error: 7 - .saturating_add(Weight::from_ref_time(538).saturating_mul(l.into())) + // Estimated: `8391586` + // Minimum execution time: 2_315 nanoseconds. + Weight::from_ref_time(2_409_000) + .saturating_add(Weight::from_proof_size(8391586)) + // Standard Error: 12 + .saturating_add(Weight::from_ref_time(984).saturating_mul(l.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) } /// Storage: Pov LargeValue (r:1 w:0) @@ -349,11 +371,12 @@ impl WeightInfo for SubstrateWeight { fn mel_mixed_storage_double_value_read_linear_size(l: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `235 + l * (2 ±0)` - // Estimated: `4195527 + l * (2 ±0)` - // Minimum execution time: 4_552 nanoseconds. - Weight::from_parts(4_552_000, 4195527) - // Standard Error: 6 - .saturating_add(Weight::from_ref_time(507).saturating_mul(l.into())) + // Estimated: `4197507 + l * (2 ±0)` + // Minimum execution time: 2_370 nanoseconds. + Weight::from_ref_time(2_474_000) + .saturating_add(Weight::from_proof_size(4197507)) + // Standard Error: 11 + .saturating_add(Weight::from_ref_time(956).saturating_mul(l.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(Weight::from_proof_size(2).saturating_mul(l.into())) } @@ -365,11 +388,12 @@ impl WeightInfo for SubstrateWeight { fn measured_mixed_storage_double_value_read_linear_size(l: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `235 + l * (2 ±0)` - // Estimated: `4195527 + l * (2 ±0)` - // Minimum execution time: 4_236 nanoseconds. - Weight::from_parts(4_236_000, 4195527) - // Standard Error: 8 - .saturating_add(Weight::from_ref_time(517).saturating_mul(l.into())) + // Estimated: `4197507 + l * (2 ±0)` + // Minimum execution time: 2_375 nanoseconds. + Weight::from_ref_time(2_420_000) + .saturating_add(Weight::from_proof_size(4197507)) + // Standard Error: 9 + .saturating_add(Weight::from_ref_time(914).saturating_mul(l.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(Weight::from_proof_size(2).saturating_mul(l.into())) } @@ -381,11 +405,12 @@ impl WeightInfo for SubstrateWeight { fn storage_map_unbounded_both_measured_read(i: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `293 + i * (8 ±0)` - // Estimated: `5524 + i * (16 ±0)` - // Minimum execution time: 5_649 nanoseconds. - Weight::from_parts(6_111_237, 5524) - // Standard Error: 1_060 - .saturating_add(Weight::from_ref_time(2_693).saturating_mul(i.into())) + // Estimated: `7504 + i * (16 ±0)` + // Minimum execution time: 3_305 nanoseconds. + Weight::from_ref_time(3_689_335) + .saturating_add(Weight::from_proof_size(7504)) + // Standard Error: 29 + .saturating_add(Weight::from_ref_time(638).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(Weight::from_proof_size(16).saturating_mul(i.into())) } @@ -397,9 +422,12 @@ impl WeightInfo for SubstrateWeight { fn storage_map_partial_unbounded_read(i: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `260 + i * (4 ±0)` - // Estimated: `5243 + i * (4 ±0)` - // Minimum execution time: 5_997 nanoseconds. - Weight::from_parts(7_996_508, 5243) + // Estimated: `7223 + i * (4 ±0)` + // Minimum execution time: 3_469 nanoseconds. + Weight::from_ref_time(3_878_896) + .saturating_add(Weight::from_proof_size(7223)) + // Standard Error: 33 + .saturating_add(Weight::from_ref_time(356).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(Weight::from_proof_size(4).saturating_mul(i.into())) } @@ -411,11 +439,12 @@ impl WeightInfo for SubstrateWeight { fn storage_map_partial_unbounded_ignored_read(i: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `260 + i * (4 ±0)` - // Estimated: `2768 + i * (4 ±0)` - // Minimum execution time: 5_679 nanoseconds. - Weight::from_parts(6_496_804, 2768) - // Standard Error: 611 - .saturating_add(Weight::from_ref_time(930).saturating_mul(i.into())) + // Estimated: `3758 + i * (4 ±0)` + // Minimum execution time: 3_442 nanoseconds. + Weight::from_ref_time(3_881_051) + .saturating_add(Weight::from_proof_size(3758)) + // Standard Error: 35 + .saturating_add(Weight::from_ref_time(384).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(Weight::from_proof_size(4).saturating_mul(i.into())) } @@ -423,15 +452,17 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_087 nanoseconds. - Weight::from_ref_time(7_087_000) + // Minimum execution time: 1_619 nanoseconds. + Weight::from_ref_time(1_728_000) + .saturating_add(Weight::from_proof_size(0)) } fn noop() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_719 nanoseconds. - Weight::from_ref_time(2_719_000) + // Minimum execution time: 546 nanoseconds. + Weight::from_ref_time(640_000) + .saturating_add(Weight::from_proof_size(0)) } } @@ -442,9 +473,10 @@ impl WeightInfo for () { fn storage_single_value_read() -> Weight { // Proof Size summary in bytes: // Measured: `136` - // Estimated: `499` - // Minimum execution time: 3_291 nanoseconds. - Weight::from_parts(3_291_000, 499) + // Estimated: `1489` + // Minimum execution time: 1_968 nanoseconds. + Weight::from_ref_time(2_060_000) + .saturating_add(Weight::from_proof_size(1489)) .saturating_add(RocksDbWeight::get().reads(1_u64)) } /// Storage: Pov Value (r:1 w:0) @@ -453,8 +485,9 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `136` // Estimated: `0` - // Minimum execution time: 2_918 nanoseconds. - Weight::from_ref_time(2_918_000) + // Minimum execution time: 1_934 nanoseconds. + Weight::from_ref_time(2_092_000) + .saturating_add(Weight::from_proof_size(0)) .saturating_add(RocksDbWeight::get().reads(1_u64)) } /// Storage: Pov Value (r:1 w:0) @@ -464,9 +497,10 @@ impl WeightInfo for () { fn storage_single_value_ignored_some_read() -> Weight { // Proof Size summary in bytes: // Measured: `160` - // Estimated: `659` - // Minimum execution time: 4_056 nanoseconds. - Weight::from_parts(4_056_000, 659) + // Estimated: `1649` + // Minimum execution time: 2_605 nanoseconds. + Weight::from_ref_time(2_786_000) + .saturating_add(Weight::from_proof_size(1649)) .saturating_add(RocksDbWeight::get().reads(2_u64)) } /// Storage: Pov Value (r:1 w:0) @@ -474,9 +508,10 @@ impl WeightInfo for () { fn storage_single_value_read_twice() -> Weight { // Proof Size summary in bytes: // Measured: `136` - // Estimated: `499` - // Minimum execution time: 3_552 nanoseconds. - Weight::from_parts(3_552_000, 499) + // Estimated: `1489` + // Minimum execution time: 2_019 nanoseconds. + Weight::from_ref_time(2_214_000) + .saturating_add(Weight::from_proof_size(1489)) .saturating_add(RocksDbWeight::get().reads(1_u64)) } /// Storage: Pov Value (r:0 w:1) @@ -485,8 +520,9 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 795 nanoseconds. - Weight::from_ref_time(795_000) + // Minimum execution time: 279 nanoseconds. + Weight::from_ref_time(357_000) + .saturating_add(Weight::from_proof_size(0)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: Pov Value (r:0 w:1) @@ -495,8 +531,9 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 865 nanoseconds. - Weight::from_ref_time(865_000) + // Minimum execution time: 291 nanoseconds. + Weight::from_ref_time(378_000) + .saturating_add(Weight::from_proof_size(0)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: Pov Map1M (r:1 w:0) @@ -504,9 +541,10 @@ impl WeightInfo for () { fn storage_1m_map_read_one_value_two_additional_layers() -> Weight { // Proof Size summary in bytes: // Measured: `1275` - // Estimated: `3750` - // Minimum execution time: 9_571 nanoseconds. - Weight::from_parts(9_571_000, 3750) + // Estimated: `4740` + // Minimum execution time: 5_077 nanoseconds. + Weight::from_ref_time(5_400_000) + .saturating_add(Weight::from_proof_size(4740)) .saturating_add(RocksDbWeight::get().reads(1_u64)) } /// Storage: Pov Map1M (r:1 w:0) @@ -514,9 +552,10 @@ impl WeightInfo for () { fn storage_1m_map_read_one_value_three_additional_layers() -> Weight { // Proof Size summary in bytes: // Measured: `1544` - // Estimated: `4019` - // Minimum execution time: 14_597 nanoseconds. - Weight::from_parts(14_597_000, 4019) + // Estimated: `5009` + // Minimum execution time: 5_878 nanoseconds. + Weight::from_ref_time(6_239_000) + .saturating_add(Weight::from_proof_size(5009)) .saturating_add(RocksDbWeight::get().reads(1_u64)) } /// Storage: Pov Map1M (r:1 w:0) @@ -524,9 +563,10 @@ impl WeightInfo for () { fn storage_1m_map_read_one_value_four_additional_layers() -> Weight { // Proof Size summary in bytes: // Measured: `2044` - // Estimated: `4519` - // Minimum execution time: 19_793 nanoseconds. - Weight::from_parts(19_793_000, 4519) + // Estimated: `5509` + // Minimum execution time: 7_282 nanoseconds. + Weight::from_ref_time(8_022_000) + .saturating_add(Weight::from_proof_size(5509)) .saturating_add(RocksDbWeight::get().reads(1_u64)) } /// Storage: Pov Map1M (r:100 w:0) @@ -538,13 +578,14 @@ impl WeightInfo for () { fn storage_map_read_per_component(n: u32, m: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `515 + n * (188 ±0) + m * (188 ±0)` - // Estimated: `0 + n * (3006 ±0) + m * (2511 ±0)` - // Minimum execution time: 266_160 nanoseconds. - Weight::from_ref_time(190_477_747) - // Standard Error: 96_405 - .saturating_add(Weight::from_ref_time(1_049_993).saturating_mul(n.into())) - // Standard Error: 96_405 - .saturating_add(Weight::from_ref_time(1_202_546).saturating_mul(m.into())) + // Estimated: `1980 + n * (3006 ±0) + m * (2511 ±0)` + // Minimum execution time: 195_406 nanoseconds. + Weight::from_ref_time(129_093_464) + .saturating_add(Weight::from_proof_size(1980)) + // Standard Error: 12_134 + .saturating_add(Weight::from_ref_time(855_330).saturating_mul(n.into())) + // Standard Error: 12_134 + .saturating_add(Weight::from_ref_time(870_523).saturating_mul(m.into())) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(m.into()))) .saturating_add(Weight::from_proof_size(3006).saturating_mul(n.into())) @@ -559,13 +600,14 @@ impl WeightInfo for () { fn storage_map_read_per_component_one_ignored(n: u32, m: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `515 + n * (188 ±0) + m * (188 ±0)` - // Estimated: `695 + n * (3195 ±2) + m * (189 ±2)` - // Minimum execution time: 265_113 nanoseconds. - Weight::from_parts(215_943_973, 695) - // Standard Error: 199_907 - .saturating_add(Weight::from_ref_time(988_371).saturating_mul(n.into())) - // Standard Error: 199_907 - .saturating_add(Weight::from_ref_time(1_145_693).saturating_mul(m.into())) + // Estimated: `1685 + n * (3195 ±0) + m * (189 ±0)` + // Minimum execution time: 195_053 nanoseconds. + Weight::from_ref_time(131_322_479) + .saturating_add(Weight::from_proof_size(1685)) + // Standard Error: 12_161 + .saturating_add(Weight::from_ref_time(843_047).saturating_mul(n.into())) + // Standard Error: 12_161 + .saturating_add(Weight::from_ref_time(858_668).saturating_mul(m.into())) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(m.into()))) .saturating_add(Weight::from_proof_size(3195).saturating_mul(n.into())) @@ -577,11 +619,12 @@ impl WeightInfo for () { fn storage_1m_map_one_entry_repeated_read(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `170` - // Estimated: `2511` - // Minimum execution time: 119 nanoseconds. - Weight::from_parts(3_649_405, 2511) - // Standard Error: 4_472 - .saturating_add(Weight::from_ref_time(432_147).saturating_mul(n.into())) + // Estimated: `3501` + // Minimum execution time: 22 nanoseconds. + Weight::from_ref_time(2_334_945) + .saturating_add(Weight::from_proof_size(3501)) + // Standard Error: 624 + .saturating_add(Weight::from_ref_time(282_046).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) } /// Storage: Pov Map1M (r:100 w:0) @@ -590,11 +633,12 @@ impl WeightInfo for () { fn storage_1m_map_multiple_entry_repeated_read(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `147 + n * (40 ±0)` - // Estimated: `0 + n * (2511 ±0)` - // Minimum execution time: 106 nanoseconds. - Weight::from_ref_time(59_892_609) - // Standard Error: 418_004 - .saturating_add(Weight::from_ref_time(5_919_793).saturating_mul(n.into())) + // Estimated: `990 + n * (2511 ±0)` + // Minimum execution time: 20 nanoseconds. + Weight::from_ref_time(525_027) + .saturating_add(Weight::from_proof_size(990)) + // Standard Error: 2_767 + .saturating_add(Weight::from_ref_time(3_887_350).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(Weight::from_proof_size(2511).saturating_mul(n.into())) } @@ -604,11 +648,12 @@ impl WeightInfo for () { fn storage_1m_double_map_read_per_component(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `21938 + n * (57 ±0)` - // Estimated: `0 + n * (2543 ±0)` - // Minimum execution time: 550 nanoseconds. - Weight::from_ref_time(65_431_603) - // Standard Error: 66_935 - .saturating_add(Weight::from_ref_time(2_825_371).saturating_mul(n.into())) + // Estimated: `990 + n * (2543 ±0)` + // Minimum execution time: 34 nanoseconds. + Weight::from_ref_time(18_341_393) + .saturating_add(Weight::from_proof_size(990)) + // Standard Error: 1_312 + .saturating_add(Weight::from_ref_time(2_053_135).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(Weight::from_proof_size(2543).saturating_mul(n.into())) } @@ -617,9 +662,10 @@ impl WeightInfo for () { fn storage_value_bounded_read() -> Weight { // Proof Size summary in bytes: // Measured: `109` - // Estimated: `528` - // Minimum execution time: 2_541 nanoseconds. - Weight::from_parts(2_541_000, 528) + // Estimated: `1518` + // Minimum execution time: 1_163 nanoseconds. + Weight::from_ref_time(1_274_000) + .saturating_add(Weight::from_proof_size(1518)) .saturating_add(RocksDbWeight::get().reads(1_u64)) } /// Storage: Pov UnboundedValue (r:1 w:0) @@ -627,9 +673,10 @@ impl WeightInfo for () { fn storage_value_unbounded_read() -> Weight { // Proof Size summary in bytes: // Measured: `109` - // Estimated: `604` - // Minimum execution time: 2_226 nanoseconds. - Weight::from_parts(2_226_000, 604) + // Estimated: `1594` + // Minimum execution time: 1_167 nanoseconds. + Weight::from_ref_time(1_367_000) + .saturating_add(Weight::from_proof_size(1594)) .saturating_add(RocksDbWeight::get().reads(1_u64)) } /// Storage: Pov UnboundedValue (r:1 w:0) @@ -638,8 +685,9 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `109` // Estimated: `0` - // Minimum execution time: 2_100 nanoseconds. - Weight::from_ref_time(2_100_000) + // Minimum execution time: 1_155 nanoseconds. + Weight::from_ref_time(1_248_000) + .saturating_add(Weight::from_proof_size(0)) .saturating_add(RocksDbWeight::get().reads(1_u64)) } /// Storage: Pov UnboundedValue (r:1 w:0) @@ -649,9 +697,10 @@ impl WeightInfo for () { fn storage_value_bounded_and_unbounded_read() -> Weight { // Proof Size summary in bytes: // Measured: `109` - // Estimated: `1132` - // Minimum execution time: 2_808 nanoseconds. - Weight::from_parts(2_808_000, 1132) + // Estimated: `3112` + // Minimum execution time: 1_424 nanoseconds. + Weight::from_ref_time(1_601_000) + .saturating_add(Weight::from_proof_size(3112)) .saturating_add(RocksDbWeight::get().reads(2_u64)) } /// Storage: Pov LargeValue (r:1 w:0) @@ -660,11 +709,12 @@ impl WeightInfo for () { fn measured_storage_value_read_linear_size(l: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `174 + l * (1 ±0)` - // Estimated: `666 + l * (1 ±0)` - // Minimum execution time: 3_385 nanoseconds. - Weight::from_parts(3_385_000, 666) - // Standard Error: 10 - .saturating_add(Weight::from_ref_time(356).saturating_mul(l.into())) + // Estimated: `1656 + l * (1 ±0)` + // Minimum execution time: 1_744 nanoseconds. + Weight::from_ref_time(1_800_000) + .saturating_add(Weight::from_proof_size(1656)) + // Standard Error: 4 + .saturating_add(Weight::from_ref_time(443).saturating_mul(l.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(Weight::from_proof_size(1).saturating_mul(l.into())) } @@ -674,11 +724,12 @@ impl WeightInfo for () { fn mel_storage_value_read_linear_size(l: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `174 + l * (1 ±0)` - // Estimated: `4194803` - // Minimum execution time: 3_342 nanoseconds. - Weight::from_parts(3_342_000, 4194803) + // Estimated: `4195793` + // Minimum execution time: 1_770 nanoseconds. + Weight::from_ref_time(1_813_000) + .saturating_add(Weight::from_proof_size(4195793)) // Standard Error: 6 - .saturating_add(Weight::from_ref_time(345).saturating_mul(l.into())) + .saturating_add(Weight::from_ref_time(495).saturating_mul(l.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) } /// Storage: Pov LargeValue (r:1 w:0) @@ -689,11 +740,12 @@ impl WeightInfo for () { fn measured_storage_double_value_read_linear_size(l: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `235 + l * (2 ±0)` - // Estimated: `1448 + l * (4 ±0)` - // Minimum execution time: 4_519 nanoseconds. - Weight::from_parts(4_519_000, 1448) - // Standard Error: 9 - .saturating_add(Weight::from_ref_time(560).saturating_mul(l.into())) + // Estimated: `3428 + l * (4 ±0)` + // Minimum execution time: 2_349 nanoseconds. + Weight::from_ref_time(2_423_000) + .saturating_add(Weight::from_proof_size(3428)) + // Standard Error: 11 + .saturating_add(Weight::from_ref_time(950).saturating_mul(l.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(Weight::from_proof_size(4).saturating_mul(l.into())) } @@ -705,11 +757,12 @@ impl WeightInfo for () { fn mel_storage_double_value_read_linear_size(l: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `235 + l * (2 ±0)` - // Estimated: `8389606` - // Minimum execution time: 4_462 nanoseconds. - Weight::from_parts(4_462_000, 8389606) - // Standard Error: 7 - .saturating_add(Weight::from_ref_time(538).saturating_mul(l.into())) + // Estimated: `8391586` + // Minimum execution time: 2_315 nanoseconds. + Weight::from_ref_time(2_409_000) + .saturating_add(Weight::from_proof_size(8391586)) + // Standard Error: 12 + .saturating_add(Weight::from_ref_time(984).saturating_mul(l.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) } /// Storage: Pov LargeValue (r:1 w:0) @@ -720,11 +773,12 @@ impl WeightInfo for () { fn mel_mixed_storage_double_value_read_linear_size(l: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `235 + l * (2 ±0)` - // Estimated: `4195527 + l * (2 ±0)` - // Minimum execution time: 4_552 nanoseconds. - Weight::from_parts(4_552_000, 4195527) - // Standard Error: 6 - .saturating_add(Weight::from_ref_time(507).saturating_mul(l.into())) + // Estimated: `4197507 + l * (2 ±0)` + // Minimum execution time: 2_370 nanoseconds. + Weight::from_ref_time(2_474_000) + .saturating_add(Weight::from_proof_size(4197507)) + // Standard Error: 11 + .saturating_add(Weight::from_ref_time(956).saturating_mul(l.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(Weight::from_proof_size(2).saturating_mul(l.into())) } @@ -736,11 +790,12 @@ impl WeightInfo for () { fn measured_mixed_storage_double_value_read_linear_size(l: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `235 + l * (2 ±0)` - // Estimated: `4195527 + l * (2 ±0)` - // Minimum execution time: 4_236 nanoseconds. - Weight::from_parts(4_236_000, 4195527) - // Standard Error: 8 - .saturating_add(Weight::from_ref_time(517).saturating_mul(l.into())) + // Estimated: `4197507 + l * (2 ±0)` + // Minimum execution time: 2_375 nanoseconds. + Weight::from_ref_time(2_420_000) + .saturating_add(Weight::from_proof_size(4197507)) + // Standard Error: 9 + .saturating_add(Weight::from_ref_time(914).saturating_mul(l.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(Weight::from_proof_size(2).saturating_mul(l.into())) } @@ -752,11 +807,12 @@ impl WeightInfo for () { fn storage_map_unbounded_both_measured_read(i: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `293 + i * (8 ±0)` - // Estimated: `5524 + i * (16 ±0)` - // Minimum execution time: 5_649 nanoseconds. - Weight::from_parts(6_111_237, 5524) - // Standard Error: 1_060 - .saturating_add(Weight::from_ref_time(2_693).saturating_mul(i.into())) + // Estimated: `7504 + i * (16 ±0)` + // Minimum execution time: 3_305 nanoseconds. + Weight::from_ref_time(3_689_335) + .saturating_add(Weight::from_proof_size(7504)) + // Standard Error: 29 + .saturating_add(Weight::from_ref_time(638).saturating_mul(i.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(Weight::from_proof_size(16).saturating_mul(i.into())) } @@ -768,9 +824,12 @@ impl WeightInfo for () { fn storage_map_partial_unbounded_read(i: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `260 + i * (4 ±0)` - // Estimated: `5243 + i * (4 ±0)` - // Minimum execution time: 5_997 nanoseconds. - Weight::from_parts(7_996_508, 5243) + // Estimated: `7223 + i * (4 ±0)` + // Minimum execution time: 3_469 nanoseconds. + Weight::from_ref_time(3_878_896) + .saturating_add(Weight::from_proof_size(7223)) + // Standard Error: 33 + .saturating_add(Weight::from_ref_time(356).saturating_mul(i.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(Weight::from_proof_size(4).saturating_mul(i.into())) } @@ -782,11 +841,12 @@ impl WeightInfo for () { fn storage_map_partial_unbounded_ignored_read(i: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `260 + i * (4 ±0)` - // Estimated: `2768 + i * (4 ±0)` - // Minimum execution time: 5_679 nanoseconds. - Weight::from_parts(6_496_804, 2768) - // Standard Error: 611 - .saturating_add(Weight::from_ref_time(930).saturating_mul(i.into())) + // Estimated: `3758 + i * (4 ±0)` + // Minimum execution time: 3_442 nanoseconds. + Weight::from_ref_time(3_881_051) + .saturating_add(Weight::from_proof_size(3758)) + // Standard Error: 35 + .saturating_add(Weight::from_ref_time(384).saturating_mul(i.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(Weight::from_proof_size(4).saturating_mul(i.into())) } @@ -794,14 +854,16 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_087 nanoseconds. - Weight::from_ref_time(7_087_000) + // Minimum execution time: 1_619 nanoseconds. + Weight::from_ref_time(1_728_000) + .saturating_add(Weight::from_proof_size(0)) } fn noop() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_719 nanoseconds. - Weight::from_ref_time(2_719_000) + // Minimum execution time: 546 nanoseconds. + Weight::from_ref_time(640_000) + .saturating_add(Weight::from_proof_size(0)) } } diff --git a/frame/glutton/src/tests.rs b/frame/glutton/src/tests.rs index d2d2d4edec421..8d2c86ed45471 100644 --- a/frame/glutton/src/tests.rs +++ b/frame/glutton/src/tests.rs @@ -177,7 +177,7 @@ fn on_idle_weight_low_proof_is_close_enough_works() { let ratio = Perbill::from_rational(got.proof_size(), should.proof_size()); // Just a sanity check here. assert!( - ratio >= Perbill::from_percent(80), + ratio >= Perbill::from_percent(50), "Too few proof size consumed, was only {:?} of expected", ratio ); diff --git a/frame/glutton/src/weights.rs b/frame/glutton/src/weights.rs index 1e09d02c69d1c..9c8e161c825f2 100644 --- a/frame/glutton/src/weights.rs +++ b/frame/glutton/src/weights.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2023 Parity Technologies (UK) Ltd. +// Copyright (C) Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,9 +18,9 @@ //! Autogenerated weights for pallet_glutton //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-02-20, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-02-28, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `runner-ehxwxxsd-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: @@ -33,7 +33,7 @@ // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --json-file=/builds/parity/mirrors/substrate/.git/.artifacts/bench.json +// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/substrate/.git/.artifacts/bench.json // --pallet=pallet_glutton // --chain=dev // --header=./HEADER-APACHE2 @@ -71,12 +71,12 @@ impl WeightInfo for SubstrateWeight { fn initialize_pallet_grow(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `4` - // Estimated: `499` - // Minimum execution time: 9_248 nanoseconds. - Weight::from_ref_time(9_582_000) - .saturating_add(Weight::from_proof_size(499)) - // Standard Error: 1_144 - .saturating_add(Weight::from_ref_time(1_624_225).saturating_mul(n.into())) + // Estimated: `1489` + // Minimum execution time: 10_218 nanoseconds. + Weight::from_ref_time(10_510_000) + .saturating_add(Weight::from_proof_size(1489)) + // Standard Error: 1_582 + .saturating_add(Weight::from_ref_time(1_577_660).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(n.into()))) @@ -89,12 +89,12 @@ impl WeightInfo for SubstrateWeight { fn initialize_pallet_shrink(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `65` - // Estimated: `499` - // Minimum execution time: 10_210 nanoseconds. - Weight::from_ref_time(7_260_854) - .saturating_add(Weight::from_proof_size(499)) - // Standard Error: 1_459 - .saturating_add(Weight::from_ref_time(1_053_844).saturating_mul(n.into())) + // Estimated: `1489` + // Minimum execution time: 10_993 nanoseconds. + Weight::from_ref_time(11_208_000) + .saturating_add(Weight::from_proof_size(1489)) + // Standard Error: 1_386 + .saturating_add(Weight::from_ref_time(1_072_330).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(n.into()))) @@ -104,11 +104,11 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 605 nanoseconds. - Weight::from_ref_time(1_102_112) + // Minimum execution time: 740 nanoseconds. + Weight::from_ref_time(770_000) .saturating_add(Weight::from_proof_size(0)) - // Standard Error: 28 - .saturating_add(Weight::from_ref_time(120_597).saturating_mul(i.into())) + // Standard Error: 24 + .saturating_add(Weight::from_ref_time(96_434).saturating_mul(i.into())) } /// Storage: Glutton TrashData (r:5000 w:0) /// Proof: Glutton TrashData (max_values: Some(65000), max_size: Some(1036), added: 3016, mode: MaxEncodedLen) @@ -116,12 +116,12 @@ impl WeightInfo for SubstrateWeight { fn waste_proof_size_some(i: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `119036 + i * (1053 ±0)` - // Estimated: `0 + i * (3016 ±0)` - // Minimum execution time: 464 nanoseconds. - Weight::from_ref_time(552_000) - .saturating_add(Weight::from_proof_size(0)) - // Standard Error: 1_962 - .saturating_add(Weight::from_ref_time(5_780_304).saturating_mul(i.into())) + // Estimated: `990 + i * (3016 ±0)` + // Minimum execution time: 630 nanoseconds. + Weight::from_ref_time(712_000) + .saturating_add(Weight::from_proof_size(990)) + // Standard Error: 4_326 + .saturating_add(Weight::from_ref_time(5_500_880).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(i.into()))) .saturating_add(Weight::from_proof_size(3016).saturating_mul(i.into())) } @@ -129,31 +129,31 @@ impl WeightInfo for SubstrateWeight { /// Proof: Glutton Storage (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: Glutton Compute (r:1 w:0) /// Proof: Glutton Compute (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Glutton TrashData (r:1738 w:0) + /// Storage: Glutton TrashData (r:1737 w:0) /// Proof: Glutton TrashData (max_values: Some(65000), max_size: Some(1036), added: 3016, mode: MaxEncodedLen) fn on_idle_high_proof_waste() -> Weight { // Proof Size summary in bytes: - // Measured: `1955391` - // Estimated: `5242806` - // Minimum execution time: 55_398_405 nanoseconds. - Weight::from_ref_time(55_594_848_000) - .saturating_add(Weight::from_proof_size(5242806)) - .saturating_add(T::DbWeight::get().reads(1740_u64)) + // Measured: `1954313` + // Estimated: `5242760` + // Minimum execution time: 56_743_236 nanoseconds. + Weight::from_ref_time(57_088_040_000) + .saturating_add(Weight::from_proof_size(5242760)) + .saturating_add(T::DbWeight::get().reads(1739_u64)) } /// Storage: Glutton Storage (r:1 w:0) /// Proof: Glutton Storage (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: Glutton Compute (r:1 w:0) /// Proof: Glutton Compute (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Glutton TrashData (r:6 w:0) + /// Storage: Glutton TrashData (r:5 w:0) /// Proof: Glutton TrashData (max_values: Some(65000), max_size: Some(1036), added: 3016, mode: MaxEncodedLen) fn on_idle_low_proof_waste() -> Weight { // Proof Size summary in bytes: - // Measured: `11717` - // Estimated: `19094` - // Minimum execution time: 98_888_667 nanoseconds. - Weight::from_ref_time(99_157_239_000) - .saturating_add(Weight::from_proof_size(19094)) - .saturating_add(T::DbWeight::get().reads(8_u64)) + // Measured: `9671` + // Estimated: `19048` + // Minimum execution time: 100_387_042 nanoseconds. + Weight::from_ref_time(100_987_577_000) + .saturating_add(Weight::from_proof_size(19048)) + .saturating_add(T::DbWeight::get().reads(7_u64)) } /// Storage: Glutton Storage (r:1 w:0) /// Proof: Glutton Storage (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) @@ -162,10 +162,10 @@ impl WeightInfo for SubstrateWeight { fn empty_on_idle() -> Weight { // Proof Size summary in bytes: // Measured: `4` - // Estimated: `998` - // Minimum execution time: 3_967 nanoseconds. - Weight::from_ref_time(4_121_000) - .saturating_add(Weight::from_proof_size(998)) + // Estimated: `2978` + // Minimum execution time: 4_256 nanoseconds. + Weight::from_ref_time(4_447_000) + .saturating_add(Weight::from_proof_size(2978)) .saturating_add(T::DbWeight::get().reads(2_u64)) } /// Storage: Glutton Compute (r:0 w:1) @@ -174,8 +174,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_112 nanoseconds. - Weight::from_ref_time(7_484_000) + // Minimum execution time: 8_663 nanoseconds. + Weight::from_ref_time(8_864_000) .saturating_add(Weight::from_proof_size(0)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -185,8 +185,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_056 nanoseconds. - Weight::from_ref_time(7_414_000) + // Minimum execution time: 8_653 nanoseconds. + Weight::from_ref_time(8_998_000) .saturating_add(Weight::from_proof_size(0)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -202,12 +202,12 @@ impl WeightInfo for () { fn initialize_pallet_grow(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `4` - // Estimated: `499` - // Minimum execution time: 9_248 nanoseconds. - Weight::from_ref_time(9_582_000) - .saturating_add(Weight::from_proof_size(499)) - // Standard Error: 1_144 - .saturating_add(Weight::from_ref_time(1_624_225).saturating_mul(n.into())) + // Estimated: `1489` + // Minimum execution time: 10_218 nanoseconds. + Weight::from_ref_time(10_510_000) + .saturating_add(Weight::from_proof_size(1489)) + // Standard Error: 1_582 + .saturating_add(Weight::from_ref_time(1_577_660).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(n.into()))) @@ -220,12 +220,12 @@ impl WeightInfo for () { fn initialize_pallet_shrink(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `65` - // Estimated: `499` - // Minimum execution time: 10_210 nanoseconds. - Weight::from_ref_time(7_260_854) - .saturating_add(Weight::from_proof_size(499)) - // Standard Error: 1_459 - .saturating_add(Weight::from_ref_time(1_053_844).saturating_mul(n.into())) + // Estimated: `1489` + // Minimum execution time: 10_993 nanoseconds. + Weight::from_ref_time(11_208_000) + .saturating_add(Weight::from_proof_size(1489)) + // Standard Error: 1_386 + .saturating_add(Weight::from_ref_time(1_072_330).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(n.into()))) @@ -235,11 +235,11 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 605 nanoseconds. - Weight::from_ref_time(1_102_112) + // Minimum execution time: 740 nanoseconds. + Weight::from_ref_time(770_000) .saturating_add(Weight::from_proof_size(0)) - // Standard Error: 28 - .saturating_add(Weight::from_ref_time(120_597).saturating_mul(i.into())) + // Standard Error: 24 + .saturating_add(Weight::from_ref_time(96_434).saturating_mul(i.into())) } /// Storage: Glutton TrashData (r:5000 w:0) /// Proof: Glutton TrashData (max_values: Some(65000), max_size: Some(1036), added: 3016, mode: MaxEncodedLen) @@ -247,12 +247,12 @@ impl WeightInfo for () { fn waste_proof_size_some(i: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `119036 + i * (1053 ±0)` - // Estimated: `0 + i * (3016 ±0)` - // Minimum execution time: 464 nanoseconds. - Weight::from_ref_time(552_000) - .saturating_add(Weight::from_proof_size(0)) - // Standard Error: 1_962 - .saturating_add(Weight::from_ref_time(5_780_304).saturating_mul(i.into())) + // Estimated: `990 + i * (3016 ±0)` + // Minimum execution time: 630 nanoseconds. + Weight::from_ref_time(712_000) + .saturating_add(Weight::from_proof_size(990)) + // Standard Error: 4_326 + .saturating_add(Weight::from_ref_time(5_500_880).saturating_mul(i.into())) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(i.into()))) .saturating_add(Weight::from_proof_size(3016).saturating_mul(i.into())) } @@ -260,31 +260,31 @@ impl WeightInfo for () { /// Proof: Glutton Storage (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: Glutton Compute (r:1 w:0) /// Proof: Glutton Compute (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Glutton TrashData (r:1738 w:0) + /// Storage: Glutton TrashData (r:1737 w:0) /// Proof: Glutton TrashData (max_values: Some(65000), max_size: Some(1036), added: 3016, mode: MaxEncodedLen) fn on_idle_high_proof_waste() -> Weight { // Proof Size summary in bytes: - // Measured: `1955391` - // Estimated: `5242806` - // Minimum execution time: 55_398_405 nanoseconds. - Weight::from_ref_time(55_594_848_000) - .saturating_add(Weight::from_proof_size(5242806)) - .saturating_add(RocksDbWeight::get().reads(1740_u64)) + // Measured: `1954313` + // Estimated: `5242760` + // Minimum execution time: 56_743_236 nanoseconds. + Weight::from_ref_time(57_088_040_000) + .saturating_add(Weight::from_proof_size(5242760)) + .saturating_add(RocksDbWeight::get().reads(1739_u64)) } /// Storage: Glutton Storage (r:1 w:0) /// Proof: Glutton Storage (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: Glutton Compute (r:1 w:0) /// Proof: Glutton Compute (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Glutton TrashData (r:6 w:0) + /// Storage: Glutton TrashData (r:5 w:0) /// Proof: Glutton TrashData (max_values: Some(65000), max_size: Some(1036), added: 3016, mode: MaxEncodedLen) fn on_idle_low_proof_waste() -> Weight { // Proof Size summary in bytes: - // Measured: `11717` - // Estimated: `19094` - // Minimum execution time: 98_888_667 nanoseconds. - Weight::from_ref_time(99_157_239_000) - .saturating_add(Weight::from_proof_size(19094)) - .saturating_add(RocksDbWeight::get().reads(8_u64)) + // Measured: `9671` + // Estimated: `19048` + // Minimum execution time: 100_387_042 nanoseconds. + Weight::from_ref_time(100_987_577_000) + .saturating_add(Weight::from_proof_size(19048)) + .saturating_add(RocksDbWeight::get().reads(7_u64)) } /// Storage: Glutton Storage (r:1 w:0) /// Proof: Glutton Storage (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) @@ -293,10 +293,10 @@ impl WeightInfo for () { fn empty_on_idle() -> Weight { // Proof Size summary in bytes: // Measured: `4` - // Estimated: `998` - // Minimum execution time: 3_967 nanoseconds. - Weight::from_ref_time(4_121_000) - .saturating_add(Weight::from_proof_size(998)) + // Estimated: `2978` + // Minimum execution time: 4_256 nanoseconds. + Weight::from_ref_time(4_447_000) + .saturating_add(Weight::from_proof_size(2978)) .saturating_add(RocksDbWeight::get().reads(2_u64)) } /// Storage: Glutton Compute (r:0 w:1) @@ -305,8 +305,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_112 nanoseconds. - Weight::from_ref_time(7_484_000) + // Minimum execution time: 8_663 nanoseconds. + Weight::from_ref_time(8_864_000) .saturating_add(Weight::from_proof_size(0)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -316,8 +316,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_056 nanoseconds. - Weight::from_ref_time(7_414_000) + // Minimum execution time: 8_653 nanoseconds. + Weight::from_ref_time(8_998_000) .saturating_add(Weight::from_proof_size(0)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } diff --git a/frame/message-queue/src/weights.rs b/frame/message-queue/src/weights.rs index b48cf811a17ef..3421c2f2f59af 100644 --- a/frame/message-queue/src/weights.rs +++ b/frame/message-queue/src/weights.rs @@ -18,7 +18,7 @@ //! Autogenerated weights for pallet_message_queue //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-02-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-02-27, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 @@ -70,11 +70,11 @@ impl WeightInfo for SubstrateWeight { /// Proof: MessageQueue BookStateFor (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) fn ready_ring_knit() -> Weight { // Proof Size summary in bytes: - // Measured: `829` - // Estimated: `5547` - // Minimum execution time: 15_241 nanoseconds. - Weight::from_ref_time(15_603_000) - .saturating_add(Weight::from_proof_size(5547)) + // Measured: `295` + // Estimated: `7527` + // Minimum execution time: 12_538 nanoseconds. + Weight::from_ref_time(12_799_000) + .saturating_add(Weight::from_proof_size(7527)) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -84,11 +84,11 @@ impl WeightInfo for SubstrateWeight { /// Proof: MessageQueue ServiceHead (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn ready_ring_unknit() -> Weight { // Proof Size summary in bytes: - // Measured: `829` - // Estimated: `5547` - // Minimum execution time: 14_652 nanoseconds. - Weight::from_ref_time(14_983_000) - .saturating_add(Weight::from_proof_size(5547)) + // Measured: `295` + // Estimated: `7527` + // Minimum execution time: 11_727 nanoseconds. + Weight::from_ref_time(12_177_000) + .saturating_add(Weight::from_proof_size(7527)) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -96,11 +96,11 @@ impl WeightInfo for SubstrateWeight { /// Proof: MessageQueue BookStateFor (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) fn service_queue_base() -> Weight { // Proof Size summary in bytes: - // Measured: `576` - // Estimated: `2524` - // Minimum execution time: 5_750 nanoseconds. - Weight::from_ref_time(6_003_000) - .saturating_add(Weight::from_proof_size(2524)) + // Measured: `42` + // Estimated: `3514` + // Minimum execution time: 4_983 nanoseconds. + Weight::from_ref_time(5_174_000) + .saturating_add(Weight::from_proof_size(3514)) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -108,11 +108,11 @@ impl WeightInfo for SubstrateWeight { /// Proof: MessageQueue Pages (max_values: None, max_size: Some(65584), added: 68059, mode: MaxEncodedLen) fn service_page_base_completion() -> Weight { // Proof Size summary in bytes: - // Measured: `647` - // Estimated: `68059` - // Minimum execution time: 8_257 nanoseconds. - Weight::from_ref_time(8_506_000) - .saturating_add(Weight::from_proof_size(68059)) + // Measured: `113` + // Estimated: `69049` + // Minimum execution time: 6_299 nanoseconds. + Weight::from_ref_time(6_670_000) + .saturating_add(Weight::from_proof_size(69049)) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -120,20 +120,20 @@ impl WeightInfo for SubstrateWeight { /// Proof: MessageQueue Pages (max_values: None, max_size: Some(65584), added: 68059, mode: MaxEncodedLen) fn service_page_base_no_completion() -> Weight { // Proof Size summary in bytes: - // Measured: `647` - // Estimated: `68059` - // Minimum execution time: 8_422 nanoseconds. - Weight::from_ref_time(8_589_000) - .saturating_add(Weight::from_proof_size(68059)) + // Measured: `113` + // Estimated: `69049` + // Minimum execution time: 6_762 nanoseconds. + Weight::from_ref_time(7_059_000) + .saturating_add(Weight::from_proof_size(69049)) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } fn service_page_item() -> Weight { // Proof Size summary in bytes: - // Measured: `972` + // Measured: `0` // Estimated: `0` - // Minimum execution time: 81_929 nanoseconds. - Weight::from_ref_time(82_375_000) + // Minimum execution time: 72_681 nanoseconds. + Weight::from_ref_time(73_147_000) .saturating_add(Weight::from_proof_size(0)) } /// Storage: MessageQueue ServiceHead (r:1 w:1) @@ -142,11 +142,11 @@ impl WeightInfo for SubstrateWeight { /// Proof: MessageQueue BookStateFor (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) fn bump_service_head() -> Weight { // Proof Size summary in bytes: - // Measured: `706` - // Estimated: `3023` - // Minimum execution time: 8_992 nanoseconds. - Weight::from_ref_time(9_200_000) - .saturating_add(Weight::from_proof_size(3023)) + // Measured: `172` + // Estimated: `5003` + // Minimum execution time: 7_066 nanoseconds. + Weight::from_ref_time(7_214_000) + .saturating_add(Weight::from_proof_size(5003)) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -156,11 +156,11 @@ impl WeightInfo for SubstrateWeight { /// Proof: MessageQueue Pages (max_values: None, max_size: Some(65584), added: 68059, mode: MaxEncodedLen) fn reap_page() -> Weight { // Proof Size summary in bytes: - // Measured: `66825` - // Estimated: `70583` - // Minimum execution time: 68_292 nanoseconds. - Weight::from_ref_time(69_108_000) - .saturating_add(Weight::from_proof_size(70583)) + // Measured: `65742` + // Estimated: `72563` + // Minimum execution time: 57_778 nanoseconds. + Weight::from_ref_time(58_778_000) + .saturating_add(Weight::from_proof_size(72563)) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -170,11 +170,11 @@ impl WeightInfo for SubstrateWeight { /// Proof: MessageQueue Pages (max_values: None, max_size: Some(65584), added: 68059, mode: MaxEncodedLen) fn execute_overweight_page_removed() -> Weight { // Proof Size summary in bytes: - // Measured: `66825` - // Estimated: `70583` - // Minimum execution time: 83_855 nanoseconds. - Weight::from_ref_time(84_946_000) - .saturating_add(Weight::from_proof_size(70583)) + // Measured: `65742` + // Estimated: `72563` + // Minimum execution time: 72_144 nanoseconds. + Weight::from_ref_time(72_942_000) + .saturating_add(Weight::from_proof_size(72563)) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -184,11 +184,11 @@ impl WeightInfo for SubstrateWeight { /// Proof: MessageQueue Pages (max_values: None, max_size: Some(65584), added: 68059, mode: MaxEncodedLen) fn execute_overweight_page_updated() -> Weight { // Proof Size summary in bytes: - // Measured: `66825` - // Estimated: `70583` - // Minimum execution time: 96_997 nanoseconds. - Weight::from_ref_time(98_668_000) - .saturating_add(Weight::from_proof_size(70583)) + // Measured: `65742` + // Estimated: `72563` + // Minimum execution time: 84_890 nanoseconds. + Weight::from_ref_time(86_073_000) + .saturating_add(Weight::from_proof_size(72563)) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -202,11 +202,11 @@ impl WeightInfo for () { /// Proof: MessageQueue BookStateFor (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) fn ready_ring_knit() -> Weight { // Proof Size summary in bytes: - // Measured: `829` - // Estimated: `5547` - // Minimum execution time: 15_241 nanoseconds. - Weight::from_ref_time(15_603_000) - .saturating_add(Weight::from_proof_size(5547)) + // Measured: `295` + // Estimated: `7527` + // Minimum execution time: 12_538 nanoseconds. + Weight::from_ref_time(12_799_000) + .saturating_add(Weight::from_proof_size(7527)) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -216,11 +216,11 @@ impl WeightInfo for () { /// Proof: MessageQueue ServiceHead (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn ready_ring_unknit() -> Weight { // Proof Size summary in bytes: - // Measured: `829` - // Estimated: `5547` - // Minimum execution time: 14_652 nanoseconds. - Weight::from_ref_time(14_983_000) - .saturating_add(Weight::from_proof_size(5547)) + // Measured: `295` + // Estimated: `7527` + // Minimum execution time: 11_727 nanoseconds. + Weight::from_ref_time(12_177_000) + .saturating_add(Weight::from_proof_size(7527)) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -228,11 +228,11 @@ impl WeightInfo for () { /// Proof: MessageQueue BookStateFor (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) fn service_queue_base() -> Weight { // Proof Size summary in bytes: - // Measured: `576` - // Estimated: `2524` - // Minimum execution time: 5_750 nanoseconds. - Weight::from_ref_time(6_003_000) - .saturating_add(Weight::from_proof_size(2524)) + // Measured: `42` + // Estimated: `3514` + // Minimum execution time: 4_983 nanoseconds. + Weight::from_ref_time(5_174_000) + .saturating_add(Weight::from_proof_size(3514)) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -240,11 +240,11 @@ impl WeightInfo for () { /// Proof: MessageQueue Pages (max_values: None, max_size: Some(65584), added: 68059, mode: MaxEncodedLen) fn service_page_base_completion() -> Weight { // Proof Size summary in bytes: - // Measured: `647` - // Estimated: `68059` - // Minimum execution time: 8_257 nanoseconds. - Weight::from_ref_time(8_506_000) - .saturating_add(Weight::from_proof_size(68059)) + // Measured: `113` + // Estimated: `69049` + // Minimum execution time: 6_299 nanoseconds. + Weight::from_ref_time(6_670_000) + .saturating_add(Weight::from_proof_size(69049)) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -252,20 +252,20 @@ impl WeightInfo for () { /// Proof: MessageQueue Pages (max_values: None, max_size: Some(65584), added: 68059, mode: MaxEncodedLen) fn service_page_base_no_completion() -> Weight { // Proof Size summary in bytes: - // Measured: `647` - // Estimated: `68059` - // Minimum execution time: 8_422 nanoseconds. - Weight::from_ref_time(8_589_000) - .saturating_add(Weight::from_proof_size(68059)) + // Measured: `113` + // Estimated: `69049` + // Minimum execution time: 6_762 nanoseconds. + Weight::from_ref_time(7_059_000) + .saturating_add(Weight::from_proof_size(69049)) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } fn service_page_item() -> Weight { // Proof Size summary in bytes: - // Measured: `972` + // Measured: `0` // Estimated: `0` - // Minimum execution time: 81_929 nanoseconds. - Weight::from_ref_time(82_375_000) + // Minimum execution time: 72_681 nanoseconds. + Weight::from_ref_time(73_147_000) .saturating_add(Weight::from_proof_size(0)) } /// Storage: MessageQueue ServiceHead (r:1 w:1) @@ -274,11 +274,11 @@ impl WeightInfo for () { /// Proof: MessageQueue BookStateFor (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen) fn bump_service_head() -> Weight { // Proof Size summary in bytes: - // Measured: `706` - // Estimated: `3023` - // Minimum execution time: 8_992 nanoseconds. - Weight::from_ref_time(9_200_000) - .saturating_add(Weight::from_proof_size(3023)) + // Measured: `172` + // Estimated: `5003` + // Minimum execution time: 7_066 nanoseconds. + Weight::from_ref_time(7_214_000) + .saturating_add(Weight::from_proof_size(5003)) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -288,11 +288,11 @@ impl WeightInfo for () { /// Proof: MessageQueue Pages (max_values: None, max_size: Some(65584), added: 68059, mode: MaxEncodedLen) fn reap_page() -> Weight { // Proof Size summary in bytes: - // Measured: `66825` - // Estimated: `70583` - // Minimum execution time: 68_292 nanoseconds. - Weight::from_ref_time(69_108_000) - .saturating_add(Weight::from_proof_size(70583)) + // Measured: `65742` + // Estimated: `72563` + // Minimum execution time: 57_778 nanoseconds. + Weight::from_ref_time(58_778_000) + .saturating_add(Weight::from_proof_size(72563)) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -302,11 +302,11 @@ impl WeightInfo for () { /// Proof: MessageQueue Pages (max_values: None, max_size: Some(65584), added: 68059, mode: MaxEncodedLen) fn execute_overweight_page_removed() -> Weight { // Proof Size summary in bytes: - // Measured: `66825` - // Estimated: `70583` - // Minimum execution time: 83_855 nanoseconds. - Weight::from_ref_time(84_946_000) - .saturating_add(Weight::from_proof_size(70583)) + // Measured: `65742` + // Estimated: `72563` + // Minimum execution time: 72_144 nanoseconds. + Weight::from_ref_time(72_942_000) + .saturating_add(Weight::from_proof_size(72563)) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -316,11 +316,11 @@ impl WeightInfo for () { /// Proof: MessageQueue Pages (max_values: None, max_size: Some(65584), added: 68059, mode: MaxEncodedLen) fn execute_overweight_page_updated() -> Weight { // Proof Size summary in bytes: - // Measured: `66825` - // Estimated: `70583` - // Minimum execution time: 96_997 nanoseconds. - Weight::from_ref_time(98_668_000) - .saturating_add(Weight::from_proof_size(70583)) + // Measured: `65742` + // Estimated: `72563` + // Minimum execution time: 84_890 nanoseconds. + Weight::from_ref_time(86_073_000) + .saturating_add(Weight::from_proof_size(72563)) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } diff --git a/frame/support/procedural/src/benchmark.rs b/frame/support/procedural/src/benchmark.rs index 1aca2f87b1d1d..4f9994b6cd073 100644 --- a/frame/support/procedural/src/benchmark.rs +++ b/frame/support/procedural/src/benchmark.rs @@ -567,7 +567,12 @@ pub fn benchmarks( #support::storage::transactional::TRANSACTION_LEVEL_KEY.into(), ); whitelist.push(transactional_layer_key); - #krate::benchmarking::set_whitelist(whitelist); + // Whitelist the `:extrinsic_index`. + let extrinsic_index = #krate::TrackedStorageKey::new( + #krate::well_known_keys::EXTRINSIC_INDEX.into() + ); + whitelist.push(extrinsic_index); + #krate::benchmarking::set_whitelist(whitelist.clone()); let mut results: #krate::Vec<#krate::BenchmarkResult> = #krate::Vec::new(); // Always do at least one internal repeat... @@ -590,6 +595,12 @@ pub fn benchmarks( // This will enable worst case scenario for reading from the database. #krate::benchmarking::commit_db(); + // Access all whitelisted keys to get them into the proof recorder since the + // recorder does now have a whitelist. + for key in &whitelist { + #krate::frame_support::storage::unhashed::get_raw(&key.key); + } + // Reset the read/write counter so we don't count operations in the setup process. #krate::benchmarking::reset_read_write_count(); diff --git a/utils/frame/benchmarking-cli/src/pallet/mod.rs b/utils/frame/benchmarking-cli/src/pallet/mod.rs index 9ae9846745918..f214569051d45 100644 --- a/utils/frame/benchmarking-cli/src/pallet/mod.rs +++ b/utils/frame/benchmarking-cli/src/pallet/mod.rs @@ -187,7 +187,7 @@ pub struct PalletCmd { /// Each layer will result in an additional 495 bytes PoV per distinct top-level access. /// Therefore multiple `StorageMap` accesses only suffer from this increase once. The exact /// number of storage items depends on the runtime and the deployed pallets. - #[clap(long, default_value = "0")] + #[clap(long, default_value = "2")] pub additional_trie_layers: u8, /// A path to a `.json` file with existing benchmark results generated with `--json` or From 1c20979a4a732abb4aa340edd113751947e65c4c Mon Sep 17 00:00:00 2001 From: Davide Galassi Date: Tue, 28 Feb 2023 15:56:22 +0100 Subject: [PATCH 30/80] Move BEEFY code to consensus (#13484) * Move beefy primitives to consensus dir * Move beefy gadget to client consensus folder * Rename beefy crates --- Cargo.lock | 174 +++++++++--------- Cargo.toml | 6 +- client/beefy/Cargo.toml | 49 ----- client/consensus/beefy/Cargo.toml | 49 +++++ client/{ => consensus}/beefy/README.md | 0 client/{ => consensus}/beefy/rpc/Cargo.toml | 18 +- client/{ => consensus}/beefy/rpc/src/lib.rs | 12 +- .../beefy/rpc/src/notification.rs | 4 +- .../{ => consensus}/beefy/src/aux_schema.rs | 0 .../beefy/src/communication/gossip.rs | 4 +- .../beefy/src/communication/mod.rs | 0 .../beefy/src/communication/notification.rs | 0 .../beefy/src/communication/peers.rs | 0 .../incoming_requests_handler.rs | 2 +- .../src/communication/request_response/mod.rs | 0 .../outgoing_requests_engine.rs | 2 +- client/{ => consensus}/beefy/src/error.rs | 0 client/{ => consensus}/beefy/src/import.rs | 2 +- .../beefy/src/justification.rs | 10 +- client/{ => consensus}/beefy/src/keystore.rs | 8 +- client/{ => consensus}/beefy/src/lib.rs | 8 +- client/{ => consensus}/beefy/src/metrics.rs | 0 client/{ => consensus}/beefy/src/round.rs | 8 +- client/{ => consensus}/beefy/src/tests.rs | 18 +- client/{ => consensus}/beefy/src/worker.rs | 20 +- client/merkle-mountain-range/Cargo.toml | 4 +- client/merkle-mountain-range/src/lib.rs | 2 +- .../merkle-mountain-range/src/offchain_mmr.rs | 2 +- frame/beefy-mmr/Cargo.toml | 4 +- frame/beefy-mmr/src/lib.rs | 18 +- frame/beefy-mmr/src/mock.rs | 6 +- frame/beefy-mmr/src/tests.rs | 4 +- frame/beefy/Cargo.toml | 4 +- frame/beefy/src/equivocation.rs | 4 +- frame/beefy/src/lib.rs | 12 +- frame/beefy/src/mock.rs | 2 +- frame/beefy/src/tests.rs | 20 +- primitives/{ => consensus}/beefy/Cargo.toml | 18 +- .../{ => consensus}/beefy/src/commitment.rs | 0 primitives/{ => consensus}/beefy/src/lib.rs | 0 primitives/{ => consensus}/beefy/src/mmr.rs | 0 .../{ => consensus}/beefy/src/payload.rs | 0 .../{ => consensus}/beefy/src/test_utils.rs | 0 .../{ => consensus}/beefy/src/witness.rs | 0 .../beefy/test-res/large-raw-commitment | Bin test-utils/runtime/Cargo.toml | 4 +- test-utils/runtime/src/lib.rs | 24 +-- 47 files changed, 260 insertions(+), 262 deletions(-) delete mode 100644 client/beefy/Cargo.toml create mode 100644 client/consensus/beefy/Cargo.toml rename client/{ => consensus}/beefy/README.md (100%) rename client/{ => consensus}/beefy/rpc/Cargo.toml (60%) rename client/{ => consensus}/beefy/rpc/src/lib.rs (97%) rename client/{ => consensus}/beefy/rpc/src/notification.rs (90%) rename client/{ => consensus}/beefy/src/aux_schema.rs (100%) rename client/{ => consensus}/beefy/src/communication/gossip.rs (99%) rename client/{ => consensus}/beefy/src/communication/mod.rs (100%) rename client/{ => consensus}/beefy/src/communication/notification.rs (100%) rename client/{ => consensus}/beefy/src/communication/peers.rs (100%) rename client/{ => consensus}/beefy/src/communication/request_response/incoming_requests_handler.rs (99%) rename client/{ => consensus}/beefy/src/communication/request_response/mod.rs (100%) rename client/{ => consensus}/beefy/src/communication/request_response/outgoing_requests_engine.rs (99%) rename client/{ => consensus}/beefy/src/error.rs (100%) rename client/{ => consensus}/beefy/src/import.rs (99%) rename client/{ => consensus}/beefy/src/justification.rs (98%) rename client/{ => consensus}/beefy/src/keystore.rs (97%) rename client/{ => consensus}/beefy/src/lib.rs (99%) rename client/{ => consensus}/beefy/src/metrics.rs (100%) rename client/{ => consensus}/beefy/src/round.rs (99%) rename client/{ => consensus}/beefy/src/tests.rs (99%) rename client/{ => consensus}/beefy/src/worker.rs (99%) rename primitives/{ => consensus}/beefy/Cargo.toml (84%) rename primitives/{ => consensus}/beefy/src/commitment.rs (100%) rename primitives/{ => consensus}/beefy/src/lib.rs (100%) rename primitives/{ => consensus}/beefy/src/mmr.rs (100%) rename primitives/{ => consensus}/beefy/src/payload.rs (100%) rename primitives/{ => consensus}/beefy/src/test_utils.rs (100%) rename primitives/{ => consensus}/beefy/src/witness.rs (100%) rename primitives/{ => consensus}/beefy/test-res/large-raw-commitment (100%) diff --git a/Cargo.lock b/Cargo.lock index 2b57985f823a8..49ef979f1ae60 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -515,69 +515,6 @@ dependencies = [ "serde", ] -[[package]] -name = "beefy-gadget" -version = "4.0.0-dev" -dependencies = [ - "array-bytes", - "async-trait", - "fnv", - "futures", - "log", - "parity-scale-codec", - "parking_lot 0.12.1", - "sc-block-builder", - "sc-client-api", - "sc-consensus", - "sc-keystore", - "sc-network", - "sc-network-common", - "sc-network-gossip", - "sc-network-test", - "sc-utils", - "serde", - "sp-api", - "sp-application-crypto", - "sp-arithmetic", - "sp-beefy", - "sp-blockchain", - "sp-consensus", - "sp-consensus-grandpa", - "sp-core", - "sp-keyring", - "sp-keystore", - "sp-mmr-primitives", - "sp-runtime", - "sp-tracing", - "substrate-prometheus-endpoint", - "substrate-test-runtime-client", - "tempfile", - "thiserror", - "tokio", - "wasm-timer", -] - -[[package]] -name = "beefy-gadget-rpc" -version = "4.0.0-dev" -dependencies = [ - "beefy-gadget", - "futures", - "jsonrpsee", - "log", - "parity-scale-codec", - "parking_lot 0.12.1", - "sc-rpc", - "serde", - "serde_json", - "sp-beefy", - "sp-core", - "sp-runtime", - "substrate-test-runtime-client", - "thiserror", - "tokio", -] - [[package]] name = "binary-merkle-tree" version = "4.0.0-dev" @@ -4560,9 +4497,9 @@ dependencies = [ "sc-client-api", "sc-offchain", "sp-api", - "sp-beefy", "sp-blockchain", "sp-consensus", + "sp-consensus-beefy", "sp-core", "sp-mmr-primitives", "sp-runtime", @@ -5654,7 +5591,7 @@ dependencies = [ "parity-scale-codec", "scale-info", "serde", - "sp-beefy", + "sp-consensus-beefy", "sp-core", "sp-io", "sp-runtime", @@ -5679,7 +5616,7 @@ dependencies = [ "scale-info", "serde", "sp-api", - "sp-beefy", + "sp-consensus-beefy", "sp-core", "sp-io", "sp-runtime", @@ -8423,6 +8360,69 @@ dependencies = [ "tokio", ] +[[package]] +name = "sc-consensus-beefy" +version = "4.0.0-dev" +dependencies = [ + "array-bytes", + "async-trait", + "fnv", + "futures", + "log", + "parity-scale-codec", + "parking_lot 0.12.1", + "sc-block-builder", + "sc-client-api", + "sc-consensus", + "sc-keystore", + "sc-network", + "sc-network-common", + "sc-network-gossip", + "sc-network-test", + "sc-utils", + "serde", + "sp-api", + "sp-application-crypto", + "sp-arithmetic", + "sp-blockchain", + "sp-consensus", + "sp-consensus-beefy", + "sp-consensus-grandpa", + "sp-core", + "sp-keyring", + "sp-keystore", + "sp-mmr-primitives", + "sp-runtime", + "sp-tracing", + "substrate-prometheus-endpoint", + "substrate-test-runtime-client", + "tempfile", + "thiserror", + "tokio", + "wasm-timer", +] + +[[package]] +name = "sc-consensus-beefy-rpc" +version = "4.0.0-dev" +dependencies = [ + "futures", + "jsonrpsee", + "log", + "parity-scale-codec", + "parking_lot 0.12.1", + "sc-consensus-beefy", + "sc-rpc", + "serde", + "serde_json", + "sp-consensus-beefy", + "sp-core", + "sp-runtime", + "substrate-test-runtime-client", + "thiserror", + "tokio", +] + [[package]] name = "sc-consensus-epochs" version = "0.10.0-dev" @@ -9930,26 +9930,6 @@ dependencies = [ "sp-std", ] -[[package]] -name = "sp-beefy" -version = "4.0.0-dev" -dependencies = [ - "array-bytes", - "lazy_static", - "parity-scale-codec", - "scale-info", - "serde", - "sp-api", - "sp-application-crypto", - "sp-core", - "sp-io", - "sp-keystore", - "sp-mmr-primitives", - "sp-runtime", - "sp-std", - "strum", -] - [[package]] name = "sp-block-builder" version = "4.0.0-dev" @@ -10035,6 +10015,26 @@ dependencies = [ "sp-timestamp", ] +[[package]] +name = "sp-consensus-beefy" +version = "4.0.0-dev" +dependencies = [ + "array-bytes", + "lazy_static", + "parity-scale-codec", + "scale-info", + "serde", + "sp-api", + "sp-application-crypto", + "sp-core", + "sp-io", + "sp-keystore", + "sp-mmr-primitives", + "sp-runtime", + "sp-std", + "strum", +] + [[package]] name = "sp-consensus-grandpa" version = "4.0.0-dev" @@ -10938,11 +10938,11 @@ dependencies = [ "serde", "sp-api", "sp-application-crypto", - "sp-beefy", "sp-block-builder", "sp-consensus", "sp-consensus-aura", "sp-consensus-babe", + "sp-consensus-beefy", "sp-consensus-grandpa", "sp-core", "sp-externalities", diff --git a/Cargo.toml b/Cargo.toml index 88c9c1998f415..af2d8f9066fa1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,8 +18,6 @@ members = [ "client/api", "client/authority-discovery", "client/basic-authorship", - "client/beefy", - "client/beefy/rpc", "client/block-builder", "client/chain-spec", "client/chain-spec/derive", @@ -27,6 +25,8 @@ members = [ "client/consensus/aura", "client/consensus/babe", "client/consensus/babe/rpc", + "client/consensus/beefy", + "client/consensus/beefy/rpc", "client/consensus/common", "client/consensus/epochs", "client/consensus/grandpa", @@ -178,11 +178,11 @@ members = [ "primitives/arithmetic", "primitives/arithmetic/fuzzer", "primitives/authority-discovery", - "primitives/beefy", "primitives/block-builder", "primitives/blockchain", "primitives/consensus/aura", "primitives/consensus/babe", + "primitives/consensus/beefy", "primitives/consensus/common", "primitives/consensus/grandpa", "primitives/consensus/pow", diff --git a/client/beefy/Cargo.toml b/client/beefy/Cargo.toml deleted file mode 100644 index eb616823680aa..0000000000000 --- a/client/beefy/Cargo.toml +++ /dev/null @@ -1,49 +0,0 @@ -[package] -name = "beefy-gadget" -version = "4.0.0-dev" -authors = ["Parity Technologies "] -edition = "2021" -license = "GPL-3.0-or-later WITH Classpath-exception-2.0" -repository = "https://github.com/paritytech/substrate" -description = "BEEFY Client gadget for substrate" -homepage = "https://substrate.io" - -[dependencies] -array-bytes = "4.1" -async-trait = "0.1.57" -codec = { package = "parity-scale-codec", version = "3.2.2", features = ["derive"] } -fnv = "1.0.6" -futures = "0.3" -log = "0.4" -parking_lot = "0.12.1" -thiserror = "1.0" -wasm-timer = "0.2.5" -beefy-primitives = { version = "4.0.0-dev", path = "../../primitives/beefy", package = "sp-beefy" } -prometheus = { package = "substrate-prometheus-endpoint", version = "0.10.0-dev", path = "../../utils/prometheus" } -sc-client-api = { version = "4.0.0-dev", path = "../api" } -sc-consensus = { version = "0.10.0-dev", path = "../consensus/common" } -sc-keystore = { version = "4.0.0-dev", path = "../keystore" } -sc-network = { version = "0.10.0-dev", path = "../network" } -sc-network-common = { version = "0.10.0-dev", path = "../network/common" } -sc-network-gossip = { version = "0.10.0-dev", path = "../network-gossip" } -sc-utils = { version = "4.0.0-dev", path = "../utils" } -sp-api = { version = "4.0.0-dev", path = "../../primitives/api" } -sp-application-crypto = { version = "7.0.0", path = "../../primitives/application-crypto" } -sp-arithmetic = { version = "6.0.0", path = "../../primitives/arithmetic" } -sp-blockchain = { version = "4.0.0-dev", path = "../../primitives/blockchain" } -sp-consensus = { version = "0.10.0-dev", path = "../../primitives/consensus/common" } -sp-core = { version = "7.0.0", path = "../../primitives/core" } -sp-keystore = { version = "0.13.0", path = "../../primitives/keystore" } -sp-mmr-primitives = { version = "4.0.0-dev", path = "../../primitives/merkle-mountain-range" } -sp-runtime = { version = "7.0.0", path = "../../primitives/runtime" } - -[dev-dependencies] -serde = "1.0.136" -tempfile = "3.1.0" -tokio = "1.22.0" -sc-block-builder = { version = "0.10.0-dev", path = "../block-builder" } -sc-network-test = { version = "0.8.0", path = "../network/test" } -sp-consensus-grandpa = { version = "4.0.0-dev", path = "../../primitives/consensus/grandpa" } -sp-keyring = { version = "7.0.0", path = "../../primitives/keyring" } -sp-tracing = { version = "6.0.0", path = "../../primitives/tracing" } -substrate-test-runtime-client = { version = "2.0.0", path = "../../test-utils/runtime/client" } diff --git a/client/consensus/beefy/Cargo.toml b/client/consensus/beefy/Cargo.toml new file mode 100644 index 0000000000000..d88c07df2612f --- /dev/null +++ b/client/consensus/beefy/Cargo.toml @@ -0,0 +1,49 @@ +[package] +name = "sc-consensus-beefy" +version = "4.0.0-dev" +authors = ["Parity Technologies "] +edition = "2021" +license = "GPL-3.0-or-later WITH Classpath-exception-2.0" +repository = "https://github.com/paritytech/substrate" +description = "BEEFY Client gadget for substrate" +homepage = "https://substrate.io" + +[dependencies] +array-bytes = "4.1" +async-trait = "0.1.57" +codec = { package = "parity-scale-codec", version = "3.2.2", features = ["derive"] } +fnv = "1.0.6" +futures = "0.3" +log = "0.4" +parking_lot = "0.12.1" +thiserror = "1.0" +wasm-timer = "0.2.5" +prometheus = { package = "substrate-prometheus-endpoint", version = "0.10.0-dev", path = "../../../utils/prometheus" } +sc-client-api = { version = "4.0.0-dev", path = "../../api" } +sc-consensus = { version = "0.10.0-dev", path = "../../consensus/common" } +sc-keystore = { version = "4.0.0-dev", path = "../../keystore" } +sc-network = { version = "0.10.0-dev", path = "../../network" } +sc-network-common = { version = "0.10.0-dev", path = "../../network/common" } +sc-network-gossip = { version = "0.10.0-dev", path = "../../network-gossip" } +sc-utils = { version = "4.0.0-dev", path = "../../utils" } +sp-api = { version = "4.0.0-dev", path = "../../../primitives/api" } +sp-application-crypto = { version = "7.0.0", path = "../../../primitives/application-crypto" } +sp-arithmetic = { version = "6.0.0", path = "../../../primitives/arithmetic" } +sp-blockchain = { version = "4.0.0-dev", path = "../../../primitives/blockchain" } +sp-consensus = { version = "0.10.0-dev", path = "../../../primitives/consensus/common" } +sp-consensus-beefy = { version = "4.0.0-dev", path = "../../../primitives/consensus/beefy" } +sp-core = { version = "7.0.0", path = "../../../primitives/core" } +sp-keystore = { version = "0.13.0", path = "../../../primitives/keystore" } +sp-mmr-primitives = { version = "4.0.0-dev", path = "../../../primitives/merkle-mountain-range" } +sp-runtime = { version = "7.0.0", path = "../../../primitives/runtime" } + +[dev-dependencies] +serde = "1.0.136" +tempfile = "3.1.0" +tokio = "1.22.0" +sc-block-builder = { version = "0.10.0-dev", path = "../../block-builder" } +sc-network-test = { version = "0.8.0", path = "../../network/test" } +sp-consensus-grandpa = { version = "4.0.0-dev", path = "../../../primitives/consensus/grandpa" } +sp-keyring = { version = "7.0.0", path = "../../../primitives/keyring" } +sp-tracing = { version = "6.0.0", path = "../../../primitives/tracing" } +substrate-test-runtime-client = { version = "2.0.0", path = "../../../test-utils/runtime/client" } diff --git a/client/beefy/README.md b/client/consensus/beefy/README.md similarity index 100% rename from client/beefy/README.md rename to client/consensus/beefy/README.md diff --git a/client/beefy/rpc/Cargo.toml b/client/consensus/beefy/rpc/Cargo.toml similarity index 60% rename from client/beefy/rpc/Cargo.toml rename to client/consensus/beefy/rpc/Cargo.toml index ab3e6921f3cfe..d6dfa8731a3be 100644 --- a/client/beefy/rpc/Cargo.toml +++ b/client/consensus/beefy/rpc/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "beefy-gadget-rpc" +name = "sc-consensus-beefy-rpc" version = "4.0.0-dev" authors = ["Parity Technologies "] edition = "2021" @@ -16,16 +16,14 @@ log = "0.4" parking_lot = "0.12.1" serde = { version = "1.0.136", features = ["derive"] } thiserror = "1.0" -beefy-gadget = { version = "4.0.0-dev", path = "../." } -beefy-primitives = { version = "4.0.0-dev", path = "../../../primitives/beefy", package = "sp-beefy" } -sc-rpc = { version = "4.0.0-dev", path = "../../rpc" } -sp-core = { version = "7.0.0", path = "../../../primitives/core" } -sp-runtime = { version = "7.0.0", path = "../../../primitives/runtime" } +sc-consensus-beefy = { version = "4.0.0-dev", path = "../" } +sp-consensus-beefy = { version = "4.0.0-dev", path = "../../../../primitives/consensus/beefy" } +sc-rpc = { version = "4.0.0-dev", path = "../../../rpc" } +sp-core = { version = "7.0.0", path = "../../../../primitives/core" } +sp-runtime = { version = "7.0.0", path = "../../../../primitives/runtime" } [dev-dependencies] serde_json = "1.0.85" -sc-rpc = { version = "4.0.0-dev", features = [ - "test-helpers", -], path = "../../rpc" } -substrate-test-runtime-client = { version = "2.0.0", path = "../../../test-utils/runtime/client" } +sc-rpc = { version = "4.0.0-dev", features = ["test-helpers"], path = "../../../rpc" } +substrate-test-runtime-client = { version = "2.0.0", path = "../../../../test-utils/runtime/client" } tokio = { version = "1.22.0", features = ["macros"] } diff --git a/client/beefy/rpc/src/lib.rs b/client/consensus/beefy/rpc/src/lib.rs similarity index 97% rename from client/beefy/rpc/src/lib.rs rename to client/consensus/beefy/rpc/src/lib.rs index 0a7a4de14cbcc..f5c0ff32627d5 100644 --- a/client/beefy/rpc/src/lib.rs +++ b/client/consensus/beefy/rpc/src/lib.rs @@ -35,7 +35,7 @@ use jsonrpsee::{ }; use log::warn; -use beefy_gadget::communication::notification::{ +use sc_consensus_beefy::communication::notification::{ BeefyBestBlockStream, BeefyVersionedFinalityProofStream, }; @@ -166,13 +166,13 @@ where mod tests { use super::*; - use beefy_gadget::{ + use codec::{Decode, Encode}; + use jsonrpsee::{types::EmptyServerParams as EmptyParams, RpcModule}; + use sc_consensus_beefy::{ communication::notification::BeefyVersionedFinalityProofSender, justification::BeefyVersionedFinalityProof, }; - use beefy_primitives::{known_payloads, Payload, SignedCommitment}; - use codec::{Decode, Encode}; - use jsonrpsee::{types::EmptyServerParams as EmptyParams, RpcModule}; + use sp_consensus_beefy::{known_payloads, Payload, SignedCommitment}; use sp_runtime::traits::{BlakeTwo256, Hash}; use substrate_test_runtime_client::runtime::Block; @@ -269,7 +269,7 @@ mod tests { let payload = Payload::from_single_entry(known_payloads::MMR_ROOT_ID, "Hello World!".encode()); BeefyVersionedFinalityProof::::V1(SignedCommitment { - commitment: beefy_primitives::Commitment { + commitment: sp_consensus_beefy::Commitment { payload, block_number: 5, validator_set_id: 0, diff --git a/client/beefy/rpc/src/notification.rs b/client/consensus/beefy/rpc/src/notification.rs similarity index 90% rename from client/beefy/rpc/src/notification.rs rename to client/consensus/beefy/rpc/src/notification.rs index 286385187c342..690c511b999ac 100644 --- a/client/beefy/rpc/src/notification.rs +++ b/client/consensus/beefy/rpc/src/notification.rs @@ -23,13 +23,13 @@ use sp_runtime::traits::Block as BlockT; /// An encoded finality proof proving that the given header has been finalized. /// The given bytes should be the SCALE-encoded representation of a -/// `beefy_primitives::VersionedFinalityProof`. +/// `sp_consensus_beefy::VersionedFinalityProof`. #[derive(Clone, Serialize, Deserialize)] pub struct EncodedVersionedFinalityProof(sp_core::Bytes); impl EncodedVersionedFinalityProof { pub fn new( - finality_proof: beefy_gadget::justification::BeefyVersionedFinalityProof, + finality_proof: sc_consensus_beefy::justification::BeefyVersionedFinalityProof, ) -> Self where Block: BlockT, diff --git a/client/beefy/src/aux_schema.rs b/client/consensus/beefy/src/aux_schema.rs similarity index 100% rename from client/beefy/src/aux_schema.rs rename to client/consensus/beefy/src/aux_schema.rs diff --git a/client/beefy/src/communication/gossip.rs b/client/consensus/beefy/src/communication/gossip.rs similarity index 99% rename from client/beefy/src/communication/gossip.rs rename to client/consensus/beefy/src/communication/gossip.rs index a1fb6fa26e5d4..219203ee4e173 100644 --- a/client/beefy/src/communication/gossip.rs +++ b/client/consensus/beefy/src/communication/gossip.rs @@ -29,7 +29,7 @@ use parking_lot::{Mutex, RwLock}; use wasm_timer::Instant; use crate::{communication::peers::KnownPeers, keystore::BeefyKeystore, LOG_TARGET}; -use beefy_primitives::{ +use sp_consensus_beefy::{ crypto::{Public, Signature}, VoteMessage, }; @@ -243,7 +243,7 @@ mod tests { use sp_keystore::{SyncCryptoStore, SyncCryptoStorePtr}; use crate::keystore::BeefyKeystore; - use beefy_primitives::{ + use sp_consensus_beefy::{ crypto::Signature, known_payloads, Commitment, Keyring, MmrRootHash, Payload, VoteMessage, KEY_TYPE, }; diff --git a/client/beefy/src/communication/mod.rs b/client/consensus/beefy/src/communication/mod.rs similarity index 100% rename from client/beefy/src/communication/mod.rs rename to client/consensus/beefy/src/communication/mod.rs diff --git a/client/beefy/src/communication/notification.rs b/client/consensus/beefy/src/communication/notification.rs similarity index 100% rename from client/beefy/src/communication/notification.rs rename to client/consensus/beefy/src/communication/notification.rs diff --git a/client/beefy/src/communication/peers.rs b/client/consensus/beefy/src/communication/peers.rs similarity index 100% rename from client/beefy/src/communication/peers.rs rename to client/consensus/beefy/src/communication/peers.rs diff --git a/client/beefy/src/communication/request_response/incoming_requests_handler.rs b/client/consensus/beefy/src/communication/request_response/incoming_requests_handler.rs similarity index 99% rename from client/beefy/src/communication/request_response/incoming_requests_handler.rs rename to client/consensus/beefy/src/communication/request_response/incoming_requests_handler.rs index 3266f6dba3989..ab6c21a187c95 100644 --- a/client/beefy/src/communication/request_response/incoming_requests_handler.rs +++ b/client/consensus/beefy/src/communication/request_response/incoming_requests_handler.rs @@ -16,7 +16,6 @@ //! Helper for handling (i.e. answering) BEEFY justifications requests from a remote peer. -use beefy_primitives::BEEFY_ENGINE_ID; use codec::Decode; use futures::{ channel::{mpsc, oneshot}, @@ -26,6 +25,7 @@ use log::{debug, trace}; use sc_client_api::BlockBackend; use sc_network::{config as netconfig, config::RequestResponseConfig, PeerId, ReputationChange}; use sc_network_common::protocol::ProtocolName; +use sp_consensus_beefy::BEEFY_ENGINE_ID; use sp_runtime::traits::Block; use std::{marker::PhantomData, sync::Arc}; diff --git a/client/beefy/src/communication/request_response/mod.rs b/client/consensus/beefy/src/communication/request_response/mod.rs similarity index 100% rename from client/beefy/src/communication/request_response/mod.rs rename to client/consensus/beefy/src/communication/request_response/mod.rs diff --git a/client/beefy/src/communication/request_response/outgoing_requests_engine.rs b/client/consensus/beefy/src/communication/request_response/outgoing_requests_engine.rs similarity index 99% rename from client/beefy/src/communication/request_response/outgoing_requests_engine.rs rename to client/consensus/beefy/src/communication/request_response/outgoing_requests_engine.rs index 0f4f07835ca82..7450d4b3239f1 100644 --- a/client/beefy/src/communication/request_response/outgoing_requests_engine.rs +++ b/client/consensus/beefy/src/communication/request_response/outgoing_requests_engine.rs @@ -18,7 +18,6 @@ //! Generating request logic for request/response protocol for syncing BEEFY justifications. -use beefy_primitives::{crypto::AuthorityId, ValidatorSet}; use codec::Encode; use futures::channel::{oneshot, oneshot::Canceled}; use log::{debug, warn}; @@ -28,6 +27,7 @@ use sc_network_common::{ request_responses::{IfDisconnected, RequestFailure}, service::NetworkRequest, }; +use sp_consensus_beefy::{crypto::AuthorityId, ValidatorSet}; use sp_runtime::traits::{Block, NumberFor}; use std::{collections::VecDeque, result::Result, sync::Arc}; diff --git a/client/beefy/src/error.rs b/client/consensus/beefy/src/error.rs similarity index 100% rename from client/beefy/src/error.rs rename to client/consensus/beefy/src/error.rs diff --git a/client/beefy/src/import.rs b/client/consensus/beefy/src/import.rs similarity index 99% rename from client/beefy/src/import.rs rename to client/consensus/beefy/src/import.rs index 44d30d5d7df03..177a99b1066b2 100644 --- a/client/beefy/src/import.rs +++ b/client/consensus/beefy/src/import.rs @@ -16,8 +16,8 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use beefy_primitives::{BeefyApi, BEEFY_ENGINE_ID}; use log::debug; +use sp_consensus_beefy::{BeefyApi, BEEFY_ENGINE_ID}; use std::{collections::HashMap, sync::Arc}; use sp_api::{ProvideRuntimeApi, TransactionFor}; diff --git a/client/beefy/src/justification.rs b/client/consensus/beefy/src/justification.rs similarity index 98% rename from client/beefy/src/justification.rs rename to client/consensus/beefy/src/justification.rs index 6ceb3d2f5b369..1bd250b2a25f3 100644 --- a/client/beefy/src/justification.rs +++ b/client/consensus/beefy/src/justification.rs @@ -17,17 +17,17 @@ // along with this program. If not, see . use crate::keystore::BeefyKeystore; -use beefy_primitives::{ +use codec::{Decode, Encode}; +use sp_consensus::Error as ConsensusError; +use sp_consensus_beefy::{ crypto::{AuthorityId, Signature}, ValidatorSet, VersionedFinalityProof, }; -use codec::{Decode, Encode}; -use sp_consensus::Error as ConsensusError; use sp_runtime::traits::{Block as BlockT, NumberFor}; /// A finality proof with matching BEEFY authorities' signatures. pub type BeefyVersionedFinalityProof = - beefy_primitives::VersionedFinalityProof, Signature>; + sp_consensus_beefy::VersionedFinalityProof, Signature>; /// Decode and verify a Beefy FinalityProof. pub(crate) fn decode_and_verify_finality_proof( @@ -80,7 +80,7 @@ fn verify_with_validator_set( #[cfg(test)] pub(crate) mod tests { - use beefy_primitives::{ + use sp_consensus_beefy::{ known_payloads, Commitment, Keyring, Payload, SignedCommitment, VersionedFinalityProof, }; use substrate_test_runtime_client::runtime::Block; diff --git a/client/beefy/src/keystore.rs b/client/consensus/beefy/src/keystore.rs similarity index 97% rename from client/beefy/src/keystore.rs rename to client/consensus/beefy/src/keystore.rs index 3f0d8a5f316af..421f7149018c8 100644 --- a/client/beefy/src/keystore.rs +++ b/client/consensus/beefy/src/keystore.rs @@ -22,7 +22,7 @@ use sp_keystore::{SyncCryptoStore, SyncCryptoStorePtr}; use log::warn; -use beefy_primitives::{ +use sp_consensus_beefy::{ crypto::{Public, Signature}, BeefyAuthorityId, KEY_TYPE, }; @@ -89,8 +89,8 @@ impl BeefyKeystore { Ok(sig) } - /// Returns a vector of [`beefy_primitives::crypto::Public`] keys which are currently supported - /// (i.e. found in the keystore). + /// Returns a vector of [`sp_consensus_beefy::crypto::Public`] keys which are currently + /// supported (i.e. found in the keystore). pub fn public_keys(&self) -> Result, error::Error> { let store = self.0.clone().ok_or_else(|| error::Error::Keystore("no Keystore".into()))?; @@ -123,7 +123,7 @@ pub mod tests { use sc_keystore::LocalKeystore; use sp_core::{ecdsa, Pair}; - use beefy_primitives::{crypto, Keyring}; + use sp_consensus_beefy::{crypto, Keyring}; use super::*; use crate::error::Error; diff --git a/client/beefy/src/lib.rs b/client/consensus/beefy/src/lib.rs similarity index 99% rename from client/beefy/src/lib.rs rename to client/consensus/beefy/src/lib.rs index 4f5f8b44329bf..9b627e3ff8fef 100644 --- a/client/beefy/src/lib.rs +++ b/client/consensus/beefy/src/lib.rs @@ -32,10 +32,6 @@ use crate::{ round::Rounds, worker::PersistedState, }; -use beefy_primitives::{ - crypto::AuthorityId, BeefyApi, MmrRootHash, PayloadProvider, ValidatorSet, BEEFY_ENGINE_ID, - GENESIS_AUTHORITY_SET_ID, -}; use futures::{stream::Fuse, StreamExt}; use log::{error, info}; use parking_lot::Mutex; @@ -50,6 +46,10 @@ use sp_blockchain::{ Backend as BlockchainBackend, Error as ClientError, HeaderBackend, Result as ClientResult, }; use sp_consensus::{Error as ConsensusError, SyncOracle}; +use sp_consensus_beefy::{ + crypto::AuthorityId, BeefyApi, MmrRootHash, PayloadProvider, ValidatorSet, BEEFY_ENGINE_ID, + GENESIS_AUTHORITY_SET_ID, +}; use sp_keystore::SyncCryptoStorePtr; use sp_mmr_primitives::MmrApi; use sp_runtime::traits::{Block, Zero}; diff --git a/client/beefy/src/metrics.rs b/client/consensus/beefy/src/metrics.rs similarity index 100% rename from client/beefy/src/metrics.rs rename to client/consensus/beefy/src/metrics.rs diff --git a/client/beefy/src/round.rs b/client/consensus/beefy/src/round.rs similarity index 99% rename from client/beefy/src/round.rs rename to client/consensus/beefy/src/round.rs index 142e138f599d5..64d03beeee854 100644 --- a/client/beefy/src/round.rs +++ b/client/consensus/beefy/src/round.rs @@ -18,12 +18,12 @@ use crate::LOG_TARGET; -use beefy_primitives::{ +use codec::{Decode, Encode}; +use log::debug; +use sp_consensus_beefy::{ crypto::{AuthorityId, Public, Signature}, Commitment, EquivocationProof, SignedCommitment, ValidatorSet, ValidatorSetId, VoteMessage, }; -use codec::{Decode, Encode}; -use log::debug; use sp_runtime::traits::{Block, NumberFor}; use std::collections::BTreeMap; @@ -198,7 +198,7 @@ where mod tests { use sc_network_test::Block; - use beefy_primitives::{ + use sp_consensus_beefy::{ crypto::Public, known_payloads::MMR_ROOT_ID, Commitment, EquivocationProof, Keyring, Payload, SignedCommitment, ValidatorSet, VoteMessage, }; diff --git a/client/beefy/src/tests.rs b/client/consensus/beefy/src/tests.rs similarity index 99% rename from client/beefy/src/tests.rs rename to client/consensus/beefy/src/tests.rs index 419033efe367f..e4fe16a2acfd3 100644 --- a/client/beefy/src/tests.rs +++ b/client/consensus/beefy/src/tests.rs @@ -29,14 +29,6 @@ use crate::{ load_or_init_voter_state, wait_for_runtime_pallet, BeefyRPCLinks, BeefyVoterLinks, KnownPeers, PersistedState, }; -use beefy_primitives::{ - crypto::{AuthorityId, Signature}, - known_payloads, - mmr::MmrRootProvider, - BeefyApi, Commitment, ConsensusLog, EquivocationProof, Keyring as BeefyKeyring, MmrRootHash, - OpaqueKeyOwnershipProof, Payload, SignedCommitment, ValidatorSet, ValidatorSetId, - VersionedFinalityProof, BEEFY_ENGINE_ID, KEY_TYPE as BeefyKeyType, -}; use futures::{future, stream::FuturesUnordered, Future, StreamExt}; use parking_lot::Mutex; use sc_client_api::{Backend as BackendT, BlockchainEvents, FinalityNotifications, HeaderBackend}; @@ -53,6 +45,14 @@ use sc_utils::notification::NotificationReceiver; use serde::{Deserialize, Serialize}; use sp_api::{ApiRef, ProvideRuntimeApi}; use sp_consensus::BlockOrigin; +use sp_consensus_beefy::{ + crypto::{AuthorityId, Signature}, + known_payloads, + mmr::MmrRootProvider, + BeefyApi, Commitment, ConsensusLog, EquivocationProof, Keyring as BeefyKeyring, MmrRootHash, + OpaqueKeyOwnershipProof, Payload, SignedCommitment, ValidatorSet, ValidatorSetId, + VersionedFinalityProof, BEEFY_ENGINE_ID, KEY_TYPE as BeefyKeyType, +}; use sp_core::H256; use sp_keystore::{testing::KeyStore as TestKeystore, SyncCryptoStore, SyncCryptoStorePtr}; use sp_mmr_primitives::{Error as MmrError, MmrApi}; @@ -484,7 +484,7 @@ async fn wait_for_beefy_signed_commitments( let expected = expected.next(); async move { let signed_commitment = match versioned_finality_proof { - beefy_primitives::VersionedFinalityProof::V1(sc) => sc, + sp_consensus_beefy::VersionedFinalityProof::V1(sc) => sc, }; let commitment_block_num = signed_commitment.commitment.block_number; assert_eq!(expected, Some(commitment_block_num).as_ref()); diff --git a/client/beefy/src/worker.rs b/client/consensus/beefy/src/worker.rs similarity index 99% rename from client/beefy/src/worker.rs rename to client/consensus/beefy/src/worker.rs index 439da213818df..7f3114958647f 100644 --- a/client/beefy/src/worker.rs +++ b/client/consensus/beefy/src/worker.rs @@ -29,12 +29,6 @@ use crate::{ round::{Rounds, VoteImportResult}, BeefyVoterLinks, LOG_TARGET, }; -use beefy_primitives::{ - check_equivocation_proof, - crypto::{AuthorityId, Signature}, - BeefyApi, Commitment, ConsensusLog, EquivocationProof, PayloadProvider, ValidatorSet, - VersionedFinalityProof, VoteMessage, BEEFY_ENGINE_ID, -}; use codec::{Codec, Decode, Encode}; use futures::{stream::Fuse, FutureExt, StreamExt}; use log::{debug, error, info, log_enabled, trace, warn}; @@ -45,6 +39,12 @@ use sc_utils::notification::NotificationReceiver; use sp_api::{BlockId, ProvideRuntimeApi}; use sp_arithmetic::traits::{AtLeast32Bit, Saturating}; use sp_consensus::SyncOracle; +use sp_consensus_beefy::{ + check_equivocation_proof, + crypto::{AuthorityId, Signature}, + BeefyApi, Commitment, ConsensusLog, EquivocationProof, PayloadProvider, ValidatorSet, + VersionedFinalityProof, VoteMessage, BEEFY_ENGINE_ID, +}; use sp_runtime::{ generic::OpaqueDigestItemId, traits::{Block, ConstU32, Header, NumberFor, Zero}, @@ -1062,10 +1062,6 @@ pub(crate) mod tests { }, BeefyRPCLinks, KnownPeers, }; - use beefy_primitives::{ - generate_equivocation_proof, known_payloads, known_payloads::MMR_ROOT_ID, - mmr::MmrRootProvider, Keyring, Payload, SignedCommitment, - }; use futures::{future::poll_fn, task::Poll}; use parking_lot::Mutex; use sc_client_api::{Backend as BackendT, HeaderBackend}; @@ -1073,6 +1069,10 @@ pub(crate) mod tests { use sc_network_test::TestNetFactory; use sp_api::HeaderT; use sp_blockchain::Backend as BlockchainBackendT; + use sp_consensus_beefy::{ + generate_equivocation_proof, known_payloads, known_payloads::MMR_ROOT_ID, + mmr::MmrRootProvider, Keyring, Payload, SignedCommitment, + }; use sp_runtime::traits::One; use substrate_test_runtime_client::{ runtime::{Block, Digest, DigestItem, Header, H256}, diff --git a/client/merkle-mountain-range/Cargo.toml b/client/merkle-mountain-range/Cargo.toml index 90fb65453ba12..899f4cc2e08da 100644 --- a/client/merkle-mountain-range/Cargo.toml +++ b/client/merkle-mountain-range/Cargo.toml @@ -14,10 +14,10 @@ homepage = "https://substrate.io" codec = { package = "parity-scale-codec", version = "3.2.2" } futures = "0.3" log = "0.4" -beefy-primitives = { version = "4.0.0-dev", path = "../../primitives/beefy", package = "sp-beefy" } -sc-client-api = { version = "4.0.0-dev", path = "../api" } sp-api = { version = "4.0.0-dev", path = "../../primitives/api" } sp-blockchain = { version = "4.0.0-dev", path = "../../primitives/blockchain" } +sc-client-api = { version = "4.0.0-dev", path = "../api" } +sp-consensus-beefy = { version = "4.0.0-dev", path = "../../primitives/consensus/beefy" } sp-consensus = { version = "0.10.0-dev", path = "../../primitives/consensus/common" } sp-core = { version = "7.0.0", path = "../../primitives/core" } sp-mmr-primitives = { version = "4.0.0-dev", path = "../../primitives/merkle-mountain-range" } diff --git a/client/merkle-mountain-range/src/lib.rs b/client/merkle-mountain-range/src/lib.rs index de21b9b4967fb..e174af7068abb 100644 --- a/client/merkle-mountain-range/src/lib.rs +++ b/client/merkle-mountain-range/src/lib.rs @@ -43,13 +43,13 @@ mod offchain_mmr; pub mod test_utils; use crate::offchain_mmr::OffchainMmr; -use beefy_primitives::MmrRootHash; use futures::StreamExt; use log::{debug, error, trace, warn}; use sc_client_api::{Backend, BlockchainEvents, FinalityNotification, FinalityNotifications}; use sc_offchain::OffchainDb; use sp_api::ProvideRuntimeApi; use sp_blockchain::{HeaderBackend, HeaderMetadata}; +use sp_consensus_beefy::MmrRootHash; use sp_mmr_primitives::{utils, LeafIndex, MmrApi}; use sp_runtime::traits::{Block, Header, NumberFor}; use std::{marker::PhantomData, sync::Arc}; diff --git a/client/merkle-mountain-range/src/offchain_mmr.rs b/client/merkle-mountain-range/src/offchain_mmr.rs index 33d85f0cb14e3..3c3f0beb6c6a9 100644 --- a/client/merkle-mountain-range/src/offchain_mmr.rs +++ b/client/merkle-mountain-range/src/offchain_mmr.rs @@ -22,11 +22,11 @@ #![warn(missing_docs)] use crate::{aux_schema, MmrClient, LOG_TARGET}; -use beefy_primitives::MmrRootHash; use log::{debug, error, info, warn}; use sc_client_api::{Backend, FinalityNotification}; use sc_offchain::OffchainDb; use sp_blockchain::{CachedHeaderMetadata, ForkBackend}; +use sp_consensus_beefy::MmrRootHash; use sp_core::offchain::{DbExternalities, StorageKind}; use sp_mmr_primitives::{utils, utils::NodesUtils, MmrApi, NodeIndex}; use sp_runtime::{ diff --git a/frame/beefy-mmr/Cargo.toml b/frame/beefy-mmr/Cargo.toml index 1d24e821c5012..721e24282c45b 100644 --- a/frame/beefy-mmr/Cargo.toml +++ b/frame/beefy-mmr/Cargo.toml @@ -15,12 +15,12 @@ log = { version = "0.4.17", default-features = false } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } serde = { version = "1.0.136", optional = true } binary-merkle-tree = { version = "4.0.0-dev", default-features = false, path = "../../utils/binary-merkle-tree" } -beefy-primitives = { version = "4.0.0-dev", default-features = false, path = "../../primitives/beefy", package = "sp-beefy" } frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" } frame-system = { version = "4.0.0-dev", default-features = false, path = "../system" } pallet-beefy = { version = "4.0.0-dev", default-features = false, path = "../beefy" } pallet-mmr = { version = "4.0.0-dev", default-features = false, path = "../merkle-mountain-range" } pallet-session = { version = "4.0.0-dev", default-features = false, path = "../session" } +sp-consensus-beefy = { version = "4.0.0-dev", default-features = false, path = "../../primitives/consensus/beefy" } sp-core = { version = "7.0.0", default-features = false, path = "../../primitives/core" } sp-io = { version = "7.0.0", default-features = false, path = "../../primitives/io" } sp-runtime = { version = "7.0.0", default-features = false, path = "../../primitives/runtime" } @@ -36,7 +36,6 @@ default = ["std"] std = [ "array-bytes", "binary-merkle-tree/std", - "beefy-primitives/std", "codec/std", "frame-support/std", "frame-system/std", @@ -46,6 +45,7 @@ std = [ "pallet-session/std", "scale-info/std", "serde", + "sp-consensus-beefy/std", "sp-core/std", "sp-io/std", "sp-runtime/std", diff --git a/frame/beefy-mmr/src/lib.rs b/frame/beefy-mmr/src/lib.rs index 8bb3aaa7e69b8..ba52be4f883f0 100644 --- a/frame/beefy-mmr/src/lib.rs +++ b/frame/beefy-mmr/src/lib.rs @@ -36,11 +36,11 @@ use sp_runtime::traits::{Convert, Member}; use sp_std::prelude::*; -use beefy_primitives::{ +use pallet_mmr::{LeafDataProvider, ParentNumberAndHash}; +use sp_consensus_beefy::{ mmr::{BeefyAuthoritySet, BeefyDataProvider, BeefyNextAuthoritySet, MmrLeaf, MmrLeafVersion}, ValidatorSet as BeefyValidatorSet, }; -use pallet_mmr::{LeafDataProvider, ParentNumberAndHash}; use frame_support::{crypto::ecdsa::ECDSAExt, traits::Get}; @@ -54,15 +54,15 @@ mod tests; /// A BEEFY consensus digest item with MMR root hash. pub struct DepositBeefyDigest(sp_std::marker::PhantomData); -impl pallet_mmr::primitives::OnNewRoot for DepositBeefyDigest +impl pallet_mmr::primitives::OnNewRoot for DepositBeefyDigest where - T: pallet_mmr::Config, + T: pallet_mmr::Config, T: pallet_beefy::Config, { fn on_new_root(root: &::Hash) { let digest = sp_runtime::generic::DigestItem::Consensus( - beefy_primitives::BEEFY_ENGINE_ID, - codec::Encode::encode(&beefy_primitives::ConsensusLog::< + sp_consensus_beefy::BEEFY_ENGINE_ID, + codec::Encode::encode(&sp_consensus_beefy::ConsensusLog::< ::BeefyId, >::MmrRoot(*root)), ); @@ -72,8 +72,8 @@ where /// Convert BEEFY secp256k1 public keys into Ethereum addresses pub struct BeefyEcdsaToEthereum; -impl Convert> for BeefyEcdsaToEthereum { - fn convert(beefy_id: beefy_primitives::crypto::AuthorityId) -> Vec { +impl Convert> for BeefyEcdsaToEthereum { + fn convert(beefy_id: sp_consensus_beefy::crypto::AuthorityId) -> Vec { sp_core::ecdsa::Public::from(beefy_id) .to_eth_address() .map(|v| v.to_vec()) @@ -156,7 +156,7 @@ impl LeafDataProvider for Pallet { } } -impl beefy_primitives::OnNewValidatorSet<::BeefyId> for Pallet +impl sp_consensus_beefy::OnNewValidatorSet<::BeefyId> for Pallet where T: pallet::Config, { diff --git a/frame/beefy-mmr/src/mock.rs b/frame/beefy-mmr/src/mock.rs index 922f882e1f1df..d31effc9ab577 100644 --- a/frame/beefy-mmr/src/mock.rs +++ b/frame/beefy-mmr/src/mock.rs @@ -17,7 +17,6 @@ use std::vec; -use beefy_primitives::mmr::MmrLeafVersion; use codec::Encode; use frame_support::{ construct_runtime, parameter_types, @@ -25,6 +24,7 @@ use frame_support::{ traits::{ConstU16, ConstU32, ConstU64, GenesisBuild, KeyOwnerProofSystem}, BasicExternalities, }; +use sp_consensus_beefy::mmr::MmrLeafVersion; use sp_core::{crypto::KeyTypeId, Hasher, H256}; use sp_runtime::{ app_crypto::ecdsa::Public, @@ -35,7 +35,7 @@ use sp_runtime::{ use crate as pallet_beefy_mmr; -pub use beefy_primitives::{ +pub use sp_consensus_beefy::{ crypto::AuthorityId as BeefyId, mmr::BeefyDataProvider, ConsensusLog, BEEFY_ENGINE_ID, }; @@ -101,7 +101,7 @@ impl pallet_session::Config for Test { type WeightInfo = (); } -pub type MmrLeaf = beefy_primitives::mmr::MmrLeaf< +pub type MmrLeaf = sp_consensus_beefy::mmr::MmrLeaf< ::BlockNumber, ::Hash, ::Hash, diff --git a/frame/beefy-mmr/src/tests.rs b/frame/beefy-mmr/src/tests.rs index af10d1127ebd7..dc2e46f31fe64 100644 --- a/frame/beefy-mmr/src/tests.rs +++ b/frame/beefy-mmr/src/tests.rs @@ -17,11 +17,11 @@ use std::vec; -use beefy_primitives::{ +use codec::{Decode, Encode}; +use sp_consensus_beefy::{ mmr::{BeefyNextAuthoritySet, MmrLeafVersion}, ValidatorSet, }; -use codec::{Decode, Encode}; use sp_core::H256; use sp_io::TestExternalities; diff --git a/frame/beefy/Cargo.toml b/frame/beefy/Cargo.toml index b2d6635377571..3778ca5f37a56 100644 --- a/frame/beefy/Cargo.toml +++ b/frame/beefy/Cargo.toml @@ -12,11 +12,11 @@ homepage = "https://substrate.io" codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } serde = { version = "1.0.136", optional = true } -beefy-primitives = { version = "4.0.0-dev", default-features = false, path = "../../primitives/beefy", package = "sp-beefy" } frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" } frame-system = { version = "4.0.0-dev", default-features = false, path = "../system" } pallet-authorship = { version = "4.0.0-dev", default-features = false, path = "../authorship" } pallet-session = { version = "4.0.0-dev", default-features = false, path = "../session" } +sp-consensus-beefy = { version = "4.0.0-dev", default-features = false, path = "../../primitives/consensus/beefy" } sp-runtime = { version = "7.0.0", default-features = false, path = "../../primitives/runtime" } sp-session = { version = "4.0.0-dev", default-features = false, path = "../../primitives/session" } sp-staking = { version = "4.0.0-dev", default-features = false, path = "../../primitives/staking" } @@ -36,7 +36,6 @@ sp-staking = { version = "4.0.0-dev", path = "../../primitives/staking" } [features] default = ["std"] std = [ - "beefy-primitives/std", "codec/std", "frame-support/std", "frame-system/std", @@ -44,6 +43,7 @@ std = [ "pallet-session/std", "scale-info/std", "serde", + "sp-consensus-beefy/std", "sp-runtime/std", "sp-session/std", "sp-staking/std", diff --git a/frame/beefy/src/equivocation.rs b/frame/beefy/src/equivocation.rs index 19c41cbfacea5..cc04f316c3638 100644 --- a/frame/beefy/src/equivocation.rs +++ b/frame/beefy/src/equivocation.rs @@ -36,13 +36,13 @@ use sp_std::prelude::*; -use beefy_primitives::{EquivocationProof, ValidatorSetId}; use codec::{self as codec, Decode, Encode}; use frame_support::{ log, traits::{Get, KeyOwnerProofSystem}, }; use frame_system::pallet_prelude::BlockNumberFor; +use sp_consensus_beefy::{EquivocationProof, ValidatorSetId}; use sp_runtime::{ transaction_validity::{ InvalidTransaction, TransactionPriority, TransactionSource, TransactionValidity, @@ -271,7 +271,7 @@ fn is_known_offence( ) -> Result<(), TransactionValidityError> { // check the membership proof to extract the offender's id, // equivocation validity will be fully checked during the call. - let key = (beefy_primitives::KEY_TYPE, equivocation_proof.offender_id().clone()); + let key = (sp_consensus_beefy::KEY_TYPE, equivocation_proof.offender_id().clone()); let offender = T::KeyOwnerProofSystem::check_proof(key, key_owner_proof.clone()) .ok_or(InvalidTransaction::BadProof)?; diff --git a/frame/beefy/src/lib.rs b/frame/beefy/src/lib.rs index bcb7fc126520b..698e6e73312f1 100644 --- a/frame/beefy/src/lib.rs +++ b/frame/beefy/src/lib.rs @@ -40,7 +40,7 @@ use sp_session::{GetSessionNumber, GetValidatorCount}; use sp_staking::SessionIndex; use sp_std::prelude::*; -use beefy_primitives::{ +use sp_consensus_beefy::{ AuthorityIndex, BeefyAuthorityId, ConsensusLog, EquivocationProof, OnNewValidatorSet, ValidatorSet, BEEFY_ENGINE_ID, GENESIS_AUTHORITY_SET_ID, }; @@ -135,7 +135,7 @@ pub mod pallet { #[pallet::storage] #[pallet::getter(fn validator_set_id)] pub(super) type ValidatorSetId = - StorageValue<_, beefy_primitives::ValidatorSetId, ValueQuery>; + StorageValue<_, sp_consensus_beefy::ValidatorSetId, ValueQuery>; /// Authorities set scheduled to be used with the next session #[pallet::storage] @@ -156,7 +156,7 @@ pub mod pallet { #[pallet::storage] #[pallet::getter(fn session_for_set)] pub(super) type SetIdSession = - StorageMap<_, Twox64Concat, beefy_primitives::ValidatorSetId, SessionIndex>; + StorageMap<_, Twox64Concat, sp_consensus_beefy::ValidatorSetId, SessionIndex>; /// Block number where BEEFY consensus is enabled/started. /// If changing this, make sure `Self::ValidatorSetId` is also reset to @@ -280,7 +280,7 @@ impl Pallet { /// Return the current active BEEFY validator set. pub fn validator_set() -> Option> { let validators: BoundedVec = Self::authorities(); - let id: beefy_primitives::ValidatorSetId = Self::validator_set_id(); + let id: sp_consensus_beefy::ValidatorSetId = Self::validator_set_id(); ValidatorSet::::new(validators, id) } @@ -390,13 +390,13 @@ impl Pallet { // validate the key ownership proof extracting the id of the offender. let offender = T::KeyOwnerProofSystem::check_proof( - (beefy_primitives::KEY_TYPE, offender_id), + (sp_consensus_beefy::KEY_TYPE, offender_id), key_owner_proof, ) .ok_or(Error::::InvalidKeyOwnershipProof)?; // validate equivocation proof (check votes are different and signatures are valid). - if !beefy_primitives::check_equivocation_proof(&equivocation_proof) { + if !sp_consensus_beefy::check_equivocation_proof(&equivocation_proof) { return Err(Error::::InvalidEquivocationProof.into()) } diff --git a/frame/beefy/src/mock.rs b/frame/beefy/src/mock.rs index e39c4d948c862..b804ba1608770 100644 --- a/frame/beefy/src/mock.rs +++ b/frame/beefy/src/mock.rs @@ -42,7 +42,7 @@ use sp_staking::{EraIndex, SessionIndex}; use crate as pallet_beefy; -pub use beefy_primitives::{ +pub use sp_consensus_beefy::{ crypto::{AuthorityId as BeefyId, AuthoritySignature as BeefySignature}, ConsensusLog, EquivocationProof, BEEFY_ENGINE_ID, }; diff --git a/frame/beefy/src/tests.rs b/frame/beefy/src/tests.rs index 767b1e5657502..f9da20e90dc74 100644 --- a/frame/beefy/src/tests.rs +++ b/frame/beefy/src/tests.rs @@ -17,11 +17,11 @@ use std::vec; -use beefy_primitives::{ +use codec::Encode; +use sp_consensus_beefy::{ check_equivocation_proof, generate_equivocation_proof, known_payloads::MMR_ROOT_ID, Keyring as BeefyKeyring, Payload, ValidatorSet, }; -use codec::Encode; use sp_runtime::DigestItem; @@ -298,7 +298,7 @@ fn report_equivocation_current_set_works() { // create the key ownership proof let key_owner_proof = - Historical::prove((beefy_primitives::KEY_TYPE, &equivocation_key)).unwrap(); + Historical::prove((sp_consensus_beefy::KEY_TYPE, &equivocation_key)).unwrap(); // report the equivocation and the tx should be dispatched successfully assert_ok!(Beefy::report_equivocation_unsigned( @@ -355,7 +355,7 @@ fn report_equivocation_old_set_works() { // create the key ownership proof in the "old" set let key_owner_proof = - Historical::prove((beefy_primitives::KEY_TYPE, &equivocation_key)).unwrap(); + Historical::prove((sp_consensus_beefy::KEY_TYPE, &equivocation_key)).unwrap(); start_era(2); @@ -437,7 +437,7 @@ fn report_equivocation_invalid_set_id() { let equivocation_keyring = BeefyKeyring::from_public(equivocation_key).unwrap(); let key_owner_proof = - Historical::prove((beefy_primitives::KEY_TYPE, &equivocation_key)).unwrap(); + Historical::prove((sp_consensus_beefy::KEY_TYPE, &equivocation_key)).unwrap(); let payload1 = Payload::from_single_entry(MMR_ROOT_ID, vec![42]); let payload2 = Payload::from_single_entry(MMR_ROOT_ID, vec![128]); @@ -476,7 +476,7 @@ fn report_equivocation_invalid_session() { // generate a key ownership proof at current era set id let key_owner_proof = - Historical::prove((beefy_primitives::KEY_TYPE, &equivocation_key)).unwrap(); + Historical::prove((sp_consensus_beefy::KEY_TYPE, &equivocation_key)).unwrap(); start_era(2); @@ -520,7 +520,7 @@ fn report_equivocation_invalid_key_owner_proof() { // generate a key ownership proof for the authority at index 1 let invalid_key_owner_proof = - Historical::prove((beefy_primitives::KEY_TYPE, &invalid_owner_key)).unwrap(); + Historical::prove((sp_consensus_beefy::KEY_TYPE, &invalid_owner_key)).unwrap(); let equivocation_authority_index = 0; let equivocation_key = &authorities[equivocation_authority_index]; @@ -569,7 +569,7 @@ fn report_equivocation_invalid_equivocation_proof() { // generate a key ownership proof at set id in era 1 let key_owner_proof = - Historical::prove((beefy_primitives::KEY_TYPE, &equivocation_key)).unwrap(); + Historical::prove((sp_consensus_beefy::KEY_TYPE, &equivocation_key)).unwrap(); let assert_invalid_equivocation_proof = |equivocation_proof| { assert_err!( @@ -650,7 +650,7 @@ fn report_equivocation_validate_unsigned_prevents_duplicates() { ); let key_owner_proof = - Historical::prove((beefy_primitives::KEY_TYPE, &equivocation_key)).unwrap(); + Historical::prove((sp_consensus_beefy::KEY_TYPE, &equivocation_key)).unwrap(); let call = Call::report_equivocation_unsigned { equivocation_proof: Box::new(equivocation_proof.clone()), @@ -756,7 +756,7 @@ fn valid_equivocation_reports_dont_pay_fees() { // create the key ownership proof. let key_owner_proof = - Historical::prove((beefy_primitives::KEY_TYPE, &equivocation_key)).unwrap(); + Historical::prove((sp_consensus_beefy::KEY_TYPE, &equivocation_key)).unwrap(); // check the dispatch info for the call. let info = Call::::report_equivocation_unsigned { diff --git a/primitives/beefy/Cargo.toml b/primitives/consensus/beefy/Cargo.toml similarity index 84% rename from primitives/beefy/Cargo.toml rename to primitives/consensus/beefy/Cargo.toml index 5dfda3e378fab..657569d122b05 100644 --- a/primitives/beefy/Cargo.toml +++ b/primitives/consensus/beefy/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "sp-beefy" +name = "sp-consensus-beefy" version = "4.0.0-dev" authors = ["Parity Technologies "] edition = "2021" @@ -15,19 +15,19 @@ targets = ["x86_64-unknown-linux-gnu"] codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } serde = { version = "1.0.136", optional = true, features = ["derive"] } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } -sp-api = { version = "4.0.0-dev", default-features = false, path = "../api" } -sp-application-crypto = { version = "7.0.0", default-features = false, path = "../application-crypto" } -sp-core = { version = "7.0.0", default-features = false, path = "../core" } -sp-io = { version = "7.0.0", default-features = false, path = "../io" } -sp-mmr-primitives = { version = "4.0.0-dev", default-features = false, path = "../merkle-mountain-range" } -sp-runtime = { version = "7.0.0", default-features = false, path = "../runtime" } -sp-std = { version = "5.0.0", default-features = false, path = "../std" } +sp-api = { version = "4.0.0-dev", default-features = false, path = "../../api" } +sp-application-crypto = { version = "7.0.0", default-features = false, path = "../../application-crypto" } +sp-core = { version = "7.0.0", default-features = false, path = "../../core" } +sp-io = { version = "7.0.0", default-features = false, path = "../../io" } +sp-mmr-primitives = { version = "4.0.0-dev", default-features = false, path = "../../merkle-mountain-range" } +sp-runtime = { version = "7.0.0", default-features = false, path = "../../runtime" } +sp-std = { version = "5.0.0", default-features = false, path = "../../std" } strum = { version = "0.24.1", features = ["derive"], default-features = false } lazy_static = "1.4.0" [dev-dependencies] array-bytes = "4.1" -sp-keystore = { version = "0.13.0", path = "../keystore" } +sp-keystore = { version = "0.13.0", path = "../../keystore" } [features] default = ["std"] diff --git a/primitives/beefy/src/commitment.rs b/primitives/consensus/beefy/src/commitment.rs similarity index 100% rename from primitives/beefy/src/commitment.rs rename to primitives/consensus/beefy/src/commitment.rs diff --git a/primitives/beefy/src/lib.rs b/primitives/consensus/beefy/src/lib.rs similarity index 100% rename from primitives/beefy/src/lib.rs rename to primitives/consensus/beefy/src/lib.rs diff --git a/primitives/beefy/src/mmr.rs b/primitives/consensus/beefy/src/mmr.rs similarity index 100% rename from primitives/beefy/src/mmr.rs rename to primitives/consensus/beefy/src/mmr.rs diff --git a/primitives/beefy/src/payload.rs b/primitives/consensus/beefy/src/payload.rs similarity index 100% rename from primitives/beefy/src/payload.rs rename to primitives/consensus/beefy/src/payload.rs diff --git a/primitives/beefy/src/test_utils.rs b/primitives/consensus/beefy/src/test_utils.rs similarity index 100% rename from primitives/beefy/src/test_utils.rs rename to primitives/consensus/beefy/src/test_utils.rs diff --git a/primitives/beefy/src/witness.rs b/primitives/consensus/beefy/src/witness.rs similarity index 100% rename from primitives/beefy/src/witness.rs rename to primitives/consensus/beefy/src/witness.rs diff --git a/primitives/beefy/test-res/large-raw-commitment b/primitives/consensus/beefy/test-res/large-raw-commitment similarity index 100% rename from primitives/beefy/test-res/large-raw-commitment rename to primitives/consensus/beefy/test-res/large-raw-commitment diff --git a/test-utils/runtime/Cargo.toml b/test-utils/runtime/Cargo.toml index f3222dc15c280..339a435ef2a04 100644 --- a/test-utils/runtime/Cargo.toml +++ b/test-utils/runtime/Cargo.toml @@ -13,11 +13,11 @@ publish = false targets = ["x86_64-unknown-linux-gnu"] [dependencies] -beefy-primitives = { version = "4.0.0-dev", default-features = false, path = "../../primitives/beefy", package = "sp-beefy" } pallet-beefy-mmr = { version = "4.0.0-dev", default-features = false, path = "../../frame/beefy-mmr" } sp-application-crypto = { version = "7.0.0", default-features = false, path = "../../primitives/application-crypto" } sp-consensus-aura = { version = "0.10.0-dev", default-features = false, path = "../../primitives/consensus/aura" } sp-consensus-babe = { version = "0.10.0-dev", default-features = false, path = "../../primitives/consensus/babe" } +sp-consensus-beefy = { version = "4.0.0-dev", default-features = false, path = "../../primitives/consensus/beefy" } sp-block-builder = { version = "4.0.0-dev", default-features = false, path = "../../primitives/block-builder" } codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } @@ -66,11 +66,11 @@ default = [ "std", ] std = [ - "beefy-primitives/std", "pallet-beefy-mmr/std", "sp-application-crypto/std", "sp-consensus-aura/std", "sp-consensus-babe/std", + "sp-consensus-beefy/std", "sp-block-builder/std", "codec/std", "scale-info/std", diff --git a/test-utils/runtime/src/lib.rs b/test-utils/runtime/src/lib.rs index 9e8a4e119b293..87a60acfc87ce 100644 --- a/test-utils/runtime/src/lib.rs +++ b/test-utils/runtime/src/lib.rs @@ -972,36 +972,36 @@ cfg_if! { } } - impl beefy_primitives::BeefyApi for Runtime { + impl sp_consensus_beefy::BeefyApi for Runtime { fn beefy_genesis() -> Option { None } - fn validator_set() -> Option> { + fn validator_set() -> Option> { None } fn submit_report_equivocation_unsigned_extrinsic( - _equivocation_proof: beefy_primitives::EquivocationProof< + _equivocation_proof: sp_consensus_beefy::EquivocationProof< NumberFor, - beefy_primitives::crypto::AuthorityId, - beefy_primitives::crypto::Signature + sp_consensus_beefy::crypto::AuthorityId, + sp_consensus_beefy::crypto::Signature >, - _key_owner_proof: beefy_primitives::OpaqueKeyOwnershipProof, + _key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof, ) -> Option<()> { None } fn generate_key_ownership_proof( - _set_id: beefy_primitives::ValidatorSetId, - _authority_id: beefy_primitives::crypto::AuthorityId, - ) -> Option { None } + _set_id: sp_consensus_beefy::ValidatorSetId, + _authority_id: sp_consensus_beefy::crypto::AuthorityId, + ) -> Option { None } } - impl pallet_beefy_mmr::BeefyMmrApi for Runtime { - fn authority_set_proof() -> beefy_primitives::mmr::BeefyAuthoritySet { + impl pallet_beefy_mmr::BeefyMmrApi for Runtime { + fn authority_set_proof() -> sp_consensus_beefy::mmr::BeefyAuthoritySet { Default::default() } - fn next_authority_set_proof() -> beefy_primitives::mmr::BeefyNextAuthoritySet { + fn next_authority_set_proof() -> sp_consensus_beefy::mmr::BeefyNextAuthoritySet { Default::default() } } From 8ba9e1e79a154418dfc0ad0e6718b1c888446e13 Mon Sep 17 00:00:00 2001 From: yjh Date: Wed, 1 Mar 2023 03:50:57 +0800 Subject: [PATCH 31/80] chore: move genesis block builder to chain-spec crate. (#13427) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: move genesis block builder to block builder crate. * add missing file * chore: move genesis block builder to sc-chain-spec * Update client/chain-spec/src/genesis.rs Co-authored-by: Bastian Köcher * Update test-utils/runtime/src/genesismap.rs Co-authored-by: Bastian Köcher * Update test-utils/runtime/client/src/lib.rs * fix warnings * fix warnings --------- Co-authored-by: Bastian Köcher --- Cargo.lock | 5 ++ client/block-builder/Cargo.toml | 2 +- client/block-builder/src/lib.rs | 3 +- client/chain-spec/Cargo.toml | 4 ++ .../src/client => chain-spec/src}/genesis.rs | 49 +++++++++++++++--- client/chain-spec/src/lib.rs | 11 ++-- client/service/src/client/client.rs | 50 +++---------------- client/service/src/client/mod.rs | 3 +- client/service/src/lib.rs | 11 ++-- test-utils/runtime/client/Cargo.toml | 1 + test-utils/runtime/client/src/lib.rs | 17 +++---- test-utils/runtime/src/genesismap.rs | 6 +-- 12 files changed, 88 insertions(+), 74 deletions(-) rename client/{service/src/client => chain-spec/src}/genesis.rs (68%) diff --git a/Cargo.lock b/Cargo.lock index 49ef979f1ae60..571ae20c82716 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8101,12 +8101,16 @@ version = "4.0.0-dev" dependencies = [ "memmap2", "sc-chain-spec-derive", + "sc-client-api", + "sc-executor", "sc-network-common", "sc-telemetry", "serde", "serde_json", + "sp-blockchain", "sp-core", "sp-runtime", + "sp-state-machine", ] [[package]] @@ -10970,6 +10974,7 @@ dependencies = [ "futures", "parity-scale-codec", "sc-block-builder", + "sc-chain-spec", "sc-client-api", "sc-consensus", "sp-api", diff --git a/client/block-builder/Cargo.toml b/client/block-builder/Cargo.toml index 3b4bea9818c9e..d009826b2fae4 100644 --- a/client/block-builder/Cargo.toml +++ b/client/block-builder/Cargo.toml @@ -23,7 +23,7 @@ sp-blockchain = { version = "4.0.0-dev", path = "../../primitives/blockchain" } sp-core = { version = "7.0.0", path = "../../primitives/core" } sp-inherents = { version = "4.0.0-dev", path = "../../primitives/inherents" } sp-runtime = { version = "7.0.0", path = "../../primitives/runtime" } -sp-state-machine = { version = "0.13.0", path = "../../primitives/state-machine" } [dev-dependencies] +sp-state-machine = { version = "0.13.0", path = "../../primitives/state-machine" } substrate-test-runtime-client = { path = "../../test-utils/runtime/client" } diff --git a/client/block-builder/src/lib.rs b/client/block-builder/src/lib.rs index d7ef3b1da5123..d97afadd40156 100644 --- a/client/block-builder/src/lib.rs +++ b/client/block-builder/src/lib.rs @@ -39,9 +39,8 @@ use sp_runtime::{ Digest, }; -pub use sp_block_builder::BlockBuilder as BlockBuilderApi; - use sc_client_api::backend; +pub use sp_block_builder::BlockBuilder as BlockBuilderApi; /// Used as parameter to [`BlockBuilderProvider`] to express if proof recording should be enabled. /// diff --git a/client/chain-spec/Cargo.toml b/client/chain-spec/Cargo.toml index 0a4e54e8d6a67..6168a897c962c 100644 --- a/client/chain-spec/Cargo.toml +++ b/client/chain-spec/Cargo.toml @@ -16,8 +16,12 @@ targets = ["x86_64-unknown-linux-gnu"] memmap2 = "0.5.0" serde = { version = "1.0.136", features = ["derive"] } serde_json = "1.0.85" +sc-client-api = { version = "4.0.0-dev", path = "../api" } sc-chain-spec-derive = { version = "4.0.0-dev", path = "./derive" } +sc-executor = { version = "0.10.0-dev", path = "../executor" } sc-network-common = { version = "0.10.0-dev", path = "../network/common" } sc-telemetry = { version = "4.0.0-dev", path = "../telemetry" } +sp-blockchain = { version = "4.0.0-dev", path = "../../primitives/blockchain" } sp-core = { version = "7.0.0", path = "../../primitives/core" } sp-runtime = { version = "7.0.0", path = "../../primitives/runtime" } +sp-state-machine = { version = "0.13.0", path = "../../primitives/state-machine" } diff --git a/client/service/src/client/genesis.rs b/client/chain-spec/src/genesis.rs similarity index 68% rename from client/service/src/client/genesis.rs rename to client/chain-spec/src/genesis.rs index b3ed46c1550c7..6aa156a620a79 100644 --- a/client/service/src/client/genesis.rs +++ b/client/chain-spec/src/genesis.rs @@ -18,20 +18,56 @@ //! Tool for creating the genesis block. +use std::{collections::hash_map::DefaultHasher, marker::PhantomData, sync::Arc}; + use sc_client_api::{backend::Backend, BlockImportOperation}; use sc_executor::RuntimeVersionOf; -use sp_core::storage::Storage; +use sp_core::storage::{well_known_keys, StateVersion, Storage}; use sp_runtime::{ traits::{Block as BlockT, Hash as HashT, Header as HeaderT, Zero}, BuildStorage, }; -use std::{marker::PhantomData, sync::Arc}; + +/// Return the state version given the genesis storage and executor. +pub fn resolve_state_version_from_wasm( + storage: &Storage, + executor: &E, +) -> sp_blockchain::Result +where + E: RuntimeVersionOf, +{ + if let Some(wasm) = storage.top.get(well_known_keys::CODE) { + let mut ext = sp_state_machine::BasicExternalities::new_empty(); // just to read runtime version. + + let code_fetcher = sp_core::traits::WrappedRuntimeCode(wasm.as_slice().into()); + let runtime_code = sp_core::traits::RuntimeCode { + code_fetcher: &code_fetcher, + heap_pages: None, + hash: { + use std::hash::{Hash, Hasher}; + let mut state = DefaultHasher::new(); + wasm.hash(&mut state); + state.finish().to_le_bytes().to_vec() + }, + }; + let runtime_version = RuntimeVersionOf::runtime_version(executor, &mut ext, &runtime_code) + .map_err(|e| sp_blockchain::Error::VersionInvalid(e.to_string()))?; + Ok(runtime_version.state_version()) + } else { + Err(sp_blockchain::Error::VersionInvalid( + "Runtime missing from initial storage, could not read state version.".to_string(), + )) + } +} /// Create a genesis block, given the initial storage. -pub fn construct_genesis_block(state_root: Block::Hash) -> Block { +pub fn construct_genesis_block( + state_root: Block::Hash, + state_version: StateVersion, +) -> Block { let extrinsics_root = <<::Header as HeaderT>::Hashing as HashT>::trie_root( Vec::new(), - sp_runtime::StateVersion::V0, + state_version, ); Block::new( @@ -93,12 +129,11 @@ impl, E: RuntimeVersionOf> BuildGenesisBlock sp_blockchain::Result<(Block, Self::BlockImportOperation)> { let Self { genesis_storage, commit_genesis_state, backend, executor, _phantom } = self; - let genesis_state_version = - crate::resolve_state_version_from_wasm(&genesis_storage, &executor)?; + let genesis_state_version = resolve_state_version_from_wasm(&genesis_storage, &executor)?; let mut op = backend.begin_operation()?; let state_root = op.set_genesis_state(genesis_storage, commit_genesis_state, genesis_state_version)?; - let genesis_block = construct_genesis_block::(state_root); + let genesis_block = construct_genesis_block::(state_root, genesis_state_version); Ok((genesis_block, op)) } diff --git a/client/chain-spec/src/lib.rs b/client/chain-spec/src/lib.rs index 414df1fe1296f..e43a247961f02 100644 --- a/client/chain-spec/src/lib.rs +++ b/client/chain-spec/src/lib.rs @@ -177,10 +177,15 @@ mod chain_spec; mod extension; +mod genesis; -pub use chain_spec::{ChainSpec as GenericChainSpec, NoExtension}; -pub use extension::{ - get_extension, get_extension_mut, Extension, Fork, Forks, GetExtension, Group, +pub use self::{ + chain_spec::{ChainSpec as GenericChainSpec, NoExtension}, + extension::{get_extension, get_extension_mut, Extension, Fork, Forks, GetExtension, Group}, + genesis::{ + construct_genesis_block, resolve_state_version_from_wasm, BuildGenesisBlock, + GenesisBlockBuilder, + }, }; pub use sc_chain_spec_derive::{ChainSpecExtension, ChainSpecGroup}; diff --git a/client/service/src/client/client.rs b/client/service/src/client/client.rs index 4b5822ae0e017..9a2a376ebc19f 100644 --- a/client/service/src/client/client.rs +++ b/client/service/src/client/client.rs @@ -18,16 +18,14 @@ //! Substrate Client -use super::{ - block_rules::{BlockRules, LookupResult as BlockLookupResult}, - genesis::BuildGenesisBlock, -}; +use super::block_rules::{BlockRules, LookupResult as BlockLookupResult}; use futures::{FutureExt, StreamExt}; use log::{error, info, trace, warn}; use parking_lot::{Mutex, RwLock}; use prometheus_endpoint::Registry; use rand::Rng; use sc_block_builder::{BlockBuilderApi, BlockBuilderProvider, RecordProof}; +use sc_chain_spec::{resolve_state_version_from_wasm, BuildGenesisBlock}; use sc_client_api::{ backend::{ self, apply_aux, BlockImportOperation, ClientImportOperation, FinalizeSummary, Finalizer, @@ -46,7 +44,7 @@ use sc_client_api::{ use sc_consensus::{ BlockCheckParams, BlockImportParams, ForkChoiceStrategy, ImportResult, StateAction, }; -use sc_executor::{RuntimeVersion, RuntimeVersionOf}; +use sc_executor::RuntimeVersion; use sc_telemetry::{telemetry, TelemetryHandle, SUBSTRATE_INFO}; use sp_api::{ ApiExt, ApiRef, CallApiAt, CallApiAtParams, ConstructRuntimeApi, Core as CoreApi, @@ -61,8 +59,8 @@ use sp_consensus::{BlockOrigin, BlockStatus, Error as ConsensusError}; use sc_utils::mpsc::{tracing_unbounded, TracingUnboundedSender}; use sp_core::{ storage::{ - well_known_keys, ChildInfo, ChildType, PrefixedStorageKey, Storage, StorageChild, - StorageData, StorageKey, + well_known_keys, ChildInfo, ChildType, PrefixedStorageKey, StorageChild, StorageData, + StorageKey, }, traits::SpawnNamed, }; @@ -84,7 +82,7 @@ use sp_state_machine::{ }; use sp_trie::{CompactProof, StorageProof}; use std::{ - collections::{hash_map::DefaultHasher, HashMap, HashSet}, + collections::{HashMap, HashSet}, marker::PhantomData, path::PathBuf, sync::Arc, @@ -172,7 +170,7 @@ pub fn new_in_mem( Client, LocalCallExecutor, E>, Block, RA>, > where - E: CodeExecutor + RuntimeVersionOf, + E: CodeExecutor + sc_executor::RuntimeVersionOf, Block: BlockT, G: BuildGenesisBlock< Block, @@ -233,7 +231,7 @@ pub fn new_with_backend( config: ClientConfig, ) -> sp_blockchain::Result, Block, RA>> where - E: CodeExecutor + RuntimeVersionOf, + E: CodeExecutor + sc_executor::RuntimeVersionOf, G: BuildGenesisBlock< Block, BlockImportOperation = >::BlockImportOperation, @@ -1222,38 +1220,6 @@ where } } -/// Return the genesis state version given the genesis storage and executor. -pub fn resolve_state_version_from_wasm( - storage: &Storage, - executor: &E, -) -> sp_blockchain::Result -where - E: RuntimeVersionOf, -{ - if let Some(wasm) = storage.top.get(well_known_keys::CODE) { - let mut ext = sp_state_machine::BasicExternalities::new_empty(); // just to read runtime version. - - let code_fetcher = sp_core::traits::WrappedRuntimeCode(wasm.as_slice().into()); - let runtime_code = sp_core::traits::RuntimeCode { - code_fetcher: &code_fetcher, - heap_pages: None, - hash: { - use std::hash::{Hash, Hasher}; - let mut state = DefaultHasher::new(); - wasm.hash(&mut state); - state.finish().to_le_bytes().to_vec() - }, - }; - let runtime_version = RuntimeVersionOf::runtime_version(executor, &mut ext, &runtime_code) - .map_err(|e| sp_blockchain::Error::VersionInvalid(e.to_string()))?; - Ok(runtime_version.state_version()) - } else { - Err(sp_blockchain::Error::VersionInvalid( - "Runtime missing from initial storage, could not read state version.".to_string(), - )) - } -} - impl UsageProvider for Client where B: backend::Backend, diff --git a/client/service/src/client/mod.rs b/client/service/src/client/mod.rs index 38d818c498a6a..a13fd4317e155 100644 --- a/client/service/src/client/mod.rs +++ b/client/service/src/client/mod.rs @@ -47,13 +47,12 @@ mod block_rules; mod call_executor; mod client; -pub mod genesis; mod wasm_override; mod wasm_substitutes; pub use self::{ call_executor::LocalCallExecutor, - client::{resolve_state_version_from_wasm, Client, ClientConfig}, + client::{Client, ClientConfig}, }; #[cfg(feature = "test-helpers")] diff --git a/client/service/src/lib.rs b/client/service/src/lib.rs index af0b11f2092c4..6bafa9936c0bf 100644 --- a/client/service/src/lib.rs +++ b/client/service/src/lib.rs @@ -61,12 +61,15 @@ pub use self::{ new_full_parts, spawn_tasks, BuildNetworkParams, KeystoreContainer, NetworkStarter, SpawnTasksParams, TFullBackend, TFullCallExecutor, TFullClient, }, - client::{ - genesis::{BuildGenesisBlock, GenesisBlockBuilder}, - resolve_state_version_from_wasm, ClientConfig, LocalCallExecutor, - }, + client::{ClientConfig, LocalCallExecutor}, error::Error, }; + +pub use sc_chain_spec::{ + construct_genesis_block, resolve_state_version_from_wasm, BuildGenesisBlock, + GenesisBlockBuilder, +}; + pub use config::{ BasePath, BlocksPruning, Configuration, DatabaseSource, PruningMode, Role, RpcMethods, TaskType, }; diff --git a/test-utils/runtime/client/Cargo.toml b/test-utils/runtime/client/Cargo.toml index 7d5c9673f6e21..986db0ba60283 100644 --- a/test-utils/runtime/client/Cargo.toml +++ b/test-utils/runtime/client/Cargo.toml @@ -15,6 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"] codec = { package = "parity-scale-codec", version = "3.2.2" } futures = "0.3.21" sc-block-builder = { version = "0.10.0-dev", path = "../../../client/block-builder" } +sc-chain-spec = { version = "4.0.0-dev", path = "../../../client/chain-spec" } sc-client-api = { version = "4.0.0-dev", path = "../../../client/api" } sc-consensus = { version = "0.10.0-dev", path = "../../../client/consensus/common" } sp-api = { version = "4.0.0-dev", path = "../../../primitives/api" } diff --git a/test-utils/runtime/client/src/lib.rs b/test-utils/runtime/client/src/lib.rs index 97ee525f6eb9a..099aeab11f768 100644 --- a/test-utils/runtime/client/src/lib.rs +++ b/test-utils/runtime/client/src/lib.rs @@ -30,6 +30,8 @@ pub use substrate_test_runtime as runtime; pub use self::block_builder_ext::BlockBuilderExt; +use sc_chain_spec::construct_genesis_block; +use sp_api::StateVersion; use sp_core::{ sr25519, storage::{ChildInfo, Storage, StorageChild}, @@ -122,7 +124,7 @@ impl GenesisParameters { } } -impl substrate_test_client::GenesisInit for GenesisParameters { +impl GenesisInit for GenesisParameters { fn genesis_storage(&self) -> Storage { use codec::Encode; @@ -148,7 +150,7 @@ impl substrate_test_client::GenesisInit for GenesisParameters { storage.top.clone().into_iter().chain(child_roots).collect(), sp_runtime::StateVersion::V1, ); - let block: runtime::Block = client::genesis::construct_genesis_block(state_root); + let block: runtime::Block = construct_genesis_block(state_root, StateVersion::V1); storage.top.extend(additional_storage_with_genesis(&block)); storage @@ -260,7 +262,7 @@ impl TestClientBuilderExt client::LocalCallExecutor< substrate_test_runtime::Block, B, - sc_executor::NativeElseWasmExecutor, + NativeElseWasmExecutor, >, B, > where @@ -288,11 +290,6 @@ pub fn new() -> Client { } /// Create a new native executor. -pub fn new_native_executor() -> sc_executor::NativeElseWasmExecutor { - sc_executor::NativeElseWasmExecutor::new( - sc_executor::WasmExecutionMethod::Interpreted, - None, - 8, - 2, - ) +pub fn new_native_executor() -> NativeElseWasmExecutor { + NativeElseWasmExecutor::new(sc_executor::WasmExecutionMethod::Interpreted, None, 8, 2) } diff --git a/test-utils/runtime/src/genesismap.rs b/test-utils/runtime/src/genesismap.rs index 77fdf59ea8cb4..9e00dd29999f8 100644 --- a/test-utils/runtime/src/genesismap.rs +++ b/test-utils/runtime/src/genesismap.rs @@ -20,10 +20,10 @@ use super::{system, wasm_binary_unwrap, AccountId, AuthorityId, Runtime}; use codec::{Encode, Joiner, KeyedVec}; use frame_support::traits::GenesisBuild; -use sc_service::client::genesis; +use sc_service::construct_genesis_block; use sp_core::{ map, - storage::{well_known_keys, Storage}, + storage::{well_known_keys, StateVersion, Storage}, }; use sp_io::hashing::{blake2_256, twox_128}; use sp_runtime::traits::{Block as BlockT, Hash as HashT, Header as HeaderT}; @@ -106,7 +106,7 @@ pub fn insert_genesis_block(storage: &mut Storage) -> sp_core::hash::H256 { storage.top.clone().into_iter().collect(), sp_runtime::StateVersion::V1, ); - let block: crate::Block = genesis::construct_genesis_block(state_root); + let block: crate::Block = construct_genesis_block(state_root, StateVersion::V1); let genesis_hash = block.header.hash(); storage.top.extend(additional_storage_with_genesis(&block)); genesis_hash From 761d7ae8af2d179a07b755421b183ab0a4a49139 Mon Sep 17 00:00:00 2001 From: Koute Date: Wed, 1 Mar 2023 17:58:18 +0900 Subject: [PATCH 32/80] Speed up storage iteration from within the runtime (#13479) * Speed up storage iteration from within the runtime * Move the cached iterator into an `Option` * Use `RefCell` in no_std * Simplify the code slightly * Use `Option::replace` * Update doc comment for `next_storage_key_slow` --- Cargo.lock | 8 +- frame/benchmarking/pov/src/benchmarking.rs | 13 +++ frame/benchmarking/pov/src/lib.rs | 5 ++ primitives/state-machine/Cargo.toml | 2 +- primitives/state-machine/src/trie_backend.rs | 85 ++++++++++++++++++- .../state-machine/src/trie_backend_essence.rs | 13 ++- primitives/trie/Cargo.toml | 4 +- test-utils/runtime/Cargo.toml | 2 +- .../rpc/state-trie-migration-rpc/Cargo.toml | 2 +- 9 files changed, 118 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 571ae20c82716..ca0719b94dd9e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11538,9 +11538,9 @@ dependencies = [ [[package]] name = "trie-bench" -version = "0.35.0" +version = "0.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22c1d18c423077531e693e87ace54ed9e4af1e4ce0a3ea8c9aa6608741074e2b" +checksum = "ac2b7695feb8041efc0adaa09ed3a692ca7b7c997395954fdc838b5b078346f6" dependencies = [ "criterion", "hash-db", @@ -11554,9 +11554,9 @@ dependencies = [ [[package]] name = "trie-db" -version = "0.25.1" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3390c0409daaa6027d6681393316f4ccd3ff82e1590a1e4725014e3ae2bf1920" +checksum = "879380c0061b165ba1f036325b7f3478bc1a947814d9fc36d22c5d8e960b11bd" dependencies = [ "hash-db", "hashbrown 0.13.2", diff --git a/frame/benchmarking/pov/src/benchmarking.rs b/frame/benchmarking/pov/src/benchmarking.rs index ebe9b241416ad..46a98ae3ff183 100644 --- a/frame/benchmarking/pov/src/benchmarking.rs +++ b/frame/benchmarking/pov/src/benchmarking.rs @@ -316,6 +316,19 @@ frame_benchmarking::benchmarks! { call.dispatch_bypass_filter(RawOrigin::Root.into()).unwrap(); } + storage_iteration { + for i in 0..65000 { + UnboundedMapTwox::::insert(i, sp_std::vec![0; 64]); + } + }: { + for (key, value) in UnboundedMapTwox::::iter() { + unsafe { + core::ptr::read_volatile(&key); + core::ptr::read_volatile(value.as_ptr()); + } + } + } + impl_benchmark_test_suite!( Pallet, mock::new_test_ext(), diff --git a/frame/benchmarking/pov/src/lib.rs b/frame/benchmarking/pov/src/lib.rs index 7dee5c37c1288..b66b5e417817a 100644 --- a/frame/benchmarking/pov/src/lib.rs +++ b/frame/benchmarking/pov/src/lib.rs @@ -107,6 +107,11 @@ pub mod pallet { pub(crate) type UnboundedMap2 = StorageMap, QueryKind = OptionQuery>; + #[pallet::storage] + #[pallet::unbounded] + pub(crate) type UnboundedMapTwox = + StorageMap, QueryKind = OptionQuery>; + #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event { diff --git a/primitives/state-machine/Cargo.toml b/primitives/state-machine/Cargo.toml index 2969a51c4eba0..56fbe0726b82e 100644 --- a/primitives/state-machine/Cargo.toml +++ b/primitives/state-machine/Cargo.toml @@ -33,7 +33,7 @@ array-bytes = "4.1" pretty_assertions = "1.2.1" rand = "0.8.5" sp-runtime = { version = "7.0.0", path = "../runtime" } -trie-db = "0.25.1" +trie-db = "0.26.0" assert_matches = "1.5" [features] diff --git a/primitives/state-machine/src/trie_backend.rs b/primitives/state-machine/src/trie_backend.rs index 3e8d0a7a3bf0a..10e2dfd16d66a 100644 --- a/primitives/state-machine/src/trie_backend.rs +++ b/primitives/state-machine/src/trie_backend.rs @@ -20,8 +20,8 @@ #[cfg(feature = "std")] use crate::backend::AsTrieBackend; use crate::{ - backend::IterArgs, - trie_backend_essence::{TrieBackendEssence, TrieBackendStorage}, + backend::{IterArgs, StorageIterator}, + trie_backend_essence::{RawIter, TrieBackendEssence, TrieBackendStorage}, Backend, StorageKey, StorageValue, }; use codec::Codec; @@ -172,6 +172,7 @@ where self.cache, self.recorder, ), + next_storage_key_cache: Default::default(), } } @@ -180,19 +181,62 @@ where pub fn build(self) -> TrieBackend { let _ = self.cache; - TrieBackend { essence: TrieBackendEssence::new(self.storage, self.root) } + TrieBackend { + essence: TrieBackendEssence::new(self.storage, self.root), + next_storage_key_cache: Default::default(), + } + } +} + +/// A cached iterator. +struct CachedIter +where + H: Hasher, +{ + last_key: sp_std::vec::Vec, + iter: RawIter, +} + +impl Default for CachedIter +where + H: Hasher, +{ + fn default() -> Self { + Self { last_key: Default::default(), iter: Default::default() } } } +#[cfg(feature = "std")] +type CacheCell = parking_lot::Mutex; + +#[cfg(not(feature = "std"))] +type CacheCell = core::cell::RefCell; + +#[cfg(feature = "std")] +fn access_cache(cell: &CacheCell, callback: impl FnOnce(&mut T) -> R) -> R { + callback(&mut *cell.lock()) +} + +#[cfg(not(feature = "std"))] +fn access_cache(cell: &CacheCell, callback: impl FnOnce(&mut T) -> R) -> R { + callback(&mut *cell.borrow_mut()) +} + /// Patricia trie-based backend. Transaction type is an overlay of changes to commit. pub struct TrieBackend, H: Hasher, C = LocalTrieCache> { pub(crate) essence: TrieBackendEssence, + next_storage_key_cache: CacheCell>>, } impl, H: Hasher, C: AsLocalTrieCache + Send + Sync> TrieBackend where H::Out: Codec, { + #[cfg(test)] + pub(crate) fn from_essence(essence: TrieBackendEssence) -> Self { + Self { essence, next_storage_key_cache: Default::default() } + } + /// Get backend essence reference. pub fn essence(&self) -> &TrieBackendEssence { &self.essence @@ -265,7 +309,40 @@ where } fn next_storage_key(&self, key: &[u8]) -> Result, Self::Error> { - self.essence.next_storage_key(key) + let (is_cached, mut cache) = access_cache(&self.next_storage_key_cache, Option::take) + .map(|cache| (cache.last_key == key, cache)) + .unwrap_or_default(); + + if !is_cached { + cache.iter = self.raw_iter(IterArgs { + start_at: Some(key), + start_at_exclusive: true, + ..IterArgs::default() + })? + }; + + let next_key = match cache.iter.next_key(self) { + None => return Ok(None), + Some(Err(error)) => return Err(error), + Some(Ok(next_key)) => next_key, + }; + + cache.last_key.clear(); + cache.last_key.extend_from_slice(&next_key); + access_cache(&self.next_storage_key_cache, |cache_cell| cache_cell.replace(cache)); + + #[cfg(debug_assertions)] + debug_assert_eq!( + self.essence + .next_storage_key_slow(key) + .expect( + "fetching the next key through iterator didn't fail so this shouldn't either" + ) + .as_ref(), + Some(&next_key) + ); + + Ok(Some(next_key)) } fn next_child_storage_key( diff --git a/primitives/state-machine/src/trie_backend_essence.rs b/primitives/state-machine/src/trie_backend_essence.rs index f071a32cede89..1f6d71b2dce80 100644 --- a/primitives/state-machine/src/trie_backend_essence.rs +++ b/primitives/state-machine/src/trie_backend_essence.rs @@ -415,9 +415,14 @@ where }) } - /// Return the next key in the trie i.e. the minimum key that is strictly superior to `key` in + /// Returns the next key in the trie i.e. the minimum key that is strictly superior to `key` in /// lexicographic order. - pub fn next_storage_key(&self, key: &[u8]) -> Result> { + /// + /// Will always traverse the trie from scratch in search of the key, which is slow. + /// Used only when debug assertions are enabled to crosscheck the results of finding + /// the next key through an iterator. + #[cfg(debug_assertions)] + pub fn next_storage_key_slow(&self, key: &[u8]) -> Result> { self.next_storage_key_from_root(&self.root, None, key) } @@ -859,6 +864,7 @@ impl, H: Hasher, C: AsLocalTrieCache + Send + Sync> #[cfg(test)] mod test { use super::*; + use crate::{Backend, TrieBackend}; use sp_core::{Blake2Hasher, H256}; use sp_trie::{ cache::LocalTrieCache, trie_types::TrieDBMutBuilderV1 as TrieDBMutBuilder, KeySpacedDBMut, @@ -897,6 +903,8 @@ mod test { }; let essence_1 = TrieBackendEssence::<_, _, LocalTrieCache<_>>::new(mdb, root_1); + let mdb = essence_1.backend_storage().clone(); + let essence_1 = TrieBackend::from_essence(essence_1); assert_eq!(essence_1.next_storage_key(b"2"), Ok(Some(b"3".to_vec()))); assert_eq!(essence_1.next_storage_key(b"3"), Ok(Some(b"4".to_vec()))); @@ -904,7 +912,6 @@ mod test { assert_eq!(essence_1.next_storage_key(b"5"), Ok(Some(b"6".to_vec()))); assert_eq!(essence_1.next_storage_key(b"6"), Ok(None)); - let mdb = essence_1.backend_storage().clone(); let essence_2 = TrieBackendEssence::<_, _, LocalTrieCache<_>>::new(mdb, root_2); assert_eq!(essence_2.next_child_storage_key(child_info, b"2"), Ok(Some(b"3".to_vec()))); diff --git a/primitives/trie/Cargo.toml b/primitives/trie/Cargo.toml index 33a62cdd94084..fae39ec34c0ea 100644 --- a/primitives/trie/Cargo.toml +++ b/primitives/trie/Cargo.toml @@ -29,7 +29,7 @@ parking_lot = { version = "0.12.1", optional = true } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } thiserror = { version = "1.0.30", optional = true } tracing = { version = "0.1.29", optional = true } -trie-db = { version = "0.25.0", default-features = false } +trie-db = { version = "0.26.0", default-features = false } trie-root = { version = "0.17.0", default-features = false } sp-core = { version = "7.0.0", default-features = false, path = "../core" } sp-std = { version = "5.0.0", default-features = false, path = "../std" } @@ -38,7 +38,7 @@ schnellru = { version = "0.2.1", optional = true } [dev-dependencies] array-bytes = "4.1" criterion = "0.4.0" -trie-bench = "0.35.0" +trie-bench = "0.36.0" trie-standardmap = "0.15.2" sp-runtime = { version = "7.0.0", path = "../runtime" } diff --git a/test-utils/runtime/Cargo.toml b/test-utils/runtime/Cargo.toml index 339a435ef2a04..e0f414b161cf5 100644 --- a/test-utils/runtime/Cargo.toml +++ b/test-utils/runtime/Cargo.toml @@ -41,7 +41,7 @@ pallet-timestamp = { version = "4.0.0-dev", default-features = false, path = ".. sp-consensus-grandpa = { version = "4.0.0-dev", default-features = false, path = "../../primitives/consensus/grandpa" } sp-trie = { version = "7.0.0", default-features = false, path = "../../primitives/trie" } sp-transaction-pool = { version = "4.0.0-dev", default-features = false, path = "../../primitives/transaction-pool" } -trie-db = { version = "0.25.1", default-features = false } +trie-db = { version = "0.26.0", default-features = false } sc-service = { version = "0.10.0-dev", default-features = false, optional = true, features = ["test-helpers"], path = "../../client/service" } sp-state-machine = { version = "0.13.0", default-features = false, path = "../../primitives/state-machine" } sp-externalities = { version = "0.13.0", default-features = false, path = "../../primitives/externalities" } diff --git a/utils/frame/rpc/state-trie-migration-rpc/Cargo.toml b/utils/frame/rpc/state-trie-migration-rpc/Cargo.toml index 1dd9da9a56fee..e6eccc6ff62e0 100644 --- a/utils/frame/rpc/state-trie-migration-rpc/Cargo.toml +++ b/utils/frame/rpc/state-trie-migration-rpc/Cargo.toml @@ -21,7 +21,7 @@ log = { version = "0.4.17", default-features = false } sp-core = { path = "../../../../primitives/core" } sp-state-machine = { path = "../../../../primitives/state-machine" } sp-trie = { path = "../../../../primitives/trie" } -trie-db = "0.25.1" +trie-db = "0.26.0" jsonrpsee = { version = "0.16.2", features = ["client-core", "server", "macros"] } From 31369665d45e35e908cf47c7d0e003337af355c4 Mon Sep 17 00:00:00 2001 From: Dmitry Markin Date: Wed, 1 Mar 2023 12:54:31 +0300 Subject: [PATCH 33/80] Make unbounded channels size warning exact (part 1) (#13490) * Replace `futures-channel` with `async-channel` in `out_events` * Apply suggestions from code review Co-authored-by: Koute * Also print the backtrace of `send()` call * Switch from `backtrace` crate to `std::backtrace` * Remove outdated `backtrace` dependency * Remove `backtrace` from `Cargo.lock` --------- Co-authored-by: Koute --- Cargo.lock | 13 ++++++- client/network/Cargo.toml | 2 +- client/network/src/service/out_events.rs | 48 ++++++++++-------------- 3 files changed, 32 insertions(+), 31 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ca0719b94dd9e..3693bb5025f95 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -347,6 +347,17 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" +[[package]] +name = "async-channel" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf46fee83e5ccffc220104713af3292ff9bc7c64c7de289f66dae8e38d826833" +dependencies = [ + "concurrent-queue", + "event-listener", + "futures-core", +] + [[package]] name = "async-io" version = "1.12.0" @@ -8716,9 +8727,9 @@ version = "0.10.0-dev" dependencies = [ "array-bytes", "assert_matches", + "async-channel", "async-trait", "asynchronous-codec", - "backtrace", "bytes", "either", "fnv", diff --git a/client/network/Cargo.toml b/client/network/Cargo.toml index b6b21247128d7..5a918bebd626e 100644 --- a/client/network/Cargo.toml +++ b/client/network/Cargo.toml @@ -15,9 +15,9 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] array-bytes = "4.1" +async-channel = "1.8.0" async-trait = "0.1" asynchronous-codec = "0.6" -backtrace = "0.3.67" bytes = "1" codec = { package = "parity-scale-codec", version = "3.2.2", features = ["derive"] } either = "1.5.3" diff --git a/client/network/src/service/out_events.rs b/client/network/src/service/out_events.rs index 57a5092ae62ea..99ac022c2d8b6 100644 --- a/client/network/src/service/out_events.rs +++ b/client/network/src/service/out_events.rs @@ -31,20 +31,17 @@ //! - Send events by calling [`OutChannels::send`]. Events are cloned for each sender in the //! collection. -use backtrace::Backtrace; -use futures::{channel::mpsc, prelude::*, ready, stream::FusedStream}; +use futures::{prelude::*, ready, stream::FusedStream}; use log::error; use parking_lot::Mutex; use prometheus_endpoint::{register, CounterVec, GaugeVec, Opts, PrometheusError, Registry, U64}; use sc_network_common::protocol::event::Event; use std::{ + backtrace::Backtrace, cell::RefCell, fmt, pin::Pin, - sync::{ - atomic::{AtomicI64, Ordering}, - Arc, - }, + sync::Arc, task::{Context, Poll}, }; @@ -52,20 +49,18 @@ use std::{ /// /// The name is used in Prometheus reports, the queue size threshold is used /// to warn if there are too many unprocessed events in the channel. -pub fn channel(name: &'static str, queue_size_warning: i64) -> (Sender, Receiver) { - let (tx, rx) = mpsc::unbounded(); +pub fn channel(name: &'static str, queue_size_warning: usize) -> (Sender, Receiver) { + let (tx, rx) = async_channel::unbounded(); let metrics = Arc::new(Mutex::new(None)); - let queue_size = Arc::new(AtomicI64::new(0)); let tx = Sender { inner: tx, name, - queue_size: queue_size.clone(), queue_size_warning, warning_fired: false, - creation_backtrace: Backtrace::new_unresolved(), + creation_backtrace: Backtrace::force_capture(), metrics: metrics.clone(), }; - let rx = Receiver { inner: rx, name, queue_size, metrics }; + let rx = Receiver { inner: rx, name, metrics }; (tx, rx) } @@ -77,16 +72,11 @@ pub fn channel(name: &'static str, queue_size_warning: i64) -> (Sender, Receiver /// implement the `Clone` trait e.g. in Order to not complicate the logic keeping the metrics in /// sync on drop. If someone adds a `#[derive(Clone)]` below, it is **wrong**. pub struct Sender { - inner: mpsc::UnboundedSender, + inner: async_channel::Sender, /// Name to identify the channel (e.g., in Prometheus and logs). name: &'static str, - /// Number of events in the queue. Clone of [`Receiver::in_transit`]. - // To not bother with ordering and possible underflow errors of the unsigned counter - // we just use `i64` and `Ordering::Relaxed`, and perceive `queue_size` as approximate. - // It can turn < 0 though. - queue_size: Arc, /// Threshold queue size to generate an error message in the logs. - queue_size_warning: i64, + queue_size_warning: usize, /// We generate the error message only once to not spam the logs. warning_fired: bool, /// Backtrace of a place where the channel was created. @@ -113,9 +103,8 @@ impl Drop for Sender { /// Receiving side of a channel. pub struct Receiver { - inner: mpsc::UnboundedReceiver, + inner: async_channel::Receiver, name: &'static str, - queue_size: Arc, /// Initially contains `None`, and will be set to a value once the corresponding [`Sender`] /// is assigned to an instance of [`OutChannels`]. metrics: Arc>>>>, @@ -126,7 +115,6 @@ impl Stream for Receiver { fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll> { if let Some(ev) = ready!(Pin::new(&mut self.inner).poll_next(cx)) { - let _ = self.queue_size.fetch_sub(1, Ordering::Relaxed); let metrics = self.metrics.lock().clone(); match metrics.as_ref().map(|m| m.as_ref()) { Some(Some(metrics)) => metrics.event_out(&ev, self.name), @@ -191,17 +179,19 @@ impl OutChannels { /// Sends an event. pub fn send(&mut self, event: Event) { self.event_streams.retain_mut(|sender| { - let queue_size = sender.queue_size.fetch_add(1, Ordering::Relaxed); - if queue_size == sender.queue_size_warning && !sender.warning_fired { + if sender.inner.len() >= sender.queue_size_warning && !sender.warning_fired { sender.warning_fired = true; - sender.creation_backtrace.resolve(); error!( - "The number of unprocessed events in channel `{}` reached {}.\n\ - The channel was created at:\n{:?}", - sender.name, sender.queue_size_warning, sender.creation_backtrace, + "The number of unprocessed events in channel `{}` exceeded {}.\n\ + The channel was created at:\n{:}\n + The last event was sent from:\n{:}", + sender.name, + sender.queue_size_warning, + sender.creation_backtrace, + Backtrace::force_capture(), ); } - sender.inner.unbounded_send(event.clone()).is_ok() + sender.inner.try_send(event.clone()).is_ok() }); if let Some(metrics) = &*self.metrics { From 8d78bee9dfb106ec6288557814138b52055a57fe Mon Sep 17 00:00:00 2001 From: Anthony Lazam Date: Wed, 1 Mar 2023 19:15:18 +0800 Subject: [PATCH 34/80] Removal of Prometheus alerting rules deployment in cloud-infra (#13499) --- .gitlab-ci.yml | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 12a1ff825d162..336e97cdd4433 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -311,28 +311,6 @@ include: rules: - if: $PIPELINE != "automatic-crate-publishing" -#### stage: deploy - -deploy-prometheus-alerting-rules: - stage: deploy - needs: - - job: test-prometheus-alerting-rules - artifacts: false - allow_failure: true - trigger: - project: parity/infrastructure/cloud-infra - variables: - SUBSTRATE_CI_COMMIT_NAME: "${CI_COMMIT_REF_NAME}" - SUBSTRATE_CI_COMMIT_REF: "${CI_COMMIT_SHORT_SHA}" - UPSTREAM_TRIGGER_PROJECT: "${CI_PROJECT_PATH}" - rules: - - if: $CI_PIPELINE_SOURCE == "pipeline" - when: never - - if: $CI_COMMIT_REF_NAME == "master" - changes: - - .gitlab-ci.yml - - ./scripts/ci/monitoring/**/* - #### stage: notify # This job notifies rusty-cachier about the latest commit with the cache. From 397ce89b6ecb8271f1f75d34de963a0d5146d2d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Silva?= <123550+andresilva@users.noreply.github.com> Date: Wed, 1 Mar 2023 13:04:57 +0000 Subject: [PATCH 35/80] sp-consensus: remove unused error variants (#13495) --- Cargo.lock | 3 -- client/consensus/pow/src/lib.rs | 3 +- primitives/consensus/common/Cargo.toml | 5 -- primitives/consensus/common/src/error.rs | 69 +++++------------------- 4 files changed, 15 insertions(+), 65 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3693bb5025f95..d22c735ce560d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9980,14 +9980,11 @@ dependencies = [ "async-trait", "futures", "log", - "parity-scale-codec", "sp-core", "sp-inherents", "sp-runtime", "sp-state-machine", - "sp-std", "sp-test-primitives", - "sp-version", "thiserror", ] diff --git a/client/consensus/pow/src/lib.rs b/client/consensus/pow/src/lib.rs index 44eaccd2a40ac..513386fb22ac0 100644 --- a/client/consensus/pow/src/lib.rs +++ b/client/consensus/pow/src/lib.rs @@ -331,7 +331,8 @@ where .select_chain .best_chain() .await - .map_err(|e| format!("Fetch best chain failed via select chain: {}", e))?; + .map_err(|e| format!("Fetch best chain failed via select chain: {}", e)) + .map_err(ConsensusError::ChainLookup)?; let best_hash = best_header.hash(); let parent_hash = *block.header.parent_hash(); diff --git a/primitives/consensus/common/Cargo.toml b/primitives/consensus/common/Cargo.toml index 83b09f9eb47e2..1179261340f6e 100644 --- a/primitives/consensus/common/Cargo.toml +++ b/primitives/consensus/common/Cargo.toml @@ -15,9 +15,6 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] async-trait = "0.1.57" -codec = { package = "parity-scale-codec", version = "3.2.2", features = [ - "derive", -] } futures = { version = "0.3.21", features = ["thread-pool"] } log = "0.4.17" thiserror = "1.0.30" @@ -25,8 +22,6 @@ sp-core = { version = "7.0.0", path = "../../core" } sp-inherents = { version = "4.0.0-dev", path = "../../inherents" } sp-runtime = { version = "7.0.0", path = "../../runtime" } sp-state-machine = { version = "0.13.0", path = "../../state-machine" } -sp-std = { version = "5.0.0", path = "../../std" } -sp-version = { version = "5.0.0", path = "../../version" } [dev-dependencies] futures = "0.3.21" diff --git a/primitives/consensus/common/src/error.rs b/primitives/consensus/common/src/error.rs index 33c1afa63fe70..e881259da11e4 100644 --- a/primitives/consensus/common/src/error.rs +++ b/primitives/consensus/common/src/error.rs @@ -15,85 +15,42 @@ // See the License for the specific language governing permissions and // limitations under the License. -//! Error types in Consensus -use sp_core::ed25519::Public; -use sp_version::RuntimeVersion; -use std::error; +//! Error types for consensus modules. /// Result type alias. pub type Result = std::result::Result; -/// Error type. +/// The error type for consensus-related operations. #[derive(Debug, thiserror::Error)] -#[non_exhaustive] pub enum Error { /// Missing state at block with given descriptor. #[error("State unavailable at block {0}")] StateUnavailable(String), - /// I/O terminated unexpectedly - #[error("I/O terminated unexpectedly.")] - IoTerminated, /// Intermediate missing. - #[error("Missing intermediate.")] + #[error("Missing intermediate")] NoIntermediate, /// Intermediate is of wrong type. - #[error("Invalid intermediate.")] + #[error("Invalid intermediate")] InvalidIntermediate, - /// Unable to schedule wake-up. - #[error("Timer error: {0}")] - FaultyTimer(#[from] std::io::Error), - /// Error while working with inherent data. - #[error("InherentData error: {0}")] - InherentData(#[from] sp_inherents::Error), - /// Unable to propose a block. - #[error("Unable to create block proposal.")] - CannotPropose, - /// Error checking signature - #[error("Message signature {0:?} by {1:?} is invalid.")] + /// Error checking signature. + #[error("Message signature {0:?} by {1:?} is invalid")] InvalidSignature(Vec, Vec), /// Invalid authorities set received from the runtime. #[error("Current state of blockchain has invalid authorities set")] InvalidAuthoritiesSet, - /// Account is not an authority. - #[error("Message sender {0:?} is not a valid authority")] - InvalidAuthority(Public), - /// Authoring interface does not match the runtime. - #[error( - "Authoring for current \ - runtime is not supported. Native ({native}) cannot author for on-chain ({on_chain})." - )] - IncompatibleAuthoringRuntime { native: RuntimeVersion, on_chain: RuntimeVersion }, - /// Authoring interface does not match the runtime. - #[error("Authoring for current runtime is not supported since it has no version.")] - RuntimeVersionMissing, - /// Authoring interface does not match the runtime. - #[error("Authoring in current build is not supported since it has no runtime.")] - NativeRuntimeMissing, /// Justification requirements not met. - #[error("Invalid justification.")] + #[error("Invalid justification")] InvalidJustification, - /// Some other error. - #[error(transparent)] - Other(#[from] Box), - /// Error from the client while importing + /// Error from the client while importing. #[error("Import failed: {0}")] ClientImport(String), - /// Error from the client while importing + /// Error from the client while fetching some data from the chain. #[error("Chain lookup failed: {0}")] ChainLookup(String), - /// Signing failed + /// Signing failed. #[error("Failed to sign using key: {0:?}. Reason: {1}")] CannotSign(Vec, String), -} - -impl From for Error { - fn from(p: Public) -> Self { - Self::InvalidAuthority(p) - } -} - -impl From for Error { - fn from(s: String) -> Self { - Self::StateUnavailable(s) - } + /// Some other error. + #[error(transparent)] + Other(#[from] Box), } From 1349e6a43df8ba5af273038e2f862211d6ffec66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Wed, 1 Mar 2023 14:35:32 +0100 Subject: [PATCH 36/80] Expose `ChargedAmount` (#13488) * Expose `ChargedAmount` * Fix imports --- frame/contracts/src/chain_extension.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frame/contracts/src/chain_extension.rs b/frame/contracts/src/chain_extension.rs index 9b94542547ea8..56d41a759391b 100644 --- a/frame/contracts/src/chain_extension.rs +++ b/frame/contracts/src/chain_extension.rs @@ -71,7 +71,6 @@ //! on how to use a chain extension in order to provide new features to ink! contracts. use crate::{ - gas::ChargedAmount, wasm::{Runtime, RuntimeCosts}, Error, }; @@ -80,7 +79,7 @@ use frame_support::weights::Weight; use sp_runtime::DispatchError; use sp_std::{marker::PhantomData, vec::Vec}; -pub use crate::{exec::Ext, Config}; +pub use crate::{exec::Ext, gas::ChargedAmount, Config}; pub use frame_system::Config as SysConfig; pub use pallet_contracts_primitives::ReturnFlags; From 92b12318380b0e6b4f958e0dff9470c62b744856 Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Wed, 1 Mar 2023 18:04:09 +0200 Subject: [PATCH 37/80] sc-consensus-beefy: fix metrics: use correct names (#13494) Signed-off-by: acatangiu --- client/consensus/beefy/src/metrics.rs | 34 +++++++++++++++++++++------ 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/client/consensus/beefy/src/metrics.rs b/client/consensus/beefy/src/metrics.rs index 85438f1ca7cd6..0ce48e60ebc84 100644 --- a/client/consensus/beefy/src/metrics.rs +++ b/client/consensus/beefy/src/metrics.rs @@ -18,7 +18,8 @@ //! BEEFY Prometheus metrics definition -use log::debug; +use crate::LOG_TARGET; +use log::{debug, error}; use prometheus::{register, Counter, Gauge, PrometheusError, Registry, U64}; /// Helper trait for registering BEEFY metrics to Prometheus registry. @@ -129,13 +130,13 @@ impl PrometheusRegister for VoterMetrics { )?, beefy_equivocation_votes: register( Counter::new( - "substrate_beefy_stale_votes", + "substrate_beefy_equivocation_votes", "Number of equivocation votes received", )?, registry, )?, beefy_invalid_votes: register( - Counter::new("substrate_beefy_stale_votes", "Number of invalid votes received")?, + Counter::new("substrate_beefy_invalid_votes", "Number of invalid votes received")?, registry, )?, beefy_stale_votes: register( @@ -200,14 +201,14 @@ impl PrometheusRegister for BlockImportMetrics { beefy_good_justification_imports: register( Counter::new( "substrate_beefy_good_justification_imports", - "Number of Good Justification imports", + "Number of good justifications on block-import", )?, registry, )?, beefy_bad_justification_imports: register( Counter::new( "substrate_beefy_bad_justification_imports", - "Number of Bad Justification imports", + "Number of bad justifications on block-import", )?, registry, )?, @@ -309,11 +310,16 @@ pub(crate) fn register_metrics( ) -> Option { prometheus_registry.as_ref().map(T::register).and_then(|result| match result { Ok(metrics) => { - debug!(target: "beefy", "🥩 Registered {} metrics", T::DESCRIPTION); + debug!(target: LOG_TARGET, "🥩 Registered {} metrics", T::DESCRIPTION); Some(metrics) }, Err(err) => { - debug!(target: "beefy", "🥩 Failed to register {} metrics: {:?}", T::DESCRIPTION, err); + error!( + target: LOG_TARGET, + "🥩 Failed to register {} metrics: {:?}", + T::DESCRIPTION, + err + ); None }, }) @@ -347,3 +353,17 @@ macro_rules! metric_get { $self.metrics.as_ref().map(|metrics| metrics.$m.clone()) }}; } + +#[cfg(test)] +pub(crate) mod tests { + use super::*; + + #[test] + fn should_register_metrics() { + let registry = Some(Registry::new()); + assert!(register_metrics::(registry.clone()).is_some()); + assert!(register_metrics::(registry.clone()).is_some()); + assert!(register_metrics::(registry.clone()).is_some()); + assert!(register_metrics::(registry.clone()).is_some()); + } +} From 42eeb97e16f36e789303abfab113465c3f099cb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Wed, 1 Mar 2023 20:39:05 +0100 Subject: [PATCH 38/80] clippy fix --- frame/staking/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/staking/src/lib.rs b/frame/staking/src/lib.rs index 4c0a408b6c7cd..7c340fe2b2152 100644 --- a/frame/staking/src/lib.rs +++ b/frame/staking/src/lib.rs @@ -777,7 +777,7 @@ pub trait NominationsQuota { /// Returns the voter's nomination quota within reasonable bounds [`min`, `max`], where `min` /// is 1 and `max` is `Self::MaxNominations`. fn get_quota(balance: Balance) -> u32 { - Self::curve(balance).max(1).min(Self::MaxNominations::get()) + Self::curve(balance).clamp(1, Self::MaxNominations::get()) } // Returns the voter's nomination quota based on its balance and a curve. From d067a1c3e10640bb958d56107710a45553c705ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Mon, 6 Mar 2023 08:49:00 +0100 Subject: [PATCH 39/80] removes NominationsQuotaExceeded event --- frame/staking/src/pallet/impls.rs | 15 +++------------ frame/staking/src/pallet/mod.rs | 2 -- frame/staking/src/tests.rs | 7 +------ 3 files changed, 4 insertions(+), 20 deletions(-) diff --git a/frame/staking/src/pallet/impls.rs b/frame/staking/src/pallet/impls.rs index 846c62145f06f..490dc2370987e 100644 --- a/frame/staking/src/pallet/impls.rs +++ b/frame/staking/src/pallet/impls.rs @@ -787,18 +787,9 @@ impl Pallet { // if this voter is a nominator: let voter_weight = weight_of(&voter); if !targets.is_empty() { - // select only targets allowed by voter's nomination quota. - let nominations_quota = T::NominationsQuota::get_quota(voter_weight.into()); - - // if the current number of targets exceeds the nomination quota, emit an event - // but proceed without truncating or failing. The nomination quota checks are - // lazy and only fail when setting/updating the nominations. - if targets.len() > nominations_quota as usize { - Self::deposit_event(Event::::NominationsQuotaExceeded { - staker: voter.clone(), - exceeded_by: (targets.len() as u32 - nominations_quota).into(), - }); - } + // Note on lazy nomination quota: we do not check the nomination quota of the + // voter at this point and accept all the current nominations. The nomination + // quota is only enforced at `nominate` time. if voters_size_tracker.try_register_voter(targets.len(), voter_bounds).is_err() { diff --git a/frame/staking/src/pallet/mod.rs b/frame/staking/src/pallet/mod.rs index b5cfd0dd199bc..ed42977b53f16 100644 --- a/frame/staking/src/pallet/mod.rs +++ b/frame/staking/src/pallet/mod.rs @@ -723,8 +723,6 @@ pub mod pallet { PayoutStarted { era_index: EraIndex, validator_stash: T::AccountId }, /// A validator has set their preferences. ValidatorPrefsSet { stash: T::AccountId, prefs: ValidatorPrefs }, - /// The number of nominations has exceeded the allowed by the voter's nomination quota. - NominationsQuotaExceeded { staker: T::AccountId, exceeded_by: BalanceOf }, /// Voters size limit reached due to too many nominations. SnapshotVotersSizeExceeded { size: u32 }, /// A new force era mode was set. diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index 2915755daa204..18132ac3efe97 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -4646,7 +4646,7 @@ mod election_data_provider { assert_ok!(Staking::unbond(RuntimeOrigin::signed(60), 78)); // even through 61 has nomination quota of 2 at the time of the election, all the - // nominations (5) will be used and an `Event::NominationsQuotaExceeded` emitted. + // nominations (5) will be used. assert_eq!( Staking::electing_voters(DataProviderBounds::new_unbounded()) .unwrap() @@ -4655,11 +4655,6 @@ mod election_data_provider { .collect::>(), vec![(11, 1), (21, 1), (31, 1), (61, 5)], ); - - assert_eq!( - *staking_events().last().unwrap(), - Event::NominationsQuotaExceeded { staker: 61, exceeded_by: 3 } - ); }); } From 422393c0ef687197067669dd166e24e8667ba99f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Thu, 16 Mar 2023 12:20:39 +0000 Subject: [PATCH 40/80] Update frame/staking/src/lib.rs Co-authored-by: Ross Bulat --- frame/staking/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/frame/staking/src/lib.rs b/frame/staking/src/lib.rs index 7c340fe2b2152..677774025e0af 100644 --- a/frame/staking/src/lib.rs +++ b/frame/staking/src/lib.rs @@ -317,7 +317,6 @@ use sp_staking::{ EraIndex, SessionIndex, }; use sp_std::{collections::btree_map::BTreeMap, prelude::*}; - pub use weights::WeightInfo; pub use pallet::{pallet::*, *}; From fb418a934d52886398ef67691f8fac39866dbf81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Thu, 16 Mar 2023 13:28:43 +0100 Subject: [PATCH 41/80] adds back the npos_max_iter --- frame/staking/src/pallet/impls.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frame/staking/src/pallet/impls.rs b/frame/staking/src/pallet/impls.rs index 490dc2370987e..a755df4ed3b09 100644 --- a/frame/staking/src/pallet/impls.rs +++ b/frame/staking/src/pallet/impls.rs @@ -774,7 +774,9 @@ impl Pallet { let mut min_active_stake = u64::MAX; let mut sorted_voters = T::VoterList::iter(); - while all_voters.len() < max_allowed_len as usize { + while all_voters.len() < max_allowed_len as usize && + voters_seen < (NPOS_MAX_ITERATIONS_COEFFICIENT * max_allowed_len as u32) + { let voter = match sorted_voters.next() { Some(voter) => { voters_seen.saturating_inc(); From af3b8baf87694e0a7e25478c3726fd73b49e8ba9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Thu, 16 Mar 2023 14:10:51 +0100 Subject: [PATCH 42/80] remove duplicate imports added after merge --- frame/nomination-pools/benchmarking/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/frame/nomination-pools/benchmarking/src/lib.rs b/frame/nomination-pools/benchmarking/src/lib.rs index 701df90ef479c..26ebb8c7e76a5 100644 --- a/frame/nomination-pools/benchmarking/src/lib.rs +++ b/frame/nomination-pools/benchmarking/src/lib.rs @@ -40,7 +40,6 @@ use sp_runtime::{ Perbill, }; use pallet_staking::MaxNominationsOf; -use sp_runtime::traits::{Bounded, StaticLookup, Zero}; use sp_staking::{EraIndex, StakingInterface}; // `frame_benchmarking::benchmarks!` macro needs this use pallet_nomination_pools::Call; From 7d8ffda76217e6099d746c64bed74b0a94578428 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Thu, 16 Mar 2023 14:18:23 +0100 Subject: [PATCH 43/80] fmt --- frame/nomination-pools/benchmarking/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/nomination-pools/benchmarking/src/lib.rs b/frame/nomination-pools/benchmarking/src/lib.rs index 26ebb8c7e76a5..60602864f4f65 100644 --- a/frame/nomination-pools/benchmarking/src/lib.rs +++ b/frame/nomination-pools/benchmarking/src/lib.rs @@ -35,11 +35,11 @@ use pallet_nomination_pools::{ MaxPoolMembersPerPool, MaxPools, Metadata, MinCreateBond, MinJoinBond, Pallet as Pools, PoolMembers, PoolRoles, PoolState, RewardPools, SubPoolsStorage, }; +use pallet_staking::MaxNominationsOf; use sp_runtime::{ traits::{Bounded, StaticLookup, Zero}, Perbill, }; -use pallet_staking::MaxNominationsOf; use sp_staking::{EraIndex, StakingInterface}; // `frame_benchmarking::benchmarks!` macro needs this use pallet_nomination_pools::Call; From 1246c7398fcb725f757103edc0f1237319d4d779 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Tue, 21 Mar 2023 12:42:02 +0100 Subject: [PATCH 44/80] Adds comment in public struct; Refactors CountBound and SizeCount to struct --- bin/node/runtime/src/lib.rs | 4 +- frame/babe/src/mock.rs | 2 +- frame/beefy/src/mock.rs | 2 +- .../election-provider-multi-phase/src/lib.rs | 26 ++++--- .../election-provider-multi-phase/src/mock.rs | 4 +- .../src/signed.rs | 4 +- frame/election-provider-support/src/lib.rs | 69 +++++++++++++++++-- .../election-provider-support/src/onchain.rs | 2 +- frame/election-provider-support/src/tests.rs | 52 +++++++------- frame/grandpa/src/mock.rs | 2 +- frame/offences/benchmarking/src/mock.rs | 2 +- frame/root-offences/src/mock.rs | 2 +- frame/session/benchmarking/src/mock.rs | 2 +- frame/staking/src/lib.rs | 2 +- frame/staking/src/pallet/impls.rs | 22 ++++-- frame/staking/src/tests.rs | 38 +++++----- 16 files changed, 160 insertions(+), 75 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index b02057d4027ed..f4723304a1207 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -635,10 +635,10 @@ frame_election_provider_support::generate_solution_type!( ); parameter_types! { - pub ElectionBoundsMultiPhase: ElectionBounds = ElectionBoundsBuilder::new().voters_count(40_000).targets_count(10_000).build(); + pub ElectionBoundsMultiPhase: ElectionBounds = ElectionBoundsBuilder::new().voters_count(40_000.into()).targets_count(10_000.into()).build(); pub MaxNominations: u32 = ::LIMIT as u32; // OnChain values are lower. - pub ElectionBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::new().voters_count(5_000).targets_count(1_250).build(); + pub ElectionBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::new().voters_count(5_000.into()).targets_count(1_250.into()).build(); // The maximum winners that can be elected by the Election pallet which is equivalent to the // maximum active validators the staking pallet can have. pub MaxActiveValidators: u32 = 1000; diff --git a/frame/babe/src/mock.rs b/frame/babe/src/mock.rs index d8c7b78c60e3e..192df562b3422 100644 --- a/frame/babe/src/mock.rs +++ b/frame/babe/src/mock.rs @@ -166,7 +166,7 @@ parameter_types! { pub const SlashDeferDuration: EraIndex = 0; pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE; pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(16); - pub static ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::new().build(); + pub const ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::new().build(); } pub struct OnChainSeqPhragmen; diff --git a/frame/beefy/src/mock.rs b/frame/beefy/src/mock.rs index 8d2b5542248d2..824153dbc2b2c 100644 --- a/frame/beefy/src/mock.rs +++ b/frame/beefy/src/mock.rs @@ -188,7 +188,7 @@ parameter_types! { pub const BondingDuration: EraIndex = 3; pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE; pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17); - pub static ElectionsBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::new().build(); + pub const ElectionsBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::new().build(); } pub struct OnChainSeqPhragmen; diff --git a/frame/election-provider-multi-phase/src/lib.rs b/frame/election-provider-multi-phase/src/lib.rs index 7349caa07e6b6..a83b19dab0ab5 100644 --- a/frame/election-provider-multi-phase/src/lib.rs +++ b/frame/election-provider-multi-phase/src/lib.rs @@ -1086,8 +1086,8 @@ pub mod pallet { T::ForceOrigin::ensure_origin(origin)?; ensure!(Self::current_phase().is_emergency(), >::CallNotAllowed); let election_bounds = ElectionBoundsBuilder::new() - .voters_count(maybe_max_voters.unwrap_or(0)) - .targets_count(maybe_max_targets.unwrap_or(0)) + .voters_count(maybe_max_voters.unwrap_or(0).into()) + .targets_count(maybe_max_targets.unwrap_or(0).into()) .build(); let supports = T::GovernanceFallback::instant_elect( election_bounds.voters, @@ -1414,10 +1414,18 @@ impl Pallet { fn create_snapshot_external( ) -> Result<(Vec, Vec>, u32), ElectionError> { let election_bounds = T::ElectionBounds::get(); - let target_limit = - election_bounds.targets.count.unwrap_or(u32::MAX).saturated_into::(); - let voter_limit = - election_bounds.voters.count.unwrap_or(u32::MAX).saturated_into::(); + let target_limit = election_bounds + .targets + .count + .unwrap_or(u32::MAX.into()) + .0 + .saturated_into::(); + let voter_limit = election_bounds + .voters + .count + .unwrap_or(u32::MAX.into()) + .0 + .saturated_into::(); let targets = T::DataProvider::electable_targets(election_bounds.targets) .map_err(ElectionError::DataProvider)?; @@ -2428,7 +2436,7 @@ mod tests { // the `MockStaking` is designed such that if it has too many targets, it simply fails. ExtBuilder::default().build_and_execute(|| { // sets bounds on number of targets. - let new_bounds = ElectionBoundsBuilder::new().targets_count(1_000).build(); + let new_bounds = ElectionBoundsBuilder::new().targets_count(1_000.into()).build(); crate::mock::ElectionsBounds::set(new_bounds); crate::mock::Targets::set((0..(1_000 as AccountId) + 1).collect::>()); @@ -2467,7 +2475,7 @@ mod tests { // and if the backup mode is nothing, we go into the emergency mode.. ExtBuilder::default().onchain_fallback(false).build_and_execute(|| { // sets bounds on number of targets. - let new_bounds = ElectionBoundsBuilder::new().targets_count(1_000).build(); + let new_bounds = ElectionBoundsBuilder::new().targets_count(1_000.into()).build(); crate::mock::ElectionsBounds::set(new_bounds); crate::mock::Targets::set((0..(1_000 as AccountId) + 1).collect::>()); @@ -2502,7 +2510,7 @@ mod tests { // we have 8 voters in total. assert_eq!(crate::mock::Voters::get().len(), 8); // but we want to take 2. - let new_bounds = ElectionBoundsBuilder::new().voters_count(2).build(); + let new_bounds = ElectionBoundsBuilder::new().voters_count(2.into()).build(); crate::mock::ElectionsBounds::set(new_bounds); // Signed phase opens just fine. diff --git a/frame/election-provider-multi-phase/src/mock.rs b/frame/election-provider-multi-phase/src/mock.rs index 62d09a1205cae..7e38a1240680b 100644 --- a/frame/election-provider-multi-phase/src/mock.rs +++ b/frame/election-provider-multi-phase/src/mock.rs @@ -443,7 +443,7 @@ impl ElectionDataProvider for StakingMock { let targets = Targets::get(); if !DataProviderAllowBadData::get() && - bounds.count.map_or(false, |max_len| targets.len() > max_len as usize) + bounds.count.map_or(false, |max_len| targets.len() > max_len.0 as usize) { return Err("Targets too big") } @@ -456,7 +456,7 @@ impl ElectionDataProvider for StakingMock { if !DataProviderAllowBadData::get() { if let Some(max_len) = bounds.count { - voters.truncate(max_len as usize) + voters.truncate(max_len.0 as usize) } } diff --git a/frame/election-provider-multi-phase/src/signed.rs b/frame/election-provider-multi-phase/src/signed.rs index a319086a79a57..0c2a4c644594a 100644 --- a/frame/election-provider-multi-phase/src/signed.rs +++ b/frame/election-provider-multi-phase/src/signed.rs @@ -561,7 +561,7 @@ mod tests { fn data_provider_should_respect_target_limits() { ExtBuilder::default().build_and_execute(|| { // given a reduced expectation of maximum electable targets - let new_bounds = crate::ElectionBoundsBuilder::new().targets_count(2).build(); + let new_bounds = crate::ElectionBoundsBuilder::new().targets_count(2.into()).build(); ElectionsBounds::set(new_bounds); // and a data provider that does not respect limits DataProviderAllowBadData::set(true); @@ -577,7 +577,7 @@ mod tests { fn data_provider_should_respect_voter_limits() { ExtBuilder::default().build_and_execute(|| { // given a reduced expectation of maximum electing voters - let new_bounds = crate::ElectionBoundsBuilder::new().voters_count(2).build(); + let new_bounds = crate::ElectionBoundsBuilder::new().voters_count(2.into()).build(); ElectionsBounds::set(new_bounds); // and a data provider that does not respect limits DataProviderAllowBadData::set(true); diff --git a/frame/election-provider-support/src/lib.rs b/frame/election-provider-support/src/lib.rs index 57e5bcd356b9d..6aa0ca73cb0b7 100644 --- a/frame/election-provider-support/src/lib.rs +++ b/frame/election-provider-support/src/lib.rs @@ -175,6 +175,8 @@ pub mod onchain; pub mod traits; +use core::ops::Add; + use sp_runtime::traits::{Bounded, Saturating, Zero}; use sp_std::{fmt::Debug, prelude::*}; @@ -664,14 +666,65 @@ pub type BoundedSupportsOf = BoundedSupports< ::AccountId, ::MaxWinners, >; + /// Count bound of data provider bounds. -pub type CountBound = u32; +#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)] +pub struct CountBound(pub u32); + +impl From for CountBound { + fn from(value: u32) -> Self { + CountBound(value) + } +} + +impl Add for CountBound { + type Output = Self; + fn add(self, rhs: Self) -> Self::Output { + CountBound(self.0 + rhs.0) + } +} + +impl Zero for CountBound { + fn is_zero(&self) -> bool { + self.0 == 0 + } + fn zero() -> Self { + CountBound(0) + } +} + /// Size bound of data provider bounds. -pub type SizeBound = u32; +#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)] +pub struct SizeBound(pub u32); + +impl Zero for SizeBound { + fn is_zero(&self) -> bool { + self.0 == 0 + } + fn zero() -> Self { + SizeBound(0) + } +} + +impl Add for SizeBound { + type Output = Self; + fn add(self, rhs: Self) -> Self::Output { + SizeBound(self.0 + rhs.0) + } +} + +impl From for SizeBound { + fn from(value: u32) -> Self { + SizeBound(value) + } +} sp_core::generate_feature_enabled_macro!(runtime_benchmarks_enabled, feature = "runtime-benchmarks", $); sp_core::generate_feature_enabled_macro!(runtime_benchmarks_or_fuzz_enabled, any(feature = "runtime-benchmarks", feature = "fuzzing"), $); +/// Data provider limits that can be bounded based on the count of elements or the scale encoded +/// size of the final result in MB. It can be used to represent the bounds of election targets +/// and voters or any other future unit. #[derive(Clone, Copy, Default, Debug)] pub struct DataProviderBounds { pub count: Option, @@ -697,16 +750,20 @@ impl DataProviderBounds { /// Returns true if `given_size` or `given_count` exhausts `self.size` or `self_count`, /// respectively. pub fn exhausted(self, given_size: Option, given_count: Option) -> bool { - self.count_exhausted(given_count.unwrap_or(0)) || - self.size_exhausted(given_size.unwrap_or(0)) + self.count_exhausted(given_count.unwrap_or(CountBound::zero())) || + self.size_exhausted(given_size.unwrap_or(SizeBound::zero())) } /// Returns an instance of `Self` that is constructed by capping both the `count` and `size` /// fields. pub fn max(self, bounds: DataProviderBounds) -> Self { DataProviderBounds { - count: self.count.map(|c| c.clamp(0, bounds.count.unwrap_or(u32::MAX)).into()), - size: self.size.map(|c| c.clamp(0, bounds.size.unwrap_or(u32::MAX)).into()), + count: self.count.map(|c| { + c.clamp(CountBound::zero(), bounds.count.unwrap_or(CountBound(u32::MAX))).into() + }), + size: self.size.map(|c| { + c.clamp(SizeBound::zero(), bounds.size.unwrap_or(SizeBound(u32::MAX))).into() + }), } } } diff --git a/frame/election-provider-support/src/onchain.rs b/frame/election-provider-support/src/onchain.rs index bc93aad22758e..70a7e21e8e4c3 100644 --- a/frame/election-provider-support/src/onchain.rs +++ b/frame/election-provider-support/src/onchain.rs @@ -234,7 +234,7 @@ mod tests { parameter_types! { pub static MaxWinners: u32 = 10; pub static DesiredTargets: u32 = 2; - pub static ElectionBounds: crate::ElectionBounds = ElectionBoundsBuilder::new().voters_count(600).targets_count(400).build(); + pub static ElectionBounds: crate::ElectionBounds = ElectionBoundsBuilder::new().voters_count(600.into()).targets_count(400.into()).build(); } impl Config for PhragmenParams { diff --git a/frame/election-provider-support/src/tests.rs b/frame/election-provider-support/src/tests.rs index cb778075a7452..8fa0ff8461331 100644 --- a/frame/election-provider-support/src/tests.rs +++ b/frame/election-provider-support/src/tests.rs @@ -461,7 +461,7 @@ mod elections_bounds { fn data_provider_bounds_unbounded() { let bounds = DataProviderBounds::new_unbounded(); assert!(!bounds.exhausted(None, None)); - assert!(!bounds.exhausted(Some(10_000), Some(10_000))); + assert!(!bounds.exhausted(SizeBound(10_000).into(), CountBound(10_000).into())); } #[test] @@ -469,40 +469,46 @@ mod elections_bounds { // voter bounds exhausts if count > 100 or size > 1_000; target bounds exhausts if count > // 200 or size > 2_000. let bounds = ElectionBoundsBuilder::new() - .voters_count(100) - .voters_size(1_000) - .targets_count(200) - .targets_size(2_000) + .voters_count(100.into()) + .voters_size(1_000.into()) + .targets_count(200.into()) + .targets_size(2_000.into()) .build(); assert!(!bounds.voters.exhausted(None, None)); - assert!(!bounds.voters.exhausted(10.into(), 10.into())); - assert!(!bounds.voters.exhausted(None, 100.into())); - assert!(!bounds.voters.exhausted(1_000.into(), None)); - assert!(bounds.voters.exhausted(None, 101.into())); - assert!(bounds.voters.exhausted(1_001.into(), None)); + assert!(!bounds.voters.exhausted(SizeBound(10).into(), CountBound(10).into())); + assert!(!bounds.voters.exhausted(None, CountBound(100).into())); + assert!(!bounds.voters.exhausted(SizeBound(1_000).into(), None)); + assert!(bounds.voters.exhausted(None, CountBound(101).into())); + assert!(bounds.voters.exhausted(SizeBound(1_001).into(), None)); assert!(!bounds.targets.exhausted(None, None)); - assert!(!bounds.targets.exhausted(20.into(), 20.into())); - assert!(!bounds.targets.exhausted(None, 200.into())); - assert!(!bounds.targets.exhausted(2_000.into(), None)); - assert!(bounds.targets.exhausted(None, 201.into())); - assert!(bounds.targets.exhausted(2_001.into(), None)); + assert!(!bounds.targets.exhausted(SizeBound(20).into(), CountBound(20).into())); + assert!(!bounds.targets.exhausted(None, CountBound(200).into())); + assert!(!bounds.targets.exhausted(SizeBound(2_000).into(), None)); + assert!(bounds.targets.exhausted(None, CountBound(201).into())); + assert!(bounds.targets.exhausted(SizeBound(2_001).into(), None)); } #[test] fn election_bounds_clamp_works() { let bounds = ElectionBoundsBuilder::new() - .voters_count(10) - .voters_size(10) - .max_voters(DataProviderBounds { count: 5.into(), size: 20.into() }) - .targets_count(20) - .max_targets(DataProviderBounds { count: 30.into(), size: 30.into() }) + .voters_count(10.into()) + .voters_size(10.into()) + .max_voters(DataProviderBounds { + count: CountBound(5).into(), + size: SizeBound(20).into(), + }) + .targets_count(20.into()) + .max_targets(DataProviderBounds { + count: CountBound(30).into(), + size: SizeBound(30).into(), + }) .build(); - assert_eq!(bounds.voters.count, 5.into()); - assert_eq!(bounds.voters.size, 10.into()); - assert_eq!(bounds.targets.count, 20.into()); + assert_eq!(bounds.voters.count.unwrap(), CountBound(5)); + assert_eq!(bounds.voters.size.unwrap(), SizeBound(10)); + assert_eq!(bounds.targets.count.unwrap(), CountBound(20)); assert_eq!(bounds.targets.size, None); } } diff --git a/frame/grandpa/src/mock.rs b/frame/grandpa/src/mock.rs index fafeecb1cf04e..5fdfe264cdb47 100644 --- a/frame/grandpa/src/mock.rs +++ b/frame/grandpa/src/mock.rs @@ -169,7 +169,7 @@ parameter_types! { pub const BondingDuration: EraIndex = 3; pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE; pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17); - pub static ElectionsBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::new().build(); + pub const ElectionsBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::new().build(); } pub struct OnChainSeqPhragmen; diff --git a/frame/offences/benchmarking/src/mock.rs b/frame/offences/benchmarking/src/mock.rs index 5484cb95101cc..f8677d29b7d23 100644 --- a/frame/offences/benchmarking/src/mock.rs +++ b/frame/offences/benchmarking/src/mock.rs @@ -140,7 +140,7 @@ pallet_staking_reward_curve::build! { } parameter_types! { pub const RewardCurve: &'static sp_runtime::curve::PiecewiseLinear<'static> = &I_NPOS; - pub static ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::new().build(); + pub const ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::new().build(); } pub type Extrinsic = sp_runtime::testing::TestXt; diff --git a/frame/root-offences/src/mock.rs b/frame/root-offences/src/mock.rs index 3b39e1ffeb630..577feb65b231f 100644 --- a/frame/root-offences/src/mock.rs +++ b/frame/root-offences/src/mock.rs @@ -137,7 +137,7 @@ pallet_staking_reward_curve::build! { } parameter_types! { - pub static ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::new().build(); + pub const ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::new().build(); } pub struct OnChainSeqPhragmen; diff --git a/frame/session/benchmarking/src/mock.rs b/frame/session/benchmarking/src/mock.rs index cf211b3cdb5f3..f95ccb3e0759f 100644 --- a/frame/session/benchmarking/src/mock.rs +++ b/frame/session/benchmarking/src/mock.rs @@ -144,7 +144,7 @@ pallet_staking_reward_curve::build! { } parameter_types! { pub const RewardCurve: &'static sp_runtime::curve::PiecewiseLinear<'static> = &I_NPOS; - pub static ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::new().build(); + pub const ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::new().build(); } pub struct OnChainSeqPhragmen; diff --git a/frame/staking/src/lib.rs b/frame/staking/src/lib.rs index 677774025e0af..3197960bb7415 100644 --- a/frame/staking/src/lib.rs +++ b/frame/staking/src/lib.rs @@ -833,7 +833,7 @@ impl ElectionSizeTracker { let voter_size = Self::voter_size(votes); let size_after = self.size.saturating_add(voter_size); - match bounds.size_exhausted(size_after as SizeBound) { + match bounds.size_exhausted(SizeBound(size_after as u32)) { true => Err(()), false => { self.size = size_after; diff --git a/frame/staking/src/pallet/impls.rs b/frame/staking/src/pallet/impls.rs index 860b2b75c4627..a1717329cdfdf 100644 --- a/frame/staking/src/pallet/impls.rs +++ b/frame/staking/src/pallet/impls.rs @@ -18,8 +18,8 @@ //! Implementations for the Staking FRAME Pallet. use frame_election_provider_support::{ - data_provider, BoundedSupportsOf, DataProviderBounds, ElectionDataProvider, ElectionProvider, - ScoreProvider, SortedListProvider, VoteWeight, VoterOf, + data_provider, BoundedSupportsOf, CountBound, DataProviderBounds, ElectionDataProvider, + ElectionProvider, ScoreProvider, SizeBound, SortedListProvider, VoteWeight, VoterOf, }; use frame_support::{ dispatch::WithPostDispatchInfo, @@ -760,7 +760,11 @@ impl Pallet { let max_allowed_len = { let all_voter_count = T::VoterList::count(); - voter_bounds.count.unwrap_or(all_voter_count).min(all_voter_count) + voter_bounds + .count + .unwrap_or(all_voter_count.into()) + .min(all_voter_count.into()) + .0 }; let mut all_voters = Vec::<_>::with_capacity(max_allowed_len as usize); @@ -868,7 +872,11 @@ impl Pallet { pub fn get_npos_targets(target_bounds: DataProviderBounds) -> Vec { let max_allowed_len = { let all_target_count = T::TargetList::count(); - target_bounds.count.unwrap_or(all_target_count).min(all_target_count) + target_bounds + .count + .unwrap_or(all_target_count.into()) + .min(all_target_count.into()) + .0 }; let mut all_targets = Vec::::with_capacity(max_allowed_len as usize); @@ -1024,8 +1032,8 @@ impl ElectionDataProvider for Pallet { let voters = Self::get_npos_voters(bounds); debug_assert!(!bounds.exhausted( - (voters.encoded_size().saturating_sub(1) as u32).into(), - (voters.len() as u32).into() + SizeBound(voters.encoded_size().saturating_sub(1) as u32).into(), + CountBound(voters.len() as u32).into() )); Ok(voters) @@ -1035,7 +1043,7 @@ impl ElectionDataProvider for Pallet { let target_count = T::TargetList::count(); // We can't handle this case yet -- return an error. - if bounds.exhausted(None, Some(target_count as u32)) { + if bounds.exhausted(None, CountBound(target_count as u32).into()) { return Err("Target snapshot too big") } diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index 5e72e4310565c..9b4dd236e035b 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -4514,7 +4514,7 @@ mod election_data_provider { // remove staker with lower bond by limiting the number of voters and check // `MinimumActiveStake` again after electing voters. - let bounds = ElectionBoundsBuilder::new().voters_count(5).build(); + let bounds = ElectionBoundsBuilder::new().voters_count(5.into()).build(); assert_ok!(::electing_voters(bounds.voters)); assert_eq!(MinimumActiveStake::::get(), 50); }); @@ -4554,7 +4554,7 @@ mod election_data_provider { // if limits is less.. assert_eq!( - Staking::electing_voters(bounds_builder.voters_count(1).build().voters) + Staking::electing_voters(bounds_builder.voters_count(1.into()).build().voters) .unwrap() .len(), 1 @@ -4562,7 +4562,7 @@ mod election_data_provider { // if limit is equal.. assert_eq!( - Staking::electing_voters(bounds_builder.voters_count(5).build().voters) + Staking::electing_voters(bounds_builder.voters_count(5.into()).build().voters) .unwrap() .len(), 5 @@ -4570,7 +4570,7 @@ mod election_data_provider { // if limit is more. assert_eq!( - Staking::electing_voters(bounds_builder.voters_count(55).build().voters) + Staking::electing_voters(bounds_builder.voters_count(55.into()).build().voters) .unwrap() .len(), 5 @@ -4578,22 +4578,28 @@ mod election_data_provider { // if target limit is more.. assert_eq!( - Staking::electable_targets(bounds_builder.targets_count(6).build().targets) - .unwrap() - .len(), + Staking::electable_targets( + bounds_builder.targets_count(6.into()).build().targets + ) + .unwrap() + .len(), 4 ); assert_eq!( - Staking::electable_targets(bounds_builder.targets_count(4).build().targets) - .unwrap() - .len(), + Staking::electable_targets( + bounds_builder.targets_count(4.into()).build().targets + ) + .unwrap() + .len(), 4 ); // if target limit is less, then we return an error. assert_eq!( - Staking::electable_targets(bounds_builder.targets_count(1).build().targets) - .unwrap_err(), + Staking::electable_targets( + bounds_builder.targets_count(1.into()).build().targets + ) + .unwrap_err(), "Target snapshot too big" ); }); @@ -4604,7 +4610,7 @@ mod election_data_provider { ExtBuilder::default().build_and_execute(|| { let bounds_builder = ElectionBoundsBuilder::new(); assert_eq!( - Staking::electing_voters(bounds_builder.voters_size(25).build().voters) + Staking::electing_voters(bounds_builder.voters_size(25.into()).build().voters) .unwrap() .len(), 1 @@ -4670,7 +4676,7 @@ mod election_data_provider { ) .build_and_execute(|| { // nominations of controller 70 won't be added due to voter size limit exceeded. - let bounds = ElectionBoundsBuilder::new().voters_size(100).build(); + let bounds = ElectionBoundsBuilder::new().voters_size(100.into()).build(); assert_eq!( Staking::electing_voters(bounds.voters) .unwrap() @@ -4687,7 +4693,7 @@ mod election_data_provider { // however, if the election voter size bounds were largers, the snapshot would // include the electing voters of 70. - let bounds = ElectionBoundsBuilder::new().voters_size(1_000).build(); + let bounds = ElectionBoundsBuilder::new().voters_size(1_000.into()).build(); assert_eq!( Staking::electing_voters(bounds.voters) .unwrap() @@ -5901,7 +5907,7 @@ mod election_size_tracker { #[test] pub fn election_size_tracker_works() { let mut size_tracker = ElectionSizeTracker::::new(); - let voter_bounds = ElectionBoundsBuilder::new().voters_size(1_00).build().voters; + let voter_bounds = ElectionBoundsBuilder::new().voters_size(1_00.into()).build().voters; assert!(size_tracker.try_register_voter(1, voter_bounds).is_ok()); assert!(size_tracker.try_register_voter(2, voter_bounds).is_ok()); From 325c91f8957f048363216fd389d9daa4fc8468cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Tue, 21 Mar 2023 13:11:51 +0100 Subject: [PATCH 45/80] addresses various pr comments --- bin/node/runtime/src/lib.rs | 2 +- .../election-provider-multi-phase/src/mock.rs | 2 +- frame/election-provider-support/src/onchain.rs | 18 +++++++++--------- frame/staking/src/lib.rs | 10 ++-------- frame/staking/src/mock.rs | 2 +- frame/staking/src/pallet/impls.rs | 8 ++++---- 6 files changed, 18 insertions(+), 24 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index f4723304a1207..6557a03511986 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -693,7 +693,7 @@ impl onchain::Config for OnChainSeqPhragmen { type DataProvider = ::DataProvider; type WeightInfo = frame_election_provider_support::weights::SubstrateWeight; type MaxWinners = ::MaxWinners; - type ElectionBounds = ElectionBoundsOnChain; + type Bounds = ElectionBoundsOnChain; } impl pallet_election_provider_multi_phase::MinerConfig for Runtime { diff --git a/frame/election-provider-multi-phase/src/mock.rs b/frame/election-provider-multi-phase/src/mock.rs index 7e38a1240680b..0196d00012c29 100644 --- a/frame/election-provider-multi-phase/src/mock.rs +++ b/frame/election-provider-multi-phase/src/mock.rs @@ -314,7 +314,7 @@ impl onchain::Config for OnChainSeqPhragmen { type DataProvider = StakingMock; type WeightInfo = (); type MaxWinners = MaxWinners; - type ElectionBounds = ElectionsBoundsOnChain; + type Bounds = ElectionsBoundsOnChain; } pub struct MockFallback; diff --git a/frame/election-provider-support/src/onchain.rs b/frame/election-provider-support/src/onchain.rs index 70a7e21e8e4c3..8f023b4c28efa 100644 --- a/frame/election-provider-support/src/onchain.rs +++ b/frame/election-provider-support/src/onchain.rs @@ -88,7 +88,7 @@ pub trait Config { /// Elections bounds, to use when calling into /// [`Config::DataProvider`]. It might be overwritten in the `InstantElectionProvider` impl. - type ElectionBounds: Get; + type Bounds: Get; } /// Same as `BoundedSupportsOf` but for `onchain::Config`. @@ -155,12 +155,12 @@ impl ElectionProviderBase for OnChainExecution { impl InstantElectionProvider for OnChainExecution { fn instant_elect( - voters_bounds: DataProviderBounds, - targets_bounds: DataProviderBounds, + forced_input_voters_bounds: DataProviderBounds, + forced_input_targets_bounds: DataProviderBounds, ) -> Result, Self::Error> { - let elections_bounds = ElectionBoundsBuilder::from(T::ElectionBounds::get()) - .max_voters(voters_bounds) - .max_targets(targets_bounds) + let elections_bounds = ElectionBoundsBuilder::from(T::Bounds::get()) + .max_voters(forced_input_voters_bounds) + .max_targets(forced_input_targets_bounds) .build(); elect_with_input_bounds::(elections_bounds) } @@ -172,7 +172,7 @@ impl ElectionProvider for OnChainExecution { } fn elect() -> Result, Self::Error> { - let election_bounds = ElectionBoundsBuilder::from(T::ElectionBounds::get()).build(); + let election_bounds = ElectionBoundsBuilder::from(T::Bounds::get()).build(); elect_with_input_bounds::(election_bounds) } } @@ -243,7 +243,7 @@ mod tests { type DataProvider = mock_data_provider::DataProvider; type WeightInfo = (); type MaxWinners = MaxWinners; - type ElectionBounds = ElectionBounds; + type Bounds = ElectionBounds; } impl Config for PhragMMSParams { @@ -252,7 +252,7 @@ mod tests { type DataProvider = mock_data_provider::DataProvider; type WeightInfo = (); type MaxWinners = MaxWinners; - type ElectionBounds = ElectionBounds; + type Bounds = ElectionBounds; } mod mock_data_provider { diff --git a/frame/staking/src/lib.rs b/frame/staking/src/lib.rs index 3197960bb7415..12d4ffc438958 100644 --- a/frame/staking/src/lib.rs +++ b/frame/staking/src/lib.rs @@ -302,7 +302,7 @@ mod pallet; use codec::{Decode, Encode, HasCompact, MaxEncodedLen}; use frame_election_provider_support::{DataProviderBounds, SizeBound, VoteWeight}; use frame_support::{ - traits::{Currency, Defensive, Get}, + traits::{ConstU32, Currency, Defensive, Get}, weights::Weight, BoundedVec, CloneNoBound, EqNoBound, PartialEqNoBound, RuntimeDebugNoBound, }; @@ -786,19 +786,13 @@ pub trait NominationsQuota { /// A nomination quota that allows up to MAX nominations for all validators. pub struct FixedNominationsQuota; impl NominationsQuota for FixedNominationsQuota { - type MaxNominations = Self; + type MaxNominations = ConstU32; fn curve(_: Balance) -> u32 { MAX } } -impl Get for FixedNominationsQuota { - fn get() -> u32 { - MAX - } -} - /// A static tracker for the election data snapshot. /// /// Computes the (SCALE) encoded byte length of a snapshot based on static rules, without any actual diff --git a/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index fd3a9928e6ebe..27d76ab801be0 100644 --- a/frame/staking/src/mock.rs +++ b/frame/staking/src/mock.rs @@ -256,7 +256,7 @@ impl onchain::Config for OnChainSeqPhragmen { type DataProvider = Staking; type WeightInfo = (); type MaxWinners = MaxWinners; - type ElectionBounds = ElectionsBounds; + type Bounds = ElectionsBounds; } pub struct MockReward {} diff --git a/frame/staking/src/pallet/impls.rs b/frame/staking/src/pallet/impls.rs index a1717329cdfdf..29035a0e6d25a 100644 --- a/frame/staking/src/pallet/impls.rs +++ b/frame/staking/src/pallet/impls.rs @@ -755,12 +755,12 @@ impl Pallet { /// nominators. /// /// This function is self-weighing as [`DispatchClass::Mandatory`]. - pub fn get_npos_voters(voter_bounds: DataProviderBounds) -> Vec> { + pub fn get_npos_voters(bounds: DataProviderBounds) -> Vec> { let mut voters_size_tracker: ElectionSizeTracker = ElectionSizeTracker::new(); let max_allowed_len = { let all_voter_count = T::VoterList::count(); - voter_bounds + bounds .count .unwrap_or(all_voter_count.into()) .min(all_voter_count.into()) @@ -797,7 +797,7 @@ impl Pallet { // voter at this point and accept all the current nominations. The nomination // quota is only enforced at `nominate` time. - if voters_size_tracker.try_register_voter(targets.len(), voter_bounds).is_err() + if voters_size_tracker.try_register_voter(targets.len(), bounds).is_err() { // no more space left for the election result, stop iterating. Self::deposit_event(Event::::SnapshotVotersSizeExceeded { @@ -815,7 +815,7 @@ impl Pallet { if voter_weight < min_active_stake { voter_weight } else { min_active_stake }; } else if Validators::::contains_key(&voter) { // if this voter is a validator: - if voters_size_tracker.try_register_voter(1, voter_bounds).is_err() { + if voters_size_tracker.try_register_voter(1, bounds).is_err() { // no more space left for the election result, stop iterating over. Self::deposit_event(Event::::SnapshotVotersSizeExceeded { size: voters_size_tracker.size as u32, From 1f8f50251b5097b6498737326dcb2d2ad937c460 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Thu, 23 Mar 2023 14:41:57 +0100 Subject: [PATCH 46/80] PR comment reviews --- bin/node/runtime/src/lib.rs | 10 +++++++--- .../election-provider-multi-phase/src/lib.rs | 4 ++++ frame/election-provider-support/src/lib.rs | 10 ++++++---- .../election-provider-support/src/onchain.rs | 1 + frame/election-provider-support/src/tests.rs | 19 ++++++++++++++++++- 5 files changed, 36 insertions(+), 8 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 6557a03511986..191794f6d24d2 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -635,10 +635,14 @@ frame_election_provider_support::generate_solution_type!( ); parameter_types! { - pub ElectionBoundsMultiPhase: ElectionBounds = ElectionBoundsBuilder::new().voters_count(40_000.into()).targets_count(10_000.into()).build(); + // Note: the EPM in this runtime runs the election on-chain. The election bounds must be + // carefully set so that an election round fits in one block. + pub ElectionBoundsMultiPhase: ElectionBounds = ElectionBoundsBuilder::new() + .voters_count(10_000.into()).targets_count(1_500.into()).build(); + pub ElectionBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::new() + .voters_count(5_000.into()).targets_count(1_250.into()).build(); + pub MaxNominations: u32 = ::LIMIT as u32; - // OnChain values are lower. - pub ElectionBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::new().voters_count(5_000.into()).targets_count(1_250.into()).build(); // The maximum winners that can be elected by the Election pallet which is equivalent to the // maximum active validators the staking pallet can have. pub MaxActiveValidators: u32 = 1000; diff --git a/frame/election-provider-multi-phase/src/lib.rs b/frame/election-provider-multi-phase/src/lib.rs index a83b19dab0ab5..b9b60819ace8b 100644 --- a/frame/election-provider-multi-phase/src/lib.rs +++ b/frame/election-provider-multi-phase/src/lib.rs @@ -1085,6 +1085,7 @@ pub mod pallet { ) -> DispatchResult { T::ForceOrigin::ensure_origin(origin)?; ensure!(Self::current_phase().is_emergency(), >::CallNotAllowed); + let election_bounds = ElectionBoundsBuilder::new() .voters_count(maybe_max_voters.unwrap_or(0).into()) .targets_count(maybe_max_targets.unwrap_or(0).into()) @@ -1542,9 +1543,12 @@ impl Pallet { // - signed phase was complete or not started, in which case finalization is idempotent and // inexpensive (1 read of an empty vector). let _ = Self::finalize_signed_phase(); + >::take() .ok_or(ElectionError::::NothingQueued) .or_else(|_| { + // calling `instant_elect` with unbounded data provider bounds means that the + // on-chain `T:Bounds` configs will *not* be overwritten. T::Fallback::instant_elect( DataProviderBounds::new_unbounded(), DataProviderBounds::new_unbounded(), diff --git a/frame/election-provider-support/src/lib.rs b/frame/election-provider-support/src/lib.rs index 6aa0ca73cb0b7..9efe9a8d9a6bf 100644 --- a/frame/election-provider-support/src/lib.rs +++ b/frame/election-provider-support/src/lib.rs @@ -854,15 +854,17 @@ impl ElectionBoundsBuilder { self } - /// Caps the maximum number of the voters bounds to `voters`. If `voters` bounds are less than - /// the current value, keeps it. + /// Caps the number of the voters bounds in self to `voters` bounds. If `voters` bounds are + /// higher than the self bounds, keeps it. Note that `None` bounds are equivalent to maximum + /// and should be treated as such. pub fn max_voters(mut self, voters: DataProviderBounds) -> Self { self.voters = self.voters.map_or(None, |v| Some(v.max(voters))); self } - /// Caps the maximum number of the targets to `targets`. If `targets` bounds are less than the - /// current value, keeps it. + /// Caps the number of the voters bounds in self to `voters` bounds. If `voters` bounds are + /// higher than the self bounds, keeps it. Note that `None` bounds are equivalent to maximum + /// and should be treated as such. pub fn max_targets(mut self, targets: DataProviderBounds) -> Self { self.targets = self.targets.map_or(None, |t| Some(t.max(targets))); self diff --git a/frame/election-provider-support/src/onchain.rs b/frame/election-provider-support/src/onchain.rs index 8f023b4c28efa..f36879d08c18e 100644 --- a/frame/election-provider-support/src/onchain.rs +++ b/frame/election-provider-support/src/onchain.rs @@ -162,6 +162,7 @@ impl InstantElectionProvider for OnChainExecution { .max_voters(forced_input_voters_bounds) .max_targets(forced_input_targets_bounds) .build(); + elect_with_input_bounds::(elections_bounds) } } diff --git a/frame/election-provider-support/src/tests.rs b/frame/election-provider-support/src/tests.rs index 8fa0ff8461331..a4c8b52271d71 100644 --- a/frame/election-provider-support/src/tests.rs +++ b/frame/election-provider-support/src/tests.rs @@ -509,6 +509,23 @@ mod elections_bounds { assert_eq!(bounds.voters.count.unwrap(), CountBound(5)); assert_eq!(bounds.voters.size.unwrap(), SizeBound(10)); assert_eq!(bounds.targets.count.unwrap(), CountBound(20)); - assert_eq!(bounds.targets.size, None); + assert_eq!(bounds.targets.size.unwrap(), SizeBound(30)); + + // note that unbounded bounds (None) are equivalent to maximum value. + let bounds = ElectionBoundsBuilder::new() + .max_voters(DataProviderBounds { + count: CountBound(5).into(), + size: SizeBound(20).into(), + }) + .max_targets(DataProviderBounds { + count: CountBound(10).into(), + size: SizeBound(10).into(), + }) + .build(); + + assert_eq!(bounds.voters.count.unwrap(), CountBound(5)); + assert_eq!(bounds.voters.size.unwrap(), SizeBound(20)); + assert_eq!(bounds.targets.count.unwrap(), CountBound(10)); + assert_eq!(bounds.targets.size.unwrap(), SizeBound(10)); } } From 67c473408bcfc4d645e67c78c5ba42d0d44e3967 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Fri, 24 Mar 2023 17:38:26 +0100 Subject: [PATCH 47/80] Fixes on-chain election bounds and related code --- .../election-provider-multi-phase/src/lib.rs | 9 +++-- .../election-provider-multi-phase/src/mock.rs | 3 +- frame/election-provider-support/src/lib.rs | 40 ++++++++++++------- .../election-provider-support/src/onchain.rs | 4 +- frame/election-provider-support/src/tests.rs | 8 ++-- frame/staking/src/pallet/impls.rs | 9 +---- frame/staking/src/pallet/mod.rs | 9 ----- 7 files changed, 41 insertions(+), 41 deletions(-) diff --git a/frame/election-provider-multi-phase/src/lib.rs b/frame/election-provider-multi-phase/src/lib.rs index b9b60819ace8b..08054a4e92fe7 100644 --- a/frame/election-provider-multi-phase/src/lib.rs +++ b/frame/election-provider-multi-phase/src/lib.rs @@ -1087,9 +1087,10 @@ pub mod pallet { ensure!(Self::current_phase().is_emergency(), >::CallNotAllowed); let election_bounds = ElectionBoundsBuilder::new() - .voters_count(maybe_max_voters.unwrap_or(0).into()) - .targets_count(maybe_max_targets.unwrap_or(0).into()) + .voters_count(maybe_max_voters.unwrap_or(u32::MAX).into()) + .targets_count(maybe_max_targets.unwrap_or(u32::MAX).into()) .build(); + let supports = T::GovernanceFallback::instant_elect( election_bounds.voters, election_bounds.targets, @@ -1547,8 +1548,8 @@ impl Pallet { >::take() .ok_or(ElectionError::::NothingQueued) .or_else(|_| { - // calling `instant_elect` with unbounded data provider bounds means that the - // on-chain `T:Bounds` configs will *not* be overwritten. + // calling `instant_elect` with unbounded data provider bounds means that the + // on-chain `T:Bounds` configs will *not* be overwritten. T::Fallback::instant_elect( DataProviderBounds::new_unbounded(), DataProviderBounds::new_unbounded(), diff --git a/frame/election-provider-multi-phase/src/mock.rs b/frame/election-provider-multi-phase/src/mock.rs index 0196d00012c29..c44112abf3343 100644 --- a/frame/election-provider-multi-phase/src/mock.rs +++ b/frame/election-provider-multi-phase/src/mock.rs @@ -301,7 +301,8 @@ parameter_types! { #[derive(Debug)] pub static MaxWinners: u32 = 200; pub static ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::new().build(); - pub static ElectionsBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::new().build(); + pub static ElectionsBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::new() + .targets_count(5_000.into()).voters_count(1_250.into()).build(); pub static EpochLength: u64 = 30; pub static OnChainFallback: bool = true; diff --git a/frame/election-provider-support/src/lib.rs b/frame/election-provider-support/src/lib.rs index 9efe9a8d9a6bf..4a4a4b2206865 100644 --- a/frame/election-provider-support/src/lib.rs +++ b/frame/election-provider-support/src/lib.rs @@ -755,15 +755,21 @@ impl DataProviderBounds { } /// Returns an instance of `Self` that is constructed by capping both the `count` and `size` - /// fields. + /// fields. If `self` is None, overwrite it with the provided bounds. pub fn max(self, bounds: DataProviderBounds) -> Self { DataProviderBounds { - count: self.count.map(|c| { - c.clamp(CountBound::zero(), bounds.count.unwrap_or(CountBound(u32::MAX))).into() - }), - size: self.size.map(|c| { - c.clamp(SizeBound::zero(), bounds.size.unwrap_or(SizeBound(u32::MAX))).into() - }), + count: self + .count + .map(|c| { + c.clamp(CountBound::zero(), bounds.count.unwrap_or(CountBound(u32::MAX))).into() + }) + .or(bounds.count), + size: self + .size + .map(|c| { + c.clamp(SizeBound::zero(), bounds.size.unwrap_or(SizeBound(u32::MAX))).into() + }) + .or(bounds.size), } } } @@ -856,17 +862,23 @@ impl ElectionBoundsBuilder { /// Caps the number of the voters bounds in self to `voters` bounds. If `voters` bounds are /// higher than the self bounds, keeps it. Note that `None` bounds are equivalent to maximum - /// and should be treated as such. - pub fn max_voters(mut self, voters: DataProviderBounds) -> Self { - self.voters = self.voters.map_or(None, |v| Some(v.max(voters))); + /// and should be treated as such. + pub fn voters_or_lower(mut self, voters: DataProviderBounds) -> Self { + self.voters = match self.voters { + None => Some(voters), + Some(v) => Some(v.max(voters)), + }; self } - /// Caps the number of the voters bounds in self to `voters` bounds. If `voters` bounds are + /// Caps the number of the target bounds in self to `voters` bounds. If `voters` bounds are /// higher than the self bounds, keeps it. Note that `None` bounds are equivalent to maximum - /// and should be treated as such. - pub fn max_targets(mut self, targets: DataProviderBounds) -> Self { - self.targets = self.targets.map_or(None, |t| Some(t.max(targets))); + /// and should be treated as such. + pub fn targets_or_lower(mut self, targets: DataProviderBounds) -> Self { + self.targets = match self.targets { + None => Some(targets), + Some(t) => Some(t.max(targets)), + }; self } diff --git a/frame/election-provider-support/src/onchain.rs b/frame/election-provider-support/src/onchain.rs index f36879d08c18e..dcdbc93fda6b7 100644 --- a/frame/election-provider-support/src/onchain.rs +++ b/frame/election-provider-support/src/onchain.rs @@ -159,8 +159,8 @@ impl InstantElectionProvider for OnChainExecution { forced_input_targets_bounds: DataProviderBounds, ) -> Result, Self::Error> { let elections_bounds = ElectionBoundsBuilder::from(T::Bounds::get()) - .max_voters(forced_input_voters_bounds) - .max_targets(forced_input_targets_bounds) + .voters_or_lower(forced_input_voters_bounds) + .targets_or_lower(forced_input_targets_bounds) .build(); elect_with_input_bounds::(elections_bounds) diff --git a/frame/election-provider-support/src/tests.rs b/frame/election-provider-support/src/tests.rs index a4c8b52271d71..93c89e786eaae 100644 --- a/frame/election-provider-support/src/tests.rs +++ b/frame/election-provider-support/src/tests.rs @@ -495,12 +495,12 @@ mod elections_bounds { let bounds = ElectionBoundsBuilder::new() .voters_count(10.into()) .voters_size(10.into()) - .max_voters(DataProviderBounds { + .voters_or_lower(DataProviderBounds { count: CountBound(5).into(), size: SizeBound(20).into(), }) .targets_count(20.into()) - .max_targets(DataProviderBounds { + .targets_or_lower(DataProviderBounds { count: CountBound(30).into(), size: SizeBound(30).into(), }) @@ -513,11 +513,11 @@ mod elections_bounds { // note that unbounded bounds (None) are equivalent to maximum value. let bounds = ElectionBoundsBuilder::new() - .max_voters(DataProviderBounds { + .voters_or_lower(DataProviderBounds { count: CountBound(5).into(), size: SizeBound(20).into(), }) - .max_targets(DataProviderBounds { + .targets_or_lower(DataProviderBounds { count: CountBound(10).into(), size: SizeBound(10).into(), }) diff --git a/frame/staking/src/pallet/impls.rs b/frame/staking/src/pallet/impls.rs index 29035a0e6d25a..38c19ce1f4b59 100644 --- a/frame/staking/src/pallet/impls.rs +++ b/frame/staking/src/pallet/impls.rs @@ -760,11 +760,7 @@ impl Pallet { let max_allowed_len = { let all_voter_count = T::VoterList::count(); - bounds - .count - .unwrap_or(all_voter_count.into()) - .min(all_voter_count.into()) - .0 + bounds.count.unwrap_or(all_voter_count.into()).min(all_voter_count.into()).0 }; let mut all_voters = Vec::<_>::with_capacity(max_allowed_len as usize); @@ -797,8 +793,7 @@ impl Pallet { // voter at this point and accept all the current nominations. The nomination // quota is only enforced at `nominate` time. - if voters_size_tracker.try_register_voter(targets.len(), bounds).is_err() - { + if voters_size_tracker.try_register_voter(targets.len(), bounds).is_err() { // no more space left for the election result, stop iterating. Self::deposit_event(Event::::SnapshotVotersSizeExceeded { size: voters_size_tracker.size as u32, diff --git a/frame/staking/src/pallet/mod.rs b/frame/staking/src/pallet/mod.rs index 343390bb3efc2..8c291e880c9b2 100644 --- a/frame/staking/src/pallet/mod.rs +++ b/frame/staking/src/pallet/mod.rs @@ -271,15 +271,6 @@ pub mod pallet { type WeightInfo: WeightInfo; } - /// Maximum limit of nominations per nominator, regardless of `T::NominationsQuota`. - #[pallet::extra_constants] - impl Pallet { - #[pallet::constant_name(MaxNominations)] - fn absolute_max_nominations() -> u32 { - >>::MaxNominations::get() - } - } - /// The ideal number of active validators. #[pallet::storage] #[pallet::getter(fn validator_count)] From 70d8579d0751f4dd089cbd702dc1c972d4ef6452 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Fri, 24 Mar 2023 20:14:52 +0100 Subject: [PATCH 48/80] EPM checks the size of the voter list returned by the data provider --- .../election-provider-multi-phase/src/lib.rs | 17 ++++++++++++++ frame/staking/Cargo.toml | 2 +- frame/staking/src/lib.rs | 23 +++++-------------- primitives/npos-elections/src/lib.rs | 15 ++++++++++-- primitives/npos-elections/src/tests.rs | 20 ++++++++++++++++ 5 files changed, 57 insertions(+), 20 deletions(-) diff --git a/frame/election-provider-multi-phase/src/lib.rs b/frame/election-provider-multi-phase/src/lib.rs index 08054a4e92fe7..6d86143031cca 100644 --- a/frame/election-provider-multi-phase/src/lib.rs +++ b/frame/election-provider-multi-phase/src/lib.rs @@ -1435,6 +1435,23 @@ impl Pallet { let voters = T::DataProvider::electing_voters(election_bounds.voters) .map_err(ElectionError::DataProvider)?; + // check that data from data provider is within the requested bounds. + let mut voters_size: usize = 0; + for v in &voters { + let votes_len = &v.2.len(); + voters_size = voters_size + .saturating_add(sp_npos_elections::Voter::::encoded_size(*votes_len)); + } + if voters_size > + election_bounds + .voters + .size + .unwrap_or(u32::MAX.into()) + .0 + .saturated_into::() + { + return Err(ElectionError::DataProvider("Snapshot in MBs too big for submission.")) + } if targets.len() > target_limit || voters.len() > voter_limit { return Err(ElectionError::DataProvider("Snapshot too big for submission.")) } diff --git a/frame/staking/Cargo.toml b/frame/staking/Cargo.toml index 79c0bb5c2a32d..5e49bd3888dbf 100644 --- a/frame/staking/Cargo.toml +++ b/frame/staking/Cargo.toml @@ -22,6 +22,7 @@ sp-std = { version = "5.0.0", default-features = false, path = "../../primitives sp-io = { version = "7.0.0", default-features = false, path = "../../primitives/io" } sp-runtime = { version = "7.0.0", default-features = false, path = "../../primitives/runtime" } sp-staking = { version = "4.0.0-dev", default-features = false, path = "../../primitives/staking" } +sp-npos-elections = { version = "4.0.0-dev", path = "../../primitives/npos-elections" } frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" } frame-system = { version = "4.0.0-dev", default-features = false, path = "../system" } pallet-session = { version = "4.0.0-dev", default-features = false, features = [ @@ -39,7 +40,6 @@ rand_chacha = { version = "0.2", default-features = false, optional = true } [dev-dependencies] sp-tracing = { version = "6.0.0", path = "../../primitives/tracing" } sp-core = { version = "7.0.0", path = "../../primitives/core" } -sp-npos-elections = { version = "4.0.0-dev", path = "../../primitives/npos-elections" } pallet-balances = { version = "4.0.0-dev", path = "../balances" } pallet-timestamp = { version = "4.0.0-dev", path = "../timestamp" } pallet-staking-reward-curve = { version = "4.0.0-dev", path = "../staking/reward-curve" } diff --git a/frame/staking/src/lib.rs b/frame/staking/src/lib.rs index 12d4ffc438958..b6640c5db5ee7 100644 --- a/frame/staking/src/lib.rs +++ b/frame/staking/src/lib.rs @@ -300,7 +300,7 @@ pub mod weights; mod pallet; use codec::{Decode, Encode, HasCompact, MaxEncodedLen}; -use frame_election_provider_support::{DataProviderBounds, SizeBound, VoteWeight}; +use frame_election_provider_support::{DataProviderBounds, IdentifierT, SizeBound}; use frame_support::{ traits::{ConstU32, Currency, Defensive, Get}, weights::Weight, @@ -812,7 +812,10 @@ pub(crate) struct ElectionSizeTracker { _marker: sp_std::marker::PhantomData, } -impl ElectionSizeTracker { +impl ElectionSizeTracker +where + AccountId: IdentifierT, +{ pub(crate) fn new() -> Self { ElectionSizeTracker { size: 0, _marker: Default::default() } } @@ -838,21 +841,7 @@ impl ElectionSizeTracker { /// Returns the size taken by a voter with `votes`. fn voter_size(votes: usize) -> usize { - Self::length_prefix(votes) - // and each element - .saturating_add(votes * sp_std::mem::size_of::()) - // 1 vote-weight - .saturating_add(sp_std::mem::size_of::()) - // 1 voter account - .saturating_add(sp_std::mem::size_of::()) - } - - /// The length prefix of a vector with the given length. - #[inline] - pub(crate) fn length_prefix(length: usize) -> usize { - use codec::{Compact, CompactLen}; - let length = length as u32; - Compact::::compact_len(&length) + sp_npos_elections::Voter::::encoded_size(votes) } } diff --git a/primitives/npos-elections/src/lib.rs b/primitives/npos-elections/src/lib.rs index 716c4b283c68e..4c67471a174b7 100644 --- a/primitives/npos-elections/src/lib.rs +++ b/primitives/npos-elections/src/lib.rs @@ -75,7 +75,7 @@ #![cfg_attr(not(feature = "std"), no_std)] -use codec::{Decode, Encode, MaxEncodedLen}; +use codec::{Decode, Encode, MaxEncodedLen, Compact, CompactLen}; use scale_info::TypeInfo; #[cfg(feature = "std")] use serde::{Deserialize, Serialize}; @@ -404,7 +404,18 @@ impl Voter { }) } - /// This voter's budget + /// Returns the size in MBs of the scale encoded structure that stores a `Voter` with a given + /// number of cast `votes`. + #[inline] + pub fn encoded_size(votes: usize) -> usize { + // prefix size. + Compact::::compact_len(&(votes as u32)) + .saturating_add(votes * sp_std::mem::size_of::()) + .saturating_add(votes * sp_std::mem::size_of::()) + .saturating_add(sp_std::mem::size_of::()) + } + + /// This voter's budget. #[inline] pub fn budget(&self) -> ExtendedBalance { self.budget diff --git a/primitives/npos-elections/src/tests.rs b/primitives/npos-elections/src/tests.rs index 72ae9a0222be1..66c4a760b1916 100644 --- a/primitives/npos-elections/src/tests.rs +++ b/primitives/npos-elections/src/tests.rs @@ -187,6 +187,26 @@ fn balancing_core_works() { ); } +#[test] +fn voter_encoded_size_works() { + use crate::{Candidate, Edge}; + + let mut v = Voter { who: 1, ..Default::default() }; + assert_eq!(Voter::::encoded_size(v.edges.len()), 9); + + let c1 = Candidate { who: 10, elected: false, ..Default::default() }; + let c2 = Candidate { who: 20, elected: true, ..Default::default() }; + let c3 = Candidate { who: 30, elected: true, ..Default::default() }; + + let e1 = Edge::new(c1, 30); + let e2 = Edge::new(c2, 33); + let e3 = Edge::new(c3, 30); + + v.edges = vec![e1, e2, e3]; + + assert_eq!(Voter::::encoded_size(v.edges.len()), 9 + (3 * 16)); +} + #[test] fn voter_normalize_ops_works() { use crate::{Candidate, Edge}; From a68a37d24c6193b843acb2f7e93c68f029a91ffc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Fri, 24 Mar 2023 20:22:09 +0100 Subject: [PATCH 49/80] cosmetic changes --- frame/election-provider-support/src/onchain.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/frame/election-provider-support/src/onchain.rs b/frame/election-provider-support/src/onchain.rs index dcdbc93fda6b7..dc5a0a57982d8 100644 --- a/frame/election-provider-support/src/onchain.rs +++ b/frame/election-provider-support/src/onchain.rs @@ -100,9 +100,10 @@ pub type OnChainBoundedSupportsOf = BoundedSupports< fn elect_with_input_bounds( bounds: ElectionBounds, ) -> Result, Error> { - let voters = T::DataProvider::electing_voters(bounds.voters).map_err(Error::DataProvider)?; - let targets = - T::DataProvider::electable_targets(bounds.targets).map_err(Error::DataProvider)?; + let (voters, targets) = T::DataProvider::electing_voters(bounds.voters) + .and_then(|voters| Ok((voters, T::DataProvider::electable_targets(bounds.targets)?))) + .map_err(Error::DataProvider)?; + let desired_targets = T::DataProvider::desired_targets().map_err(Error::DataProvider)?; if desired_targets > T::MaxWinners::get() { From 849a2e0e7ea1e070bc2f43b2658ffe2fe2847abf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Fri, 24 Mar 2023 20:39:45 +0100 Subject: [PATCH 50/80] updates e2e tests mock --- .../test-staking-e2e/Cargo.lock | 1 + .../test-staking-e2e/src/mock.rs | 23 ++++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/frame/election-provider-multi-phase/test-staking-e2e/Cargo.lock b/frame/election-provider-multi-phase/test-staking-e2e/Cargo.lock index b179ab7059a48..0b5805b3dd2a9 100644 --- a/frame/election-provider-multi-phase/test-staking-e2e/Cargo.lock +++ b/frame/election-provider-multi-phase/test-staking-e2e/Cargo.lock @@ -1788,6 +1788,7 @@ dependencies = [ "serde", "sp-application-crypto", "sp-io", + "sp-npos-elections", "sp-runtime", "sp-staking", "sp-std", diff --git a/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs b/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs index 19f568737c852..b2ed49d5b9a43 100644 --- a/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs +++ b/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs @@ -17,7 +17,6 @@ #![allow(dead_code)] -use _feps::ExtendedBalance; use frame_support::{ parameter_types, traits, traits::{GenesisBuild, Hooks}, @@ -38,7 +37,10 @@ use sp_staking::{ use sp_std::prelude::*; use std::collections::BTreeMap; -use frame_election_provider_support::{onchain, ElectionDataProvider, SequentialPhragmen, Weight}; +use frame_election_provider_support::{ + onchain, ElectionBoundsBuilder, ElectionDataProvider, ExtendedBalance, SequentialPhragmen, + Weight, +}; use pallet_election_provider_multi_phase::{ unsigned::MinerConfig, ElectionCompute, QueuedSolution, SolutionAccuracyOf, }; @@ -177,16 +179,14 @@ parameter_types! { // we expect a minimum of 3 blocks in signed phase and unsigned phases before trying // enetering in emergency phase after the election failed. pub static MinBlocksBeforeEmergency: BlockNumber = 3; - pub static MaxElectingVoters: VoterIndex = 1000; - pub static MaxElectableTargets: TargetIndex = 1000; pub static MaxActiveValidators: u32 = 1000; pub static OffchainRepeat: u32 = 5; pub static MinerMaxLength: u32 = 256; pub static MinerMaxWeight: Weight = BlockWeights::get().max_block; pub static TransactionPriority: transaction_validity::TransactionPriority = 1; pub static MaxWinners: u32 = 100; - pub static MaxVotesPerVoter: u32 = 16; - pub static MaxNominations: u32 = 16; + pub static ElectionBounds: frame_election_provider_support::ElectionBounds = ElectionBoundsBuilder::new() + .voters_count(1_000.into()).targets_count(1_000.into()).build(); } impl pallet_election_provider_multi_phase::Config for Runtime { @@ -215,9 +215,8 @@ impl pallet_election_provider_multi_phase::Config for Runtime { type GovernanceFallback = onchain::OnChainExecution; type Solver = SequentialPhragmen, ()>; type ForceOrigin = EnsureRoot; - type MaxElectableTargets = MaxElectableTargets; - type MaxElectingVoters = MaxElectingVoters; type MaxWinners = MaxWinners; + type ElectionBounds = ElectionBounds; type BenchmarkingConfig = NoopElectionProviderBenchmarkConfig; type WeightInfo = (); } @@ -256,8 +255,10 @@ impl pallet_bags_list::Config for Runtime { type Score = VoteWeight; } +/// Upper limit on the number of NPOS nominations. +const MAX_QUOTA_NOMINATIONS: u32 = 16; + impl pallet_staking::Config for Runtime { - type MaxNominations = MaxNominations; type Currency = Balances; type CurrencyBalance = Balance; type UnixTime = Timestamp; @@ -278,6 +279,7 @@ impl pallet_staking::Config for Runtime { type ElectionProvider = ElectionProviderMultiPhase; type GenesisElectionProvider = onchain::OnChainExecution; type VoterList = BagsList; + type NominationsQuota = pallet_staking::FixedNominationsQuota; type TargetList = pallet_staking::UseValidatorsMap; type MaxUnlockingChunks = ConstU32<32>; type HistoryDepth = HistoryDepth; @@ -310,8 +312,7 @@ impl onchain::Config for OnChainSeqPhragmen { type DataProvider = Staking; type WeightInfo = (); type MaxWinners = MaxWinners; - type VotersBound = VotersBound; - type TargetsBound = TargetsBound; + type Bounds = ElectionBounds; } pub struct NoopElectionProviderBenchmarkConfig; From 306668e8b91d9fe6696049d519cfbc8a78b155e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Sat, 25 Mar 2023 12:41:59 +0100 Subject: [PATCH 51/80] Adds more tests for size tracker and refactors code --- frame/staking/src/lib.rs | 29 +++++++--- frame/staking/src/tests.rs | 86 +++++++++++++++++++++++++--- primitives/npos-elections/src/lib.rs | 4 +- 3 files changed, 101 insertions(+), 18 deletions(-) diff --git a/frame/staking/src/lib.rs b/frame/staking/src/lib.rs index b6640c5db5ee7..b03ca3e87b147 100644 --- a/frame/staking/src/lib.rs +++ b/frame/staking/src/lib.rs @@ -807,8 +807,10 @@ impl NominationsQuota for FixedNominationsQuot /// Whilst doing this, [`size`] will track the entire size of the `Vec`, except for the /// length prefix of the outer `Vec`. To get the final size at any point, use /// [`final_byte_size_of`]. +#[derive(Copy, Clone, Debug)] pub(crate) struct ElectionSizeTracker { pub size: usize, + pub num_voters: usize, _marker: sp_std::marker::PhantomData, } @@ -817,7 +819,7 @@ where AccountId: IdentifierT, { pub(crate) fn new() -> Self { - ElectionSizeTracker { size: 0, _marker: Default::default() } + ElectionSizeTracker { size: 0, num_voters: 0, _marker: Default::default() } } /// Attempts to register a new voter with `votes` for a given election `bounds`. Returns an @@ -827,21 +829,32 @@ where votes: usize, bounds: DataProviderBounds, ) -> Result<(), ()> { - let voter_size = Self::voter_size(votes); - let size_after = self.size.saturating_add(voter_size); + let voter_size = sp_npos_elections::Voter::::encoded_size(votes); + let voters_size_after = self.size.saturating_add(voter_size); - match bounds.size_exhausted(SizeBound(size_after as u32)) { + // the total encoded size takes into consideration the prefix of the outer vec, which + // contains all the voters. + let total_size_after = Self::final_byte_size_of(self.num_voters + 1, voters_size_after); + + match bounds.size_exhausted(SizeBound(total_size_after as u32)) { true => Err(()), false => { - self.size = size_after; + self.size = voters_size_after; + self.num_voters += 1; Ok(()) }, } } - /// Returns the size taken by a voter with `votes`. - fn voter_size(votes: usize) -> usize { - sp_npos_elections::Voter::::encoded_size(votes) + // Size of the SCALE encoded prefix with a given length. + #[inline] + pub(crate) fn length_prefix(len: usize) -> usize { + use codec::{Compact, CompactLen}; + Compact::::compact_len(&(len as u32)) + } + + pub(crate) fn final_byte_size_of(num_voters: usize, size: usize) -> usize { + Self::length_prefix(num_voters).saturating_add(size) } } diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index 9b4dd236e035b..44123e4b83993 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -4608,13 +4608,17 @@ mod election_data_provider { #[test] fn respects_snapshot_size_limits() { ExtBuilder::default().build_and_execute(|| { - let bounds_builder = ElectionBoundsBuilder::new(); - assert_eq!( - Staking::electing_voters(bounds_builder.voters_size(25.into()).build().voters) - .unwrap() - .len(), - 1 - ); + // set size bounds that allows only for 1 voter. + let bounds = ElectionBoundsBuilder::new().voters_size(26.into()).build(); + let elected = Staking::electing_voters(bounds.voters).unwrap(); + assert!(elected.encoded_size() <= 26 as usize); + let prev_len = elected.len(); + + // larger size bounds means more quota for voters. + let bounds = ElectionBoundsBuilder::new().voters_size(100.into()).build(); + let elected = Staking::electing_voters(bounds.voters).unwrap(); + assert!(elected.encoded_size() <= 100 as usize); + assert!(elected.len() > 1 && elected.len() > prev_len); }); } @@ -5906,19 +5910,85 @@ mod election_size_tracker { #[test] pub fn election_size_tracker_works() { + let mut voters: Vec<(u64, u64, Vec)> = vec![]; + let mut size_tracker = ElectionSizeTracker::::new(); + let voter_bounds = ElectionBoundsBuilder::new().voters_size(1_50.into()).build().voters; + + // register 1 voter with 1 vote. + voters.push((1, 10, vec![2])); + assert!(size_tracker.try_register_voter(1, voter_bounds).is_ok()); + assert_eq!( + ElectionSizeTracker::::final_byte_size_of( + size_tracker.num_voters, + size_tracker.size + ), + voters.encoded_size() + ); + + // register another voter, now with 3 votes. + voters.push((2, 20, vec![3, 4, 5])); + assert!(size_tracker.try_register_voter(3, voter_bounds).is_ok()); + assert_eq!( + ElectionSizeTracker::::final_byte_size_of( + size_tracker.num_voters, + size_tracker.size + ), + voters.encoded_size() + ); + + // register noop vote (unlikely to happen). + voters.push((3, 30, vec![])); + assert!(size_tracker.try_register_voter(0, voter_bounds).is_ok()); + assert_eq!( + ElectionSizeTracker::::final_byte_size_of( + size_tracker.num_voters, + size_tracker.size + ), + voters.encoded_size() + ); + } + + #[test] + pub fn election_size_bounds_works() { + let mut voters: Vec<(u64, u64, Vec)> = vec![]; let mut size_tracker = ElectionSizeTracker::::new(); let voter_bounds = ElectionBoundsBuilder::new().voters_size(1_00.into()).build().voters; + voters.push((1, 10, vec![2])); assert!(size_tracker.try_register_voter(1, voter_bounds).is_ok()); - assert!(size_tracker.try_register_voter(2, voter_bounds).is_ok()); + assert_eq!( + ElectionSizeTracker::::final_byte_size_of( + size_tracker.num_voters, + size_tracker.size + ), + voters.encoded_size() + ); + assert!(size_tracker.size > 0 && size_tracker.size < 1_00); let size_before_overflow = size_tracker.size; // try many voters that will overflow the tracker's buffer. + voters.push((2, 10, vec![2, 3, 4, 5, 6, 7])); assert!(size_tracker.try_register_voter(10, voter_bounds).is_err()); assert!(size_tracker.size > 0 && size_tracker.size < 1_00); + + // size of the tracker did not update when trying to register votes failed. assert_eq!(size_tracker.size, size_before_overflow); } + + #[test] + fn len_prefix_works() { + let length_samples = + vec![0usize, 1, 62, 63, 64, 16383, 16384, 16385, 1073741822, 1073741823, 1073741824]; + + for s in length_samples { + // the encoded size of a vector of n bytes should be n + the length prefix + assert_eq!( + vec![1u8; s].encoded_size(), + ElectionSizeTracker::::length_prefix(s) + s + ); + } + } } mod staking_interface { diff --git a/primitives/npos-elections/src/lib.rs b/primitives/npos-elections/src/lib.rs index 4c67471a174b7..f7d5b20d6df67 100644 --- a/primitives/npos-elections/src/lib.rs +++ b/primitives/npos-elections/src/lib.rs @@ -75,7 +75,7 @@ #![cfg_attr(not(feature = "std"), no_std)] -use codec::{Decode, Encode, MaxEncodedLen, Compact, CompactLen}; +use codec::{Compact, CompactLen, Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; #[cfg(feature = "std")] use serde::{Deserialize, Serialize}; @@ -411,7 +411,7 @@ impl Voter { // prefix size. Compact::::compact_len(&(votes as u32)) .saturating_add(votes * sp_std::mem::size_of::()) - .saturating_add(votes * sp_std::mem::size_of::()) + .saturating_add(sp_std::mem::size_of::()) .saturating_add(sp_std::mem::size_of::()) } From 7ec63057dbdaa4beaecd6997bbd4f939500981a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Sat, 25 Mar 2023 12:57:53 +0100 Subject: [PATCH 52/80] Adds back only_iterates_max_2_times_max_allowed_len test --- frame/staking/src/mock.rs | 4 +-- frame/staking/src/tests.rs | 67 ++++++++++++++++++++++++++++++++++---- 2 files changed, 63 insertions(+), 8 deletions(-) diff --git a/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index 27d76ab801be0..f7a716cb9f85b 100644 --- a/frame/staking/src/mock.rs +++ b/frame/staking/src/mock.rs @@ -236,7 +236,7 @@ parameter_types! { pub static LedgerSlashPerEra: (BalanceOf, BTreeMap>) = (Zero::zero(), BTreeMap::new()); pub static MaxWinners: u32 = 100; pub static ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::new().build(); - pub static MaxNominations: u32 = 16; + pub static AbsoluteMaxNominations: u32 = 16; } type VoterBagsListInstance = pallet_bags_list::Instance1; @@ -313,7 +313,7 @@ impl NominationsQuota for WeightedNominationsQ where u128: From, { - type MaxNominations = MaxNominations; + type MaxNominations = AbsoluteMaxNominations; fn curve(balance: Balance) -> u32 { match balance.into() { diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index 44123e4b83993..fa9dde91da757 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -4542,6 +4542,61 @@ mod election_data_provider { }) } + // Tests the criteria that in `ElectionDataProvider::voters` function, we try to get at most + // `maybe_max_len` voters, and if some of them end up being skipped, we iterate at most `2 * + // maybe_max_len`. + #[test] + fn only_iterates_max_2_times_max_allowed_len() { + ExtBuilder::default() + .nominate(false) + // the best way to invalidate a bunch of nominators is to have them nominate a lot of + // ppl, but then lower the MaxNomination limit. + .add_staker( + 61, + 60, + 2_000, + StakerStatus::::Nominator(vec![21, 22, 23, 24, 25]), + ) + .add_staker( + 71, + 70, + 2_000, + StakerStatus::::Nominator(vec![21, 22, 23, 24, 25]), + ) + .add_staker( + 81, + 80, + 2_000, + StakerStatus::::Nominator(vec![21, 22, 23, 24, 25]), + ) + .build_and_execute(|| { + let bounds_builder = ElectionBoundsBuilder::new(); + // all voters ordered by stake, + assert_eq!( + ::VoterList::iter().collect::>(), + vec![61, 71, 81, 11, 21, 31] + ); + + AbsoluteMaxNominations::set(2); + + // we want 2 voters now, and in maximum we allow 4 iterations. This is what happens: + // 61 is pruned; + // 71 is pruned; + // 81 is pruned; + // 11 is taken; + // we finish since the 2x limit is reached. + assert_eq!( + Staking::electing_voters(bounds_builder.voters_count(2.into()).build().voters) + .unwrap() + .iter() + .map(|(stash, _, _)| stash) + .copied() + .collect::>(), + vec![11], + ); + }); + } + #[test] fn respects_snapshot_count_limits() { ExtBuilder::default() @@ -5153,7 +5208,7 @@ fn min_commission_works() { } #[test] -fn change_of_max_nominations() { +fn change_of_absolute_max_nominations() { use frame_election_provider_support::ElectionDataProvider; ExtBuilder::default() .add_staker(60, 61, 10, StakerStatus::Nominator(vec![1])) @@ -5161,7 +5216,7 @@ fn change_of_max_nominations() { .balance_factor(10) .build_and_execute(|| { // pre-condition - assert_eq!(MaxNominations::get(), 16); + assert_eq!(AbsoluteMaxNominations::get(), 16); assert_eq!( Nominators::::iter() @@ -5176,7 +5231,7 @@ fn change_of_max_nominations() { assert_eq!(Staking::electing_voters(bounds).unwrap().len(), 3 + 3); // abrupt change from 16 to 4, everyone should be fine. - MaxNominations::set(4); + AbsoluteMaxNominations::set(4); assert_eq!( Nominators::::iter() @@ -5187,7 +5242,7 @@ fn change_of_max_nominations() { assert_eq!(Staking::electing_voters(bounds).unwrap().len(), 3 + 3); // abrupt change from 4 to 3, everyone should be fine. - MaxNominations::set(3); + AbsoluteMaxNominations::set(3); assert_eq!( Nominators::::iter() @@ -5199,7 +5254,7 @@ fn change_of_max_nominations() { // abrupt change from 3 to 2, this should cause some nominators to be non-decodable, and // thus non-existent unless if they update. - MaxNominations::set(2); + AbsoluteMaxNominations::set(2); assert_eq!( Nominators::::iter() @@ -5217,7 +5272,7 @@ fn change_of_max_nominations() { // abrupt change from 2 to 1, this should cause some nominators to be non-decodable, and // thus non-existent unless if they update. - MaxNominations::set(1); + AbsoluteMaxNominations::set(1); assert_eq!( Nominators::::iter() From e8576b75c8dac623c02c25e258bc6de87ca5d56b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Sat, 25 Mar 2023 16:32:30 +0100 Subject: [PATCH 53/80] Refactor --- .../election-provider-multi-phase/src/lib.rs | 20 +++------------- frame/staking/src/lib.rs | 11 +++++++-- frame/staking/src/tests.rs | 23 ++++++++++++++++++- primitives/npos-elections/src/lib.rs | 13 +---------- primitives/npos-elections/src/tests.rs | 20 ---------------- 5 files changed, 35 insertions(+), 52 deletions(-) diff --git a/frame/election-provider-multi-phase/src/lib.rs b/frame/election-provider-multi-phase/src/lib.rs index 6d86143031cca..6a97f19df17a3 100644 --- a/frame/election-provider-multi-phase/src/lib.rs +++ b/frame/election-provider-multi-phase/src/lib.rs @@ -1435,26 +1435,12 @@ impl Pallet { let voters = T::DataProvider::electing_voters(election_bounds.voters) .map_err(ElectionError::DataProvider)?; - // check that data from data provider is within the requested bounds. - let mut voters_size: usize = 0; - for v in &voters { - let votes_len = &v.2.len(); - voters_size = voters_size - .saturating_add(sp_npos_elections::Voter::::encoded_size(*votes_len)); - } - if voters_size > - election_bounds - .voters - .size - .unwrap_or(u32::MAX.into()) - .0 - .saturated_into::() - { - return Err(ElectionError::DataProvider("Snapshot in MBs too big for submission.")) - } if targets.len() > target_limit || voters.len() > voter_limit { return Err(ElectionError::DataProvider("Snapshot too big for submission.")) } + if voters.encoded_size() as u32 > election_bounds.voters.size.unwrap_or(u32::MAX.into()).0 { + return Err(ElectionError::DataProvider("Snapshot in MBs too big for submission.")) + } let mut desired_targets = as ElectionProviderBase>::desired_targets_checked() .map_err(|e| ElectionError::DataProvider(e))?; diff --git a/frame/staking/src/lib.rs b/frame/staking/src/lib.rs index b03ca3e87b147..e50c5d5bb7bbf 100644 --- a/frame/staking/src/lib.rs +++ b/frame/staking/src/lib.rs @@ -829,8 +829,7 @@ where votes: usize, bounds: DataProviderBounds, ) -> Result<(), ()> { - let voter_size = sp_npos_elections::Voter::::encoded_size(votes); - let voters_size_after = self.size.saturating_add(voter_size); + let voters_size_after = self.size.saturating_add(Self::encoded_size(votes)); // the total encoded size takes into consideration the prefix of the outer vec, which // contains all the voters. @@ -846,6 +845,14 @@ where } } + /// Returns the size in MBs of the scale encoded structure that stores a `Voter` with a given + /// number of cast `votes`. + pub fn encoded_size(votes: usize) -> usize { + Self::length_prefix(votes) + .saturating_add(votes * sp_std::mem::size_of::()) + .saturating_add(sp_std::mem::size_of::()) + .saturating_add(sp_std::mem::size_of::()) + } // Size of the SCALE encoded prefix with a given length. #[inline] pub(crate) fn length_prefix(len: usize) -> usize { diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index fa9dde91da757..d9295e0447401 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -5963,6 +5963,27 @@ fn set_min_commission_works_with_admin_origin() { mod election_size_tracker { use super::*; + #[test] + pub fn encoded_size_works() { + let voter: (u64, u64, Vec) = (1, 100, vec![]); + assert_eq!( + voter.encoded_size(), + ElectionSizeTracker::::encoded_size(voter.2.len()) + ); + + let voter: (u64, u64, Vec) = (1, 100, vec![2]); + assert_eq!( + voter.encoded_size(), + ElectionSizeTracker::::encoded_size(voter.2.len()) + ); + + let voter: (u64, u64, Vec) = (1, 100, vec![1, 2, 3, 4]); + assert_eq!( + voter.encoded_size(), + ElectionSizeTracker::::encoded_size(voter.2.len()) + ); + } + #[test] pub fn election_size_tracker_works() { let mut voters: Vec<(u64, u64, Vec)> = vec![]; @@ -6004,7 +6025,7 @@ mod election_size_tracker { } #[test] - pub fn election_size_bounds_works() { + pub fn election_size_tracker_bounds_works() { let mut voters: Vec<(u64, u64, Vec)> = vec![]; let mut size_tracker = ElectionSizeTracker::::new(); let voter_bounds = ElectionBoundsBuilder::new().voters_size(1_00.into()).build().voters; diff --git a/primitives/npos-elections/src/lib.rs b/primitives/npos-elections/src/lib.rs index f7d5b20d6df67..012ee0e554b06 100644 --- a/primitives/npos-elections/src/lib.rs +++ b/primitives/npos-elections/src/lib.rs @@ -75,7 +75,7 @@ #![cfg_attr(not(feature = "std"), no_std)] -use codec::{Compact, CompactLen, Decode, Encode, MaxEncodedLen}; +use codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; #[cfg(feature = "std")] use serde::{Deserialize, Serialize}; @@ -404,17 +404,6 @@ impl Voter { }) } - /// Returns the size in MBs of the scale encoded structure that stores a `Voter` with a given - /// number of cast `votes`. - #[inline] - pub fn encoded_size(votes: usize) -> usize { - // prefix size. - Compact::::compact_len(&(votes as u32)) - .saturating_add(votes * sp_std::mem::size_of::()) - .saturating_add(sp_std::mem::size_of::()) - .saturating_add(sp_std::mem::size_of::()) - } - /// This voter's budget. #[inline] pub fn budget(&self) -> ExtendedBalance { diff --git a/primitives/npos-elections/src/tests.rs b/primitives/npos-elections/src/tests.rs index 66c4a760b1916..72ae9a0222be1 100644 --- a/primitives/npos-elections/src/tests.rs +++ b/primitives/npos-elections/src/tests.rs @@ -187,26 +187,6 @@ fn balancing_core_works() { ); } -#[test] -fn voter_encoded_size_works() { - use crate::{Candidate, Edge}; - - let mut v = Voter { who: 1, ..Default::default() }; - assert_eq!(Voter::::encoded_size(v.edges.len()), 9); - - let c1 = Candidate { who: 10, elected: false, ..Default::default() }; - let c2 = Candidate { who: 20, elected: true, ..Default::default() }; - let c3 = Candidate { who: 30, elected: true, ..Default::default() }; - - let e1 = Edge::new(c1, 30); - let e2 = Edge::new(c2, 33); - let e3 = Edge::new(c3, 30); - - v.edges = vec![e1, e2, e3]; - - assert_eq!(Voter::::encoded_size(v.edges.len()), 9 + (3 * 16)); -} - #[test] fn voter_normalize_ops_works() { use crate::{Candidate, Edge}; From e12f2871ff8e4e1b5385f868d02338dce9ed7ad7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Sat, 25 Mar 2023 16:34:50 +0100 Subject: [PATCH 54/80] removes unecessary dependency --- frame/staking/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/staking/Cargo.toml b/frame/staking/Cargo.toml index 5e49bd3888dbf..79c0bb5c2a32d 100644 --- a/frame/staking/Cargo.toml +++ b/frame/staking/Cargo.toml @@ -22,7 +22,6 @@ sp-std = { version = "5.0.0", default-features = false, path = "../../primitives sp-io = { version = "7.0.0", default-features = false, path = "../../primitives/io" } sp-runtime = { version = "7.0.0", default-features = false, path = "../../primitives/runtime" } sp-staking = { version = "4.0.0-dev", default-features = false, path = "../../primitives/staking" } -sp-npos-elections = { version = "4.0.0-dev", path = "../../primitives/npos-elections" } frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" } frame-system = { version = "4.0.0-dev", default-features = false, path = "../system" } pallet-session = { version = "4.0.0-dev", default-features = false, features = [ @@ -40,6 +39,7 @@ rand_chacha = { version = "0.2", default-features = false, optional = true } [dev-dependencies] sp-tracing = { version = "6.0.0", path = "../../primitives/tracing" } sp-core = { version = "7.0.0", path = "../../primitives/core" } +sp-npos-elections = { version = "4.0.0-dev", path = "../../primitives/npos-elections" } pallet-balances = { version = "4.0.0-dev", path = "../balances" } pallet-timestamp = { version = "4.0.0-dev", path = "../timestamp" } pallet-staking-reward-curve = { version = "4.0.0-dev", path = "../staking/reward-curve" } From 61a8ca5414b8db280c29325fd481df82685eb9b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Mon, 27 Mar 2023 09:07:07 +0200 Subject: [PATCH 55/80] empty commit -- restart all stuck CI jobs From 5c8a034497da97565b7352f6b746dd20e3217428 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Fri, 31 Mar 2023 11:52:31 +0200 Subject: [PATCH 56/80] restarts ci jobs From 187ce071900acfc6377247f215bd81716dad9937 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Sun, 2 Apr 2023 08:32:47 +0200 Subject: [PATCH 57/80] Renames ElectionBounds -> Bounds in benchmarking mocks et al --- frame/babe/src/mock.rs | 2 +- frame/beefy/src/mock.rs | 2 +- frame/grandpa/src/mock.rs | 2 +- frame/offences/benchmarking/src/mock.rs | 2 +- frame/root-offences/src/mock.rs | 2 +- frame/session/benchmarking/src/mock.rs | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/frame/babe/src/mock.rs b/frame/babe/src/mock.rs index c4768d8b6142a..daf7f21853b61 100644 --- a/frame/babe/src/mock.rs +++ b/frame/babe/src/mock.rs @@ -180,7 +180,7 @@ impl onchain::Config for OnChainSeqPhragmen { type DataProvider = Staking; type WeightInfo = (); type MaxWinners = ConstU32<100>; - type ElectionBounds = ElectionsBounds; + type Bounds = ElectionsBounds; } impl pallet_staking::Config for Test { diff --git a/frame/beefy/src/mock.rs b/frame/beefy/src/mock.rs index 0027632a98eca..1d2cf01ee1a03 100644 --- a/frame/beefy/src/mock.rs +++ b/frame/beefy/src/mock.rs @@ -202,7 +202,7 @@ impl onchain::Config for OnChainSeqPhragmen { type DataProvider = Staking; type WeightInfo = (); type MaxWinners = ConstU32<100>; - type ElectionBounds = ElectionsBoundsOnChain; + type Bounds = ElectionsBoundsOnChain; } impl pallet_staking::Config for Test { diff --git a/frame/grandpa/src/mock.rs b/frame/grandpa/src/mock.rs index 0553a0ac6e11a..1f711f08094cd 100644 --- a/frame/grandpa/src/mock.rs +++ b/frame/grandpa/src/mock.rs @@ -183,7 +183,7 @@ impl onchain::Config for OnChainSeqPhragmen { type DataProvider = Staking; type WeightInfo = (); type MaxWinners = ConstU32<100>; - type ElectionBounds = ElectionsBoundsOnChain; + type Bounds = ElectionsBoundsOnChain; } impl pallet_staking::Config for Test { diff --git a/frame/offences/benchmarking/src/mock.rs b/frame/offences/benchmarking/src/mock.rs index 927b9cb527ef0..0961e1afdbf55 100644 --- a/frame/offences/benchmarking/src/mock.rs +++ b/frame/offences/benchmarking/src/mock.rs @@ -156,7 +156,7 @@ impl onchain::Config for OnChainSeqPhragmen { type DataProvider = Staking; type WeightInfo = (); type MaxWinners = ConstU32<100>; - type ElectionBounds = ElectionsBounds; + type Bounds = ElectionsBounds; } impl pallet_staking::Config for Test { diff --git a/frame/root-offences/src/mock.rs b/frame/root-offences/src/mock.rs index b06b4eb47ee2c..c726c633da790 100644 --- a/frame/root-offences/src/mock.rs +++ b/frame/root-offences/src/mock.rs @@ -151,7 +151,7 @@ impl onchain::Config for OnChainSeqPhragmen { type DataProvider = Staking; type WeightInfo = (); type MaxWinners = ConstU32<100>; - type ElectionBounds = ElectionsBounds; + type Bounds = ElectionsBounds; } pub struct OnStakerSlashMock(core::marker::PhantomData); diff --git a/frame/session/benchmarking/src/mock.rs b/frame/session/benchmarking/src/mock.rs index 9f0e2107a9bbd..4a3fb5bb2075e 100644 --- a/frame/session/benchmarking/src/mock.rs +++ b/frame/session/benchmarking/src/mock.rs @@ -158,7 +158,7 @@ impl onchain::Config for OnChainSeqPhragmen { type DataProvider = Staking; type WeightInfo = (); type MaxWinners = ConstU32<100>; - type ElectionBounds = ElectionsBounds; + type Bounds = ElectionsBounds; } impl pallet_staking::Config for Test { From 9023997eeccc43ef89c35b42ec6dba93815e4bb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Sun, 2 Apr 2023 13:35:11 +0200 Subject: [PATCH 58/80] updates mocks --- frame/babe/src/mock.rs | 2 +- frame/beefy/src/mock.rs | 2 +- frame/grandpa/src/mock.rs | 2 +- frame/offences/benchmarking/src/mock.rs | 2 +- frame/root-offences/src/mock.rs | 2 +- frame/session/benchmarking/src/mock.rs | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/frame/babe/src/mock.rs b/frame/babe/src/mock.rs index daf7f21853b61..bcf2f4d2ec08d 100644 --- a/frame/babe/src/mock.rs +++ b/frame/babe/src/mock.rs @@ -170,7 +170,7 @@ parameter_types! { pub const SlashDeferDuration: EraIndex = 0; pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE; pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(16); - pub const ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::new().build(); + pub static ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::new().build(); } pub struct OnChainSeqPhragmen; diff --git a/frame/beefy/src/mock.rs b/frame/beefy/src/mock.rs index 1d2cf01ee1a03..f223b26d35e04 100644 --- a/frame/beefy/src/mock.rs +++ b/frame/beefy/src/mock.rs @@ -192,7 +192,7 @@ parameter_types! { pub const BondingDuration: EraIndex = 3; pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE; pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17); - pub const ElectionsBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::new().build(); + pub static ElectionsBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::new().build(); } pub struct OnChainSeqPhragmen; diff --git a/frame/grandpa/src/mock.rs b/frame/grandpa/src/mock.rs index 1f711f08094cd..b6677a3d8c648 100644 --- a/frame/grandpa/src/mock.rs +++ b/frame/grandpa/src/mock.rs @@ -173,7 +173,7 @@ parameter_types! { pub const BondingDuration: EraIndex = 3; pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE; pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17); - pub const ElectionsBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::new().build(); + pub static ElectionsBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::new().build(); } pub struct OnChainSeqPhragmen; diff --git a/frame/offences/benchmarking/src/mock.rs b/frame/offences/benchmarking/src/mock.rs index 0961e1afdbf55..083268268884d 100644 --- a/frame/offences/benchmarking/src/mock.rs +++ b/frame/offences/benchmarking/src/mock.rs @@ -144,7 +144,7 @@ pallet_staking_reward_curve::build! { } parameter_types! { pub const RewardCurve: &'static sp_runtime::curve::PiecewiseLinear<'static> = &I_NPOS; - pub const ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::new().build(); + pub static ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::new().build(); } pub type Extrinsic = sp_runtime::testing::TestXt; diff --git a/frame/root-offences/src/mock.rs b/frame/root-offences/src/mock.rs index c726c633da790..6ffb5c5707478 100644 --- a/frame/root-offences/src/mock.rs +++ b/frame/root-offences/src/mock.rs @@ -141,7 +141,7 @@ pallet_staking_reward_curve::build! { } parameter_types! { - pub const ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::new().build(); + pub static ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::new().build(); } pub struct OnChainSeqPhragmen; diff --git a/frame/session/benchmarking/src/mock.rs b/frame/session/benchmarking/src/mock.rs index 4a3fb5bb2075e..888dbc6042f03 100644 --- a/frame/session/benchmarking/src/mock.rs +++ b/frame/session/benchmarking/src/mock.rs @@ -148,7 +148,7 @@ pallet_staking_reward_curve::build! { } parameter_types! { pub const RewardCurve: &'static sp_runtime::curve::PiecewiseLinear<'static> = &I_NPOS; - pub const ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::new().build(); + pub static ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::new().build(); } pub struct OnChainSeqPhragmen; From c3b4375f283a2152797f75e1ff3869a9a4e582bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Tue, 11 Apr 2023 10:59:40 +0100 Subject: [PATCH 59/80] Update frame/election-provider-support/src/lib.rs Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> --- frame/election-provider-support/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/election-provider-support/src/lib.rs b/frame/election-provider-support/src/lib.rs index 4a4a4b2206865..cf75e3c060504 100644 --- a/frame/election-provider-support/src/lib.rs +++ b/frame/election-provider-support/src/lib.rs @@ -800,7 +800,7 @@ impl ElectionBoundsBuilder { ElectionBoundsBuilder { voters: Some(bounds.voters), targets: Some(bounds.targets) } } - // Sets the voters count bounds. + /// Sets the voters count bounds. pub fn voters_count(mut self, count: CountBound) -> Self { self.voters = self.voters.map_or( Some(DataProviderBounds { count: Some(count), size: None }), From 9f0319de30b355d6640bcc09b68c727c0a621fd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Tue, 11 Apr 2023 11:18:29 +0100 Subject: [PATCH 60/80] Update frame/staking/src/pallet/impls.rs Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> --- frame/staking/src/pallet/impls.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/staking/src/pallet/impls.rs b/frame/staking/src/pallet/impls.rs index 38c19ce1f4b59..7fe1abeb9946c 100644 --- a/frame/staking/src/pallet/impls.rs +++ b/frame/staking/src/pallet/impls.rs @@ -811,7 +811,7 @@ impl Pallet { } else if Validators::::contains_key(&voter) { // if this voter is a validator: if voters_size_tracker.try_register_voter(1, bounds).is_err() { - // no more space left for the election result, stop iterating over. + // no more space left for the election snapshot, stop iterating over. Self::deposit_event(Event::::SnapshotVotersSizeExceeded { size: voters_size_tracker.size as u32, }); From 8bd5ce9f18947622624edb6ab404de5b9c97996b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Tue, 11 Apr 2023 13:48:09 +0100 Subject: [PATCH 61/80] Update frame/election-provider-support/src/lib.rs Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> --- frame/election-provider-support/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/election-provider-support/src/lib.rs b/frame/election-provider-support/src/lib.rs index cf75e3c060504..e74540d59bed1 100644 --- a/frame/election-provider-support/src/lib.rs +++ b/frame/election-provider-support/src/lib.rs @@ -774,7 +774,7 @@ impl DataProviderBounds { } } -/// The limits of an election result. The bounds are defined over the count of element of the +/// The limits of an election snapshot size. The bounds are defined over the count of element of the /// election (voters or targets) or the overall size of the elements in MB. #[derive(Clone, Debug)] pub struct ElectionBounds { From 7970ade29b6a597e3f8b14345e05b43c78e15360 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Tue, 11 Apr 2023 14:09:31 +0100 Subject: [PATCH 62/80] Update frame/staking/src/tests.rs Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> --- frame/staking/src/tests.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index 1824fb4bfce93..620e1078c51ce 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -4682,6 +4682,7 @@ mod election_data_provider { ExtBuilder::default().nominate(false).build_and_execute(|| { // stash bond of 222 has a nomination quota of 2 targets. bond(61, 60, 222); + assert_eq(Staking::api_nomination_quota(222), 2); // nominating with targets below the nomination quota works. assert_ok!(Staking::nominate(RuntimeOrigin::signed(60), vec![11])); From 208ee20a1a7dec3053fa9bdf86372d3e77f7a4cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Tue, 11 Apr 2023 14:26:23 +0100 Subject: [PATCH 63/80] more checks in api_nominations_quota in tests --- frame/election-provider-support/src/lib.rs | 4 ++-- frame/staking/src/tests.rs | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/frame/election-provider-support/src/lib.rs b/frame/election-provider-support/src/lib.rs index e74540d59bed1..6c8ae430d1683 100644 --- a/frame/election-provider-support/src/lib.rs +++ b/frame/election-provider-support/src/lib.rs @@ -680,7 +680,7 @@ impl From for CountBound { impl Add for CountBound { type Output = Self; fn add(self, rhs: Self) -> Self::Output { - CountBound(self.0 + rhs.0) + CountBound(self.0.saturating_add(rhs.0)) } } @@ -709,7 +709,7 @@ impl Zero for SizeBound { impl Add for SizeBound { type Output = Self; fn add(self, rhs: Self) -> Self::Output { - SizeBound(self.0 + rhs.0) + SizeBound(self.0.saturating_add(rhs.0)) } } diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index 620e1078c51ce..ed5a75332de59 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -4682,7 +4682,7 @@ mod election_data_provider { ExtBuilder::default().nominate(false).build_and_execute(|| { // stash bond of 222 has a nomination quota of 2 targets. bond(61, 60, 222); - assert_eq(Staking::api_nomination_quota(222), 2); + assert_eq!(Staking::api_nominations_quota(222), 2); // nominating with targets below the nomination quota works. assert_ok!(Staking::nominate(RuntimeOrigin::signed(60), vec![11])); @@ -4710,6 +4710,7 @@ mod election_data_provider { // unbond 78 from stash 60 so that it's bonded balance is 222, which has a lower // nomination quota than at nomination time (max 2 targets). assert_ok!(Staking::unbond(RuntimeOrigin::signed(60), 78)); + assert_eq!(Staking::api_nominations_quota(300 - 78), 2); // even through 61 has nomination quota of 2 at the time of the election, all the // nominations (5) will be used. From 6c5b3b193637b07bb750498617be7fefcffc361f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Tue, 11 Apr 2023 18:04:13 +0100 Subject: [PATCH 64/80] Improves docs --- frame/staking/src/lib.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/frame/staking/src/lib.rs b/frame/staking/src/lib.rs index e50c5d5bb7bbf..94528f3bcc556 100644 --- a/frame/staking/src/lib.rs +++ b/frame/staking/src/lib.rs @@ -767,10 +767,13 @@ impl UnappliedSlash { } /// Something that defines the maximum number of nominations per nominator based on a curve. +/// +/// The method `curve` implements the nomination quota curve and should not be used directly. +/// However, `get_quota` returns the bounded maximum number of nominations based on `fn curve` and +/// the nominator's balance. pub trait NominationsQuota { - /// Maximum number of nominations. The method `curve` implements the nomination quota curve and - /// should not be used directly. However, `get_quota` returns the bounded maximum number of - // nominations based on `fn curve` and the nominator's balance. + /// Strict maximum number of nominations that caps the nominations curve. This value can be + /// used as the upper bound of the number of votes per nominator. type MaxNominations: Get; /// Returns the voter's nomination quota within reasonable bounds [`min`, `max`], where `min` @@ -779,7 +782,7 @@ pub trait NominationsQuota { Self::curve(balance).clamp(1, Self::MaxNominations::get()) } - // Returns the voter's nomination quota based on its balance and a curve. + /// Returns the voter's nomination quota based on its balance and a curve. fn curve(balance: Balance) -> u32; } @@ -849,7 +852,7 @@ where /// number of cast `votes`. pub fn encoded_size(votes: usize) -> usize { Self::length_prefix(votes) - .saturating_add(votes * sp_std::mem::size_of::()) + .saturating_add(votes.saturating_mul(sp_std::mem::size_of::())) .saturating_add(sp_std::mem::size_of::()) .saturating_add(sp_std::mem::size_of::()) } From 6619b5d3017245448a3e8d7f229b00f7d49aa607 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Wed, 12 Apr 2023 10:08:52 +0100 Subject: [PATCH 65/80] fixes e2e tests --- .../test-staking-e2e/Cargo.lock | 116 ++++++++++-------- .../test-staking-e2e/src/mock.rs | 4 + 2 files changed, 72 insertions(+), 48 deletions(-) diff --git a/frame/election-provider-multi-phase/test-staking-e2e/Cargo.lock b/frame/election-provider-multi-phase/test-staking-e2e/Cargo.lock index 0b5805b3dd2a9..75201e5f35724 100644 --- a/frame/election-provider-multi-phase/test-staking-e2e/Cargo.lock +++ b/frame/election-provider-multi-phase/test-staking-e2e/Cargo.lock @@ -150,15 +150,9 @@ dependencies = [ [[package]] name = "base16ct" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" - -[[package]] -name = "base58" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6107fe1be6682a68940da878d9e9f5e90ca5745b3dec9fd1bb393c8777d4f581" +checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" [[package]] name = "base64" @@ -270,6 +264,12 @@ dependencies = [ "serde", ] +[[package]] +name = "bs58" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" + [[package]] name = "bumpalo" version = "3.11.1" @@ -351,9 +351,9 @@ dependencies = [ [[package]] name = "const-oid" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cec318a675afcb6a1ea1d4340e2d377e56e47c266f28043ceccbf4412ddfdd3b" +checksum = "520fbf3c07483f94e3e3ca9d0cfd913d7718ef2483d2cfd91c0d9e91474ab913" [[package]] name = "constant_time_eq" @@ -411,9 +411,9 @@ checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" [[package]] name = "crypto-bigint" -version = "0.4.9" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" +checksum = "7c2538c4e68e52548bacb3e83ac549f903d44f011ac9d5abb5e132e67d0808f7" dependencies = [ "generic-array 0.14.6", "rand_core 0.6.4", @@ -523,9 +523,9 @@ dependencies = [ [[package]] name = "der" -version = "0.6.1" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de" +checksum = "82b10af9f9f9f2134a42d3f8aa74658660f2e0234b0eb81bd171df8aa32779ed" dependencies = [ "const-oid", "zeroize", @@ -578,6 +578,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" dependencies = [ "block-buffer 0.10.3", + "const-oid", "crypto-common", "subtle", ] @@ -617,14 +618,15 @@ checksum = "4f94fa09c2aeea5b8839e414b7b841bf429fd25b9c522116ac97ee87856d88b2" [[package]] name = "ecdsa" -version = "0.14.8" +version = "0.16.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" +checksum = "a48e5d537b8a30c0b023116d981b16334be1485af7ca68db3a2b7024cbc957fd" dependencies = [ "der", + "digest 0.10.6", "elliptic-curve", "rfc6979", - "signature", + "signature 2.1.0", ] [[package]] @@ -633,7 +635,7 @@ version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e9c280362032ea4203659fc489832d0204ef09f247a0506f170dafcac08c369" dependencies = [ - "signature", + "signature 1.6.4", ] [[package]] @@ -670,17 +672,17 @@ checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" [[package]] name = "elliptic-curve" -version = "0.12.3" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" +checksum = "75c71eaa367f2e5d556414a8eea812bc62985c879748d6403edabd9cb03f16e7" dependencies = [ "base16ct", "crypto-bigint", - "der", "digest 0.10.6", "ff", "generic-array 0.14.6", "group", + "pkcs8", "rand_core 0.6.4", "sec1", "subtle", @@ -741,9 +743,9 @@ checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" [[package]] name = "ff" -version = "0.12.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" +checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" dependencies = [ "rand_core 0.6.4", "subtle", @@ -873,6 +875,7 @@ dependencies = [ "derive-syn-parse", "frame-support-procedural-tools", "itertools", + "proc-macro-warning", "proc-macro2", "quote", "syn", @@ -1040,6 +1043,7 @@ checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" dependencies = [ "typenum", "version_check", + "zeroize", ] [[package]] @@ -1076,9 +1080,9 @@ dependencies = [ [[package]] name = "group" -version = "0.12.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" +checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" dependencies = [ "ff", "rand_core 0.6.4", @@ -1298,13 +1302,14 @@ dependencies = [ [[package]] name = "k256" -version = "0.11.6" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72c1e0b51e7ec0a97369623508396067a486bd0cbed95a2659a4b863d28cfc8b" +checksum = "cadb76004ed8e97623117f3df85b17aaa6626ab0b0831e6573f104df16cd1bcc" dependencies = [ "cfg-if", "ecdsa", "elliptic-curve", + "once_cell", "sha2 0.10.6", ] @@ -1631,9 +1636,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.16.0" +version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" +checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" [[package]] name = "opaque-debug" @@ -1788,7 +1793,6 @@ dependencies = [ "serde", "sp-application-crypto", "sp-io", - "sp-npos-elections", "sp-runtime", "sp-staking", "sp-std", @@ -1911,9 +1915,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkcs8" -version = "0.9.0" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" dependencies = [ "der", "spki", @@ -1949,11 +1953,22 @@ dependencies = [ "toml", ] +[[package]] +name = "proc-macro-warning" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d4f284d87b9cedc2ff57223cbc4e3937cd6063c01e92c8e2a8c080df0013933" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "proc-macro2" -version = "1.0.47" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725" +checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" dependencies = [ "unicode-ident", ] @@ -1969,9 +1984,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.21" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" +checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" dependencies = [ "proc-macro2", ] @@ -2116,13 +2131,12 @@ checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" [[package]] name = "rfc6979" -version = "0.3.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" +checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" dependencies = [ - "crypto-bigint", "hmac 0.12.1", - "zeroize", + "subtle", ] [[package]] @@ -2247,9 +2261,9 @@ checksum = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898" [[package]] name = "sec1" -version = "0.3.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" +checksum = "48518a2b5775ba8ca5b46596aae011caa431e6ce7e4a67ead66d92f08884220e" dependencies = [ "base16ct", "der", @@ -2377,6 +2391,12 @@ name = "signature" version = "1.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" + +[[package]] +name = "signature" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" dependencies = [ "digest 0.10.6", "rand_core 0.6.4", @@ -2470,10 +2490,10 @@ name = "sp-core" version = "7.0.0" dependencies = [ "array-bytes", - "base58", "bitflags", "blake2", "bounded-collections", + "bs58", "dyn-clonable", "ed25519-zebra", "futures", @@ -2574,6 +2594,7 @@ dependencies = [ "libsecp256k1", "log", "parity-scale-codec", + "rustversion", "secp256k1", "sp-core", "sp-externalities", @@ -2591,7 +2612,6 @@ dependencies = [ name = "sp-keystore" version = "0.13.0" dependencies = [ - "async-trait", "futures", "merlin", "parity-scale-codec", @@ -2763,7 +2783,7 @@ version = "7.0.0" dependencies = [ "ahash 0.8.3", "hash-db", - "hashbrown 0.12.3", + "hashbrown 0.13.2", "lazy_static", "memory-db", "nohash-hasher", @@ -2834,9 +2854,9 @@ dependencies = [ [[package]] name = "spki" -version = "0.6.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" +checksum = "37a5be806ab6f127c3da44b7378837ebf01dadca8510a0e572460216b228bd0e" dependencies = [ "base64ct", "der", @@ -2912,9 +2932,9 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "syn" -version = "1.0.105" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60b9b43d45702de4c839cb9b51d9f529c5dd26a4aff255b42b1ebc03e88ee908" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ "proc-macro2", "quote", diff --git a/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs b/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs index b2ed49d5b9a43..e0a316a896487 100644 --- a/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs +++ b/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs @@ -126,6 +126,10 @@ impl pallet_balances::Config for Runtime { type DustRemoval = (); type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; + type MaxHolds = (); + type MaxFreezes = (); + type HoldIdentifier = (); + type FreezeIdentifier = (); type WeightInfo = (); } From 02d8e78101eff3d85f540e9ee8a9030d0787331c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Wed, 12 Apr 2023 10:10:00 +0100 Subject: [PATCH 66/80] Uses size_hint rather than mem::size_of in size tracker; Refactor size tracker to own module --- frame/election-provider-support/src/lib.rs | 2 +- .../election-provider-support/src/onchain.rs | 3 +- frame/staking/src/election_size_tracker.rs | 243 ++++++++++++++++++ frame/staking/src/lib.rs | 74 +----- frame/staking/src/pallet/impls.rs | 30 ++- frame/staking/src/tests.rs | 111 +------- 6 files changed, 264 insertions(+), 199 deletions(-) create mode 100644 frame/staking/src/election_size_tracker.rs diff --git a/frame/election-provider-support/src/lib.rs b/frame/election-provider-support/src/lib.rs index 6c8ae430d1683..f85f49ccca225 100644 --- a/frame/election-provider-support/src/lib.rs +++ b/frame/election-provider-support/src/lib.rs @@ -274,7 +274,7 @@ pub mod data_provider { /// Something that can provide the data to an [`ElectionProvider`]. pub trait ElectionDataProvider { /// The account identifier type. - type AccountId; + type AccountId: Encode; /// The block number type. type BlockNumber; diff --git a/frame/election-provider-support/src/onchain.rs b/frame/election-provider-support/src/onchain.rs index dc5a0a57982d8..cd4ef205fa4ee 100644 --- a/frame/election-provider-support/src/onchain.rs +++ b/frame/election-provider-support/src/onchain.rs @@ -53,8 +53,7 @@ impl From for Error { /// This implements both `ElectionProvider` and `InstantElectionProvider`. /// /// This type has some utilities to make it safe. Nonetheless, it should be used with utmost care. A -/// thoughtful value must be set as [`Config::ElectionBounds`] to ensure the size of the input is -/// sensible. +/// thoughtful value must be set as [`Config::Bounds`] to ensure the size of the input is sensible. pub struct OnChainExecution(PhantomData); #[deprecated(note = "use OnChainExecution, which is bounded by default")] diff --git a/frame/staking/src/election_size_tracker.rs b/frame/staking/src/election_size_tracker.rs new file mode 100644 index 0000000000000..6d478a71b9139 --- /dev/null +++ b/frame/staking/src/election_size_tracker.rs @@ -0,0 +1,243 @@ +// 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. + +//! ## A static size tracker for the election snapshot data. +//! +//! ### Overview + +//! The goal of the size tracker is to provide a static, no-allocation byte tracker to be +//! used by the election data provider when preparing the results of +//! [`ElectionDataProvider::electing_voters`]. The [`StaticTracker`] implementation uses +//! [`codec::Encode::size_hint`] to estimate the SCALE encoded size of the snapshot voters struct +//! as it is being constructed without requiring extra stack allocations. +//! The [`StaticTracker::try_register_voter`] is called to update the static tracker internal +//! state, if It will return an error if the resulting SCALE encoded size (in bytes) is larger than +//! the provided `DataProviderBounds`. +//! +//! ### Example +//! +//! ```rust,ignore +//! // instantiates a new tracker. +//! let mut size_tracker = StaticTracker::::default(); +//! +//! let voter_bounds = ElectionBoundsBuilder::new().voter_size(1_00.into()).build().voters; +//! +//! let mut sorted_voters = T::VoterList.iter(); +//! let mut selected_voters = vec![]; +//! +//! // fit as many voters in the vec as the bounds permit. +//! for v in sorted_voters { +//! let voter = (v, weight_of(&v), targets_of(&v)); +//! if size_tracker.try_register_voter(&voter, &voter_bounds).is_err() { +//! log!(warn, "voter bounds size exhausted"); +//! break +//! } +//! selected_voters.push(voter); +//! } +//! +//! // The SCALE encoded size in bytes of `selected_voters` is guaranteed to be below +//! // `voter_bounds`. +//! debug_assert!( +//! selected_voters.encoded_size() <= +//! SizeTracker::::final_byte_size_of(size_tracker.num_voters, size_tracker.size) +//! ); +//! ``` +//! +//! ### Implementation Details +//! +//! The current implementation of the static tracker is tightly coupled with the staking pallet +//! implementation, namely the representation of a voter ([`VoterOf`]). The SCALE encoded byte size +//! is calculated using [`Encode::size_hint`] of each type in the voter tuple. Each voter's byte +//! size is the sum of: +//! - 1 * [`Encode::size_hint`] of the `AccountId` type; +//! - 1 * [`Encode::size_hint`] of the `VoteWeight` type; +//! - `num_votes` * [`Encode::size_hint`] of the `AccountId` type. + +use codec::Encode; +use frame_election_provider_support::{ + DataProviderBounds, ElectionDataProvider, SizeBound, VoterOf, +}; + +/// Keeps track of the SCALE encoded byte length of the snapshot's voters struct. +/// +/// The tracker calculates the bytes used based on static rules, without requiring any actual +/// encoding or extra allocations. +#[derive(Clone, Copy, Debug)] +pub struct StaticTracker { + pub size: usize, + pub num_voters: usize, + _marker: sp_std::marker::PhantomData, +} + +impl Default for StaticTracker { + fn default() -> Self { + Self { size: 0, num_voters: 0, _marker: Default::default() } + } +} + +impl StaticTracker +where + DataProvider: ElectionDataProvider, +{ + /// Tries to register a new voter. + /// + /// If the new voter exhausts the provided bounds, return an error. Otherwise, the internal + /// state of the tracker is updated with the new registered voter. + pub fn try_register_voter( + &mut self, + voter: &VoterOf, + bounds: &DataProviderBounds, + ) -> Result<(), ()> { + let tracker_size_after = { + let voter_hint = Self::voter_size_hint(voter); + Self::final_byte_size_of(self.num_voters + 1, self.size.saturating_add(voter_hint)) + }; + + match bounds.size_exhausted(SizeBound(tracker_size_after as u32)) { + true => Err(()), + false => { + self.size = tracker_size_after; + self.num_voters += 1; + Ok(()) + }, + } + } + + /// Size of the SCALE encoded prefix with a given length. + #[inline] + fn length_prefix(len: usize) -> usize { + use codec::{Compact, CompactLen}; + Compact::::compact_len(&(len as u32)) + } + + /// Calculates the size of the voter to register based on [`Encode::size_hint`]. + fn voter_size_hint(voter: &VoterOf) -> usize { + let (voter_account, vote_weight, targets) = voter; + + voter_account + .size_hint() + .saturating_add(vote_weight.size_hint()) + .saturating_add(voter_account.size_hint().saturating_mul(targets.len())) + } + + /// Calculates the final size in bytes of the SCALE encoded snapshot voter struct. + fn final_byte_size_of(num_voters: usize, size: usize) -> usize { + Self::length_prefix(num_voters).saturating_add(size) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::{ + mock::{AccountId, Staking, Test}, + BoundedVec, MaxNominationsOf, + }; + use frame_election_provider_support::ElectionBoundsBuilder; + use sp_core::bounded_vec; + + type Voters = BoundedVec>; + + #[test] + pub fn election_size_tracker_works() { + let mut voters: Vec<(u64, u64, Voters)> = vec![]; + let mut size_tracker = StaticTracker::::default(); + let voter_bounds = ElectionBoundsBuilder::new().voters_size(1_50.into()).build().voters; + + // register 1 voter with 1 vote. + let voter = (1, 10, bounded_vec![2]); + assert!(size_tracker.try_register_voter(&voter, &voter_bounds).is_ok()); + voters.push(voter); + + assert_eq!( + StaticTracker::::final_byte_size_of( + size_tracker.num_voters, + size_tracker.size + ), + voters.encoded_size() + ); + + // register another voter, now with 3 votes. + let voter = (2, 20, bounded_vec![3, 4, 5]); + assert!(size_tracker.try_register_voter(&voter, &voter_bounds).is_ok()); + voters.push(voter); + + assert_eq!( + StaticTracker::::final_byte_size_of( + size_tracker.num_voters, + size_tracker.size + ), + voters.encoded_size() + ); + + // register noop vote (unlikely to happen). + let voter = (3, 30, bounded_vec![]); + assert!(size_tracker.try_register_voter(&voter, &voter_bounds).is_ok()); + voters.push(voter); + + assert_eq!( + StaticTracker::::final_byte_size_of( + size_tracker.num_voters, + size_tracker.size + ), + voters.encoded_size() + ); + } + + #[test] + pub fn election_size_tracker_bounds_works() { + let mut voters: Vec<(u64, u64, Voters)> = vec![]; + let mut size_tracker = StaticTracker::::default(); + let voter_bounds = ElectionBoundsBuilder::new().voters_size(1_00.into()).build().voters; + + let voter = (1, 10, bounded_vec![2]); + assert!(size_tracker.try_register_voter(&voter, &voter_bounds).is_ok()); + voters.push(voter); + + assert_eq!( + StaticTracker::::final_byte_size_of( + size_tracker.num_voters, + size_tracker.size + ), + voters.encoded_size() + ); + + assert!(size_tracker.size > 0 && size_tracker.size < 1_00); + let size_before_overflow = size_tracker.size; + + // try many voters that will overflow the tracker's buffer. + let voter = (2, 10, bounded_vec![2, 3, 4, 5, 6, 7, 8, 9]); + voters.push(voter.clone()); + + assert!(size_tracker.try_register_voter(&voter, &voter_bounds).is_err()); + assert!(size_tracker.size > 0 && size_tracker.size < 1_00); + + // size of the tracker did not update when trying to register votes failed. + assert_eq!(size_tracker.size, size_before_overflow); + } + + #[test] + fn len_prefix_works() { + let length_samples = + vec![0usize, 1, 62, 63, 64, 16383, 16384, 16385, 1073741822, 1073741823, 1073741824]; + + for s in length_samples { + // the encoded size of a vector of n bytes should be n + the length prefix + assert_eq!(vec![1u8; s].encoded_size(), StaticTracker::::length_prefix(s) + s); + } + } +} diff --git a/frame/staking/src/lib.rs b/frame/staking/src/lib.rs index 94528f3bcc556..d325eac81c683 100644 --- a/frame/staking/src/lib.rs +++ b/frame/staking/src/lib.rs @@ -292,6 +292,7 @@ pub(crate) mod mock; #[cfg(test)] mod tests; +pub mod election_size_tracker; pub mod inflation; pub mod migrations; pub mod slashing; @@ -300,7 +301,6 @@ pub mod weights; mod pallet; use codec::{Decode, Encode, HasCompact, MaxEncodedLen}; -use frame_election_provider_support::{DataProviderBounds, IdentifierT, SizeBound}; use frame_support::{ traits::{ConstU32, Currency, Defensive, Get}, weights::Weight, @@ -796,78 +796,6 @@ impl NominationsQuota for FixedNominationsQuot } } -/// A static tracker for the election data snapshot. -/// -/// Computes the (SCALE) encoded byte length of a snapshot based on static rules, without any actual -/// encoding. -/// -/// ## Details -/// -/// The snapshot has the form of `Vec` where `Voter = (Account, u64, Vec)`. For -/// each voter added to the snapshot, [`try_register_voter`] should be called, with the number -/// of votes (length of the internal `Vec`). -/// -/// Whilst doing this, [`size`] will track the entire size of the `Vec`, except for the -/// length prefix of the outer `Vec`. To get the final size at any point, use -/// [`final_byte_size_of`]. -#[derive(Copy, Clone, Debug)] -pub(crate) struct ElectionSizeTracker { - pub size: usize, - pub num_voters: usize, - _marker: sp_std::marker::PhantomData, -} - -impl ElectionSizeTracker -where - AccountId: IdentifierT, -{ - pub(crate) fn new() -> Self { - ElectionSizeTracker { size: 0, num_voters: 0, _marker: Default::default() } - } - - /// Attempts to register a new voter with `votes` for a given election `bounds`. Returns an - /// error if the new size exceeds the capacity of the tracker. - pub(crate) fn try_register_voter( - &mut self, - votes: usize, - bounds: DataProviderBounds, - ) -> Result<(), ()> { - let voters_size_after = self.size.saturating_add(Self::encoded_size(votes)); - - // the total encoded size takes into consideration the prefix of the outer vec, which - // contains all the voters. - let total_size_after = Self::final_byte_size_of(self.num_voters + 1, voters_size_after); - - match bounds.size_exhausted(SizeBound(total_size_after as u32)) { - true => Err(()), - false => { - self.size = voters_size_after; - self.num_voters += 1; - Ok(()) - }, - } - } - - /// Returns the size in MBs of the scale encoded structure that stores a `Voter` with a given - /// number of cast `votes`. - pub fn encoded_size(votes: usize) -> usize { - Self::length_prefix(votes) - .saturating_add(votes.saturating_mul(sp_std::mem::size_of::())) - .saturating_add(sp_std::mem::size_of::()) - .saturating_add(sp_std::mem::size_of::()) - } - // Size of the SCALE encoded prefix with a given length. - #[inline] - pub(crate) fn length_prefix(len: usize) -> usize { - use codec::{Compact, CompactLen}; - Compact::::compact_len(&(len as u32)) - } - - pub(crate) fn final_byte_size_of(num_voters: usize, size: usize) -> usize { - Self::length_prefix(num_voters).saturating_add(size) - } -} - /// Means for interacting with a specialized version of the `session` trait. /// /// This is needed because `Staking` sets the `ValidatorIdOf` of the `pallet_session::Config` diff --git a/frame/staking/src/pallet/impls.rs b/frame/staking/src/pallet/impls.rs index 7fe1abeb9946c..057ec5856a893 100644 --- a/frame/staking/src/pallet/impls.rs +++ b/frame/staking/src/pallet/impls.rs @@ -43,10 +43,10 @@ use sp_staking::{ use sp_std::prelude::*; use crate::{ - log, slashing, weights::WeightInfo, ActiveEraInfo, BalanceOf, ElectionSizeTracker, EraPayout, - Exposure, ExposureOf, Forcing, IndividualExposure, MaxNominationsOf, MaxWinnersOf, Nominations, - NominationsQuota, PositiveImbalanceOf, RewardDestination, SessionInterface, StakingLedger, - ValidatorPrefs, + election_size_tracker::StaticTracker, log, slashing, weights::WeightInfo, ActiveEraInfo, + BalanceOf, EraPayout, Exposure, ExposureOf, Forcing, IndividualExposure, MaxNominationsOf, + MaxWinnersOf, Nominations, NominationsQuota, PositiveImbalanceOf, RewardDestination, + SessionInterface, StakingLedger, ValidatorPrefs, }; use super::{pallet::*, STAKING_ID}; @@ -756,7 +756,7 @@ impl Pallet { /// /// This function is self-weighing as [`DispatchClass::Mandatory`]. pub fn get_npos_voters(bounds: DataProviderBounds) -> Vec> { - let mut voters_size_tracker: ElectionSizeTracker = ElectionSizeTracker::new(); + let mut voters_size_tracker: StaticTracker = StaticTracker::default(); let max_allowed_len = { let all_voter_count = T::VoterList::count(); @@ -793,7 +793,8 @@ impl Pallet { // voter at this point and accept all the current nominations. The nomination // quota is only enforced at `nominate` time. - if voters_size_tracker.try_register_voter(targets.len(), bounds).is_err() { + let voter = (voter, voter_weight, targets); + if voters_size_tracker.try_register_voter(&voter, &bounds).is_err() { // no more space left for the election result, stop iterating. Self::deposit_event(Event::::SnapshotVotersSizeExceeded { size: voters_size_tracker.size as u32, @@ -801,7 +802,7 @@ impl Pallet { break } - all_voters.push((voter.clone(), voter_weight, targets)); + all_voters.push(voter); nominators_taken.saturating_inc(); } else { // technically should never happen, but not much we can do about it. @@ -810,13 +811,6 @@ impl Pallet { if voter_weight < min_active_stake { voter_weight } else { min_active_stake }; } else if Validators::::contains_key(&voter) { // if this voter is a validator: - if voters_size_tracker.try_register_voter(1, bounds).is_err() { - // no more space left for the election snapshot, stop iterating over. - Self::deposit_event(Event::::SnapshotVotersSizeExceeded { - size: voters_size_tracker.size as u32, - }); - break - } let self_vote = ( voter.clone(), weight_of(&voter), @@ -824,6 +818,14 @@ impl Pallet { .try_into() .expect("`MaxVotesPerVoter` must be greater than or equal to 1"), ); + + if voters_size_tracker.try_register_voter(&self_vote, &bounds).is_err() { + // no more space left for the election snapshot, stop iterating. + Self::deposit_event(Event::::SnapshotVotersSizeExceeded { + size: voters_size_tracker.size as u32, + }); + break + } all_voters.push(self_vote); validators_taken.saturating_inc(); } else { diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index ed5a75332de59..8aa0749fc03cb 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -19,7 +19,7 @@ use super::{ConfigOp, Event, *}; use frame_election_provider_support::{ - ElectionBoundsBuilder, ElectionProvider, SortedListProvider, Support, + DataProviderBounds, ElectionBoundsBuilder, ElectionProvider, SortedListProvider, Support, }; use frame_support::{ assert_noop, assert_ok, assert_storage_noop, bounded_vec, @@ -4666,7 +4666,7 @@ mod election_data_provider { // set size bounds that allows only for 1 voter. let bounds = ElectionBoundsBuilder::new().voters_size(26.into()).build(); let elected = Staking::electing_voters(bounds.voters).unwrap(); - assert!(elected.encoded_size() <= 26 as usize); + assert!(elected.encoded_size() == 26 as usize); let prev_len = elected.len(); // larger size bounds means more quota for voters. @@ -5962,113 +5962,6 @@ fn set_min_commission_works_with_admin_origin() { }) } -mod election_size_tracker { - use super::*; - - #[test] - pub fn encoded_size_works() { - let voter: (u64, u64, Vec) = (1, 100, vec![]); - assert_eq!( - voter.encoded_size(), - ElectionSizeTracker::::encoded_size(voter.2.len()) - ); - - let voter: (u64, u64, Vec) = (1, 100, vec![2]); - assert_eq!( - voter.encoded_size(), - ElectionSizeTracker::::encoded_size(voter.2.len()) - ); - - let voter: (u64, u64, Vec) = (1, 100, vec![1, 2, 3, 4]); - assert_eq!( - voter.encoded_size(), - ElectionSizeTracker::::encoded_size(voter.2.len()) - ); - } - - #[test] - pub fn election_size_tracker_works() { - let mut voters: Vec<(u64, u64, Vec)> = vec![]; - let mut size_tracker = ElectionSizeTracker::::new(); - let voter_bounds = ElectionBoundsBuilder::new().voters_size(1_50.into()).build().voters; - - // register 1 voter with 1 vote. - voters.push((1, 10, vec![2])); - assert!(size_tracker.try_register_voter(1, voter_bounds).is_ok()); - assert_eq!( - ElectionSizeTracker::::final_byte_size_of( - size_tracker.num_voters, - size_tracker.size - ), - voters.encoded_size() - ); - - // register another voter, now with 3 votes. - voters.push((2, 20, vec![3, 4, 5])); - assert!(size_tracker.try_register_voter(3, voter_bounds).is_ok()); - assert_eq!( - ElectionSizeTracker::::final_byte_size_of( - size_tracker.num_voters, - size_tracker.size - ), - voters.encoded_size() - ); - - // register noop vote (unlikely to happen). - voters.push((3, 30, vec![])); - assert!(size_tracker.try_register_voter(0, voter_bounds).is_ok()); - assert_eq!( - ElectionSizeTracker::::final_byte_size_of( - size_tracker.num_voters, - size_tracker.size - ), - voters.encoded_size() - ); - } - - #[test] - pub fn election_size_tracker_bounds_works() { - let mut voters: Vec<(u64, u64, Vec)> = vec![]; - let mut size_tracker = ElectionSizeTracker::::new(); - let voter_bounds = ElectionBoundsBuilder::new().voters_size(1_00.into()).build().voters; - - voters.push((1, 10, vec![2])); - assert!(size_tracker.try_register_voter(1, voter_bounds).is_ok()); - assert_eq!( - ElectionSizeTracker::::final_byte_size_of( - size_tracker.num_voters, - size_tracker.size - ), - voters.encoded_size() - ); - - assert!(size_tracker.size > 0 && size_tracker.size < 1_00); - let size_before_overflow = size_tracker.size; - - // try many voters that will overflow the tracker's buffer. - voters.push((2, 10, vec![2, 3, 4, 5, 6, 7])); - assert!(size_tracker.try_register_voter(10, voter_bounds).is_err()); - assert!(size_tracker.size > 0 && size_tracker.size < 1_00); - - // size of the tracker did not update when trying to register votes failed. - assert_eq!(size_tracker.size, size_before_overflow); - } - - #[test] - fn len_prefix_works() { - let length_samples = - vec![0usize, 1, 62, 63, 64, 16383, 16384, 16385, 1073741822, 1073741823, 1073741824]; - - for s in length_samples { - // the encoded size of a vector of n bytes should be n + the length prefix - assert_eq!( - vec![1u8; s].encoded_size(), - ElectionSizeTracker::::length_prefix(s) + s - ); - } - } -} - mod staking_interface { use frame_support::storage::with_storage_layer; use sp_staking::StakingInterface; From d18b1752e973b258cb3608f1e53304132978d533 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Thu, 13 Apr 2023 09:51:09 +0100 Subject: [PATCH 67/80] nits from reviews --- frame/staking/src/pallet/impls.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frame/staking/src/pallet/impls.rs b/frame/staking/src/pallet/impls.rs index 2d5c0ee6b20d6..b167da0c3cc47 100644 --- a/frame/staking/src/pallet/impls.rs +++ b/frame/staking/src/pallet/impls.rs @@ -1029,7 +1029,7 @@ impl ElectionDataProvider for Pallet { let voters = Self::get_npos_voters(bounds); debug_assert!(!bounds.exhausted( - SizeBound(voters.encoded_size().saturating_sub(1) as u32).into(), + SizeBound(voters.encoded_size() as u32).into(), CountBound(voters.len() as u32).into() )); @@ -1039,7 +1039,8 @@ impl ElectionDataProvider for Pallet { fn electable_targets(bounds: DataProviderBounds) -> data_provider::Result> { let target_count = T::TargetList::count(); - // We can't handle this case yet -- return an error. + // We can't handle this case yet -- return an error. WIP to improve handling this case in + // . if bounds.exhausted(None, CountBound(target_count as u32).into()) { return Err("Target snapshot too big") } From 4769857b8453cb33b7b33059cc356baa7b81861f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Wed, 19 Apr 2023 16:15:24 +0200 Subject: [PATCH 68/80] Refactors bounds to own module; improves docs --- bin/node/runtime/src/lib.rs | 8 +- frame/babe/src/mock.rs | 5 +- frame/bags-list/remote-tests/src/snapshot.rs | 2 +- frame/beefy/src/mock.rs | 5 +- .../src/benchmarking.rs | 2 +- .../election-provider-multi-phase/src/lib.rs | 14 +- .../election-provider-multi-phase/src/mock.rs | 9 +- .../src/signed.rs | 4 +- .../test-staking-e2e/Cargo.lock | 679 +++++++++++------- .../test-staking-e2e/src/mock.rs | 14 +- frame/election-provider-support/src/bounds.rs | 374 ++++++++++ frame/election-provider-support/src/lib.rs | 226 +----- .../election-provider-support/src/onchain.rs | 12 +- frame/election-provider-support/src/tests.rs | 76 -- frame/grandpa/src/mock.rs | 5 +- frame/offences/benchmarking/src/mock.rs | 5 +- frame/root-offences/src/mock.rs | 5 +- frame/session/benchmarking/src/mock.rs | 5 +- frame/staking/src/benchmarking.rs | 2 +- frame/staking/src/election_size_tracker.rs | 51 +- frame/staking/src/mock.rs | 5 +- frame/staking/src/pallet/impls.rs | 5 +- frame/staking/src/tests.rs | 17 +- 23 files changed, 886 insertions(+), 644 deletions(-) create mode 100644 frame/election-provider-support/src/bounds.rs diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index e9d3246c7160d..ff993766a3e24 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -24,8 +24,8 @@ use codec::{Decode, Encode, MaxEncodedLen}; use frame_election_provider_support::{ - onchain, BalancingConfig, ElectionBounds, ElectionBoundsBuilder, ElectionDataProvider, - SequentialPhragmen, VoteWeight, + bounds::{ElectionBounds, ElectionBoundsBuilder}, + onchain, BalancingConfig, ElectionDataProvider, SequentialPhragmen, VoteWeight, }; use frame_support::{ construct_runtime, @@ -654,9 +654,9 @@ frame_election_provider_support::generate_solution_type!( parameter_types! { // Note: the EPM in this runtime runs the election on-chain. The election bounds must be // carefully set so that an election round fits in one block. - pub ElectionBoundsMultiPhase: ElectionBounds = ElectionBoundsBuilder::new() + pub ElectionBoundsMultiPhase: ElectionBounds = ElectionBoundsBuilder::default() .voters_count(10_000.into()).targets_count(1_500.into()).build(); - pub ElectionBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::new() + pub ElectionBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::default() .voters_count(5_000.into()).targets_count(1_250.into()).build(); pub MaxNominations: u32 = ::LIMIT as u32; diff --git a/frame/babe/src/mock.rs b/frame/babe/src/mock.rs index b6c594b8543ab..5e0bad71639b7 100644 --- a/frame/babe/src/mock.rs +++ b/frame/babe/src/mock.rs @@ -20,7 +20,8 @@ use crate::{self as pallet_babe, Config, CurrentSlot}; use codec::Encode; use frame_election_provider_support::{ - onchain, ElectionBounds, ElectionBoundsBuilder, SequentialPhragmen, + bounds::{ElectionBounds, ElectionBoundsBuilder}, + onchain, SequentialPhragmen, }; use frame_support::{ parameter_types, @@ -169,7 +170,7 @@ parameter_types! { pub const SlashDeferDuration: EraIndex = 0; pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE; pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(16); - pub static ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::new().build(); + pub static ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::default().build(); } pub struct OnChainSeqPhragmen; diff --git a/frame/bags-list/remote-tests/src/snapshot.rs b/frame/bags-list/remote-tests/src/snapshot.rs index 4235f513ba066..270ef01d508c3 100644 --- a/frame/bags-list/remote-tests/src/snapshot.rs +++ b/frame/bags-list/remote-tests/src/snapshot.rs @@ -16,7 +16,7 @@ //! Test to execute the snapshot using the voter bag. -use frame_election_provider_support::{ElectionBounds, SortedListProvider}; +use frame_election_provider_support::{bounds::ElectionBounds, SortedListProvider}; use frame_support::traits::PalletInfoAccess; use remote_externalities::{Builder, Mode, OnlineConfig}; use sp_runtime::{traits::Block as BlockT, DeserializeOwned}; diff --git a/frame/beefy/src/mock.rs b/frame/beefy/src/mock.rs index f223b26d35e04..a55bdf11f5097 100644 --- a/frame/beefy/src/mock.rs +++ b/frame/beefy/src/mock.rs @@ -18,7 +18,8 @@ use std::vec; use frame_election_provider_support::{ - onchain, ElectionBounds, ElectionBoundsBuilder, SequentialPhragmen, + bounds::{ElectionBounds, ElectionBoundsBuilder}, + onchain, SequentialPhragmen, }; use frame_support::{ construct_runtime, parameter_types, @@ -192,7 +193,7 @@ parameter_types! { pub const BondingDuration: EraIndex = 3; pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE; pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17); - pub static ElectionsBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::new().build(); + pub static ElectionsBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::default().build(); } pub struct OnChainSeqPhragmen; diff --git a/frame/election-provider-multi-phase/src/benchmarking.rs b/frame/election-provider-multi-phase/src/benchmarking.rs index 57867355f79b0..e05136ce31eab 100644 --- a/frame/election-provider-multi-phase/src/benchmarking.rs +++ b/frame/election-provider-multi-phase/src/benchmarking.rs @@ -20,7 +20,7 @@ use super::*; use crate::{unsigned::IndexAssignmentOf, Pallet as MultiPhase}; use frame_benchmarking::account; -use frame_election_provider_support::DataProviderBounds; +use frame_election_provider_support::bounds::DataProviderBounds; use frame_support::{ assert_ok, traits::{Hooks, TryCollect}, diff --git a/frame/election-provider-multi-phase/src/lib.rs b/frame/election-provider-multi-phase/src/lib.rs index a72bc2a88cbfb..c27cf0d7be7a0 100644 --- a/frame/election-provider-multi-phase/src/lib.rs +++ b/frame/election-provider-multi-phase/src/lib.rs @@ -231,9 +231,9 @@ use codec::{Decode, Encode}; use frame_election_provider_support::{ - BoundedSupportsOf, DataProviderBounds, ElectionBounds, ElectionBoundsBuilder, - ElectionDataProvider, ElectionProvider, ElectionProviderBase, InstantElectionProvider, - NposSolution, + bounds::{ElectionBounds, ElectionBoundsBuilder}, + BoundedSupportsOf, DataProviderBounds, ElectionDataProvider, ElectionProvider, + ElectionProviderBase, InstantElectionProvider, NposSolution, }; use frame_support::{ dispatch::DispatchClass, @@ -1086,7 +1086,7 @@ pub mod pallet { T::ForceOrigin::ensure_origin(origin)?; ensure!(Self::current_phase().is_emergency(), >::CallNotAllowed); - let election_bounds = ElectionBoundsBuilder::new() + let election_bounds = ElectionBoundsBuilder::default() .voters_count(maybe_max_voters.unwrap_or(u32::MAX).into()) .targets_count(maybe_max_targets.unwrap_or(u32::MAX).into()) .build(); @@ -2444,7 +2444,7 @@ mod tests { // the `MockStaking` is designed such that if it has too many targets, it simply fails. ExtBuilder::default().build_and_execute(|| { // sets bounds on number of targets. - let new_bounds = ElectionBoundsBuilder::new().targets_count(1_000.into()).build(); + let new_bounds = ElectionBoundsBuilder::default().targets_count(1_000.into()).build(); crate::mock::ElectionsBounds::set(new_bounds); crate::mock::Targets::set((0..(1_000 as AccountId) + 1).collect::>()); @@ -2483,7 +2483,7 @@ mod tests { // and if the backup mode is nothing, we go into the emergency mode.. ExtBuilder::default().onchain_fallback(false).build_and_execute(|| { // sets bounds on number of targets. - let new_bounds = ElectionBoundsBuilder::new().targets_count(1_000.into()).build(); + let new_bounds = ElectionBoundsBuilder::default().targets_count(1_000.into()).build(); crate::mock::ElectionsBounds::set(new_bounds); crate::mock::Targets::set((0..(1_000 as AccountId) + 1).collect::>()); @@ -2518,7 +2518,7 @@ mod tests { // we have 8 voters in total. assert_eq!(crate::mock::Voters::get().len(), 8); // but we want to take 2. - let new_bounds = ElectionBoundsBuilder::new().voters_count(2.into()).build(); + let new_bounds = ElectionBoundsBuilder::default().voters_count(2.into()).build(); crate::mock::ElectionsBounds::set(new_bounds); // Signed phase opens just fine. diff --git a/frame/election-provider-multi-phase/src/mock.rs b/frame/election-provider-multi-phase/src/mock.rs index 507d7837e01c9..117ba2a41203c 100644 --- a/frame/election-provider-multi-phase/src/mock.rs +++ b/frame/election-provider-multi-phase/src/mock.rs @@ -18,9 +18,8 @@ use super::*; use crate::{self as multi_phase, unsigned::MinerConfig}; use frame_election_provider_support::{ - data_provider, - onchain::{self}, - DataProviderBounds, ElectionBounds, ElectionDataProvider, NposSolution, SequentialPhragmen, + bounds::{DataProviderBounds, ElectionBounds}, + data_provider, onchain, ElectionDataProvider, NposSolution, SequentialPhragmen, }; pub use frame_support::{assert_noop, assert_ok, pallet_prelude::GetDefault}; use frame_support::{ @@ -304,8 +303,8 @@ parameter_types! { #[derive(Debug)] pub static MaxWinners: u32 = 200; - pub static ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::new().build(); - pub static ElectionsBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::new() + pub static ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::default().build(); + pub static ElectionsBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::default() .targets_count(5_000.into()).voters_count(1_250.into()).build(); pub static EpochLength: u64 = 30; diff --git a/frame/election-provider-multi-phase/src/signed.rs b/frame/election-provider-multi-phase/src/signed.rs index 0c2a4c644594a..9d99e4caf699e 100644 --- a/frame/election-provider-multi-phase/src/signed.rs +++ b/frame/election-provider-multi-phase/src/signed.rs @@ -561,7 +561,7 @@ mod tests { fn data_provider_should_respect_target_limits() { ExtBuilder::default().build_and_execute(|| { // given a reduced expectation of maximum electable targets - let new_bounds = crate::ElectionBoundsBuilder::new().targets_count(2.into()).build(); + let new_bounds = crate::ElectionBoundsBuilder::default().targets_count(2.into()).build(); ElectionsBounds::set(new_bounds); // and a data provider that does not respect limits DataProviderAllowBadData::set(true); @@ -577,7 +577,7 @@ mod tests { fn data_provider_should_respect_voter_limits() { ExtBuilder::default().build_and_execute(|| { // given a reduced expectation of maximum electing voters - let new_bounds = crate::ElectionBoundsBuilder::new().voters_count(2.into()).build(); + let new_bounds = crate::ElectionBoundsBuilder::default().voters_count(2.into()).build(); ElectionsBounds::set(new_bounds); // and a data provider that does not respect limits DataProviderAllowBadData::set(true); diff --git a/frame/election-provider-multi-phase/test-staking-e2e/Cargo.lock b/frame/election-provider-multi-phase/test-staking-e2e/Cargo.lock index 75201e5f35724..7c4304458851d 100644 --- a/frame/election-provider-multi-phase/test-staking-e2e/Cargo.lock +++ b/frame/election-provider-multi-phase/test-staking-e2e/Cargo.lock @@ -18,7 +18,16 @@ version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b" dependencies = [ - "gimli", + "gimli 0.26.2", +] + +[[package]] +name = "addr2line" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97" +dependencies = [ + "gimli 0.27.2", ] [[package]] @@ -33,7 +42,7 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" dependencies = [ - "getrandom 0.2.8", + "getrandom 0.2.9", "once_cell", "version_check", ] @@ -45,7 +54,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" dependencies = [ "cfg-if", - "getrandom 0.2.8", + "getrandom 0.2.9", "once_cell", "version_check", ] @@ -79,9 +88,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.69" +version = "1.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "224afbd727c3d6e4b90103ece64b8d1b67fbb1973b1046c2281eed3f3803f800" +checksum = "7de8ce5e0f9f8d88245311066a578d72b7af3e7088f32783804676302df237e4" [[package]] name = "approx" @@ -100,9 +109,9 @@ checksum = "f52f63c5c1316a16a4b35eaac8b76a98248961a533f061684cb2a7cb0eafb6c6" [[package]] name = "arrayref" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" +checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" [[package]] name = "arrayvec" @@ -118,13 +127,13 @@ checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" [[package]] name = "async-trait" -version = "0.1.59" +version = "0.1.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e6e93155431f3931513b243d371981bb2770112b370c82745a1d19d2f99364" +checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] @@ -135,16 +144,16 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "backtrace" -version = "0.3.66" +version = "0.3.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cab84319d616cfb654d03394f38ab7e6f0919e181b1b57e1fd15e7fb4077d9a7" +checksum = "233d376d6d185f2a3093e58f283f60f880315b6c60075b01f36b3b85154564ca" dependencies = [ - "addr2line", + "addr2line 0.19.0", "cc", "cfg-if", "libc", "miniz_oxide", - "object", + "object 0.30.3", "rustc-demangle", ] @@ -162,9 +171,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64ct" -version = "1.5.3" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b645a089122eccb6111b4f81cbc1a49f5900ac4666bb93ac027feaecf15607bf" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "bincode" @@ -195,9 +204,9 @@ dependencies = [ [[package]] name = "blake2" -version = "0.10.5" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b12e5fd123190ce1c2e559308a94c9bacad77907d4c6005d9e58fe1a0689e55e" +checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" dependencies = [ "digest 0.10.6", ] @@ -231,16 +240,16 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", ] [[package]] name = "block-buffer" -version = "0.10.3" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", ] [[package]] @@ -272,9 +281,9 @@ checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" [[package]] name = "bumpalo" -version = "3.11.1" +version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba" +checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" [[package]] name = "byte-slice-cast" @@ -302,15 +311,15 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "bytes" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfb24e866b15a1af2a1b663f10c6b6b8f397a84aadb828f12e5b289ec23a3a3c" +checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" [[package]] name = "cc" -version = "1.0.77" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9f73505338f7d905b19d18738976aae232eb46b8efc15554ffc56deb5d9ebe4" +checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" [[package]] name = "cfg-expr" @@ -329,9 +338,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.23" +version = "0.4.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" +checksum = "4e3c5919066adf22df73762e50cffcde3a758f2a848b113b586d1f86728b673b" dependencies = [ "iana-time-zone", "num-integer", @@ -363,9 +372,9 @@ checksum = "13418e745008f7349ec7e449155f419a61b92b58a99cc3616942b926825ec76b" [[package]] name = "core-foundation-sys" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" +checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" [[package]] name = "cpp_demangle" @@ -378,9 +387,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +checksum = "280a9f2d8b3a38871a3c8a46fb80db65e5e5ed97da80c4d08bf27fb63e35e181" dependencies = [ "libc", ] @@ -415,7 +424,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c2538c4e68e52548bacb3e83ac549f903d44f011ac9d5abb5e132e67d0808f7" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", "rand_core 0.6.4", "subtle", "zeroize", @@ -427,7 +436,7 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", "typenum", ] @@ -437,7 +446,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", "subtle", ] @@ -447,7 +456,7 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", "subtle", ] @@ -479,9 +488,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.83" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdf07d07d6531bfcdbe9b8b739b104610c6508dcc4d63b410585faf338241daf" +checksum = "f61f1b6389c3fe1c316bf8a4dccc90a38208354b330925bce1f74a6c4756eb93" dependencies = [ "cc", "cxxbridge-flags", @@ -491,9 +500,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.83" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2eb5b96ecdc99f72657332953d4d9c50135af1bac34277801cc3937906ebd39" +checksum = "12cee708e8962df2aeb38f594aae5d827c022b6460ac71a7a3e2c3c2aae5a07b" dependencies = [ "cc", "codespan-reporting", @@ -501,24 +510,24 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn", + "syn 2.0.15", ] [[package]] name = "cxxbridge-flags" -version = "1.0.83" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac040a39517fd1674e0f32177648334b0f4074625b5588a64519804ba0553b12" +checksum = "7944172ae7e4068c533afbb984114a56c46e9ccddda550499caa222902c7f7bb" [[package]] name = "cxxbridge-macro" -version = "1.0.83" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1362b0ddcfc4eb0a1f57b68bd77dd99f0e826958a96abd0ae9bd092e114ffed6" +checksum = "2345488264226bf682893e25de0769f3360aac9957980ec49361b083ddaa5bc5" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] @@ -539,7 +548,7 @@ checksum = "e79116f119dd1dba1abf1f3405f03b9b0e79a27a3883864bfebded8a3dc768cd" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -550,7 +559,7 @@ checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -568,7 +577,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", ] [[package]] @@ -577,7 +586,7 @@ version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" dependencies = [ - "block-buffer 0.10.3", + "block-buffer 0.10.4", "const-oid", "crypto-common", "subtle", @@ -607,14 +616,14 @@ checksum = "558e40ea573c374cf53507fd240b7ee2f5477df7cfebdb97323ec61c719399c5" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] name = "dyn-clone" -version = "1.0.9" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f94fa09c2aeea5b8839e414b7b841bf429fd25b9c522116ac97ee87856d88b2" +checksum = "68b0cf012f1230e43cd00ebb729c6bb58707ecfa8ad08b52ef3a4ccd2697fc30" [[package]] name = "ecdsa" @@ -631,9 +640,9 @@ dependencies = [ [[package]] name = "ed25519" -version = "1.5.2" +version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e9c280362032ea4203659fc489832d0204ef09f247a0506f170dafcac08c369" +checksum = "91cff35c70bba8a626e3185d8cd48cc11b5437e1a5bcd15b9b5fa3c64b6dfee7" dependencies = [ "signature 1.6.4", ] @@ -666,9 +675,9 @@ dependencies = [ [[package]] name = "either" -version = "1.8.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" +checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" [[package]] name = "elliptic-curve" @@ -680,7 +689,7 @@ dependencies = [ "crypto-bigint", "digest 0.10.6", "ff", - "generic-array 0.14.6", + "generic-array 0.14.7", "group", "pkcs8", "rand_core 0.6.4", @@ -697,13 +706,13 @@ checksum = "e48c92028aaa870e83d51c64e5d4e0b6981b360c522198c23959f219a4e1b15b" [[package]] name = "errno" -version = "0.2.8" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" +checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" dependencies = [ "errno-dragonfly", "libc", - "winapi", + "windows-sys 0.48.0", ] [[package]] @@ -726,7 +735,7 @@ dependencies = [ "fs-err", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -803,7 +812,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] @@ -824,9 +833,9 @@ dependencies = [ [[package]] name = "frame-metadata" -version = "15.0.0" +version = "15.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df6bb8542ef006ef0de09a5c4420787d79823c0ed7924225822362fd2bf2ff2d" +checksum = "878babb0b136e731cc77ec2fd883ff02745ff21e6fb662729953d44923df009c" dependencies = [ "cfg-if", "parity-scale-codec", @@ -878,7 +887,7 @@ dependencies = [ "proc-macro-warning", "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] @@ -889,7 +898,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] @@ -898,7 +907,7 @@ version = "3.0.0" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] @@ -932,9 +941,9 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "futures" -version = "0.3.25" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38390104763dc37a5145a53c29c63c1290b5d316d6086ec32c293f6736051bb0" +checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" dependencies = [ "futures-channel", "futures-core", @@ -947,9 +956,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.25" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52ba265a92256105f45b719605a571ffe2d1f0fea3807304b522c1d778f79eed" +checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" dependencies = [ "futures-core", "futures-sink", @@ -957,15 +966,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.25" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04909a7a7e4633ae6c4a9ab280aeb86da1236243a77b694a49eacd659a4bd3ac" +checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" [[package]] name = "futures-executor" -version = "0.3.25" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7acc85df6714c176ab5edf386123fafe217be88c0840ec11f199441134a074e2" +checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" dependencies = [ "futures-core", "futures-task", @@ -975,32 +984,32 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.25" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00f5fb52a06bdcadeb54e8d3671f8888a39697dcb0b81b23b55174030427f4eb" +checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" [[package]] name = "futures-macro" -version = "0.3.25" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdfb8ce053d86b91919aad980c220b1fb8401a9394410e1c289ed7e66b61835d" +checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] name = "futures-sink" -version = "0.3.25" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39c15cf1a4aa79df40f1bb462fb39676d0ad9e366c2a33b590d7c66f4f81fcf9" +checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" [[package]] name = "futures-task" -version = "0.3.25" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ffb393ac5d9a6eaa9d3fdf37ae2776656b706e200c8e16b1bdb227f5198e6ea" +checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" [[package]] name = "futures-timer" @@ -1010,9 +1019,9 @@ checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" [[package]] name = "futures-util" -version = "0.3.25" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "197676987abd2f9cadff84926f410af1c183608d36641465df73ae8211dc65d6" +checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" dependencies = [ "futures-channel", "futures-core", @@ -1037,9 +1046,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.14.6" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", @@ -1059,9 +1068,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" dependencies = [ "cfg-if", "libc", @@ -1078,6 +1087,12 @@ dependencies = [ "stable_deref_trait", ] +[[package]] +name = "gimli" +version = "0.27.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad0a93d233ebf96623465aad4046a8d3aa4da22d4f4beba5388838c8a434bbb4" + [[package]] name = "group" version = "0.13.0" @@ -1124,19 +1139,25 @@ dependencies = [ [[package]] name = "heck" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.1.19" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" dependencies = [ "libc", ] +[[package]] +name = "hermit-abi" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" + [[package]] name = "hex" version = "0.4.3" @@ -1179,22 +1200,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17ea0a1394df5b6574da6e0c1ade9e78868c9fb0a4e5ef4428e32da4676b85b1" dependencies = [ "digest 0.9.0", - "generic-array 0.14.6", + "generic-array 0.14.7", "hmac 0.8.1", ] [[package]] name = "iana-time-zone" -version = "0.1.53" +version = "0.1.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765" +checksum = "0722cd7114b7de04316e7ea5456a0bbb20e4adb46fd27a3697adb812cff0f37c" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "winapi", + "windows", ] [[package]] @@ -1243,14 +1264,14 @@ checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] name = "indexmap" -version = "1.9.2" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", "hashbrown 0.12.3", @@ -1268,12 +1289,13 @@ dependencies = [ [[package]] name = "io-lifetimes" -version = "1.0.6" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfa919a82ea574332e2de6e74b4c36e74d41982b335080fa59d4ef31be20fdf3" +checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220" dependencies = [ + "hermit-abi 0.3.1", "libc", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] @@ -1287,15 +1309,15 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.4" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" +checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" [[package]] name = "js-sys" -version = "0.3.60" +version = "0.3.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" +checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" dependencies = [ "wasm-bindgen", ] @@ -1330,9 +1352,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.138" +version = "0.2.141" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8" +checksum = "3304a64d199bb964be99741b7a14d26972741915b3649639149b2479bb46f4b5" [[package]] name = "libm" @@ -1390,9 +1412,9 @@ dependencies = [ [[package]] name = "link-cplusplus" -version = "1.0.7" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9272ab7b96c9046fbc5bc56c06c117cb639fe2d509df0c421cad82d2915cf369" +checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5" dependencies = [ "cc", ] @@ -1412,6 +1434,12 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" +[[package]] +name = "linux-raw-sys" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f508063cc7bb32987c71511216bd5a32be15bccb6a80b52df8b9d7f01fc3aa2" + [[package]] name = "lock_api" version = "0.4.9" @@ -1466,11 +1494,11 @@ checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "memfd" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b20a59d985586e4a5aef64564ac77299f8586d8be6cf9106a5a40207e8908efb" +checksum = "ffc89ccdc6e10d6907450f753537ebc5c5d3460d2e4e62ea74bd571db62c0f9e" dependencies = [ - "rustix", + "rustix 0.37.12", ] [[package]] @@ -1511,9 +1539,9 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.5.4" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96590ba8f175222643a85693f33d26e9c8a015f599c216509b1a6894af675d34" +checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" dependencies = [ "adler", ] @@ -1542,7 +1570,7 @@ checksum = "d232c68884c0c99810a5a4d333ef7e47689cfd0edc85efc9e54e1e6bf5212766" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1564,9 +1592,9 @@ dependencies = [ [[package]] name = "num-complex" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ae39348c8bc5fbd7f40c727a9925f03517afd2ab27d46702108b6a7e5414c19" +checksum = "02e0d21255c828d6f128a1e41534206671e8c3ea0c62f32291e808dc82cff17d" dependencies = [ "num-traits", ] @@ -1614,11 +1642,11 @@ dependencies = [ [[package]] name = "num_cpus" -version = "1.14.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6058e64324c71e02bc2b150e4f3bc8286db6c83092132ffa3f6b1eab0f9def5" +checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" dependencies = [ - "hermit-abi", + "hermit-abi 0.2.6", "libc", ] @@ -1634,6 +1662,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "object" +version = "0.30.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea86265d3d3dcb6a27fc51bd29a4bf387fae9d2986b823079d4986af253eb439" +dependencies = [ + "memchr", +] + [[package]] name = "once_cell" version = "1.17.1" @@ -1839,7 +1876,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1860,22 +1897,22 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.5" +version = "0.9.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ff9f3fef3968a3ec5945535ed654cb38ff72d7495a25619e2247fb15a2ed9ba" +checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] name = "paste" -version = "1.0.10" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1c2c742266c2f1041c914ba65355a83ae8747b05f208319784083583494b4b" +checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" [[package]] name = "pbkdf2" @@ -1944,24 +1981,23 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "1.2.1" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eda0fc3b0fb7c975631757e14d9049da17374063edb6ebbcbc54d880d4fe94e9" +checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" dependencies = [ "once_cell", - "thiserror", - "toml", + "toml_edit", ] [[package]] name = "proc-macro-warning" -version = "0.2.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d4f284d87b9cedc2ff57223cbc4e3937cd6063c01e92c8e2a8c080df0013933" +checksum = "0e99670bafb56b9a106419397343bdbc8b8742c3cc449fec6345f86173f47cd4" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] @@ -2056,7 +2092,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.8", + "getrandom 0.2.9", ] [[package]] @@ -2085,29 +2121,29 @@ dependencies = [ [[package]] name = "ref-cast" -version = "1.0.13" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53b15debb4f9d60d767cd8ca9ef7abb2452922f3214671ff052defc7f3502c44" +checksum = "f43faa91b1c8b36841ee70e97188a869d37ae21759da6846d4be66de5bf7b12c" dependencies = [ "ref-cast-impl", ] [[package]] name = "ref-cast-impl" -version = "1.0.13" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abfa8511e9e94fd3de6585a3d3cd00e01ed556dc9814829280af0e8dc72a8f36" +checksum = "8d2275aab483050ab2a7364c1a46604865ee7d6906684e08db0f090acf74f9e7" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] name = "regex" -version = "1.7.0" +version = "1.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e076559ef8e241f2ae3479e36f97bd5741c0330689e217ad51ce2c76808b868a" +checksum = "8b1f693b24f6ac912f4893ef08244d70b6067480d2f1a46e950c9691e6749d1d" dependencies = [ "aho-corasick", "memchr", @@ -2125,9 +2161,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.28" +version = "0.6.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "rfc6979" @@ -2141,9 +2177,9 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.21" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" [[package]] name = "rustc-hash" @@ -2159,29 +2195,43 @@ checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" [[package]] name = "rustix" -version = "0.36.9" +version = "0.36.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd5c6ff11fecd55b40746d1995a02f2eb375bf8c00d192d521ee09f42bef37bc" +checksum = "e0af200a3324fa5bcd922e84e9b55a298ea9f431a489f01961acdebc6e908f25" dependencies = [ "bitflags", "errno", "io-lifetimes", "libc", - "linux-raw-sys", + "linux-raw-sys 0.1.4", "windows-sys 0.45.0", ] +[[package]] +name = "rustix" +version = "0.37.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "722529a737f5a942fdbac3a46cee213053196737c5eaa3386d52e85b786f2659" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys 0.3.2", + "windows-sys 0.48.0", +] + [[package]] name = "rustversion" -version = "1.0.9" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97477e48b4cf8603ad5f7aaf897467cf42ab4218a38ef76fb14c2d6773a6d6a8" +checksum = "4f3208ce4d8448b3f3e7d168a73f5e0c43a61e32930de3bceeccedb388b6bf06" [[package]] name = "ryu" -version = "1.0.11" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" +checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" [[package]] name = "safe_arch" @@ -2194,9 +2244,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.3.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "001cf62ece89779fd16105b5f515ad0e5cedcd5440d3dd806bb067978e7c3608" +checksum = "0cfdffd972d76b22f3d7f81c8be34b2296afd3a25e0a547bd9abe340a4dbbe97" dependencies = [ "bitvec", "cfg-if", @@ -2208,14 +2258,14 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.3.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "303959cf613a6f6efd19ed4b4ad5bf79966a13352716299ad532cfb115f4205c" +checksum = "61fa974aea2d63dd18a4ec3a49d59af9f34178c73a4f56d2f18205628d00681e" dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -2255,19 +2305,19 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "scratch" -version = "1.0.2" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898" +checksum = "1792db035ce95be60c3f8853017b3999209281c24e2ba5bc8e59bf97a0c590c1" [[package]] name = "sec1" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48518a2b5775ba8ca5b46596aae011caa431e6ce7e4a67ead66d92f08884220e" +checksum = "f0aec48e813d6b90b15f0b8948af3c63483992dee44c03e9930b3eebdabe046e" dependencies = [ "base16ct", "der", - "generic-array 0.14.6", + "generic-array 0.14.7", "pkcs8", "subtle", "zeroize", @@ -2275,9 +2325,9 @@ dependencies = [ [[package]] name = "secp256k1" -version = "0.24.2" +version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9512ffd81e3a3503ed401f79c33168b9148c75038956039166cd750eaa037c3" +checksum = "6b1629c9c557ef9b293568b338dddfc8208c98a18c59d722a9d53f859d9c9b62" dependencies = [ "secp256k1-sys", ] @@ -2302,29 +2352,29 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.150" +version = "1.0.160" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e326c9ec8042f1b5da33252c8a37e9ffbd2c9bef0155215b6e6c80c790e05f91" +checksum = "bb2f3770c8bce3bcda7e149193a069a0f4365bda1fa5cd88e03bca26afc1216c" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.150" +version = "1.0.160" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42a3df25b0713732468deadad63ab9da1f1fd75a48a15024b50363f128db627e" +checksum = "291a097c63d8497e00160b166a967a4a79c64f3facdd01cbd7502231688d77df" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] name = "serde_json" -version = "1.0.89" +version = "1.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "020ff22c755c2ed3f8cf162dbb41a7268d934702f3ed3631656ea597e08fc3db" +checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" dependencies = [ "itoa", "ryu", @@ -2369,9 +2419,9 @@ dependencies = [ [[package]] name = "sha3" -version = "0.10.6" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdf0c33fae925bdc080598b84bc15c55e7b9a4a43b3c704da051f977469691c9" +checksum = "54c2bb1a323307527314a36bfb73f24febb08ce2b8a554bf4ffd6f51ad15198c" dependencies = [ "digest 0.10.6", "keccak", @@ -2404,9 +2454,9 @@ dependencies = [ [[package]] name = "simba" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50582927ed6f77e4ac020c057f37a268fc6aebc29225050365aacbb9deeeddc4" +checksum = "061507c94fc6ab4ba1c9a0305018408e312e17c041eb63bef8aa726fa33aceae" dependencies = [ "approx", "num-complex", @@ -2417,9 +2467,9 @@ dependencies = [ [[package]] name = "slab" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" dependencies = [ "autocfg", ] @@ -2437,8 +2487,10 @@ dependencies = [ "hash-db", "log", "parity-scale-codec", + "scale-info", "sp-api-proc-macro", "sp-core", + "sp-metadata-ir", "sp-runtime", "sp-state-machine", "sp-std", @@ -2457,7 +2509,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] @@ -2547,7 +2599,7 @@ dependencies = [ "proc-macro2", "quote", "sp-core-hashing", - "syn", + "syn 2.0.15", ] [[package]] @@ -2556,7 +2608,7 @@ version = "5.0.0" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] @@ -2613,15 +2665,23 @@ name = "sp-keystore" version = "0.13.0" dependencies = [ "futures", - "merlin", "parity-scale-codec", "parking_lot", - "schnorrkel", "sp-core", "sp-externalities", "thiserror", ] +[[package]] +name = "sp-metadata-ir" +version = "0.1.0" +dependencies = [ + "frame-metadata", + "parity-scale-codec", + "scale-info", + "sp-std", +] + [[package]] name = "sp-npos-elections" version = "4.0.0-dev" @@ -2690,7 +2750,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] @@ -2822,7 +2882,7 @@ dependencies = [ "parity-scale-codec", "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] @@ -2864,9 +2924,9 @@ dependencies = [ [[package]] name = "ss58-registry" -version = "1.36.0" +version = "1.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23d92659e7d18d82b803824a9ba5a6022cff101c3491d027c1c1d8d30e749284" +checksum = "ecf0bd63593ef78eca595a7fc25e9a443ca46fe69fd472f8f09f5245cdcd769d" dependencies = [ "Inflector", "num-format", @@ -2908,7 +2968,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn", + "syn 1.0.109", ] [[package]] @@ -2942,15 +3002,14 @@ dependencies = [ ] [[package]] -name = "synstructure" -version = "0.12.6" +name = "syn" +version = "2.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" +checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822" dependencies = [ "proc-macro2", "quote", - "syn", - "unicode-xid", + "unicode-ident", ] [[package]] @@ -2961,45 +3020,46 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "target-lexicon" -version = "0.12.5" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9410d0f6853b1d94f0e519fb95df60f29d2c1eff2d921ffdf01a4c8a3b54f12d" +checksum = "8ae9980cab1db3fceee2f6c6f643d5d8de2997c58ee8d25fb0cc8a9e9e7348e5" [[package]] name = "termcolor" -version = "1.1.3" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" +checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" dependencies = [ "winapi-util", ] [[package]] name = "thiserror" -version = "1.0.37" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e" +checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.37" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" +checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] name = "thread_local" -version = "1.1.4" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180" +checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" dependencies = [ + "cfg-if", "once_cell", ] @@ -3033,17 +3093,25 @@ dependencies = [ [[package]] name = "tinyvec_macros" -version = "0.1.0" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "toml_datetime" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" +checksum = "3ab8ed2edee10b50132aed5f331333428b011c99402b5a534154ed15746f9622" [[package]] -name = "toml" -version = "0.5.9" +name = "toml_edit" +version = "0.19.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" +checksum = "239410c8609e8125456927e6707163a3b1fdb40561e4b803bc041f466ccfdc13" dependencies = [ - "serde", + "indexmap", + "toml_datetime", + "winnow", ] [[package]] @@ -3066,7 +3134,7 @@ checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -3124,9 +3192,9 @@ dependencies = [ [[package]] name = "trie-db" -version = "0.27.0" +version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634d75c77ea43f2ad8ea9d9c58de49dfc9c3995bdef32b503df7883ff054e7f1" +checksum = "767abe6ffed88a1889671a102c2861ae742726f52e0a5a425b92c9fbfa7e9c85" dependencies = [ "hash-db", "hashbrown 0.13.2", @@ -3146,9 +3214,9 @@ dependencies = [ [[package]] name = "tt-call" -version = "1.0.8" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e66dcbec4290c69dd03c57e76c2469ea5c7ce109c6dd4351c13055cf71ea055" +checksum = "f4f195fd851901624eee5a58c4bb2b4f06399148fcd0ed336e6f1cb60a9881df" [[package]] name = "twox-hash" @@ -3182,15 +3250,15 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.11" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524b68aca1d05e03fdf03fcdce2c6c94b6daf6d16861ddaa7e4f2b6638a9052c" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" -version = "1.0.5" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" +checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" [[package]] name = "unicode-normalization" @@ -3250,9 +3318,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.83" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" +checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -3260,24 +3328,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.83" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" +checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn", + "syn 1.0.109", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.83" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" +checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3285,22 +3353,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.83" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" +checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.83" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" +checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" [[package]] name = "wasmi" @@ -3357,7 +3425,7 @@ dependencies = [ "indexmap", "libc", "log", - "object", + "object 0.29.0", "once_cell", "paste", "psm", @@ -3387,10 +3455,10 @@ checksum = "9a6db9fc52985ba06ca601f2ff0ff1f526c5d724c7ac267b47326304b0c97883" dependencies = [ "anyhow", "cranelift-entity", - "gimli", + "gimli 0.26.2", "indexmap", "log", - "object", + "object 0.29.0", "serde", "target-lexicon", "thiserror", @@ -3404,14 +3472,14 @@ version = "6.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b77e3a52cd84d0f7f18554afa8060cfe564ccac61e3b0802d3fd4084772fa5f6" dependencies = [ - "addr2line", + "addr2line 0.17.0", "anyhow", "bincode", "cfg-if", "cpp_demangle", - "gimli", + "gimli 0.26.2", "log", - "object", + "object 0.29.0", "rustc-demangle", "serde", "target-lexicon", @@ -3458,7 +3526,7 @@ dependencies = [ "memoffset", "paste", "rand 0.8.5", - "rustix", + "rustix 0.36.12", "wasmtime-asm-macros", "wasmtime-environ", "wasmtime-jit-debug", @@ -3518,19 +3586,28 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" +dependencies = [ + "windows-targets 0.48.0", +] + [[package]] name = "windows-sys" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", ] [[package]] @@ -3539,7 +3616,16 @@ version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" dependencies = [ - "windows-targets", + "windows-targets 0.42.2", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.0", ] [[package]] @@ -3548,13 +3634,28 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + +[[package]] +name = "windows-targets" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +dependencies = [ + "windows_aarch64_gnullvm 0.48.0", + "windows_aarch64_msvc 0.48.0", + "windows_i686_gnu 0.48.0", + "windows_i686_msvc 0.48.0", + "windows_x86_64_gnu 0.48.0", + "windows_x86_64_gnullvm 0.48.0", + "windows_x86_64_msvc 0.48.0", ] [[package]] @@ -3563,42 +3664,93 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" + [[package]] name = "windows_aarch64_msvc" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" + [[package]] name = "windows_i686_gnu" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" +[[package]] +name = "windows_i686_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" + [[package]] name = "windows_i686_msvc" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" +[[package]] +name = "windows_i686_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" + [[package]] name = "windows_x86_64_gnu" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" + [[package]] name = "windows_x86_64_gnullvm" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" + [[package]] name = "windows_x86_64_msvc" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" + +[[package]] +name = "winnow" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae8970b36c66498d8ff1d66685dc86b91b29db0c7739899012f63a63814b4b28" +dependencies = [ + "memchr", +] + [[package]] name = "wyz" version = "0.5.1" @@ -3610,21 +3762,20 @@ dependencies = [ [[package]] name = "zeroize" -version = "1.5.7" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c394b5bd0c6f669e7275d9c20aa90ae064cb22e75a1cad54e1b34088034b149f" +checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" dependencies = [ "zeroize_derive", ] [[package]] name = "zeroize_derive" -version = "1.3.3" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44bf07cb3e50ea2003396695d58bf46bc9887a1f362260446fad6bc4e79bd36c" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn", - "synstructure", + "syn 2.0.15", ] diff --git a/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs b/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs index e0a316a896487..a3e65c26e8d80 100644 --- a/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs +++ b/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs @@ -38,8 +38,8 @@ use sp_std::prelude::*; use std::collections::BTreeMap; use frame_election_provider_support::{ - onchain, ElectionBoundsBuilder, ElectionDataProvider, ExtendedBalance, SequentialPhragmen, - Weight, + bounds::ElectionBoundsBuilder, onchain, ElectionDataProvider, ExtendedBalance, + SequentialPhragmen, Weight, }; use pallet_election_provider_multi_phase::{ unsigned::MinerConfig, ElectionCompute, QueuedSolution, SolutionAccuracyOf, @@ -126,10 +126,10 @@ impl pallet_balances::Config for Runtime { type DustRemoval = (); type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; - type MaxHolds = (); - type MaxFreezes = (); - type HoldIdentifier = (); - type FreezeIdentifier = (); + type MaxHolds = (); + type MaxFreezes = (); + type HoldIdentifier = (); + type FreezeIdentifier = (); type WeightInfo = (); } @@ -189,7 +189,7 @@ parameter_types! { pub static MinerMaxWeight: Weight = BlockWeights::get().max_block; pub static TransactionPriority: transaction_validity::TransactionPriority = 1; pub static MaxWinners: u32 = 100; - pub static ElectionBounds: frame_election_provider_support::ElectionBounds = ElectionBoundsBuilder::new() + pub static ElectionBounds: frame_election_provider_support::bounds::ElectionBounds = ElectionBoundsBuilder::default() .voters_count(1_000.into()).targets_count(1_000.into()).build(); } diff --git a/frame/election-provider-support/src/bounds.rs b/frame/election-provider-support/src/bounds.rs new file mode 100644 index 0000000000000..8d3dc7a98b4e5 --- /dev/null +++ b/frame/election-provider-support/src/bounds.rs @@ -0,0 +1,374 @@ +// 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. + +//! Types and helpers to define and handle election bounds. +//! +//! ### Overview +//! +//! This module defines and implements types that help creating and handling election bounds. +//! [`DataProviderBounds`] encapsulates the upper limits for the results of provided by +//! [`DataProvider`] implementors. Those limits can be defined over two axis: number of elements +//! returned (`count`) and/or the size of the returned SCALE encoded structure (`size`). +//! +//! [`ElectionBoundsBuilder`] is a helper to construct data election bounds and it aims at +//! preventing the caller from mistake the order of size and count limits. +//! +//! ### Examples +//! +//! [`ElectionBoundsBuilder`] helps defining the size and count bounds for both voters and targets. +//! +//! ``` +//! use frame_election_provider_support::bounds::*; +//! +//! // unbounded limits are never exhausted. +//! let unbounded = ElectionBoundsBuilder::default().build(); +//! assert!(!unbounded.targets.exhausted(SizeBound(1_000_000_000).into(), None)); +//! +//! let bounds = ElectionBoundsBuilder::default() +//! .voters_count(100.into()) +//! .voters_size(1_000.into()) +//! .targets_count(200.into()) +//! .targets_size(2_000.into()) +//! .build(); +//! +//! assert!(!bounds.targets.exhausted(SizeBound(1).into(), CountBound(1).into())); +//! assert!(bounds.targets.exhausted(SizeBound(1).into(), CountBound(100_000).into())); +//! ``` +//! +//! ### Implementation details +//! +//! As a norm, a default or `None` bound is unbounded (i.e. unlimited). In general, be careful when +//! using unbounded election bounds in production. + +use core::ops::Add; +use sp_runtime::traits::Zero; + +/// Count type for data provider bounds. +/// +/// Encapsulates the counting of things that can be bounded in an election, such as voters, +/// targets or anything else. +/// +/// This struct is defined mostly to prevent callers from mistankingly using `CountBound` instead of +/// `SizeBound` and vice-versa. +#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)] +pub struct CountBound(pub u32); + +impl From for CountBound { + fn from(value: u32) -> Self { + CountBound(value) + } +} + +impl Add for CountBound { + type Output = Self; + fn add(self, rhs: Self) -> Self::Output { + CountBound(self.0.saturating_add(rhs.0)) + } +} + +impl Zero for CountBound { + fn is_zero(&self) -> bool { + self.0 == 0 + } + fn zero() -> Self { + CountBound(0) + } +} + +/// Size type for data provider bounds. +/// +/// Encapsulates the size limit of things that can be bounded in an election, such as voters, +/// targets or anything else. The size unit can represent anything depending on the election +/// logic and implementation, but it most likely will represent bytes in SCALE encoding in this +/// context. +/// +/// This struct is defined mostly to prevent callers from mistankingly using `CountBound` instead of +/// `SizeBound` and vice-versa. +#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)] +pub struct SizeBound(pub u32); + +impl From for SizeBound { + fn from(value: u32) -> Self { + SizeBound(value) + } +} + +impl Zero for SizeBound { + fn is_zero(&self) -> bool { + self.0 == 0 + } + fn zero() -> Self { + SizeBound(0) + } +} + +impl Add for SizeBound { + type Output = Self; + fn add(self, rhs: Self) -> Self::Output { + SizeBound(self.0.saturating_add(rhs.0)) + } +} + +/// Data bounds for [`DataProvider`]. +/// +/// Limits the data returned by `DataProvider` implementors, defined over two axis: `count`, +/// defining the maximum number of elements returned and `size`, defining the limit in size (bytes) +/// of the SCALE encoded result. +/// +/// `None` represents unlimited bounds in both `count` and `size` axis. +#[derive(Clone, Copy, Default, Debug)] +pub struct DataProviderBounds { + pub count: Option, + pub size: Option, +} + +impl DataProviderBounds { + /// Constructor with unbounded data provider limits. + pub fn new_unbounded() -> Self { + DataProviderBounds { count: None, size: None } + } + + /// Returns true if `given_count` exhausts `self.count`. + pub fn count_exhausted(self, given_count: CountBound) -> bool { + self.count.map_or(false, |count| given_count > count) + } + + /// Returns true if `given_size` exhausts `self.size`. + pub fn size_exhausted(self, given_size: SizeBound) -> bool { + self.size.map_or(false, |size| given_size > size) + } + + /// Returns true if `given_size` or `given_count` exhausts `self.size` or `self_count`, + /// respectively. + pub fn exhausted(self, given_size: Option, given_count: Option) -> bool { + self.count_exhausted(given_count.unwrap_or(CountBound::zero())) || + self.size_exhausted(given_size.unwrap_or(SizeBound::zero())) + } + + /// Returns an instance of `Self` that is constructed by capping both the `count` and `size` + /// fields. If `self` is None, overwrite it with the provided bounds. + pub fn max(self, bounds: DataProviderBounds) -> Self { + DataProviderBounds { + count: self + .count + .map(|c| { + c.clamp(CountBound::zero(), bounds.count.unwrap_or(CountBound(u32::MAX))).into() + }) + .or(bounds.count), + size: self + .size + .map(|c| { + c.clamp(SizeBound::zero(), bounds.size.unwrap_or(SizeBound(u32::MAX))).into() + }) + .or(bounds.size), + } + } +} + +/// The voter and target bounds of an election. +/// +/// The bounds are defined over two axis: `count` of element of the election (voters or targets) and +/// the `size` of the SCALE encoded result snapshot. +#[derive(Clone, Debug)] +pub struct ElectionBounds { + pub voters: DataProviderBounds, + pub targets: DataProviderBounds, +} + +/// Utility builder for [`ElectionBounds`]. +#[derive(Copy, Clone, Default)] +pub struct ElectionBoundsBuilder { + voters: Option, + targets: Option, +} + +impl From for ElectionBoundsBuilder { + fn from(bounds: ElectionBounds) -> Self { + ElectionBoundsBuilder { voters: Some(bounds.voters), targets: Some(bounds.targets) } + } +} + +impl ElectionBoundsBuilder { + /// Sets the voters count bounds. + pub fn voters_count(mut self, count: CountBound) -> Self { + self.voters = self.voters.map_or( + Some(DataProviderBounds { count: Some(count), size: None }), + |mut bounds| { + bounds.count = Some(count); + Some(bounds) + }, + ); + self + } + + /// Sets the voters size bounds. + pub fn voters_size(mut self, size: SizeBound) -> Self { + self.voters = self.voters.map_or( + Some(DataProviderBounds { count: None, size: Some(size) }), + |mut bounds| { + bounds.size = Some(size); + Some(bounds) + }, + ); + self + } + + /// Sets the targets count bounds. + pub fn targets_count(mut self, count: CountBound) -> Self { + self.targets = self.targets.map_or( + Some(DataProviderBounds { count: Some(count), size: None }), + |mut bounds| { + bounds.count = Some(count); + Some(bounds) + }, + ); + self + } + + /// Sets the targets size bounds. + pub fn targets_size(mut self, size: SizeBound) -> Self { + self.targets = self.targets.map_or( + Some(DataProviderBounds { count: None, size: Some(size) }), + |mut bounds| { + bounds.size = Some(size); + Some(bounds) + }, + ); + self + } + + /// Set the voters bounds. + pub fn voters(mut self, bounds: Option) -> Self { + self.voters = bounds; + self + } + + /// Set the targets bounds. + pub fn targets(mut self, bounds: Option) -> Self { + self.targets = bounds; + self + } + + /// Caps the number of the voters bounds in self to `voters` bounds. If `voters` bounds are + /// higher than the self bounds, keeps it. Note that `None` bounds are equivalent to maximum + /// and should be treated as such. + pub fn voters_or_lower(mut self, voters: DataProviderBounds) -> Self { + self.voters = match self.voters { + None => Some(voters), + Some(v) => Some(v.max(voters)), + }; + self + } + + /// Caps the number of the target bounds in self to `voters` bounds. If `voters` bounds are + /// higher than the self bounds, keeps it. Note that `None` bounds are equivalent to maximum + /// and should be treated as such. + pub fn targets_or_lower(mut self, targets: DataProviderBounds) -> Self { + self.targets = match self.targets { + None => Some(targets), + Some(t) => Some(t.max(targets)), + }; + self + } + + /// Returns an instance of `ElectionBounds` from the current state. + pub fn build(self) -> ElectionBounds { + ElectionBounds { + voters: self.voters.unwrap_or_default(), + targets: self.targets.unwrap_or_default(), + } + } +} + +#[cfg(test)] +mod test { + use super::*; + + #[test] + fn data_provider_bounds_unbounded() { + let bounds = DataProviderBounds::new_unbounded(); + assert!(!bounds.exhausted(None, None)); + assert!(!bounds.exhausted(SizeBound(u32::MAX).into(), CountBound(u32::MAX).into())); + } + + #[test] + fn election_bounds_builder_and_exhausted_bounds() { + // voter bounds exhausts if count > 100 or size > 1_000; target bounds exhausts if count > + // 200 or size > 2_000. + let bounds = ElectionBoundsBuilder::default() + .voters_count(100.into()) + .voters_size(1_000.into()) + .targets_count(200.into()) + .targets_size(2_000.into()) + .build(); + + assert!(!bounds.voters.exhausted(None, None)); + assert!(!bounds.voters.exhausted(SizeBound(10).into(), CountBound(10).into())); + assert!(!bounds.voters.exhausted(None, CountBound(100).into())); + assert!(!bounds.voters.exhausted(SizeBound(1_000).into(), None)); + // exhausts bounds. + assert!(bounds.voters.exhausted(None, CountBound(101).into())); + assert!(bounds.voters.exhausted(SizeBound(1_001).into(), None)); + + assert!(!bounds.targets.exhausted(None, None)); + assert!(!bounds.targets.exhausted(SizeBound(20).into(), CountBound(20).into())); + assert!(!bounds.targets.exhausted(None, CountBound(200).into())); + assert!(!bounds.targets.exhausted(SizeBound(2_000).into(), None)); + // exhausts bounds. + assert!(bounds.targets.exhausted(None, CountBound(201).into())); + assert!(bounds.targets.exhausted(SizeBound(2_001).into(), None)); + } + + #[test] + fn election_bounds_clamp_works() { + let bounds = ElectionBoundsBuilder::default() + .voters_count(10.into()) + .voters_size(10.into()) + .voters_or_lower(DataProviderBounds { + count: CountBound(5).into(), + size: SizeBound(20).into(), + }) + .targets_count(20.into()) + .targets_or_lower(DataProviderBounds { + count: CountBound(30).into(), + size: SizeBound(30).into(), + }) + .build(); + + assert_eq!(bounds.voters.count.unwrap(), CountBound(5)); + assert_eq!(bounds.voters.size.unwrap(), SizeBound(10)); + assert_eq!(bounds.targets.count.unwrap(), CountBound(20)); + assert_eq!(bounds.targets.size.unwrap(), SizeBound(30)); + + // note that unbounded bounds (None) are equivalent to maximum value. + let bounds = ElectionBoundsBuilder::default() + .voters_or_lower(DataProviderBounds { + count: CountBound(5).into(), + size: SizeBound(20).into(), + }) + .targets_or_lower(DataProviderBounds { + count: CountBound(10).into(), + size: SizeBound(10).into(), + }) + .build(); + + assert_eq!(bounds.voters.count.unwrap(), CountBound(5)); + assert_eq!(bounds.voters.size.unwrap(), SizeBound(20)); + assert_eq!(bounds.targets.count.unwrap(), CountBound(10)); + assert_eq!(bounds.targets.size.unwrap(), SizeBound(10)); + } +} diff --git a/frame/election-provider-support/src/lib.rs b/frame/election-provider-support/src/lib.rs index f85f49ccca225..56f655e897458 100644 --- a/frame/election-provider-support/src/lib.rs +++ b/frame/election-provider-support/src/lib.rs @@ -173,13 +173,14 @@ #![cfg_attr(not(feature = "std"), no_std)] +pub mod bounds; pub mod onchain; pub mod traits; -use core::ops::Add; use sp_runtime::traits::{Bounded, Saturating, Zero}; use sp_std::{fmt::Debug, prelude::*}; +pub use bounds::DataProviderBounds; pub use codec::{Decode, Encode}; /// Re-export the solution generation macro. pub use frame_election_provider_solution_type::generate_solution_type; @@ -658,235 +659,16 @@ impl = (AccountId, VoteWeight, BoundedVec); + /// Same as [`Voter`], but parameterized by an [`ElectionDataProvider`]. pub type VoterOf = Voter<::AccountId, ::MaxVotesPerVoter>; + /// Same as `BoundedSupports` but parameterized by a `ElectionProviderBase`. pub type BoundedSupportsOf = BoundedSupports< ::AccountId, ::MaxWinners, >; -/// Count bound of data provider bounds. -#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)] -pub struct CountBound(pub u32); - -impl From for CountBound { - fn from(value: u32) -> Self { - CountBound(value) - } -} - -impl Add for CountBound { - type Output = Self; - fn add(self, rhs: Self) -> Self::Output { - CountBound(self.0.saturating_add(rhs.0)) - } -} - -impl Zero for CountBound { - fn is_zero(&self) -> bool { - self.0 == 0 - } - fn zero() -> Self { - CountBound(0) - } -} - -/// Size bound of data provider bounds. -#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)] -pub struct SizeBound(pub u32); - -impl Zero for SizeBound { - fn is_zero(&self) -> bool { - self.0 == 0 - } - fn zero() -> Self { - SizeBound(0) - } -} - -impl Add for SizeBound { - type Output = Self; - fn add(self, rhs: Self) -> Self::Output { - SizeBound(self.0.saturating_add(rhs.0)) - } -} - -impl From for SizeBound { - fn from(value: u32) -> Self { - SizeBound(value) - } -} - sp_core::generate_feature_enabled_macro!(runtime_benchmarks_enabled, feature = "runtime-benchmarks", $); sp_core::generate_feature_enabled_macro!(runtime_benchmarks_or_fuzz_enabled, any(feature = "runtime-benchmarks", feature = "fuzzing"), $); - -/// Data provider limits that can be bounded based on the count of elements or the scale encoded -/// size of the final result in MB. It can be used to represent the bounds of election targets -/// and voters or any other future unit. -#[derive(Clone, Copy, Default, Debug)] -pub struct DataProviderBounds { - pub count: Option, - pub size: Option, -} - -impl DataProviderBounds { - /// Unbonded data provider limit. - pub fn new_unbounded() -> Self { - DataProviderBounds { count: None, size: None } - } - - /// Returns true if `given_count` exhausts `self.count`. - pub fn count_exhausted(self, given_count: CountBound) -> bool { - self.count.map_or(false, |count| given_count > count) - } - - /// Returns true if `given_size` exhausts `self.size`. - pub fn size_exhausted(self, given_size: SizeBound) -> bool { - self.size.map_or(false, |size| given_size > size) - } - - /// Returns true if `given_size` or `given_count` exhausts `self.size` or `self_count`, - /// respectively. - pub fn exhausted(self, given_size: Option, given_count: Option) -> bool { - self.count_exhausted(given_count.unwrap_or(CountBound::zero())) || - self.size_exhausted(given_size.unwrap_or(SizeBound::zero())) - } - - /// Returns an instance of `Self` that is constructed by capping both the `count` and `size` - /// fields. If `self` is None, overwrite it with the provided bounds. - pub fn max(self, bounds: DataProviderBounds) -> Self { - DataProviderBounds { - count: self - .count - .map(|c| { - c.clamp(CountBound::zero(), bounds.count.unwrap_or(CountBound(u32::MAX))).into() - }) - .or(bounds.count), - size: self - .size - .map(|c| { - c.clamp(SizeBound::zero(), bounds.size.unwrap_or(SizeBound(u32::MAX))).into() - }) - .or(bounds.size), - } - } -} - -/// The limits of an election snapshot size. The bounds are defined over the count of element of the -/// election (voters or targets) or the overall size of the elements in MB. -#[derive(Clone, Debug)] -pub struct ElectionBounds { - pub voters: DataProviderBounds, - pub targets: DataProviderBounds, -} - -/// Utility builder for [`ElectionBounds`]. -#[derive(Copy, Clone)] -pub struct ElectionBoundsBuilder { - voters: Option, - targets: Option, -} - -impl ElectionBoundsBuilder { - /// Returns a new election bounds builder, initialized with unbounded voter and target limits. - pub fn new() -> Self { - ElectionBoundsBuilder { voters: None, targets: None } - } - - /// Returns a new election bounds builder from an instance of `ElectionBounds`. - pub fn from(bounds: ElectionBounds) -> Self { - ElectionBoundsBuilder { voters: Some(bounds.voters), targets: Some(bounds.targets) } - } - - /// Sets the voters count bounds. - pub fn voters_count(mut self, count: CountBound) -> Self { - self.voters = self.voters.map_or( - Some(DataProviderBounds { count: Some(count), size: None }), - |mut bounds| { - bounds.count = Some(count); - Some(bounds) - }, - ); - self - } - - // Sets the voters size bounds. - pub fn voters_size(mut self, size: SizeBound) -> Self { - self.voters = self.voters.map_or( - Some(DataProviderBounds { count: None, size: Some(size) }), - |mut bounds| { - bounds.size = Some(size); - Some(bounds) - }, - ); - self - } - - // Sets the targets count bounds. - pub fn targets_count(mut self, count: CountBound) -> Self { - self.targets = self.targets.map_or( - Some(DataProviderBounds { count: Some(count), size: None }), - |mut bounds| { - bounds.count = Some(count); - Some(bounds) - }, - ); - self - } - - // Sets the targets size bounds. - pub fn targets_size(mut self, size: SizeBound) -> Self { - self.targets = self.targets.map_or( - Some(DataProviderBounds { count: None, size: Some(size) }), - |mut bounds| { - bounds.size = Some(size); - Some(bounds) - }, - ); - self - } - - /// Set the voters bounds. - pub fn voters(mut self, bounds: Option) -> Self { - self.voters = bounds; - self - } - - /// Set the targets bounds. - pub fn targets(mut self, bounds: Option) -> Self { - self.targets = bounds; - self - } - - /// Caps the number of the voters bounds in self to `voters` bounds. If `voters` bounds are - /// higher than the self bounds, keeps it. Note that `None` bounds are equivalent to maximum - /// and should be treated as such. - pub fn voters_or_lower(mut self, voters: DataProviderBounds) -> Self { - self.voters = match self.voters { - None => Some(voters), - Some(v) => Some(v.max(voters)), - }; - self - } - - /// Caps the number of the target bounds in self to `voters` bounds. If `voters` bounds are - /// higher than the self bounds, keeps it. Note that `None` bounds are equivalent to maximum - /// and should be treated as such. - pub fn targets_or_lower(mut self, targets: DataProviderBounds) -> Self { - self.targets = match self.targets { - None => Some(targets), - Some(t) => Some(t.max(targets)), - }; - self - } - - /// Returns an instance of `ElectionBounds` from the current state. - pub fn build(self) -> ElectionBounds { - ElectionBounds { - voters: self.voters.unwrap_or_default(), - targets: self.targets.unwrap_or_default(), - } - } -} diff --git a/frame/election-provider-support/src/onchain.rs b/frame/election-provider-support/src/onchain.rs index cd4ef205fa4ee..b8f7ad44c7134 100644 --- a/frame/election-provider-support/src/onchain.rs +++ b/frame/election-provider-support/src/onchain.rs @@ -20,9 +20,9 @@ //! careful when using it onchain. use crate::{ - BoundedSupportsOf, DataProviderBounds, Debug, ElectionBounds, ElectionBoundsBuilder, - ElectionDataProvider, ElectionProvider, ElectionProviderBase, InstantElectionProvider, - NposSolver, WeightInfo, + bounds::{DataProviderBounds, ElectionBounds, ElectionBoundsBuilder}, + BoundedSupportsOf, Debug, ElectionDataProvider, ElectionProvider, ElectionProviderBase, + InstantElectionProvider, NposSolver, WeightInfo, }; use frame_support::{dispatch::DispatchClass, traits::Get}; use sp_npos_elections::{ @@ -235,7 +235,7 @@ mod tests { parameter_types! { pub static MaxWinners: u32 = 10; pub static DesiredTargets: u32 = 2; - pub static ElectionBounds: crate::ElectionBounds = ElectionBoundsBuilder::new().voters_count(600.into()).targets_count(400.into()).build(); + pub static Bounds: ElectionBounds = ElectionBoundsBuilder::default().voters_count(600.into()).targets_count(400.into()).build(); } impl Config for PhragmenParams { @@ -244,7 +244,7 @@ mod tests { type DataProvider = mock_data_provider::DataProvider; type WeightInfo = (); type MaxWinners = MaxWinners; - type Bounds = ElectionBounds; + type Bounds = Bounds; } impl Config for PhragMMSParams { @@ -253,7 +253,7 @@ mod tests { type DataProvider = mock_data_provider::DataProvider; type WeightInfo = (); type MaxWinners = MaxWinners; - type Bounds = ElectionBounds; + type Bounds = Bounds; } mod mock_data_provider { diff --git a/frame/election-provider-support/src/tests.rs b/frame/election-provider-support/src/tests.rs index 93c89e786eaae..2db4071e61e1c 100644 --- a/frame/election-provider-support/src/tests.rs +++ b/frame/election-provider-support/src/tests.rs @@ -453,79 +453,3 @@ fn index_assignments_generate_same_solution_as_plain_assignments() { assert_eq!(solution, index_compact); } -#[cfg(test)] -mod elections_bounds { - use crate::*; - - #[test] - fn data_provider_bounds_unbounded() { - let bounds = DataProviderBounds::new_unbounded(); - assert!(!bounds.exhausted(None, None)); - assert!(!bounds.exhausted(SizeBound(10_000).into(), CountBound(10_000).into())); - } - - #[test] - fn election_bounds_builder_and_exhausted_bounds() { - // voter bounds exhausts if count > 100 or size > 1_000; target bounds exhausts if count > - // 200 or size > 2_000. - let bounds = ElectionBoundsBuilder::new() - .voters_count(100.into()) - .voters_size(1_000.into()) - .targets_count(200.into()) - .targets_size(2_000.into()) - .build(); - - assert!(!bounds.voters.exhausted(None, None)); - assert!(!bounds.voters.exhausted(SizeBound(10).into(), CountBound(10).into())); - assert!(!bounds.voters.exhausted(None, CountBound(100).into())); - assert!(!bounds.voters.exhausted(SizeBound(1_000).into(), None)); - assert!(bounds.voters.exhausted(None, CountBound(101).into())); - assert!(bounds.voters.exhausted(SizeBound(1_001).into(), None)); - - assert!(!bounds.targets.exhausted(None, None)); - assert!(!bounds.targets.exhausted(SizeBound(20).into(), CountBound(20).into())); - assert!(!bounds.targets.exhausted(None, CountBound(200).into())); - assert!(!bounds.targets.exhausted(SizeBound(2_000).into(), None)); - assert!(bounds.targets.exhausted(None, CountBound(201).into())); - assert!(bounds.targets.exhausted(SizeBound(2_001).into(), None)); - } - - #[test] - fn election_bounds_clamp_works() { - let bounds = ElectionBoundsBuilder::new() - .voters_count(10.into()) - .voters_size(10.into()) - .voters_or_lower(DataProviderBounds { - count: CountBound(5).into(), - size: SizeBound(20).into(), - }) - .targets_count(20.into()) - .targets_or_lower(DataProviderBounds { - count: CountBound(30).into(), - size: SizeBound(30).into(), - }) - .build(); - - assert_eq!(bounds.voters.count.unwrap(), CountBound(5)); - assert_eq!(bounds.voters.size.unwrap(), SizeBound(10)); - assert_eq!(bounds.targets.count.unwrap(), CountBound(20)); - assert_eq!(bounds.targets.size.unwrap(), SizeBound(30)); - - // note that unbounded bounds (None) are equivalent to maximum value. - let bounds = ElectionBoundsBuilder::new() - .voters_or_lower(DataProviderBounds { - count: CountBound(5).into(), - size: SizeBound(20).into(), - }) - .targets_or_lower(DataProviderBounds { - count: CountBound(10).into(), - size: SizeBound(10).into(), - }) - .build(); - - assert_eq!(bounds.voters.count.unwrap(), CountBound(5)); - assert_eq!(bounds.voters.size.unwrap(), SizeBound(20)); - assert_eq!(bounds.targets.count.unwrap(), CountBound(10)); - assert_eq!(bounds.targets.size.unwrap(), SizeBound(10)); - } -} diff --git a/frame/grandpa/src/mock.rs b/frame/grandpa/src/mock.rs index b6677a3d8c648..7718162c9f84b 100644 --- a/frame/grandpa/src/mock.rs +++ b/frame/grandpa/src/mock.rs @@ -23,7 +23,8 @@ use crate::{self as pallet_grandpa, AuthorityId, AuthorityList, Config, Consensu use ::grandpa as finality_grandpa; use codec::Encode; use frame_election_provider_support::{ - onchain, ElectionBounds, ElectionBoundsBuilder, SequentialPhragmen, + bounds::{ElectionBounds, ElectionBoundsBuilder}, + onchain, SequentialPhragmen, }; use frame_support::{ parameter_types, @@ -173,7 +174,7 @@ parameter_types! { pub const BondingDuration: EraIndex = 3; pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE; pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17); - pub static ElectionsBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::new().build(); + pub static ElectionsBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::default().build(); } pub struct OnChainSeqPhragmen; diff --git a/frame/offences/benchmarking/src/mock.rs b/frame/offences/benchmarking/src/mock.rs index ff4782b9bdd60..55e85a5db7f00 100644 --- a/frame/offences/benchmarking/src/mock.rs +++ b/frame/offences/benchmarking/src/mock.rs @@ -21,7 +21,8 @@ use super::*; use frame_election_provider_support::{ - onchain, ElectionBounds, ElectionBoundsBuilder, SequentialPhragmen, + bounds::{ElectionBounds, ElectionBoundsBuilder}, + onchain, SequentialPhragmen, }; use frame_support::{ parameter_types, @@ -144,7 +145,7 @@ pallet_staking_reward_curve::build! { } parameter_types! { pub const RewardCurve: &'static sp_runtime::curve::PiecewiseLinear<'static> = &I_NPOS; - pub static ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::new().build(); + pub static ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::default().build(); } pub type Extrinsic = sp_runtime::testing::TestXt; diff --git a/frame/root-offences/src/mock.rs b/frame/root-offences/src/mock.rs index 6ffb5c5707478..83a87c0a78f88 100644 --- a/frame/root-offences/src/mock.rs +++ b/frame/root-offences/src/mock.rs @@ -19,7 +19,8 @@ use super::*; use crate as root_offences; use frame_election_provider_support::{ - onchain, ElectionBounds, ElectionBoundsBuilder, SequentialPhragmen, + bounds::{ElectionBounds, ElectionBoundsBuilder}, + onchain, SequentialPhragmen, }; use frame_support::{ parameter_types, @@ -141,7 +142,7 @@ pallet_staking_reward_curve::build! { } parameter_types! { - pub static ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::new().build(); + pub static ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::default().build(); } pub struct OnChainSeqPhragmen; diff --git a/frame/session/benchmarking/src/mock.rs b/frame/session/benchmarking/src/mock.rs index 888dbc6042f03..120fc7161aba6 100644 --- a/frame/session/benchmarking/src/mock.rs +++ b/frame/session/benchmarking/src/mock.rs @@ -20,7 +20,8 @@ #![cfg(test)] use frame_election_provider_support::{ - onchain, ElectionBounds, ElectionBoundsBuilder, SequentialPhragmen, + bounds::{ElectionBounds, ElectionBoundsBuilder}, + onchain, SequentialPhragmen, }; use frame_support::{ parameter_types, @@ -148,7 +149,7 @@ pallet_staking_reward_curve::build! { } parameter_types! { pub const RewardCurve: &'static sp_runtime::curve::PiecewiseLinear<'static> = &I_NPOS; - pub static ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::new().build(); + pub static ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::default().build(); } pub struct OnChainSeqPhragmen; diff --git a/frame/staking/src/benchmarking.rs b/frame/staking/src/benchmarking.rs index 2034909248e13..f0a253b4d04b1 100644 --- a/frame/staking/src/benchmarking.rs +++ b/frame/staking/src/benchmarking.rs @@ -22,7 +22,7 @@ use crate::{ConfigOp, Pallet as Staking}; use testing_utils::*; use codec::Decode; -use frame_election_provider_support::{DataProviderBounds, SortedListProvider}; +use frame_election_provider_support::{bounds::DataProviderBounds, SortedListProvider}; use frame_support::{ dispatch::UnfilteredDispatchable, pallet_prelude::*, diff --git a/frame/staking/src/election_size_tracker.rs b/frame/staking/src/election_size_tracker.rs index 6d478a71b9139..5af9366de9317 100644 --- a/frame/staking/src/election_size_tracker.rs +++ b/frame/staking/src/election_size_tracker.rs @@ -30,31 +30,33 @@ //! //! ### Example //! -//! ```rust,ignore -//! // instantiates a new tracker. -//! let mut size_tracker = StaticTracker::::default(); +//! ```ignore +//! use pallet_staking::election_size_tracker::*; //! -//! let voter_bounds = ElectionBoundsBuilder::new().voter_size(1_00.into()).build().voters; +//! // instantiates a new tracker. +//! let mut size_tracker = StaticTracker::::default(); //! -//! let mut sorted_voters = T::VoterList.iter(); -//! let mut selected_voters = vec![]; +//! let voter_bounds = ElectionBoundsBuilder::default().voter_size(1_00.into()).build().voters; //! -//! // fit as many voters in the vec as the bounds permit. -//! for v in sorted_voters { -//! let voter = (v, weight_of(&v), targets_of(&v)); -//! if size_tracker.try_register_voter(&voter, &voter_bounds).is_err() { -//! log!(warn, "voter bounds size exhausted"); -//! break -//! } -//! selected_voters.push(voter); +//! let mut sorted_voters = T::VoterList.iter(); +//! let mut selected_voters = vec![]; +//! +//! // fit as many voters in the vec as the bounds permit. +//! for v in sorted_voters { +//! let voter = (v, weight_of(&v), targets_of(&v)); +//! if size_tracker.try_register_voter(&voter, &voter_bounds).is_err() { +//! // voter bounds size exhausted +//! break; //! } +//! selected_voters.push(voter); +//! } //! -//! // The SCALE encoded size in bytes of `selected_voters` is guaranteed to be below -//! // `voter_bounds`. -//! debug_assert!( -//! selected_voters.encoded_size() <= -//! SizeTracker::::final_byte_size_of(size_tracker.num_voters, size_tracker.size) -//! ); +//! // The SCALE encoded size in bytes of `selected_voters` is guaranteed to be below +//! // `voter_bounds`. +//! debug_assert!( +//! selected_voters.encoded_size() <= +//! SizeTracker::::final_byte_size_of(size_tracker.num_voters, size_tracker.size) +//! ); //! ``` //! //! ### Implementation Details @@ -69,7 +71,8 @@ use codec::Encode; use frame_election_provider_support::{ - DataProviderBounds, ElectionDataProvider, SizeBound, VoterOf, + bounds::{DataProviderBounds, SizeBound}, + ElectionDataProvider, VoterOf, }; /// Keeps track of the SCALE encoded byte length of the snapshot's voters struct. @@ -147,7 +150,7 @@ mod tests { mock::{AccountId, Staking, Test}, BoundedVec, MaxNominationsOf, }; - use frame_election_provider_support::ElectionBoundsBuilder; + use frame_election_provider_support::bounds::ElectionBoundsBuilder; use sp_core::bounded_vec; type Voters = BoundedVec>; @@ -156,7 +159,7 @@ mod tests { pub fn election_size_tracker_works() { let mut voters: Vec<(u64, u64, Voters)> = vec![]; let mut size_tracker = StaticTracker::::default(); - let voter_bounds = ElectionBoundsBuilder::new().voters_size(1_50.into()).build().voters; + let voter_bounds = ElectionBoundsBuilder::default().voters_size(1_50.into()).build().voters; // register 1 voter with 1 vote. let voter = (1, 10, bounded_vec![2]); @@ -202,7 +205,7 @@ mod tests { pub fn election_size_tracker_bounds_works() { let mut voters: Vec<(u64, u64, Voters)> = vec![]; let mut size_tracker = StaticTracker::::default(); - let voter_bounds = ElectionBoundsBuilder::new().voters_size(1_00.into()).build().voters; + let voter_bounds = ElectionBoundsBuilder::default().voters_size(1_00.into()).build().voters; let voter = (1, 10, bounded_vec![2]); assert!(size_tracker.try_register_voter(&voter, &voter_bounds).is_ok()); diff --git a/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index dfdcdba3a4e62..43d7404ebc9cb 100644 --- a/frame/staking/src/mock.rs +++ b/frame/staking/src/mock.rs @@ -19,7 +19,8 @@ use crate::{self as pallet_staking, *}; use frame_election_provider_support::{ - onchain, ElectionBounds, ElectionBoundsBuilder, SequentialPhragmen, VoteWeight, + bounds::{ElectionBounds, ElectionBoundsBuilder}, + onchain, SequentialPhragmen, VoteWeight, }; use frame_support::{ assert_ok, ord_parameter_types, parameter_types, @@ -239,7 +240,7 @@ parameter_types! { pub static RewardOnUnbalanceWasCalled: bool = false; pub static LedgerSlashPerEra: (BalanceOf, BTreeMap>) = (Zero::zero(), BTreeMap::new()); pub static MaxWinners: u32 = 100; - pub static ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::new().build(); + pub static ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::default().build(); pub static AbsoluteMaxNominations: u32 = 16; } diff --git a/frame/staking/src/pallet/impls.rs b/frame/staking/src/pallet/impls.rs index aeb793c17278b..c58ebaf096af5 100644 --- a/frame/staking/src/pallet/impls.rs +++ b/frame/staking/src/pallet/impls.rs @@ -18,8 +18,9 @@ //! Implementations for the Staking FRAME Pallet. use frame_election_provider_support::{ - data_provider, BoundedSupportsOf, CountBound, DataProviderBounds, ElectionDataProvider, - ElectionProvider, ScoreProvider, SizeBound, SortedListProvider, VoteWeight, VoterOf, + bounds::{CountBound, SizeBound}, + data_provider, BoundedSupportsOf, DataProviderBounds, ElectionDataProvider, ElectionProvider, + ScoreProvider, SortedListProvider, VoteWeight, VoterOf, }; use frame_support::{ dispatch::WithPostDispatchInfo, diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index 8aa0749fc03cb..48da4bd0f2e9c 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -19,7 +19,8 @@ use super::{ConfigOp, Event, *}; use frame_election_provider_support::{ - DataProviderBounds, ElectionBoundsBuilder, ElectionProvider, SortedListProvider, Support, + bounds::{DataProviderBounds, ElectionBoundsBuilder}, + ElectionProvider, SortedListProvider, Support, }; use frame_support::{ assert_noop, assert_ok, assert_storage_noop, bounded_vec, @@ -4514,7 +4515,7 @@ mod election_data_provider { // remove staker with lower bond by limiting the number of voters and check // `MinimumActiveStake` again after electing voters. - let bounds = ElectionBoundsBuilder::new().voters_count(5.into()).build(); + let bounds = ElectionBoundsBuilder::default().voters_count(5.into()).build(); assert_ok!(::electing_voters(bounds.voters)); assert_eq!(MinimumActiveStake::::get(), 50); }); @@ -4570,7 +4571,7 @@ mod election_data_provider { StakerStatus::::Nominator(vec![21, 22, 23, 24, 25]), ) .build_and_execute(|| { - let bounds_builder = ElectionBoundsBuilder::new(); + let bounds_builder = ElectionBoundsBuilder::default(); // all voters ordered by stake, assert_eq!( ::VoterList::iter().collect::>(), @@ -4605,7 +4606,7 @@ mod election_data_provider { // sum of all nominators who'd be voters (1), plus the self-votes (4). assert_eq!(::VoterList::count(), 5); - let bounds_builder = ElectionBoundsBuilder::new(); + let bounds_builder = ElectionBoundsBuilder::default(); // if limits is less.. assert_eq!( @@ -4664,13 +4665,13 @@ mod election_data_provider { fn respects_snapshot_size_limits() { ExtBuilder::default().build_and_execute(|| { // set size bounds that allows only for 1 voter. - let bounds = ElectionBoundsBuilder::new().voters_size(26.into()).build(); + let bounds = ElectionBoundsBuilder::default().voters_size(26.into()).build(); let elected = Staking::electing_voters(bounds.voters).unwrap(); assert!(elected.encoded_size() == 26 as usize); let prev_len = elected.len(); // larger size bounds means more quota for voters. - let bounds = ElectionBoundsBuilder::new().voters_size(100.into()).build(); + let bounds = ElectionBoundsBuilder::default().voters_size(100.into()).build(); let elected = Staking::electing_voters(bounds.voters).unwrap(); assert!(elected.encoded_size() <= 100 as usize); assert!(elected.len() > 1 && elected.len() > prev_len); @@ -4737,7 +4738,7 @@ mod election_data_provider { ) .build_and_execute(|| { // nominations of controller 70 won't be added due to voter size limit exceeded. - let bounds = ElectionBoundsBuilder::new().voters_size(100.into()).build(); + let bounds = ElectionBoundsBuilder::default().voters_size(100.into()).build(); assert_eq!( Staking::electing_voters(bounds.voters) .unwrap() @@ -4754,7 +4755,7 @@ mod election_data_provider { // however, if the election voter size bounds were largers, the snapshot would // include the electing voters of 70. - let bounds = ElectionBoundsBuilder::new().voters_size(1_000.into()).build(); + let bounds = ElectionBoundsBuilder::default().voters_size(1_000.into()).build(); assert_eq!( Staking::electing_voters(bounds.voters) .unwrap() From a5cd416924a39c8f3cf7b0c5dc428cac82530e0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Wed, 19 Apr 2023 18:21:11 +0200 Subject: [PATCH 69/80] More tests and docs --- .../src/benchmarking.rs | 5 ++- .../election-provider-multi-phase/src/lib.rs | 9 +++-- .../src/signed.rs | 3 +- frame/election-provider-support/src/bounds.rs | 38 +++++++++++++++---- frame/election-provider-support/src/lib.rs | 2 +- frame/election-provider-support/src/tests.rs | 1 - frame/staking/src/benchmarking.rs | 6 ++- frame/staking/src/lib.rs | 2 +- frame/staking/src/pallet/impls.rs | 18 ++++----- frame/staking/src/pallet/mod.rs | 3 +- frame/staking/src/tests.rs | 16 +++++--- 11 files changed, 67 insertions(+), 36 deletions(-) diff --git a/frame/election-provider-multi-phase/src/benchmarking.rs b/frame/election-provider-multi-phase/src/benchmarking.rs index e05136ce31eab..a980c67b7f44d 100644 --- a/frame/election-provider-multi-phase/src/benchmarking.rs +++ b/frame/election-provider-multi-phase/src/benchmarking.rs @@ -269,8 +269,9 @@ frame_benchmarking::benchmarks! { // we don't directly need the data-provider to be populated, but it is just easy to use it. set_up_data_provider::(v, t); - let targets = T::DataProvider::electable_targets(DataProviderBounds::new_unbounded())?; - let voters = T::DataProvider::electing_voters(DataProviderBounds::new_unbounded())?; + // default bounds are unbounded. + let targets = T::DataProvider::electable_targets(DataProviderBounds::default())?; + let voters = T::DataProvider::electing_voters(DataProviderBounds::default())?; let desired_targets = T::DataProvider::desired_targets()?; assert!(>::snapshot().is_none()); }: { diff --git a/frame/election-provider-multi-phase/src/lib.rs b/frame/election-provider-multi-phase/src/lib.rs index c27cf0d7be7a0..de66c7118baf2 100644 --- a/frame/election-provider-multi-phase/src/lib.rs +++ b/frame/election-provider-multi-phase/src/lib.rs @@ -1551,11 +1551,12 @@ impl Pallet { >::take() .ok_or(ElectionError::::NothingQueued) .or_else(|_| { - // calling `instant_elect` with unbounded data provider bounds means that the - // on-chain `T:Bounds` configs will *not* be overwritten. + // default data provider bounds are unbounded. calling `instant_elect` with + // unbounded data provider bounds means that the on-chain `T:Bounds` configs will + // *not* be overwritten. T::Fallback::instant_elect( - DataProviderBounds::new_unbounded(), - DataProviderBounds::new_unbounded(), + DataProviderBounds::default(), + DataProviderBounds::default(), ) .map_err(|fe| ElectionError::Fallback(fe)) .and_then(|supports| { diff --git a/frame/election-provider-multi-phase/src/signed.rs b/frame/election-provider-multi-phase/src/signed.rs index 9d99e4caf699e..1ec3a465676d6 100644 --- a/frame/election-provider-multi-phase/src/signed.rs +++ b/frame/election-provider-multi-phase/src/signed.rs @@ -561,7 +561,8 @@ mod tests { fn data_provider_should_respect_target_limits() { ExtBuilder::default().build_and_execute(|| { // given a reduced expectation of maximum electable targets - let new_bounds = crate::ElectionBoundsBuilder::default().targets_count(2.into()).build(); + let new_bounds = + crate::ElectionBoundsBuilder::default().targets_count(2.into()).build(); ElectionsBounds::set(new_bounds); // and a data provider that does not respect limits DataProviderAllowBadData::set(true); diff --git a/frame/election-provider-support/src/bounds.rs b/frame/election-provider-support/src/bounds.rs index 8d3dc7a98b4e5..b0d5033f2e3d8 100644 --- a/frame/election-provider-support/src/bounds.rs +++ b/frame/election-provider-support/src/bounds.rs @@ -130,18 +130,13 @@ impl Add for SizeBound { /// of the SCALE encoded result. /// /// `None` represents unlimited bounds in both `count` and `size` axis. -#[derive(Clone, Copy, Default, Debug)] +#[derive(Clone, Copy, Default, Debug, Eq, PartialEq)] pub struct DataProviderBounds { pub count: Option, pub size: Option, } impl DataProviderBounds { - /// Constructor with unbounded data provider limits. - pub fn new_unbounded() -> Self { - DataProviderBounds { count: None, size: None } - } - /// Returns true if `given_count` exhausts `self.count`. pub fn count_exhausted(self, given_count: CountBound) -> bool { self.count.map_or(false, |count| given_count > count) @@ -300,7 +295,7 @@ mod test { #[test] fn data_provider_bounds_unbounded() { - let bounds = DataProviderBounds::new_unbounded(); + let bounds = DataProviderBounds::default(); assert!(!bounds.exhausted(None, None)); assert!(!bounds.exhausted(SizeBound(u32::MAX).into(), CountBound(u32::MAX).into())); } @@ -333,6 +328,35 @@ mod test { assert!(bounds.targets.exhausted(SizeBound(2_001).into(), None)); } + #[test] + fn data_provider_max_unbounded_works() { + let unbounded = DataProviderBounds::default(); + + // max of some bounds with unbounded data provider bounds will always return the defined + // bounds. + let bounds = DataProviderBounds { count: CountBound(5).into(), size: SizeBound(10).into() }; + assert_eq!(unbounded.max(bounds), bounds); + + let bounds = DataProviderBounds { count: None, size: SizeBound(10).into() }; + assert_eq!(unbounded.max(bounds), bounds); + + let bounds = DataProviderBounds { count: CountBound(5).into(), size: None }; + assert_eq!(unbounded.max(bounds), bounds); + } + + #[test] + fn data_provider_max_bounded_works() { + let bounds_one = + DataProviderBounds { count: CountBound(10).into(), size: SizeBound(100).into() }; + let bounds_two = + DataProviderBounds { count: CountBound(100).into(), size: SizeBound(10).into() }; + let max_bounds_expected = + DataProviderBounds { count: CountBound(10).into(), size: SizeBound(10).into() }; + + assert_eq!(bounds_one.max(bounds_two), max_bounds_expected); + assert_eq!(bounds_two.max(bounds_one), max_bounds_expected); + } + #[test] fn election_bounds_clamp_works() { let bounds = ElectionBoundsBuilder::default() diff --git a/frame/election-provider-support/src/lib.rs b/frame/election-provider-support/src/lib.rs index 56f655e897458..259b97f6902f5 100644 --- a/frame/election-provider-support/src/lib.rs +++ b/frame/election-provider-support/src/lib.rs @@ -145,7 +145,7 @@ //! impl ElectionProvider for GenericElectionProvider { //! fn ongoing() -> bool { false } //! fn elect() -> Result, Self::Error> { -//! Self::DataProvider::electable_targets(DataProviderBounds::new_unbounded()) +//! Self::DataProvider::electable_targets(DataProviderBounds::default()) //! .map_err(|_| "failed to elect") //! .map(|t| bounded_vec![(t[0], Support::default())]) //! } diff --git a/frame/election-provider-support/src/tests.rs b/frame/election-provider-support/src/tests.rs index 2db4071e61e1c..73ce1427cf2f0 100644 --- a/frame/election-provider-support/src/tests.rs +++ b/frame/election-provider-support/src/tests.rs @@ -452,4 +452,3 @@ fn index_assignments_generate_same_solution_as_plain_assignments() { assert_eq!(solution, index_compact); } - diff --git a/frame/staking/src/benchmarking.rs b/frame/staking/src/benchmarking.rs index f0a253b4d04b1..3d399befd182b 100644 --- a/frame/staking/src/benchmarking.rs +++ b/frame/staking/src/benchmarking.rs @@ -810,7 +810,8 @@ benchmarks! { let num_voters = (v + n) as usize; }: { - let voters = >::get_npos_voters(DataProviderBounds::new_unbounded()); + // default bounds are unbounded. + let voters = >::get_npos_voters(DataProviderBounds::default()); assert_eq!(voters.len(), num_voters); } @@ -824,7 +825,8 @@ benchmarks! { v, n, MaxNominationsOf::::get() as usize, false, None )?; }: { - let targets = >::get_npos_targets(DataProviderBounds::new_unbounded()); + // default bounds are unbounded. + let targets = >::get_npos_targets(DataProviderBounds::default()); assert_eq!(targets.len() as u32, v); } diff --git a/frame/staking/src/lib.rs b/frame/staking/src/lib.rs index d325eac81c683..16645e8ee189f 100644 --- a/frame/staking/src/lib.rs +++ b/frame/staking/src/lib.rs @@ -159,7 +159,7 @@ //! ``` //! use pallet_staking::{self as staking}; //! -//! #[frame_support::pallet] +//! #[frame_support::pallet(dev_mode)] //! pub mod pallet { //! use super::*; //! use frame_support::pallet_prelude::*; diff --git a/frame/staking/src/pallet/impls.rs b/frame/staking/src/pallet/impls.rs index c58ebaf096af5..e9ed1b26990b8 100644 --- a/frame/staking/src/pallet/impls.rs +++ b/frame/staking/src/pallet/impls.rs @@ -759,12 +759,12 @@ impl Pallet { pub fn get_npos_voters(bounds: DataProviderBounds) -> Vec> { let mut voters_size_tracker: StaticTracker = StaticTracker::default(); - let max_allowed_len = { + let final_predicted_len = { let all_voter_count = T::VoterList::count(); bounds.count.unwrap_or(all_voter_count.into()).min(all_voter_count.into()).0 }; - let mut all_voters = Vec::<_>::with_capacity(max_allowed_len as usize); + let mut all_voters = Vec::<_>::with_capacity(final_predicted_len as usize); // cache a few things. let weight_of = Self::weight_of_fn(); @@ -775,8 +775,8 @@ impl Pallet { let mut min_active_stake = u64::MAX; let mut sorted_voters = T::VoterList::iter(); - while all_voters.len() < max_allowed_len as usize && - voters_seen < (NPOS_MAX_ITERATIONS_COEFFICIENT * max_allowed_len as u32) + while all_voters.len() < final_predicted_len as usize && + voters_seen < (NPOS_MAX_ITERATIONS_COEFFICIENT * final_predicted_len as u32) { let voter = match sorted_voters.next() { Some(voter) => { @@ -844,7 +844,7 @@ impl Pallet { } // all_voters should have not re-allocated. - debug_assert!(all_voters.capacity() == max_allowed_len as usize); + debug_assert!(all_voters.capacity() == final_predicted_len as usize); Self::register_weight(T::WeightInfo::get_npos_voters(validators_taken, nominators_taken)); @@ -868,7 +868,7 @@ impl Pallet { /// /// This function is self-weighing as [`DispatchClass::Mandatory`]. pub fn get_npos_targets(target_bounds: DataProviderBounds) -> Vec { - let max_allowed_len = { + let final_predicted_len = { let all_target_count = T::TargetList::count(); target_bounds .count @@ -877,12 +877,12 @@ impl Pallet { .0 }; - let mut all_targets = Vec::::with_capacity(max_allowed_len as usize); + let mut all_targets = Vec::::with_capacity(final_predicted_len as usize); let mut targets_seen = 0; let mut targets_iter = T::TargetList::iter(); - while all_targets.len() < max_allowed_len as usize && - targets_seen < (NPOS_MAX_ITERATIONS_COEFFICIENT * max_allowed_len as u32) + while all_targets.len() < final_predicted_len as usize && + targets_seen < (NPOS_MAX_ITERATIONS_COEFFICIENT * final_predicted_len as u32) { let target = match targets_iter.next() { Some(target) => { diff --git a/frame/staking/src/pallet/mod.rs b/frame/staking/src/pallet/mod.rs index 8c291e880c9b2..348a28eebd531 100644 --- a/frame/staking/src/pallet/mod.rs +++ b/frame/staking/src/pallet/mod.rs @@ -1164,8 +1164,7 @@ pub mod pallet { ensure!(!targets.is_empty(), Error::::EmptyTargets); ensure!( - targets.len() <= - T::NominationsQuota::get_quota(Self::weight_of(&stash).into()) as usize, + targets.len() <= T::NominationsQuota::get_quota(ledger.active) as usize, Error::::TooManyTargets ); diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index 48da4bd0f2e9c..b5814690e4246 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -4508,8 +4508,9 @@ mod election_data_provider { .add_staker(71, 70, 10, StakerStatus::::Nominator(vec![21])) .add_staker(81, 80, 50, StakerStatus::::Nominator(vec![21])) .build_and_execute(|| { + // default bounds are unbounded. assert_ok!(::electing_voters( - DataProviderBounds::new_unbounded() + DataProviderBounds::default() )); assert_eq!(MinimumActiveStake::::get(), 10); @@ -4524,8 +4525,9 @@ mod election_data_provider { #[test] fn set_minimum_active_stake_zero_correct() { ExtBuilder::default().has_stakers(false).build_and_execute(|| { + // default bounds are unbounded. assert_ok!(::electing_voters( - DataProviderBounds::new_unbounded() + DataProviderBounds::default() )); assert_eq!(MinimumActiveStake::::get(), 0); }); @@ -4534,8 +4536,9 @@ mod election_data_provider { #[test] fn voters_include_self_vote() { ExtBuilder::default().nominate(false).build_and_execute(|| { + // default bounds are unbounded. assert!(>::iter().map(|(x, _)| x).all(|v| Staking::electing_voters( - DataProviderBounds::new_unbounded() + DataProviderBounds::default() ) .unwrap() .into_iter() @@ -4716,7 +4719,7 @@ mod election_data_provider { // even through 61 has nomination quota of 2 at the time of the election, all the // nominations (5) will be used. assert_eq!( - Staking::electing_voters(DataProviderBounds::new_unbounded()) + Staking::electing_voters(DataProviderBounds::default()) .unwrap() .iter() .map(|(stash, _, targets)| (*stash, targets.len())) @@ -5228,7 +5231,8 @@ fn change_of_absolute_max_nominations() { vec![(70, 3), (101, 2), (60, 1)] ); - let bounds = DataProviderBounds::new_unbounded(); + // default bounds are unbounded. + let bounds = DataProviderBounds::default(); // 3 validators and 3 nominators assert_eq!(Staking::electing_voters(bounds).unwrap().len(), 3 + 3); @@ -5320,7 +5324,7 @@ fn nomination_quota_max_changes_decoding() { // pre-condition. assert_eq!(MaxNominationsOf::::get(), 16); - let unbonded_election = DataProviderBounds::new_unbounded(); + let unbonded_election = DataProviderBounds::default(); assert_eq!( Nominators::::iter() From 742f07dfee43e2feecd69e80491dc959d2a7bba5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Wed, 19 Apr 2023 18:33:39 +0200 Subject: [PATCH 70/80] fixes docs --- frame/election-provider-support/src/bounds.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/election-provider-support/src/bounds.rs b/frame/election-provider-support/src/bounds.rs index b0d5033f2e3d8..d93be01c84e3e 100644 --- a/frame/election-provider-support/src/bounds.rs +++ b/frame/election-provider-support/src/bounds.rs @@ -21,7 +21,7 @@ //! //! This module defines and implements types that help creating and handling election bounds. //! [`DataProviderBounds`] encapsulates the upper limits for the results of provided by -//! [`DataProvider`] implementors. Those limits can be defined over two axis: number of elements +//! `DataProvider` implementors. Those limits can be defined over two axis: number of elements //! returned (`count`) and/or the size of the returned SCALE encoded structure (`size`). //! //! [`ElectionBoundsBuilder`] is a helper to construct data election bounds and it aims at From fe6118495f304790d5f6d87bfd713d0b4881052b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Thu, 20 Apr 2023 12:05:11 +0200 Subject: [PATCH 71/80] Fixes benchmarks --- bin/node/runtime/src/lib.rs | 3 ++- frame/election-provider-multi-phase/src/mock.rs | 7 +++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index ff993766a3e24..3cd8c7463be15 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -647,7 +647,7 @@ frame_election_provider_support::generate_solution_type!( VoterIndex = u32, TargetIndex = u16, Accuracy = sp_runtime::PerU16, - MaxVoters = MaxNominations, + MaxVoters = MaxElectingVotersSolution, >(16) ); @@ -660,6 +660,7 @@ parameter_types! { .voters_count(5_000.into()).targets_count(1_250.into()).build(); pub MaxNominations: u32 = ::LIMIT as u32; + pub MaxElectingVotersSolution: u32 = 40_000; // The maximum winners that can be elected by the Election pallet which is equivalent to the // maximum active validators the staking pallet can have. pub MaxActiveValidators: u32 = 1000; diff --git a/frame/election-provider-multi-phase/src/mock.rs b/frame/election-provider-multi-phase/src/mock.rs index 117ba2a41203c..90f32e882a749 100644 --- a/frame/election-provider-multi-phase/src/mock.rs +++ b/frame/election-provider-multi-phase/src/mock.rs @@ -303,10 +303,9 @@ parameter_types! { #[derive(Debug)] pub static MaxWinners: u32 = 200; + // `ElectionBounds` and `OnChainElectionsBounds` are defined separately to set them independenyly in the tests. pub static ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::default().build(); - pub static ElectionsBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::default() - .targets_count(5_000.into()).voters_count(1_250.into()).build(); - + pub static OnChainElectionsBounds: ElectionBounds = ElectionBoundsBuilder::default().build(); pub static EpochLength: u64 = 30; pub static OnChainFallback: bool = true; } @@ -318,7 +317,7 @@ impl onchain::Config for OnChainSeqPhragmen { type DataProvider = StakingMock; type WeightInfo = (); type MaxWinners = MaxWinners; - type Bounds = ElectionsBoundsOnChain; + type Bounds = OnChainElectionsBounds; } pub struct MockFallback; From 87945f6a9a046c108055b35ffa90ae6d08e49342 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Thu, 20 Apr 2023 12:32:13 +0200 Subject: [PATCH 72/80] Fixes rust docs --- frame/election-provider-support/src/bounds.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/election-provider-support/src/bounds.rs b/frame/election-provider-support/src/bounds.rs index d93be01c84e3e..a1edaea4b14ea 100644 --- a/frame/election-provider-support/src/bounds.rs +++ b/frame/election-provider-support/src/bounds.rs @@ -123,7 +123,7 @@ impl Add for SizeBound { } } -/// Data bounds for [`DataProvider`]. +/// Data bounds for election data. /// /// Limits the data returned by `DataProvider` implementors, defined over two axis: `count`, /// defining the maximum number of elements returned and `size`, defining the limit in size (bytes) From 75be8626b51fae9e777c9c1bc9d3da0f22aa76c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Thu, 20 Apr 2023 13:31:33 +0200 Subject: [PATCH 73/80] fixes bags-list remote-ext-tests --- frame/bags-list/remote-tests/src/snapshot.rs | 28 +++++++++++--------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/frame/bags-list/remote-tests/src/snapshot.rs b/frame/bags-list/remote-tests/src/snapshot.rs index 270ef01d508c3..78c5b4e1c7b6d 100644 --- a/frame/bags-list/remote-tests/src/snapshot.rs +++ b/frame/bags-list/remote-tests/src/snapshot.rs @@ -16,17 +16,17 @@ //! Test to execute the snapshot using the voter bag. -use frame_election_provider_support::{bounds::ElectionBounds, SortedListProvider}; +use frame_election_provider_support::{ + bounds::{CountBound, DataProviderBounds}, + SortedListProvider, +}; use frame_support::traits::PalletInfoAccess; use remote_externalities::{Builder, Mode, OnlineConfig}; use sp_runtime::{traits::Block as BlockT, DeserializeOwned}; /// Execute create a snapshot from pallet-staking. -pub async fn execute( - election_bounds: ElectionBounds, - currency_unit: u64, - ws_url: String, -) where +pub async fn execute(voter_limit: Option, currency_unit: u64, ws_url: String) +where Runtime: crate::RuntimeT, Block: BlockT + DeserializeOwned, Block::Header: DeserializeOwned, @@ -65,10 +65,14 @@ pub async fn execute( ::VoterList::count(), ); - let voters = as ElectionDataProvider>::electing_voters( - election_bounds.voters, - ) - .unwrap(); + let bounds = match voter_limit { + None => DataProviderBounds::default(), + Some(v) => DataProviderBounds { count: Some(CountBound(v as u32)), size: None }, + }; + + let voters = + as ElectionDataProvider>::electing_voters(bounds) + .unwrap(); let mut voters_nominator_only = voters .iter() @@ -86,8 +90,8 @@ pub async fn execute( .map(|(x, y, _)| (x.clone(), *y as f64 / currency_unit)); log::info!( target: crate::LOG_TARGET, - "a snapshot with limits {:?} has been created, {} voters are taken. min nominator: {:?}, max: {:?}", - election_bounds, + "a snapshot with limit {:?} has been created, {} voters are taken. min nominator: {:?}, max: {:?}", + voter_limit, voters.len(), min_voter, max_voter From b3aab8527e212baa1f9e8bc54e983919881d007d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Thu, 20 Apr 2023 14:38:26 +0200 Subject: [PATCH 74/80] Simplify bound checks in create_snapshot_external --- .../election-provider-multi-phase/src/lib.rs | 35 +++++----- .../src/signed.rs | 4 +- frame/election-provider-support/src/bounds.rs | 64 ++++++++++++++++++- 3 files changed, 80 insertions(+), 23 deletions(-) diff --git a/frame/election-provider-multi-phase/src/lib.rs b/frame/election-provider-multi-phase/src/lib.rs index de66c7118baf2..afde7e8ead550 100644 --- a/frame/election-provider-multi-phase/src/lib.rs +++ b/frame/election-provider-multi-phase/src/lib.rs @@ -231,7 +231,7 @@ use codec::{Decode, Encode}; use frame_election_provider_support::{ - bounds::{ElectionBounds, ElectionBoundsBuilder}, + bounds::{CountBound, ElectionBounds, ElectionBoundsBuilder, SizeBound}, BoundedSupportsOf, DataProviderBounds, ElectionDataProvider, ElectionProvider, ElectionProviderBase, InstantElectionProvider, NposSolution, }; @@ -1416,32 +1416,27 @@ impl Pallet { fn create_snapshot_external( ) -> Result<(Vec, Vec>, u32), ElectionError> { let election_bounds = T::ElectionBounds::get(); - let target_limit = election_bounds - .targets - .count - .unwrap_or(u32::MAX.into()) - .0 - .saturated_into::(); - let voter_limit = election_bounds - .voters - .count - .unwrap_or(u32::MAX.into()) - .0 - .saturated_into::(); let targets = T::DataProvider::electable_targets(election_bounds.targets) + .and_then(|t| { + election_bounds.ensure_targets_limits( + CountBound(t.len() as u32), + SizeBound(t.encoded_size() as u32), + )?; + Ok(t) + }) .map_err(ElectionError::DataProvider)?; let voters = T::DataProvider::electing_voters(election_bounds.voters) + .and_then(|v| { + election_bounds.ensure_voters_limits( + CountBound(v.len() as u32), + SizeBound(v.encoded_size() as u32), + )?; + Ok(v) + }) .map_err(ElectionError::DataProvider)?; - if targets.len() > target_limit || voters.len() > voter_limit { - return Err(ElectionError::DataProvider("Snapshot too big for submission.")) - } - if voters.encoded_size() as u32 > election_bounds.voters.size.unwrap_or(u32::MAX.into()).0 { - return Err(ElectionError::DataProvider("Snapshot in MBs too big for submission.")) - } - let mut desired_targets = as ElectionProviderBase>::desired_targets_checked() .map_err(|e| ElectionError::DataProvider(e))?; diff --git a/frame/election-provider-multi-phase/src/signed.rs b/frame/election-provider-multi-phase/src/signed.rs index 1ec3a465676d6..56c2e54d68094 100644 --- a/frame/election-provider-multi-phase/src/signed.rs +++ b/frame/election-provider-multi-phase/src/signed.rs @@ -569,7 +569,7 @@ mod tests { assert_noop!( MultiPhase::create_snapshot(), - ElectionError::DataProvider("Snapshot too big for submission."), + ElectionError::DataProvider("Ensure targets bounds: bounds exceeded."), ); }) } @@ -585,7 +585,7 @@ mod tests { assert_noop!( MultiPhase::create_snapshot(), - ElectionError::DataProvider("Snapshot too big for submission."), + ElectionError::DataProvider("Ensure voters bounds: bounds exceeded."), ); }) } diff --git a/frame/election-provider-support/src/bounds.rs b/frame/election-provider-support/src/bounds.rs index a1edaea4b14ea..c842f070146a1 100644 --- a/frame/election-provider-support/src/bounds.rs +++ b/frame/election-provider-support/src/bounds.rs @@ -178,12 +178,40 @@ impl DataProviderBounds { /// /// The bounds are defined over two axis: `count` of element of the election (voters or targets) and /// the `size` of the SCALE encoded result snapshot. -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Copy)] pub struct ElectionBounds { pub voters: DataProviderBounds, pub targets: DataProviderBounds, } +impl ElectionBounds { + /// Returns an error if the provided `count` and `size` do not fit in the voter's election + /// bounds. + pub fn ensure_voters_limits( + self, + count: CountBound, + size: SizeBound, + ) -> Result<(), &'static str> { + match self.voters.exhausted(Some(size), Some(count)) { + true => Err("Ensure voters bounds: bounds exceeded."), + false => Ok(()), + } + } + + /// Returns an error if the provided `count` and `size` do not fit in the target's election + /// bounds. + pub fn ensure_targets_limits( + self, + count: CountBound, + size: SizeBound, + ) -> Result<(), &'static str> { + match self.targets.exhausted(Some(size), Some(count).into()) { + true => Err("Ensure targets bounds: bounds exceeded."), + false => Ok(()), + } + } +} + /// Utility builder for [`ElectionBounds`]. #[derive(Copy, Clone, Default)] pub struct ElectionBoundsBuilder { @@ -293,6 +321,8 @@ impl ElectionBoundsBuilder { mod test { use super::*; + use frame_support::{assert_err, assert_ok}; + #[test] fn data_provider_bounds_unbounded() { let bounds = DataProviderBounds::default(); @@ -328,6 +358,38 @@ mod test { assert!(bounds.targets.exhausted(SizeBound(2_001).into(), None)); } + #[test] + fn election_bounds_ensure_limits_works() { + let bounds = ElectionBounds { + voters: DataProviderBounds { count: Some(CountBound(10)), size: Some(SizeBound(10)) }, + targets: DataProviderBounds { count: Some(CountBound(10)), size: Some(SizeBound(10)) }, + }; + + assert_ok!(bounds.ensure_voters_limits(CountBound(1), SizeBound(1))); + assert_ok!(bounds.ensure_voters_limits(CountBound(1), SizeBound(1))); + assert_ok!(bounds.ensure_voters_limits(CountBound(10), SizeBound(10))); + assert_err!( + bounds.ensure_voters_limits(CountBound(1), SizeBound(11)), + "Ensure voters bounds: bounds exceeded." + ); + assert_err!( + bounds.ensure_voters_limits(CountBound(11), SizeBound(10)), + "Ensure voters bounds: bounds exceeded." + ); + + assert_ok!(bounds.ensure_targets_limits(CountBound(1), SizeBound(1))); + assert_ok!(bounds.ensure_targets_limits(CountBound(1), SizeBound(1))); + assert_ok!(bounds.ensure_targets_limits(CountBound(10), SizeBound(10))); + assert_err!( + bounds.ensure_targets_limits(CountBound(1), SizeBound(11)), + "Ensure targets bounds: bounds exceeded." + ); + assert_err!( + bounds.ensure_targets_limits(CountBound(11), SizeBound(10)), + "Ensure targets bounds: bounds exceeded." + ); + } + #[test] fn data_provider_max_unbounded_works() { let unbounded = DataProviderBounds::default(); From fe2dfe3f6cd86599af86500dd6758986941519d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Sun, 4 Jun 2023 22:16:06 +0200 Subject: [PATCH 75/80] Adds target size check in get_npos_targets --- frame/election-provider-support/src/bounds.rs | 22 +++--- frame/staking/src/election_size_tracker.rs | 68 +++++++++++-------- frame/staking/src/pallet/impls.rs | 38 +++++++---- frame/staking/src/pallet/mod.rs | 4 +- frame/staking/src/tests.rs | 28 ++++++-- 5 files changed, 100 insertions(+), 60 deletions(-) diff --git a/frame/election-provider-support/src/bounds.rs b/frame/election-provider-support/src/bounds.rs index c842f070146a1..761f5220eed4d 100644 --- a/frame/election-provider-support/src/bounds.rs +++ b/frame/election-provider-support/src/bounds.rs @@ -20,9 +20,9 @@ //! ### Overview //! //! This module defines and implements types that help creating and handling election bounds. -//! [`DataProviderBounds`] encapsulates the upper limits for the results of provided by -//! `DataProvider` implementors. Those limits can be defined over two axis: number of elements -//! returned (`count`) and/or the size of the returned SCALE encoded structure (`size`). +//! [`DataProviderBounds`] encapsulates the upper limits for the results provided by `DataProvider` +//! implementors. Those limits can be defined over two axis: number of elements returned (`count`) +//! and/or the size of the returned SCALE encoded structure (`size`). //! //! [`ElectionBoundsBuilder`] is a helper to construct data election bounds and it aims at //! preventing the caller from mistake the order of size and count limits. @@ -51,8 +51,8 @@ //! //! ### Implementation details //! -//! As a norm, a default or `None` bound is unbounded (i.e. unlimited). In general, be careful when -//! using unbounded election bounds in production. +//! A default or `None` bound means that no bounds are enfirced (i.e. unlimited result size). In +//! general, be careful when using unbounded election bounds in production. use core::ops::Add; use sp_runtime::traits::Zero; @@ -82,7 +82,7 @@ impl Add for CountBound { impl Zero for CountBound { fn is_zero(&self) -> bool { - self.0 == 0 + self.0 == 0u32 } fn zero() -> Self { CountBound(0) @@ -109,7 +109,7 @@ impl From for SizeBound { impl Zero for SizeBound { fn is_zero(&self) -> bool { - self.0 == 0 + self.0 == 0u32 } fn zero() -> Self { SizeBound(0) @@ -126,8 +126,8 @@ impl Add for SizeBound { /// Data bounds for election data. /// /// Limits the data returned by `DataProvider` implementors, defined over two axis: `count`, -/// defining the maximum number of elements returned and `size`, defining the limit in size (bytes) -/// of the SCALE encoded result. +/// defining the maximum number of elements returned, and `size`, defining the limit in size +/// (bytes) of the SCALE encoded result. /// /// `None` represents unlimited bounds in both `count` and `size` axis. #[derive(Clone, Copy, Default, Debug, Eq, PartialEq)] @@ -324,14 +324,14 @@ mod test { use frame_support::{assert_err, assert_ok}; #[test] - fn data_provider_bounds_unbounded() { + fn data_provider_bounds_unbounded_works() { let bounds = DataProviderBounds::default(); assert!(!bounds.exhausted(None, None)); assert!(!bounds.exhausted(SizeBound(u32::MAX).into(), CountBound(u32::MAX).into())); } #[test] - fn election_bounds_builder_and_exhausted_bounds() { + fn election_bounds_builder_and_exhausted_bounds_work() { // voter bounds exhausts if count > 100 or size > 1_000; target bounds exhausts if count > // 200 or size > 2_000. let bounds = ElectionBoundsBuilder::default() diff --git a/frame/staking/src/election_size_tracker.rs b/frame/staking/src/election_size_tracker.rs index 5af9366de9317..61400aa1d63d2 100644 --- a/frame/staking/src/election_size_tracker.rs +++ b/frame/staking/src/election_size_tracker.rs @@ -18,7 +18,7 @@ //! ## A static size tracker for the election snapshot data. //! //! ### Overview - +//! //! The goal of the size tracker is to provide a static, no-allocation byte tracker to be //! used by the election data provider when preparing the results of //! [`ElectionDataProvider::electing_voters`]. The [`StaticTracker`] implementation uses @@ -82,13 +82,13 @@ use frame_election_provider_support::{ #[derive(Clone, Copy, Debug)] pub struct StaticTracker { pub size: usize, - pub num_voters: usize, + pub counter: usize, _marker: sp_std::marker::PhantomData, } impl Default for StaticTracker { fn default() -> Self { - Self { size: 0, num_voters: 0, _marker: Default::default() } + Self { size: 0, counter: 0, _marker: Default::default() } } } @@ -107,26 +107,19 @@ where ) -> Result<(), ()> { let tracker_size_after = { let voter_hint = Self::voter_size_hint(voter); - Self::final_byte_size_of(self.num_voters + 1, self.size.saturating_add(voter_hint)) + Self::final_byte_size_of(self.counter + 1, self.size.saturating_add(voter_hint)) }; match bounds.size_exhausted(SizeBound(tracker_size_after as u32)) { true => Err(()), false => { self.size = tracker_size_after; - self.num_voters += 1; + self.counter += 1; Ok(()) }, } } - /// Size of the SCALE encoded prefix with a given length. - #[inline] - fn length_prefix(len: usize) -> usize { - use codec::{Compact, CompactLen}; - Compact::::compact_len(&(len as u32)) - } - /// Calculates the size of the voter to register based on [`Encode::size_hint`]. fn voter_size_hint(voter: &VoterOf) -> usize { let (voter_account, vote_weight, targets) = voter; @@ -137,6 +130,37 @@ where .saturating_add(voter_account.size_hint().saturating_mul(targets.len())) } + /// Tries to register a new target. + /// + /// If the new target exhausts the provided bounds, return an error. Otherwise, the internal + /// state of the tracker is updated with the new registered target. + pub fn try_register_target( + &mut self, + target: DataProvider::AccountId, + bounds: &DataProviderBounds, + ) -> Result<(), ()> { + let tracker_size_after = Self::final_byte_size_of( + self.counter + 1, + self.size.saturating_add(target.size_hint()), + ); + + match bounds.size_exhausted(SizeBound(tracker_size_after as u32)) { + true => Err(()), + false => { + self.size = tracker_size_after; + self.counter += 1; + Ok(()) + }, + } + } + + /// Size of the SCALE encoded prefix with a given length. + #[inline] + fn length_prefix(len: usize) -> usize { + use codec::{Compact, CompactLen}; + Compact::::compact_len(&(len as u32)) + } + /// Calculates the final size in bytes of the SCALE encoded snapshot voter struct. fn final_byte_size_of(num_voters: usize, size: usize) -> usize { Self::length_prefix(num_voters).saturating_add(size) @@ -167,10 +191,7 @@ mod tests { voters.push(voter); assert_eq!( - StaticTracker::::final_byte_size_of( - size_tracker.num_voters, - size_tracker.size - ), + StaticTracker::::final_byte_size_of(size_tracker.counter, size_tracker.size), voters.encoded_size() ); @@ -180,10 +201,7 @@ mod tests { voters.push(voter); assert_eq!( - StaticTracker::::final_byte_size_of( - size_tracker.num_voters, - size_tracker.size - ), + StaticTracker::::final_byte_size_of(size_tracker.counter, size_tracker.size), voters.encoded_size() ); @@ -193,10 +211,7 @@ mod tests { voters.push(voter); assert_eq!( - StaticTracker::::final_byte_size_of( - size_tracker.num_voters, - size_tracker.size - ), + StaticTracker::::final_byte_size_of(size_tracker.counter, size_tracker.size), voters.encoded_size() ); } @@ -212,10 +227,7 @@ mod tests { voters.push(voter); assert_eq!( - StaticTracker::::final_byte_size_of( - size_tracker.num_voters, - size_tracker.size - ), + StaticTracker::::final_byte_size_of(size_tracker.counter, size_tracker.size), voters.encoded_size() ); diff --git a/frame/staking/src/pallet/impls.rs b/frame/staking/src/pallet/impls.rs index 4a8c25ebe412c..3463b174a94ea 100644 --- a/frame/staking/src/pallet/impls.rs +++ b/frame/staking/src/pallet/impls.rs @@ -841,11 +841,10 @@ impl Pallet { // because the nominators is not decodable since they have more nomination than // `T::NominationsQuota::get_quota`. The latter can rarely happen, and is not // really an emergency or bug if it does. - log!( - warn, - "DEFENSIVE: invalid item in `VoterList`: {:?}, this nominator probably has too many nominations now", - voter - ); + defensive!( + "DEFENSIVE: invalid item in `VoterList`: {:?}, this nominator probably has too many nominations now", + voter, + ); } } @@ -873,14 +872,12 @@ impl Pallet { /// Get the targets for an upcoming npos election. /// /// This function is self-weighing as [`DispatchClass::Mandatory`]. - pub fn get_npos_targets(target_bounds: DataProviderBounds) -> Vec { + pub fn get_npos_targets(bounds: DataProviderBounds) -> Vec { + let mut targets_size_tracker: StaticTracker = StaticTracker::default(); + let final_predicted_len = { let all_target_count = T::TargetList::count(); - target_bounds - .count - .unwrap_or(all_target_count.into()) - .min(all_target_count.into()) - .0 + bounds.count.unwrap_or(all_target_count.into()).min(all_target_count.into()).0 }; let mut all_targets = Vec::::with_capacity(final_predicted_len as usize); @@ -898,6 +895,14 @@ impl Pallet { None => break, }; + if targets_size_tracker.try_register_target(target.clone(), &bounds).is_err() { + // no more space left for the election snapshot, stop iterating. + Self::deposit_event(Event::::SnapshotTargetsSizeExceeded { + size: targets_size_tracker.size as u32, + }); + break + } + if Validators::::contains_key(&target) { all_targets.push(target); } @@ -1044,15 +1049,20 @@ impl ElectionDataProvider for Pallet { } fn electable_targets(bounds: DataProviderBounds) -> data_provider::Result> { - let target_count = T::TargetList::count(); + let targets = Self::get_npos_targets(bounds); // We can't handle this case yet -- return an error. WIP to improve handling this case in // . - if bounds.exhausted(None, CountBound(target_count as u32).into()) { + if bounds.exhausted(None, CountBound(T::TargetList::count() as u32).into()) { return Err("Target snapshot too big") } - Ok(Self::get_npos_targets(bounds)) + debug_assert!(!bounds.exhausted( + SizeBound(targets.encoded_size() as u32).into(), + CountBound(targets.len() as u32).into() + )); + + Ok(targets) } fn next_election_prediction(now: T::BlockNumber) -> T::BlockNumber { diff --git a/frame/staking/src/pallet/mod.rs b/frame/staking/src/pallet/mod.rs index 39aba4550137c..cf8ff61e20cc9 100644 --- a/frame/staking/src/pallet/mod.rs +++ b/frame/staking/src/pallet/mod.rs @@ -694,8 +694,10 @@ pub mod pallet { PayoutStarted { era_index: EraIndex, validator_stash: T::AccountId }, /// A validator has set their preferences. ValidatorPrefsSet { stash: T::AccountId, prefs: ValidatorPrefs }, - /// Voters size limit reached due to too many nominations. + /// Voters size limit reached. SnapshotVotersSizeExceeded { size: u32 }, + /// Targets size limit reached. + SnapshotTargetsSizeExceeded { size: u32 }, /// A new force era mode was set. ForceEra { mode: Forcing }, } diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index f83bb226b2a15..4e2bf3617dc24 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -4553,6 +4553,7 @@ mod election_data_provider { // `maybe_max_len` voters, and if some of them end up being skipped, we iterate at most `2 * // maybe_max_len`. #[test] + #[should_panic] fn only_iterates_max_2_times_max_allowed_len() { ExtBuilder::default() .nominate(false) @@ -4614,7 +4615,7 @@ mod election_data_provider { let bounds_builder = ElectionBoundsBuilder::default(); - // if limits is less.. + // if voter count limit is less.. assert_eq!( Staking::electing_voters(bounds_builder.voters_count(1.into()).build().voters) .unwrap() @@ -4622,7 +4623,7 @@ mod election_data_provider { 1 ); - // if limit is equal.. + // if voter count limit is equal.. assert_eq!( Staking::electing_voters(bounds_builder.voters_count(5.into()).build().voters) .unwrap() @@ -4630,7 +4631,7 @@ mod election_data_provider { 5 ); - // if limit is more. + // if voter count limit is more. assert_eq!( Staking::electing_voters(bounds_builder.voters_count(55.into()).build().voters) .unwrap() @@ -4638,7 +4639,7 @@ mod election_data_provider { 5 ); - // if target limit is more.. + // if target count limit is more.. assert_eq!( Staking::electable_targets( bounds_builder.targets_count(6.into()).build().targets @@ -4647,6 +4648,8 @@ mod election_data_provider { .len(), 4 ); + + // if target count limit is equal.. assert_eq!( Staking::electable_targets( bounds_builder.targets_count(4.into()).build().targets @@ -4656,7 +4659,7 @@ mod election_data_provider { 4 ); - // if target limit is less, then we return an error. + // if target limit count is less, then we return an error. assert_eq!( Staking::electable_targets( bounds_builder.targets_count(1.into()).build().targets @@ -4670,7 +4673,7 @@ mod election_data_provider { #[test] fn respects_snapshot_size_limits() { ExtBuilder::default().build_and_execute(|| { - // set size bounds that allows only for 1 voter. + // voters: set size bounds that allows only for 1 voter. let bounds = ElectionBoundsBuilder::default().voters_size(26.into()).build(); let elected = Staking::electing_voters(bounds.voters).unwrap(); assert!(elected.encoded_size() == 26 as usize); @@ -4681,6 +4684,18 @@ mod election_data_provider { let elected = Staking::electing_voters(bounds.voters).unwrap(); assert!(elected.encoded_size() <= 100 as usize); assert!(elected.len() > 1 && elected.len() > prev_len); + + // targets: set size bounds that allows for only one target to fit in the snapshot. + let bounds = ElectionBoundsBuilder::default().targets_size(10.into()).build(); + let elected = Staking::electable_targets(bounds.targets).unwrap(); + assert!(elected.encoded_size() == 9 as usize); + let prev_len = elected.len(); + + // larger size bounds means more space for targets. + let bounds = ElectionBoundsBuilder::default().targets_size(100.into()).build(); + let elected = Staking::electable_targets(bounds.targets).unwrap(); + assert!(elected.encoded_size() <= 100 as usize); + assert!(elected.len() > 1 && elected.len() > prev_len); }); } @@ -5208,6 +5223,7 @@ fn min_commission_works() { } #[test] +#[should_panic] fn change_of_absolute_max_nominations() { use frame_election_provider_support::ElectionDataProvider; ExtBuilder::default() From 8bfd7317250914166d63d234bf33a3e4c81d67f8 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Sat, 5 Aug 2023 17:31:13 +0000 Subject: [PATCH 76/80] ".git/.scripts/commands/fmt/fmt.sh" --- .../election-provider-multi-phase/test-staking-e2e/src/mock.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs b/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs index 2ed6ef075acf2..9c3511ae35751 100644 --- a/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs +++ b/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs @@ -40,11 +40,11 @@ use sp_staking::{ use sp_std::prelude::*; use std::collections::BTreeMap; +use codec::Decode; use frame_election_provider_support::{ bounds::ElectionBoundsBuilder, onchain, ElectionDataProvider, ExtendedBalance, SequentialPhragmen, Weight, }; -use codec::Decode; use pallet_election_provider_multi_phase::{ unsigned::MinerConfig, Call, ElectionCompute, QueuedSolution, SolutionAccuracyOf, }; From 747aa526240bf02f92f391d52dab79e261ad2986 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Sat, 5 Aug 2023 19:41:39 +0200 Subject: [PATCH 77/80] restart ci From 0bda7a487d5eafbcba82ad69ee5f5307e50561fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Sun, 6 Aug 2023 09:00:15 +0200 Subject: [PATCH 78/80] rust doc fixes and cosmetic nits --- .../election-provider-multi-phase/src/lib.rs | 21 +++++++++---------- .../election-provider-multi-phase/src/mock.rs | 2 +- .../src/signed.rs | 10 +++++---- frame/election-provider-support/src/bounds.rs | 4 ++-- .../election-provider-support/src/onchain.rs | 4 ++-- frame/staking/src/election_size_tracker.rs | 3 ++- 6 files changed, 23 insertions(+), 21 deletions(-) diff --git a/frame/election-provider-multi-phase/src/lib.rs b/frame/election-provider-multi-phase/src/lib.rs index c9f6cd8981574..f26a6f40d4267 100644 --- a/frame/election-provider-multi-phase/src/lib.rs +++ b/frame/election-provider-multi-phase/src/lib.rs @@ -668,9 +668,8 @@ pub mod pallet { type MaxWinners: Get; /// The maximum number of electing voters and electable targets to put in the snapshot. - /// At the moment, snapshots - /// are only over a single block, but once multi-block elections are introduced they will - /// take place over multiple blocks. + /// At the moment, snapshots are only over a single block, but once multi-block elections + /// are introduced they will take place over multiple blocks. type ElectionBounds: Get; /// Handler for the slashed deposits. @@ -1944,8 +1943,8 @@ mod tests { use crate::{ mock::{ multi_phase_events, raw_solution, roll_to, roll_to_signed, roll_to_unsigned, AccountId, - ExtBuilder, MockWeightInfo, MockedWeightInfo, MultiPhase, Runtime, RuntimeOrigin, - SignedMaxSubmissions, System, + ElectionsBounds, ExtBuilder, MockWeightInfo, MockedWeightInfo, MultiPhase, Runtime, + RuntimeOrigin, SignedMaxSubmissions, System, TargetIndex, Targets, Voters, }, Phase, }; @@ -2550,9 +2549,9 @@ mod tests { ExtBuilder::default().build_and_execute(|| { // sets bounds on number of targets. let new_bounds = ElectionBoundsBuilder::default().targets_count(1_000.into()).build(); - crate::mock::ElectionsBounds::set(new_bounds); + ElectionsBounds::set(new_bounds); - crate::mock::Targets::set((0..(1_000 as AccountId) + 1).collect::>()); + Targets::set((0..(1_000 as AccountId) + 1).collect::>()); // Signed phase failed to open. roll_to(15); @@ -2589,9 +2588,9 @@ mod tests { ExtBuilder::default().onchain_fallback(false).build_and_execute(|| { // sets bounds on number of targets. let new_bounds = ElectionBoundsBuilder::default().targets_count(1_000.into()).build(); - crate::mock::ElectionsBounds::set(new_bounds); + ElectionsBounds::set(new_bounds); - crate::mock::Targets::set((0..(1_000 as AccountId) + 1).collect::>()); + Targets::set((0..(TargetIndex::max_value() as AccountId) + 1).collect::>()); // Signed phase failed to open. roll_to(15); @@ -2621,10 +2620,10 @@ mod tests { // but if there are too many voters, we simply truncate them. ExtBuilder::default().build_and_execute(|| { // we have 8 voters in total. - assert_eq!(crate::mock::Voters::get().len(), 8); + assert_eq!(Voters::get().len(), 8); // but we want to take 2. let new_bounds = ElectionBoundsBuilder::default().voters_count(2.into()).build(); - crate::mock::ElectionsBounds::set(new_bounds); + ElectionsBounds::set(new_bounds); // Signed phase opens just fine. roll_to_signed(); diff --git a/frame/election-provider-multi-phase/src/mock.rs b/frame/election-provider-multi-phase/src/mock.rs index 7b9f0e9a4c537..82c7279879feb 100644 --- a/frame/election-provider-multi-phase/src/mock.rs +++ b/frame/election-provider-multi-phase/src/mock.rs @@ -299,7 +299,7 @@ parameter_types! { #[derive(Debug)] pub static MaxWinners: u32 = 200; - // `ElectionBounds` and `OnChainElectionsBounds` are defined separately to set them independenyly in the tests. + // `ElectionBounds` and `OnChainElectionsBounds` are defined separately to set them independently in the tests. pub static ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::default().build(); pub static OnChainElectionsBounds: ElectionBounds = ElectionBoundsBuilder::default().build(); pub static EpochLength: u64 = 30; diff --git a/frame/election-provider-multi-phase/src/signed.rs b/frame/election-provider-multi-phase/src/signed.rs index 83a9084d1388a..76068ba99d36c 100644 --- a/frame/election-provider-multi-phase/src/signed.rs +++ b/frame/election-provider-multi-phase/src/signed.rs @@ -536,7 +536,10 @@ impl Pallet { #[cfg(test)] mod tests { use super::*; - use crate::{mock::*, ElectionCompute, ElectionError, Error, Event, Perbill, Phase}; + use crate::{ + mock::*, ElectionBoundsBuilder, ElectionCompute, ElectionError, Error, Event, Perbill, + Phase, + }; use frame_support::{assert_noop, assert_ok, assert_storage_noop}; #[test] @@ -565,8 +568,7 @@ mod tests { fn data_provider_should_respect_target_limits() { ExtBuilder::default().build_and_execute(|| { // given a reduced expectation of maximum electable targets - let new_bounds = - crate::ElectionBoundsBuilder::default().targets_count(2.into()).build(); + let new_bounds = ElectionBoundsBuilder::default().targets_count(2.into()).build(); ElectionsBounds::set(new_bounds); // and a data provider that does not respect limits DataProviderAllowBadData::set(true); @@ -582,7 +584,7 @@ mod tests { fn data_provider_should_respect_voter_limits() { ExtBuilder::default().build_and_execute(|| { // given a reduced expectation of maximum electing voters - let new_bounds = crate::ElectionBoundsBuilder::default().voters_count(2.into()).build(); + let new_bounds = ElectionBoundsBuilder::default().voters_count(2.into()).build(); ElectionsBounds::set(new_bounds); // and a data provider that does not respect limits DataProviderAllowBadData::set(true); diff --git a/frame/election-provider-support/src/bounds.rs b/frame/election-provider-support/src/bounds.rs index 761f5220eed4d..b9ae21e49ca70 100644 --- a/frame/election-provider-support/src/bounds.rs +++ b/frame/election-provider-support/src/bounds.rs @@ -22,7 +22,7 @@ //! This module defines and implements types that help creating and handling election bounds. //! [`DataProviderBounds`] encapsulates the upper limits for the results provided by `DataProvider` //! implementors. Those limits can be defined over two axis: number of elements returned (`count`) -//! and/or the size of the returned SCALE encoded structure (`size`). +//! and/or the size of the returned SCALE encoded structure (`size`). //! //! [`ElectionBoundsBuilder`] is a helper to construct data election bounds and it aims at //! preventing the caller from mistake the order of size and count limits. @@ -51,7 +51,7 @@ //! //! ### Implementation details //! -//! A default or `None` bound means that no bounds are enfirced (i.e. unlimited result size). In +//! A default or `None` bound means that no bounds are enforced (i.e. unlimited result size). In //! general, be careful when using unbounded election bounds in production. use core::ops::Add; diff --git a/frame/election-provider-support/src/onchain.rs b/frame/election-provider-support/src/onchain.rs index 11a84c3fdf6f8..21ee710ea304d 100644 --- a/frame/election-provider-support/src/onchain.rs +++ b/frame/election-provider-support/src/onchain.rs @@ -85,8 +85,8 @@ pub trait Config { /// always be more than `DataProvider::desired_target`. type MaxWinners: Get; - /// Elections bounds, to use when calling into - /// [`Config::DataProvider`]. It might be overwritten in the `InstantElectionProvider` impl. + /// Elections bounds, to use when calling into [`Config::DataProvider`]. It might be overwritten + /// in the `InstantElectionProvider` impl. type Bounds: Get; } diff --git a/frame/staking/src/election_size_tracker.rs b/frame/staking/src/election_size_tracker.rs index 61400aa1d63d2..283ae0140ee68 100644 --- a/frame/staking/src/election_size_tracker.rs +++ b/frame/staking/src/election_size_tracker.rs @@ -24,6 +24,7 @@ //! [`ElectionDataProvider::electing_voters`]. The [`StaticTracker`] implementation uses //! [`codec::Encode::size_hint`] to estimate the SCALE encoded size of the snapshot voters struct //! as it is being constructed without requiring extra stack allocations. +//! //! The [`StaticTracker::try_register_voter`] is called to update the static tracker internal //! state, if It will return an error if the resulting SCALE encoded size (in bytes) is larger than //! the provided `DataProviderBounds`. @@ -75,7 +76,7 @@ use frame_election_provider_support::{ ElectionDataProvider, VoterOf, }; -/// Keeps track of the SCALE encoded byte length of the snapshot's voters struct. +/// Keeps track of the SCALE encoded byte length of the snapshot's voters or targets. /// /// The tracker calculates the bytes used based on static rules, without requiring any actual /// encoding or extra allocations. From 86ab41cbb2d8c9dff34315b283debfc0d5fc5e72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Wed, 9 Aug 2023 15:40:42 +0200 Subject: [PATCH 79/80] rollback upgrade on parity-scale-codec version (unecessary) --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 27d8d29a73d11..49b404bd4d2c4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7353,9 +7353,9 @@ dependencies = [ [[package]] name = "parity-scale-codec" -version = "3.6.4" +version = "3.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8e946cc0cc711189c0b0249fb8b599cbeeab9784d83c415719368bb8d4ac64" +checksum = "2287753623c76f953acd29d15d8100bcab84d29db78fb6f352adb3c53e83b967" dependencies = [ "arrayvec 0.7.4", "bitvec", From e4f7f9fe968eb57ac131021e32174e7b33f26520 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Pestana?= Date: Wed, 9 Aug 2023 23:04:27 +0200 Subject: [PATCH 80/80] reset cargo lock, no need to update it --- Cargo.lock | 1211 +++++++++++++++++++++++++++------------------------- 1 file changed, 637 insertions(+), 574 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 49b404bd4d2c4..0289ea601eab0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -21,15 +21,6 @@ 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" @@ -112,7 +103,7 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" dependencies = [ - "getrandom 0.2.10", + "getrandom 0.2.9", "once_cell", "version_check", ] @@ -124,11 +115,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" dependencies = [ "cfg-if", - "getrandom 0.2.10", + "getrandom 0.2.9", "once_cell", "version_check", ] +[[package]] +name = "aho-corasick" +version = "0.7.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" +dependencies = [ + "memchr", +] + [[package]] name = "aho-corasick" version = "1.0.2" @@ -185,15 +185,15 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.1" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a30da5c5f2d5e72842e00bcb57657162cdabef0931f40e2deb9b4140440cecd" +checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d" [[package]] name = "anstyle-parse" -version = "0.2.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333" +checksum = "e765fd216e48e067936442276d1d57399e37bce53c264d6fefbe298080cb57ee" dependencies = [ "utf8parse", ] @@ -219,9 +219,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.72" +version = "1.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b13c32d80ecc7ab747b80c3784bce54ee8a7a0cc4fbda9bf4cda2cf6fe90854" +checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" [[package]] name = "approx" @@ -445,6 +445,21 @@ dependencies = [ "parity-scale-codec", ] +[[package]] +name = "ark-secret-scalar" +version = "0.0.2" +source = "git+https://github.com/w3f/ring-vrf?rev=c86ebd4#c86ebd4114d3165d05f9ce28c1d9e8d7a9a4e801" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-serialize", + "ark-std", + "ark-transcript", + "digest 0.10.7", + "rand_core 0.6.4", + "zeroize", +] + [[package]] name = "ark-serialize" version = "0.4.2" @@ -478,6 +493,19 @@ dependencies = [ "rand 0.8.5", ] +[[package]] +name = "ark-transcript" +version = "0.0.2" +source = "git+https://github.com/w3f/ring-vrf?rev=c86ebd4#c86ebd4114d3165d05f9ce28c1d9e8d7a9a4e801" +dependencies = [ + "ark-ff", + "ark-serialize", + "ark-std", + "digest 0.10.7", + "rand_core 0.6.4", + "sha3", +] + [[package]] name = "array-bytes" version = "6.1.0" @@ -504,9 +532,9 @@ checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" [[package]] name = "assert_cmd" -version = "2.0.12" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88903cb14723e4d4003335bb7f8a14f27691649105346a0f0957466c096adfe6" +checksum = "86d6b683edf8d1119fe420a94f8a7e389239666aa72e65495d91c00462510151" dependencies = [ "anstyle", "bstr", @@ -525,9 +553,9 @@ checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" [[package]] name = "async-channel" -version = "1.9.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" +checksum = "cf46fee83e5ccffc220104713af3292ff9bc7c64c7de289f66dae8e38d826833" dependencies = [ "concurrent-queue", "event-listener", @@ -548,7 +576,7 @@ dependencies = [ "log", "parking", "polling", - "rustix 0.37.23", + "rustix 0.37.19", "slab", "socket2 0.4.9", "waker-fn", @@ -571,7 +599,7 @@ checksum = "0e97ce7de6cf12de5d7226c73f5ba9811622f4db3a5b91b55c53e987e5f91cba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -582,7 +610,7 @@ checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51" dependencies = [ "async-stream-impl", "futures-core", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.9", ] [[package]] @@ -593,31 +621,31 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] name = "async-trait" -version = "0.1.72" +version = "0.1.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc6dde6e4ed435a4c1ee4e73592f5ba9da2151af10076cc04858746af9352d09" +checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] name = "asynchronous-codec" -version = "0.6.2" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4057f2c32adbb2fc158e22fb38433c8e9bbf76b75a4732c7c0cbaf695fb65568" +checksum = "06a0daa378f5fd10634e44b0a29b2a87b890657658e072a30d6f26e57ddee182" dependencies = [ "bytes", "futures-sink", "futures-util", "memchr", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.9", ] [[package]] @@ -639,19 +667,40 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "backtrace" -version = "0.3.68" +version = "0.3.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4319208da049c43661739c5fade2ba182f09d1dc2299b32298d3a31692b17e12" +checksum = "233d376d6d185f2a3093e58f283f60f880315b6c60075b01f36b3b85154564ca" dependencies = [ - "addr2line 0.20.0", + "addr2line", "cc", "cfg-if", "libc", - "miniz_oxide", - "object 0.31.1", + "miniz_oxide 0.6.2", + "object", "rustc-demangle", ] +[[package]] +name = "bandersnatch_vrfs" +version = "0.0.1" +source = "git+https://github.com/w3f/ring-vrf?rev=c86ebd4#c86ebd4114d3165d05f9ce28c1d9e8d7a9a4e801" +dependencies = [ + "ark-bls12-381", + "ark-ec", + "ark-ed-on-bls12-381-bandersnatch", + "ark-ff", + "ark-serialize", + "ark-std", + "dleq_vrf", + "fflonk", + "merlin 3.0.0", + "rand_chacha 0.3.1", + "rand_core 0.6.4", + "ring 0.1.0", + "sha2 0.10.7", + "zeroize", +] + [[package]] name = "base-x" version = "0.2.11" @@ -684,9 +733,9 @@ checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "basic-toml" -version = "0.1.4" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bfc506e7a2370ec239e1d072507b2a80c833083699d3c6fa176fbb4de8448c6" +checksum = "5c0de75129aa8d0cceaf750b89013f0e08804d6ec61416da787b35ad0d7cddf1" dependencies = [ "serde", ] @@ -727,19 +776,19 @@ version = "0.65.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cfdf7b466f9a4903edc73f95d6d2bcd5baf8ae620638762244d3f60143643cc5" dependencies = [ - "bitflags 1.3.2", + "bitflags", "cexpr", "clang-sys", "lazy_static", "lazycell", "peeking_take_while", - "prettyplease 0.2.12", + "prettyplease 0.2.6", "proc-macro2", "quote", "regex", "rustc-hash", "shlex", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -748,12 +797,6 @@ 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" @@ -783,7 +826,7 @@ checksum = "3c2f0dc9a68c6317d884f97cc36cf5a3d20ba14ce404227df55e1af708ab04bc" dependencies = [ "arrayref", "arrayvec 0.7.4", - "constant_time_eq 0.2.6", + "constant_time_eq", ] [[package]] @@ -794,20 +837,20 @@ checksum = "6637f448b9e61dfadbdcbae9a885fadee1f3eaffb1f8d3c1965d3ade8bdfd44f" dependencies = [ "arrayref", "arrayvec 0.7.4", - "constant_time_eq 0.2.6", + "constant_time_eq", ] [[package]] name = "blake3" -version = "1.4.1" +version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "199c42ab6972d92c9f8995f086273d25c42fc0f7b2a1fcefba465c1352d25ba5" +checksum = "42ae2468a89544a466886840aa467a25b766499f4f04bf7d9fcd10ecee9fccef" dependencies = [ "arrayref", "arrayvec 0.7.4", "cc", "cfg-if", - "constant_time_eq 0.3.0", + "constant_time_eq", "digest 0.10.7", ] @@ -879,12 +922,13 @@ dependencies = [ [[package]] name = "bstr" -version = "1.6.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6798148dccfbff0fae41c7574d2fa8f1ef3492fba0face179de5d8d447d67b05" +checksum = "a246e68bb43f6cd9db24bea052a53e40405417c5fb372e3d1a8a7f770a564ef5" dependencies = [ "memchr", - "regex-automata 0.3.4", + "once_cell", + "regex-automata", "serde", ] @@ -946,18 +990,18 @@ dependencies = [ [[package]] name = "camino" -version = "1.1.6" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c59e92b5a388f549b863a7bea62612c09f24c8393560709a54558a9abdfb3b9c" +checksum = "c530edf18f37068ac2d977409ed5cd50d53d73bc653c7647b48eb78976ac9ae2" dependencies = [ "serde", ] [[package]] name = "cargo-platform" -version = "0.1.3" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cfa25e60aea747ec7e1124f238816749faa93759c6ff5b31f1ccdda137f4479" +checksum = "cbdb825da8a5df079a43676dbe042702f1707b1109f713a01420fbb4cc71fa27" dependencies = [ "serde", ] @@ -970,7 +1014,7 @@ checksum = "eee4243f1f26fc7a42710e7439c149e2b10b05472f88090acce52632f231a73a" dependencies = [ "camino", "cargo-platform", - "semver 1.0.18", + "semver 1.0.17", "serde", "serde_json", "thiserror", @@ -984,12 +1028,11 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.0.81" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c6b2562119bf28c3439f7f02db99faf0aa1a8cdfe5772a2ee155d32227239f0" +checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" dependencies = [ "jobserver", - "libc", ] [[package]] @@ -1003,9 +1046,9 @@ dependencies = [ [[package]] name = "cfg-expr" -version = "0.15.4" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b40ccee03b5175c18cde8f37e7d2a33bcef6f8ec8f7cc0d81090d1bb380949c9" +checksum = "e70d3ad08698a0568b0562f22710fe6bfc1f4a61a367c77d0398c562eadd453a" dependencies = [ "smallvec", ] @@ -1052,7 +1095,7 @@ name = "chain-spec-builder" version = "2.0.0" dependencies = [ "ansi_term", - "clap 4.3.19", + "clap 4.3.2", "node-cli", "rand 0.8.5", "sc-chain-spec", @@ -1161,17 +1204,17 @@ version = "3.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" dependencies = [ - "bitflags 1.3.2", + "bitflags", "clap_lex 0.2.4", - "indexmap 1.9.3", + "indexmap", "textwrap", ] [[package]] name = "clap" -version = "4.3.19" +version = "4.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fd304a20bff958a57f04c4e96a2e7594cc4490a0e809cbd48bb6437edaa452d" +checksum = "401a4694d2bf92537b6867d94de48c4842089645fdcdf6c71865b175d836e9c2" dependencies = [ "clap_builder", "clap_derive", @@ -1180,35 +1223,36 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.3.19" +version = "4.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01c6a3f08f1fe5662a35cfe393aec09c4df95f60ee93b7556505260f75eee9e1" +checksum = "72394f3339a76daf211e57d4bcb374410f3965dcc606dd0e03738c7888766980" dependencies = [ "anstream", "anstyle", + "bitflags", "clap_lex 0.5.0", "strsim", ] [[package]] name = "clap_complete" -version = "4.3.2" +version = "4.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fc443334c81a804575546c5a8a79b4913b50e28d69232903604cada1de817ce" +checksum = "7f6b5c519bab3ea61843a7923d074b04245624bb84a64a8c150f5deb014e388b" dependencies = [ - "clap 4.3.19", + "clap 4.3.2", ] [[package]] name = "clap_derive" -version = "4.3.12" +version = "4.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54a9bb5758fc5dfe728d1019941681eccaf0cf8a4189b692a0ee2f2ecf90a050" +checksum = "b8cd2b2a819ad6eec39e8f1d6b53001af1e5469f8c177579cdaeb313115b825f" dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -1244,15 +1288,29 @@ checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" [[package]] name = "comfy-table" -version = "7.0.1" +version = "7.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ab77dbd8adecaf3f0db40581631b995f312a8a5ae3aa9993188bb8f23d83a5b" +checksum = "f9e1f7e5d046697d34b593bdba8ee31f4649366e452a2ccabb3baf3511e503d1" dependencies = [ "strum", "strum_macros", "unicode-width", ] +[[package]] +name = "common" +version = "0.1.0" +source = "git+https://github.com/w3f/ring-proof#0e948f3c28cbacecdd3020403c4841c0eb339213" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-poly", + "ark-serialize", + "ark-std", + "fflonk", + "merlin 3.0.0", +] + [[package]] name = "common-path" version = "1.0.0" @@ -1283,9 +1341,9 @@ dependencies = [ [[package]] name = "const-oid" -version = "0.9.4" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "795bc6e66a8e340f075fcf6227e417a2dc976b92b91f3cdc778bb858778b6747" +checksum = "520fbf3c07483f94e3e3ca9d0cfd913d7718ef2483d2cfd91c0d9e91474ab913" [[package]] name = "const-random" @@ -1303,7 +1361,7 @@ version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d7d6ab3c3a2282db210df5f02c4dab6e0a7057af0fb7ebd4070f30fe05c0ddb" dependencies = [ - "getrandom 0.2.10", + "getrandom 0.2.9", "once_cell", "proc-macro-hack", "tiny-keccak", @@ -1311,15 +1369,9 @@ dependencies = [ [[package]] name = "constant_time_eq" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21a53c0a4d288377e7415b53dcfc3c04da5cdc2cc95c8d5ac178b58f0b861ad6" - -[[package]] -name = "constant_time_eq" -version = "0.3.0" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" +checksum = "13418e745008f7349ec7e449155f419a61b92b58a99cc3616942b926825ec76b" [[package]] name = "constcat" @@ -1363,9 +1415,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.9" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" +checksum = "3e4c1eaa2012c47becbbad2ab175484c2a84d1185b566fb2cc5b8707343dfe58" dependencies = [ "libc", ] @@ -1538,22 +1590,22 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.15" +version = "0.9.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" +checksum = "46bd5f3f85273295a9d14aedfb86f6aadbff6d8f5295c4a9edb08e819dcf5695" dependencies = [ "autocfg", "cfg-if", "crossbeam-utils", - "memoffset 0.9.0", + "memoffset 0.8.0", "scopeguard", ] [[package]] name = "crossbeam-utils" -version = "0.8.16" +version = "0.8.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" +checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b" dependencies = [ "cfg-if", ] @@ -1607,6 +1659,16 @@ 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" @@ -1667,9 +1729,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.102" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f68e12e817cb19eaab81aaec582b4052d07debd3c3c6b083b9d361db47c7dc9d" +checksum = "109308c20e8445959c2792e81871054c6a17e6976489a93d2769641a2ba5839c" dependencies = [ "cc", "cxxbridge-flags", @@ -1679,9 +1741,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.102" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e789217e4ab7cf8cc9ce82253180a9fe331f35f5d339f0ccfe0270b39433f397" +checksum = "daf4c6755cdf10798b97510e0e2b3edb9573032bd9379de8fffa59d68165494f" dependencies = [ "cc", "codespan-reporting", @@ -1689,24 +1751,24 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] name = "cxxbridge-flags" -version = "1.0.102" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78a19f4c80fd9ab6c882286fa865e92e07688f4387370a209508014ead8751d0" +checksum = "882074421238e84fe3b4c65d0081de34e5b323bf64555d3e61991f76eb64a7bb" [[package]] name = "cxxbridge-macro" -version = "1.0.102" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8fcfa71f66c8563c4fa9dd2bb68368d50267856f831ac5d85367e0805f9606c" +checksum = "4a076022ece33e7686fb76513518e219cca4fce5750a8ae6d1ce6c0f48fd1af9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -1737,9 +1799,9 @@ dependencies = [ [[package]] name = "der" -version = "0.7.7" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c7ed52955ce76b1554f509074bb357d3fb8ac9b51288a65a3fd480d1dfba946" +checksum = "56acb310e15652100da43d130af8d97b509e95af61aab1c5a7939ef24337ee17" dependencies = [ "const-oid", "zeroize", @@ -1863,9 +1925,25 @@ dependencies = [ [[package]] name = "dissimilar" -version = "1.0.7" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86e3bdc80eee6e16b2b6b0f87fbc98c04bee3455e35174c0de1a125d0688c632" +checksum = "210ec60ae7d710bed8683e333e9d2855a8a56a3e9892b38bad3bb0d4d29b0d5e" + +[[package]] +name = "dleq_vrf" +version = "0.0.2" +source = "git+https://github.com/w3f/ring-vrf?rev=c86ebd4#c86ebd4114d3165d05f9ce28c1d9e8d7a9a4e801" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-secret-scalar", + "ark-serialize", + "ark-std", + "ark-transcript", + "arrayvec 0.7.4", + "rand_core 0.6.4", + "zeroize", +] [[package]] name = "doc-comment" @@ -1894,9 +1972,9 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn 2.0.28", + "syn 2.0.18", "termcolor", - "toml 0.7.6", + "toml 0.7.4", "walkdir", ] @@ -1914,9 +1992,9 @@ checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" [[package]] name = "dtoa" -version = "1.0.9" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcbb2bf8e87535c23f7a8a321e364ce21462d0ff10cb6407820e8e96dfff6653" +checksum = "65d09067bfacaa79114679b279d7f5885b53295b1e2cfb4e79c8e4bd3d633169" [[package]] name = "dyn-clonable" @@ -1941,15 +2019,15 @@ dependencies = [ [[package]] name = "dyn-clone" -version = "1.0.12" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "304e6508efa593091e97a9abbc10f90aa7ca635b6d2784feff3c89d41dd12272" +checksum = "68b0cf012f1230e43cd00ebb729c6bb58707ecfa8ad08b52ef3a4ccd2697fc30" [[package]] name = "ecdsa" -version = "0.16.8" +version = "0.16.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4b1e0c257a9e9f25f90ff76d7a68360ed497ee519c8e428d1825ef0000799d4" +checksum = "0997c976637b606099b9985693efa3581e84e41f5c11ba5255f88711058ad428" dependencies = [ "der", "digest 0.10.7", @@ -1998,9 +2076,9 @@ dependencies = [ [[package]] name = "either" -version = "1.9.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" [[package]] name = "elliptic-curve" @@ -2056,7 +2134,7 @@ checksum = "5e9a1f9f7d83e59740248a6e14ecf93929ade55027844dfcea78beafccc15745" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -2091,17 +2169,11 @@ version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e48c92028aaa870e83d51c64e5d4e0b6981b360c522198c23959f219a4e1b15b" -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - [[package]] name = "errno" -version = "0.3.2" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b30f669a7961ef1631673d2766cc92f52d64f7ef354d4fe0ddfd30ed52f0f4f" +checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" dependencies = [ "errno-dragonfly", "libc", @@ -2143,7 +2215,7 @@ dependencies = [ "fs-err", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -2167,12 +2239,6 @@ dependencies = [ "instant", ] -[[package]] -name = "fastrand" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764" - [[package]] name = "fdlimit" version = "0.2.1" @@ -2192,6 +2258,19 @@ dependencies = [ "subtle", ] +[[package]] +name = "fflonk" +version = "0.1.0" +source = "git+https://github.com/w3f/fflonk#26a5045b24e169cffc1f9328ca83d71061145c40" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-poly", + "ark-serialize", + "ark-std", + "merlin 3.0.0", +] + [[package]] name = "fiat-crypto" version = "0.1.20" @@ -2210,13 +2289,13 @@ dependencies = [ [[package]] name = "filetime" -version = "0.2.22" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4029edd3e734da6fe05b6cd7bd2960760a616bd2ddd0d59a0124746d6272af0" +checksum = "5cbc844cecaee9d4443931972e1289c8ff485cb4cc2767cb03ca139ed6885153" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.3.5", + "redox_syscall 0.2.16", "windows-sys 0.48.0", ] @@ -2262,7 +2341,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743" dependencies = [ "crc32fast", - "miniz_oxide", + "miniz_oxide 0.7.1", ] [[package]] @@ -2346,7 +2425,7 @@ dependencies = [ "Inflector", "array-bytes", "chrono", - "clap 4.3.19", + "clap 4.3.2", "comfy-table", "frame-benchmarking", "frame-support", @@ -2412,7 +2491,7 @@ dependencies = [ "quote", "scale-info", "sp-arithmetic", - "syn 2.0.28", + "syn 2.0.18", "trybuild", ] @@ -2438,7 +2517,7 @@ dependencies = [ name = "frame-election-solution-type-fuzzer" version = "2.0.0-alpha.5" dependencies = [ - "clap 4.3.19", + "clap 4.3.2", "frame-election-provider-solution-type", "frame-election-provider-support", "frame-support", @@ -2514,7 +2593,7 @@ dependencies = [ "aquamarine", "array-bytes", "assert_matches", - "bitflags 1.3.2", + "bitflags", "environmental", "frame-metadata", "frame-support-procedural", @@ -2561,7 +2640,7 @@ dependencies = [ "proc-macro-warning", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -2572,7 +2651,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -2581,7 +2660,7 @@ version = "3.0.0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -2710,11 +2789,11 @@ dependencies = [ [[package]] name = "fs4" -version = "0.6.6" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2eeb4ed9e12f43b7fa0baae3f9cdda28352770132ef2e09a23760c29cae8bd47" +checksum = "7672706608ecb74ab2e055c68327ffc25ae4cac1e12349204fd5fb0f3487cce2" dependencies = [ - "rustix 0.38.6", + "rustix 0.37.19", "windows-sys 0.48.0", ] @@ -2785,12 +2864,12 @@ version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce" dependencies = [ - "fastrand 1.9.0", + "fastrand", "futures-core", "futures-io", "memchr", "parking", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.9", "waker-fn", ] @@ -2802,7 +2881,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -2847,7 +2926,7 @@ dependencies = [ "futures-sink", "futures-task", "memchr", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.9", "pin-utils", "slab", ] @@ -2917,9 +2996,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.10" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" dependencies = [ "cfg-if", "js-sys", @@ -2950,12 +3029,12 @@ dependencies = [ [[package]] name = "gimli" -version = "0.27.3" +version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" +checksum = "ad0a93d233ebf96623465aad4046a8d3aa4da22d4f4beba5388838c8a434bbb4" dependencies = [ "fallible-iterator", - "indexmap 1.9.3", + "indexmap", "stable_deref_trait", ] @@ -2967,11 +3046,11 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "globset" -version = "0.4.13" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "759c97c1e17c55525b57192c06a267cda0ac5210b222d6b82189a2338fa1c13d" +checksum = "029d74589adefde59de1a0c4f4732695c32805624aec7b68d91503d4dba79afc" dependencies = [ - "aho-corasick", + "aho-corasick 0.7.20", "bstr", "fnv", "log", @@ -2991,9 +3070,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.20" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97ec8491ebaf99c8eaa73058b045fe58073cd6be7f596ac993ced0b0a0c01049" +checksum = "d357c7ae988e7d2182f7d7871d0b963962420b0678b0997ce7de72001aeab782" dependencies = [ "bytes", "fnv", @@ -3001,7 +3080,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap 1.9.3", + "indexmap", "slab", "tokio", "tokio-util", @@ -3061,12 +3140,6 @@ 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" @@ -3084,9 +3157,18 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.3.2" +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" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" +checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" [[package]] name = "hex" @@ -3185,14 +3267,14 @@ checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" dependencies = [ "bytes", "http", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.9", ] [[package]] name = "http-range-header" -version = "0.3.1" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "add0ab9360ddbd88cfeb3bd9574a1d85cfdfa14db10b3e21d3700dbc4328758f" +checksum = "0bfe8eed0a9285ef776bb792479ea3834e8b94e13d615c2f66d03dd50a435a29" [[package]] name = "httparse" @@ -3214,9 +3296,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.14.27" +version = "0.14.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" +checksum = "ab302d72a6f11a3b910431ff93aae7e773078c769f0a3ef15fb9ec692ed147d4" dependencies = [ "bytes", "futures-channel", @@ -3228,7 +3310,7 @@ dependencies = [ "httparse", "httpdate", "itoa", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.9", "socket2 0.4.9", "tokio", "tower-service", @@ -3254,25 +3336,24 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.24.1" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d78e1e73ec14cf7375674f74d7dde185c8206fd9dea6fb6295e8a98098aaa97" +checksum = "0646026eb1b3eea4cd9ba47912ea5ce9cc07713d105b1a14698f4e6433d348b7" dependencies = [ - "futures-util", "http", "hyper", "log", - "rustls 0.21.6", + "rustls 0.21.1", "rustls-native-certs", "tokio", - "tokio-rustls 0.24.1", + "tokio-rustls 0.24.0", ] [[package]] name = "iana-time-zone" -version = "0.1.57" +version = "0.1.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fad5b825842d2b38bd206f3e81d6957625fd7f0a361e345c30e01a0ae2dd613" +checksum = "0722cd7114b7de04316e7ea5456a0bbb20e4adb46fd27a3697adb812cff0f37c" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -3411,16 +3492,6 @@ 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" @@ -3429,9 +3500,9 @@ checksum = "8e04e2fd2b8188ea827b32ef11de88377086d690286ab35747ef7f9bf3ccb590" [[package]] name = "indicatif" -version = "0.17.6" +version = "0.17.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b297dc40733f23a0e52728a58fa9489a5b7638a324932de16b41adc3ef80730" +checksum = "8ff8cc23a7393a397ed1d7f56e6365cba772aba9f9912ab968b03043c395d057" dependencies = [ "console", "instant", @@ -3479,7 +3550,7 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ - "hermit-abi 0.3.2", + "hermit-abi 0.3.1", "libc", "windows-sys 0.48.0", ] @@ -3492,30 +3563,31 @@ checksum = "aa2f047c0a98b2f299aa5d6d7088443570faae494e9ae1305e48be000c9e0eb1" [[package]] name = "ipconfig" -version = "0.3.2" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b58db92f96b720de98181bbbe63c831e87005ab460c1bf306eb2622b4707997f" +checksum = "bd302af1b90f2463a98fa5ad469fc212c8e3175a41c3068601bfa2727591c5be" dependencies = [ - "socket2 0.5.3", + "socket2 0.4.9", "widestring", - "windows-sys 0.48.0", + "winapi", "winreg", ] [[package]] name = "ipnet" -version = "2.8.0" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6" +checksum = "12b6ee2129af8d4fb011108c73d99a1b83a85977f23b82460c0ae2e25bb4b57f" [[package]] name = "is-terminal" -version = "0.4.9" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" +checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" dependencies = [ - "hermit-abi 0.3.2", - "rustix 0.38.6", + "hermit-abi 0.3.1", + "io-lifetimes", + "rustix 0.37.19", "windows-sys 0.48.0", ] @@ -3530,9 +3602,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.9" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" +checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" [[package]] name = "jobserver" @@ -3545,9 +3617,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.64" +version = "0.3.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" +checksum = "2f37a4a5928311ac501dee68b3c7613a1037d0edb30c8e5427bd832d55d1b790" dependencies = [ "wasm-bindgen", ] @@ -3902,9 +3974,9 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.147" +version = "0.2.145" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +checksum = "fc86cde3ff845662b8f4ef6cb50ea0e20c524eb3d29ae048287e06a1b3fa6a81" [[package]] name = "libloading" @@ -3937,7 +4009,7 @@ dependencies = [ "bytes", "futures", "futures-timer", - "getrandom 0.2.10", + "getrandom 0.2.9", "instant", "libp2p-allow-block-list", "libp2p-connection-limits", @@ -3974,9 +4046,9 @@ dependencies = [ [[package]] name = "libp2p-connection-limits" -version = "0.2.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f5107ad45cb20b2f6c3628c7b6014b996fcb13a88053f4569c872c6e30abf58" +checksum = "d45dd90e8f0e1fa59e85ff5316dd4d1ac41a9a507e79cda1b0e9b7be43ad1a56" dependencies = [ "libp2p-core", "libp2p-identity", @@ -4051,9 +4123,9 @@ dependencies = [ [[package]] name = "libp2p-identity" -version = "0.2.2" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a38d6012784fe4cc14e6d443eb415b11fc7c456dc15d9f0d90d9b70bc7ac3ec1" +checksum = "d2874d9c6575f1d7a151022af5c42bb0ffdcdfbafe0a6fd039de870b384835a2" dependencies = [ "bs58 0.5.0", "ed25519-dalek", @@ -4068,9 +4140,9 @@ dependencies = [ [[package]] name = "libp2p-kad" -version = "0.44.3" +version = "0.44.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f2584b0c27f879a1cca4b753fd96874109e5a2f46bd6e30924096456c2ba9b2" +checksum = "f0eeb75763862ff762c3240722fbed06ff6bb025d6afbdf2ce887f3610657789" dependencies = [ "arrayvec 0.7.4", "asynchronous-codec", @@ -4195,9 +4267,9 @@ dependencies = [ [[package]] name = "libp2p-swarm" -version = "0.43.2" +version = "0.43.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43106820057e0f65c77b01a3873593f66e676da4e40c70c3a809b239109f1d30" +checksum = "5de15b2097fc3bde063df8c202803538ff467fedb18f01c13bc5da55913d246c" dependencies = [ "either", "fnv", @@ -4226,7 +4298,7 @@ dependencies = [ "proc-macro-warning", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -4358,9 +4430,9 @@ dependencies = [ [[package]] name = "libz-sys" -version = "1.1.12" +version = "1.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d97137b25e321a73eef1418d1d5d2eda4d77e12813f8e6dead84bc52c5870a7b" +checksum = "56ee889ecc9568871456d42f603d6a0ce59ff328d291063a45cbdf0036baf6db" dependencies = [ "cc", "pkg-config", @@ -4369,9 +4441,9 @@ dependencies = [ [[package]] name = "link-cplusplus" -version = "1.0.9" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d240c6f7e1ba3a28b0249f774e6a9dd0175054b52dfbb61b16eb8505c3785c9" +checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5" dependencies = [ "cc", ] @@ -4393,9 +4465,9 @@ dependencies = [ [[package]] name = "linregress" -version = "0.5.2" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4de0b5f52a9f84544d268f5fabb71b38962d6aa3c6600b8bcd27d44ccf9c9c45" +checksum = "475015a7f8f017edb28d2e69813be23500ad4b32cfe3421c4148efc97324ee52" dependencies = [ "nalgebra", ] @@ -4412,12 +4484,6 @@ version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" -[[package]] -name = "linux-raw-sys" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503" - [[package]] name = "lite-json" version = "0.2.0" @@ -4454,9 +4520,9 @@ checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" [[package]] name = "lru" -version = "0.10.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "718e8fae447df0c7e1ba7f5189829e63fd536945c8988d61444c19039f16b670" +checksum = "03f1160296536f10c833a82dca22267d5486734230d47bf00bf435885814ba1e" dependencies = [ "hashbrown 0.13.2", ] @@ -4508,7 +4574,7 @@ dependencies = [ "macro_magic_core", "macro_magic_macros", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -4522,7 +4588,7 @@ dependencies = [ "macro_magic_core_macros", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -4533,7 +4599,7 @@ checksum = "c12469fc165526520dff2807c2975310ab47cf7190a45b99b49a7dc8befab17b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -4544,7 +4610,7 @@ checksum = "b8fb85ec1620619edf2984a7693497d4ec88a9665d8b87e942856884c92dbf2a" dependencies = [ "macro_magic_core", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -4565,7 +4631,7 @@ version = "0.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1" dependencies = [ - "regex-automata 0.1.10", + "regex-automata", ] [[package]] @@ -4574,7 +4640,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" dependencies = [ - "regex-automata 0.1.10", + "regex-automata", ] [[package]] @@ -4605,7 +4671,7 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ffc89ccdc6e10d6907450f753537ebc5c5d3460d2e4e62ea74bd571db62c0f9e" dependencies = [ - "rustix 0.37.23", + "rustix 0.37.19", ] [[package]] @@ -4635,15 +4701,6 @@ 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" @@ -4665,12 +4722,33 @@ dependencies = [ "zeroize", ] +[[package]] +name = "merlin" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58c38e2799fc0978b65dfff8023ec7843e2330bb462f19198840b34b6582397d" +dependencies = [ + "byteorder", + "keccak", + "rand_core 0.6.4", + "zeroize", +] + [[package]] name = "minimal-lexical" 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" @@ -4894,9 +4972,9 @@ dependencies = [ [[package]] name = "nalgebra" -version = "0.32.3" +version = "0.32.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "307ed9b18cc2423f29e83f84fd23a8e73628727990181f18641a8b5dc2ab1caa" +checksum = "d68d47bba83f9e2006d117a9a33af1524e655516b8919caac694427a6fb1e511" dependencies = [ "approx", "matrixmultiply", @@ -4910,9 +4988,9 @@ dependencies = [ [[package]] name = "nalgebra-macros" -version = "0.2.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91761aed67d03ad966ef783ae962ef9bbaca728d2dd7ceb7939ec110fffad998" +checksum = "d232c68884c0c99810a5a4d333ef7e47689cfd0edc85efc9e54e1e6bf5212766" dependencies = [ "proc-macro2", "quote", @@ -4947,7 +5025,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9ea4302b9759a7a88242299225ea3688e63c85ea136371bb6cf94fd674efaab" dependencies = [ "anyhow", - "bitflags 1.3.2", + "bitflags", "byteorder", "libc", "netlink-packet-core", @@ -5000,7 +5078,7 @@ version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" dependencies = [ - "bitflags 1.3.2", + "bitflags", "cfg-if", "libc", ] @@ -5011,7 +5089,7 @@ version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a" dependencies = [ - "bitflags 1.3.2", + "bitflags", "cfg-if", "libc", "memoffset 0.7.1", @@ -5024,7 +5102,7 @@ name = "node-bench" version = "0.9.0-dev" dependencies = [ "array-bytes", - "clap 4.3.19", + "clap 4.3.2", "derive_more", "fs_extra", "futures", @@ -5061,7 +5139,7 @@ version = "3.0.0-dev" dependencies = [ "array-bytes", "assert_cmd", - "clap 4.3.19", + "clap 4.3.2", "clap_complete", "criterion", "frame-benchmarking-cli", @@ -5187,7 +5265,7 @@ dependencies = [ name = "node-inspect" version = "0.9.0-dev" dependencies = [ - "clap 4.3.19", + "clap 4.3.2", "parity-scale-codec", "sc-cli", "sc-client-api", @@ -5241,7 +5319,7 @@ dependencies = [ name = "node-runtime-generate-bags" version = "3.0.0" dependencies = [ - "clap 4.3.19", + "clap 4.3.2", "generate-bags", "kitchensink-runtime", ] @@ -5250,7 +5328,7 @@ dependencies = [ name = "node-template" version = "4.0.0-dev" dependencies = [ - "clap 4.3.19", + "clap 4.3.2", "frame-benchmarking", "frame-benchmarking-cli", "frame-system", @@ -5293,7 +5371,7 @@ dependencies = [ name = "node-template-release" version = "3.0.0" dependencies = [ - "clap 4.3.19", + "clap 4.3.2", "flate2", "fs_extra", "glob", @@ -5409,9 +5487,9 @@ dependencies = [ [[package]] name = "num" -version = "0.4.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b05180d69e3da0e530ba2a1dae5110317e49e3b7f3d41be227dc5f92e49ee7af" +checksum = "43db66d1170d347f9a065114077f7dccb00c1b9478c89384490a3425279a4606" dependencies = [ "num-bigint", "num-complex", @@ -5486,9 +5564,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.16" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" dependencies = [ "autocfg", "libm 0.2.7", @@ -5496,11 +5574,11 @@ dependencies = [ [[package]] name = "num_cpus" -version = "1.16.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" dependencies = [ - "hermit-abi 0.3.2", + "hermit-abi 0.2.6", "libc", ] @@ -5518,16 +5596,7 @@ checksum = "03b4680b86d9cfafba8fc491dc9b6df26b68cf40e9e6cd73909194759a63c385" dependencies = [ "crc32fast", "hashbrown 0.13.2", - "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 = [ + "indexmap", "memchr", ] @@ -5563,9 +5632,18 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "os_str_bytes" -version = "6.5.1" +version = "6.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d5d9eb14b174ee9aa2ef96dc2b94637a2d4b6e7cb873c7e171f0c20c6cf3eac" +checksum = "ceedf44fb00f2d1984b0bc98102627ce622e083e49a5bacdb3e514fa4238e267" + +[[package]] +name = "output_vt100" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "628223faebab4e3e40667ee0b2336d34a5b960ff60ea743ddfdbcf7770bcfb66" +dependencies = [ + "winapi", +] [[package]] name = "overload" @@ -5963,7 +6041,7 @@ version = "4.0.0-dev" dependencies = [ "array-bytes", "assert_matches", - "bitflags 1.3.2", + "bitflags", "env_logger 0.9.3", "environmental", "frame-benchmarking", @@ -6000,7 +6078,7 @@ dependencies = [ name = "pallet-contracts-primitives" version = "24.0.0" dependencies = [ - "bitflags 1.3.2", + "bitflags", "parity-scale-codec", "scale-info", "sp-runtime", @@ -6014,7 +6092,7 @@ version = "4.0.0-dev" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -7048,7 +7126,7 @@ dependencies = [ "proc-macro2", "quote", "sp-runtime", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -7089,7 +7167,7 @@ dependencies = [ "substrate-state-trie-migration-rpc", "thousands", "tokio", - "zstd 0.12.4", + "zstd 0.12.3+zstd.1.5.2", ] [[package]] @@ -7333,9 +7411,9 @@ dependencies = [ [[package]] name = "parity-db" -version = "0.4.10" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78f19d20a0d2cc52327a88d131fa1c4ea81ea4a04714aedcfeca2dd410049cf8" +checksum = "4890dcb9556136a4ec2b0c51fa4a08c8b733b829506af8fff2e853f3a065985b" dependencies = [ "blake2", "crc32fast", @@ -7368,9 +7446,9 @@ dependencies = [ [[package]] name = "parity-scale-codec-derive" -version = "3.6.4" +version = "3.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a296c3079b5fefbc499e1de58dc26c09b1b9a5952d26694ee89f04a43ebbb3e" +checksum = "2b6937b5e67bfba3351b87b040d48352a2fcb6ad72f81855412ce97b45c8f110" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -7435,7 +7513,7 @@ dependencies = [ "libc", "redox_syscall 0.3.5", "smallvec", - "windows-targets 0.48.1", + "windows-targets 0.48.0", ] [[package]] @@ -7446,9 +7524,9 @@ checksum = "7924d1d0ad836f665c9065e26d016c673ece3993f30d340068b16f282afc1156" [[package]] name = "paste" -version = "1.0.14" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" +checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" [[package]] name = "pbkdf2" @@ -7482,9 +7560,9 @@ checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pest" -version = "2.7.2" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1acb4a4365a13f749a93f1a094a7805e5cfa0955373a9de860d962eaa3a5fe5a" +checksum = "e68e84bfb01f0507134eac1e9b410a12ba379d064eab48c50ba4ce329a527b70" dependencies = [ "thiserror", "ucd-trie", @@ -7492,9 +7570,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.2" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "666d00490d4ac815001da55838c500eafb0320019bbaa44444137c48b443a853" +checksum = "6b79d4c71c865a25a4322296122e3924d30bc8ee0834c8bfc8b95f7f054afbfb" dependencies = [ "pest", "pest_generator", @@ -7502,22 +7580,22 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.2" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68ca01446f50dbda87c1786af8770d535423fa8a53aec03b8f4e3d7eb10e0929" +checksum = "6c435bf1076437b851ebc8edc3a18442796b30f1728ffea6262d59bbe28b077e" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] name = "pest_meta" -version = "2.7.2" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56af0a30af74d0445c0bf6d9d051c979b516a1a5af790d251daee76005420a48" +checksum = "745a452f8eb71e39ffd8ee32b3c5f51d03845f99786fa9b68db6ff509c505411" dependencies = [ "once_cell", "pest", @@ -7531,27 +7609,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4dd7d28ee937e54fe3080c91faa1c3a46c06de6252988a7f4592ba2310ef22a4" dependencies = [ "fixedbitset", - "indexmap 1.9.3", + "indexmap", ] [[package]] name = "pin-project" -version = "1.1.2" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "030ad2bc4db10a8944cb0d837f158bdfec4d4a4873ab701a95046770d11f8842" +checksum = "c95a7476719eab1e366eaf73d0260af3021184f18177925b07f54b30089ceead" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.2" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec2e072ecce94ec471b13398d5402c188e76ac03cf74dd1a975161b23a3f6d9c" +checksum = "39407670928234ebc5e6e580247dd567ad73a3578460c5990f9503df207e8f07" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -7562,9 +7640,9 @@ checksum = "257b64915a082f7811703966789728173279bdebb956b143dbcd23f6f970a777" [[package]] name = "pin-project-lite" -version = "0.2.10" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c40d25201921e5ff0c862a505c6557ea88568a4e3ace775ab55e93f2f4f9d57" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" [[package]] name = "pin-utils" @@ -7596,9 +7674,9 @@ checksum = "e3d7ddaed09e0eb771a79ab0fd64609ba0afb0a8366421957936ad14cbd13630" [[package]] name = "plotters" -version = "0.3.5" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2c224ba00d7cadd4d5c660deaf2098e5e80e07846537c51f9cfa4be50c1fd45" +checksum = "2538b639e642295546c50fcd545198c9d64ee2a38620a628724a3b266d5fbf97" dependencies = [ "num-traits", "plotters-backend", @@ -7609,15 +7687,15 @@ dependencies = [ [[package]] name = "plotters-backend" -version = "0.3.5" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e76628b4d3a7581389a35d5b6e2139607ad7c75b17aed325f210aa91f4a9609" +checksum = "193228616381fecdc1224c62e96946dfbc73ff4384fba576e052ff8c1bea8142" [[package]] name = "plotters-svg" -version = "0.3.5" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38f6d39893cca0701371e3c27294f09797214b86f1fb951b89ade8ec04e2abab" +checksum = "f9a81d2759aae1dae668f783c308bc5c8ebd191ff4184aaa1b37f65a6ae5a56f" dependencies = [ "plotters-backend", ] @@ -7629,12 +7707,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" dependencies = [ "autocfg", - "bitflags 1.3.2", + "bitflags", "cfg-if", "concurrent-queue", "libc", "log", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.9", "windows-sys 0.48.0", ] @@ -7675,9 +7753,9 @@ dependencies = [ [[package]] name = "portable-atomic" -version = "1.4.2" +version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f32154ba0af3a075eefa1eda8bb414ee928f62303a54ea85b8d6638ff1a6ee9e" +checksum = "767eb9f07d4a5ebcb39bbf2d452058a93c011373abf6832e24194a1c3f004794" [[package]] name = "ppv-lite86" @@ -7729,11 +7807,13 @@ dependencies = [ [[package]] name = "pretty_assertions" -version = "1.4.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af7cee1a6c8a5b9208b3cb1061f10c0cb689087b3d8ce85fb9d2dd7a29b6ba66" +checksum = "a25e9bcb20aa780fd0bb16b72403a9064d6b3f22f026946029acb941a50af755" dependencies = [ + "ctor", "diff", + "output_vt100", "yansi", ] @@ -7749,12 +7829,12 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.12" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c64d9ba0963cdcea2e1b2230fbae2bab30eb25a174be395c41e764bfb65dd62" +checksum = "3b69d39aab54d069e7f2fe8cb970493e7834601ca2d8c65fd7bbd183578080d1" dependencies = [ "proc-macro2", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -7819,14 +7899,14 @@ checksum = "70550716265d1ec349c41f70dd4f964b4fd88394efe4405f0c1da679c4799a07" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] name = "proc-macro2" -version = "1.0.66" +version = "1.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +checksum = "dec2b086b7a862cf4de201096214fa870344cf922b2b30c167badb3af3195406" dependencies = [ "unicode-ident", ] @@ -7981,9 +8061,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.32" +version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" +checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488" dependencies = [ "proc-macro2", ] @@ -8053,7 +8133,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.10", + "getrandom 0.2.9", ] [[package]] @@ -8118,7 +8198,7 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ - "bitflags 1.3.2", + "bitflags", ] [[package]] @@ -8127,7 +8207,7 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" dependencies = [ - "bitflags 1.3.2", + "bitflags", ] [[package]] @@ -8136,29 +8216,29 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ - "getrandom 0.2.10", + "getrandom 0.2.9", "redox_syscall 0.2.16", "thiserror", ] [[package]] name = "ref-cast" -version = "1.0.19" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61ef7e18e8841942ddb1cf845054f8008410030a3997875d9e49b7a363063df1" +checksum = "f43faa91b1c8b36841ee70e97188a869d37ae21759da6846d4be66de5bf7b12c" dependencies = [ "ref-cast-impl", ] [[package]] name = "ref-cast-impl" -version = "1.0.19" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dfaf0c85b766276c797f3791f5bc6d5bd116b41d53049af2789666b0c0bc9fa" +checksum = "8d2275aab483050ab2a7364c1a46604865ee7d6906684e08db0f090acf74f9e7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -8175,14 +8255,13 @@ dependencies = [ [[package]] name = "regex" -version = "1.9.1" +version = "1.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2eae68fc220f7cf2532e4494aded17545fce192d59cd996e0fe7887f4ceb575" +checksum = "d0ab3ca65655bb1e41f2a8c8cd662eb4fb035e67c3f78da1d61dffe89d07300f" dependencies = [ - "aho-corasick", + "aho-corasick 1.0.2", "memchr", - "regex-automata 0.3.4", - "regex-syntax 0.7.4", + "regex-syntax 0.7.2", ] [[package]] @@ -8194,17 +8273,6 @@ dependencies = [ "regex-syntax 0.6.29", ] -[[package]] -name = "regex-automata" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7b6d6190b7594385f61bd3911cd1be99dfddcfc365a4160cc2ab5bff4aed294" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax 0.7.4", -] - [[package]] name = "regex-syntax" version = "0.6.29" @@ -8213,9 +8281,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.7.4" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2" +checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78" [[package]] name = "resolv-conf" @@ -8237,6 +8305,21 @@ dependencies = [ "subtle", ] +[[package]] +name = "ring" +version = "0.1.0" +source = "git+https://github.com/w3f/ring-proof#0e948f3c28cbacecdd3020403c4841c0eb339213" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-poly", + "ark-serialize", + "ark-std", + "common", + "fflonk", + "merlin 3.0.0", +] + [[package]] name = "ring" version = "0.16.20" @@ -8340,16 +8423,16 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver 1.0.18", + "semver 1.0.17", ] [[package]] name = "rustix" -version = "0.36.15" +version = "0.36.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c37f1bd5ef1b5422177b7646cba67430579cfe2ace80f284fee876bca52ad941" +checksum = "14e4d67015953998ad0eb82887a0eb0129e18a7e2f3b7b0f6c422fddcd503d62" dependencies = [ - "bitflags 1.3.2", + "bitflags", "errno", "io-lifetimes", "libc", @@ -8359,11 +8442,11 @@ dependencies = [ [[package]] name = "rustix" -version = "0.37.23" +version = "0.37.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d69718bf81c6127a49dc64e44a742e8bb9213c0ff8869a22c308f84c1d4ab06" +checksum = "acf8729d8542766f1b2cf77eb034d52f40d375bb8b615d0b147089946e16613d" dependencies = [ - "bitflags 1.3.2", + "bitflags", "errno", "io-lifetimes", "libc", @@ -8371,19 +8454,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "rustix" -version = "0.38.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ee020b1716f0a80e2ace9b03441a749e402e86712f15f16fe8a8f75afac732f" -dependencies = [ - "bitflags 2.3.3", - "errno", - "libc", - "linux-raw-sys 0.4.5", - "windows-sys 0.48.0", -] - [[package]] name = "rustls" version = "0.20.8" @@ -8391,28 +8461,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fff78fc74d175294f4e83b28343315ffcfb114b156f0185e9741cb5570f50e2f" dependencies = [ "log", - "ring", + "ring 0.16.20", "sct", "webpki", ] [[package]] name = "rustls" -version = "0.21.6" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d1feddffcfcc0b33f5c6ce9a29e341e4cd59c3f78e7ee45f4a40c038b1d6cbb" +checksum = "c911ba11bc8433e811ce56fde130ccf32f5127cab0e0194e9c68c5a5b671791e" dependencies = [ "log", - "ring", - "rustls-webpki 0.101.2", + "ring 0.16.20", + "rustls-webpki", "sct", ] [[package]] name = "rustls-native-certs" -version = "0.6.3" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" +checksum = "0167bac7a9f490495f3c33013e7722b53cb087ecbe082fb0c6387c96f634ea50" dependencies = [ "openssl-probe", "rustls-pemfile", @@ -8422,9 +8492,9 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "1.0.3" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" +checksum = "d194b56d58803a43635bdc398cd17e383d6f71f9182b9a192c127ca42494a59b" dependencies = [ "base64 0.21.2", ] @@ -8435,25 +8505,15 @@ version = "0.100.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6207cd5ed3d8dca7816f8f3725513a34609c0c765bf652b8c3cb4cfd87db46b" dependencies = [ - "ring", - "untrusted", -] - -[[package]] -name = "rustls-webpki" -version = "0.101.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "513722fd73ad80a71f72b61009ea1b584bcfa1483ca93949c8f290298837fa59" -dependencies = [ - "ring", + "ring 0.16.20", "untrusted", ] [[package]] name = "rustversion" -version = "1.0.14" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" +checksum = "4f3208ce4d8448b3f3e7d168a73f5e0c43a61e32930de3bceeccedb388b6bf06" [[package]] name = "rusty-fork" @@ -8479,9 +8539,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.15" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" +checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" [[package]] name = "safe-mix" @@ -8494,9 +8554,9 @@ dependencies = [ [[package]] name = "safe_arch" -version = "0.7.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f398075ce1e6a179b46f51bd88d0598b92b00d3551f1a2d4ac49e771b56ac354" +checksum = "794821e4ccb0d9f979512f9c1973480123f9bd62a90d74ab0f9426fcf8f4a529" dependencies = [ "bytemuck", ] @@ -8616,7 +8676,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -8625,7 +8685,7 @@ version = "0.10.0-dev" dependencies = [ "array-bytes", "chrono", - "clap 4.3.19", + "clap 4.3.2", "fdlimit", "futures", "futures-timer", @@ -9147,7 +9207,7 @@ dependencies = [ "log", "parity-scale-codec", "paste", - "rustix 0.36.15", + "rustix 0.36.14", "sc-allocator", "sc-executor-common", "sc-runtime-test", @@ -9273,7 +9333,7 @@ name = "sc-network-common" version = "0.10.0-dev" dependencies = [ "async-trait", - "bitflags 1.3.2", + "bitflags", "futures", "libp2p-identity", "parity-scale-codec", @@ -9439,7 +9499,7 @@ dependencies = [ "futures", "futures-timer", "hyper", - "hyper-rustls 0.24.1", + "hyper-rustls 0.24.0", "lazy_static", "libp2p", "log", @@ -9732,7 +9792,7 @@ dependencies = [ name = "sc-storage-monitor" version = "0.1.0" dependencies = [ - "clap 4.3.19", + "clap 4.3.2", "fs4", "log", "sc-client-db", @@ -9832,7 +9892,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -9901,9 +9961,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.9.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35c0a159d0c45c12b20c5a844feb1fe4bea86e28f17b92a5f0c42193634d3782" +checksum = "b569c32c806ec3abdf3b5869fb8bf1e0d275a7c1c9b0b05603d9464632649edf" dependencies = [ "bitvec", "cfg-if", @@ -9915,9 +9975,9 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.9.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "912e55f6d20e0e80d63733872b40e1227c0bce1e1ab81ba67d696339bfd7fd29" +checksum = "53012eae69e5aa5c14671942a5dd47de59d4cdcff8532a6dd0e081faf1119482" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -9955,7 +10015,7 @@ dependencies = [ "arrayvec 0.5.2", "curve25519-dalek 2.1.3", "getrandom 0.1.16", - "merlin", + "merlin 2.0.1", "rand 0.7.3", "rand_core 0.5.1", "sha2 0.8.2", @@ -9965,15 +10025,15 @@ dependencies = [ [[package]] name = "scopeguard" -version = "1.2.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "scratch" -version = "1.0.7" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3cf7c11c38cb994f3d40e8a8cde3bbd1f72a435e4c49e85d6553d8312306152" +checksum = "1792db035ce95be60c3f8853017b3999209281c24e2ba5bc8e59bf97a0c590c1" [[package]] name = "sct" @@ -9981,15 +10041,15 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" dependencies = [ - "ring", + "ring 0.16.20", "untrusted", ] [[package]] name = "sec1" -version = "0.7.3" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" +checksum = "f0aec48e813d6b90b15f0b8948af3c63483992dee44c03e9930b3eebdabe046e" dependencies = [ "base16ct", "der", @@ -10028,11 +10088,11 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.9.2" +version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" +checksum = "1fc758eb7bffce5b308734e9b0c1468893cae9ff70ebf13e7090be8dcbcc83a8" dependencies = [ - "bitflags 1.3.2", + "bitflags", "core-foundation", "core-foundation-sys", "libc", @@ -10041,9 +10101,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.9.1" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" +checksum = "f51d0c0d83bec45f16480d0ce0058397a69e48fcdc52d1dc8855fb68acbd31a7" dependencies = [ "core-foundation-sys", "libc", @@ -10069,9 +10129,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.18" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918" +checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" dependencies = [ "serde", ] @@ -10090,29 +10150,29 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.181" +version = "1.0.164" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d3e73c93c3240c0bda063c239298e633114c69a888c3e37ca8bb33f343e9890" +checksum = "9e8c8cf938e98f769bc164923b06dce91cea1751522f46f8466461af04c9027d" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.181" +version = "1.0.164" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be02f6cb0cd3a5ec20bbcfbcbd749f57daddb1a0882dc2e46a6c236c90b977ed" +checksum = "d9735b638ccc51c28bf6914d90a2e9725b377144fc612c49a611fddd1b631d68" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] name = "serde_json" -version = "1.0.104" +version = "1.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "076066c5f1078eac5b722a31827a8832fe108bed65dfa75e233c89f8206e976c" +checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" dependencies = [ "itoa", "ryu", @@ -10121,9 +10181,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.3" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96426c9936fd7a0124915f9185ea1d20aa9445cc9821142f0a73bc9207a2e186" +checksum = "93107647184f6027e3b7dcb2e11034cf95ffa1e3a682c67951963ac69c1c007d" dependencies = [ "serde", ] @@ -10295,7 +10355,7 @@ dependencies = [ "chacha20poly1305", "curve25519-dalek 4.0.0-rc.1", "rand_core 0.6.4", - "ring", + "ring 0.16.20", "rustc_version 0.4.0", "sha2 0.10.7", "subtle", @@ -10369,7 +10429,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -10534,7 +10594,7 @@ dependencies = [ "ark-serialize", "ark-std", "derivative", - "getrandom 0.2.10", + "getrandom 0.2.9", "itertools", "num-traits", "zeroize", @@ -10692,7 +10752,9 @@ name = "sp-core" version = "21.0.0" dependencies = [ "array-bytes", - "bitflags 1.3.2", + "arrayvec 0.7.4", + "bandersnatch_vrfs", + "bitflags", "blake2", "bounded-collections", "bs58 0.4.0", @@ -10706,7 +10768,7 @@ dependencies = [ "lazy_static", "libsecp256k1", "log", - "merlin", + "merlin 2.0.1", "parity-scale-codec", "parking_lot 0.12.1", "paste", @@ -10753,7 +10815,7 @@ version = "9.0.0" dependencies = [ "quote", "sp-core-hashing", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -10797,7 +10859,7 @@ version = "8.0.0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -10886,7 +10948,7 @@ name = "sp-maybe-compressed-blob" version = "4.1.0-dev" dependencies = [ "thiserror", - "zstd 0.12.4", + "zstd 0.12.3+zstd.1.5.2", ] [[package]] @@ -10936,7 +10998,7 @@ dependencies = [ name = "sp-npos-elections-fuzzer" version = "2.0.0-alpha.5" dependencies = [ - "clap 4.3.19", + "clap 4.3.2", "honggfuzz", "rand 0.8.5", "sp-npos-elections", @@ -10995,7 +11057,7 @@ dependencies = [ "sp-tracing", "sp-weights", "substrate-test-runtime-client", - "zstd 0.12.4", + "zstd 0.12.3+zstd.1.5.2", ] [[package]] @@ -11029,7 +11091,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -11269,7 +11331,7 @@ dependencies = [ "proc-macro2", "quote", "sp-version", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -11333,9 +11395,9 @@ dependencies = [ [[package]] name = "ss58-registry" -version = "1.41.0" +version = "1.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfc443bad666016e012538782d9e3006213a7db43e9fb1dda91657dc06a6fa08" +checksum = "eb47a8ad42e5fc72d5b1eb104a5546937eaf39843499948bb666d6e93c62423b" dependencies = [ "Inflector", "num-format", @@ -11364,7 +11426,7 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a2a1c578e98c1c16fc3b8ec1328f7659a500737d7a0c6d625e73e830ff9c1f6" dependencies = [ - "bitflags 1.3.2", + "bitflags", "cfg_aliases", "libc", "parking_lot 0.11.2", @@ -11392,7 +11454,7 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fabb238a1cccccfa4c4fb703670c0d157e1256c1ba695abf1b93bd2bb14bab2d" dependencies = [ - "bitflags 1.3.2", + "bitflags", "byteorder", "keccak", "subtle", @@ -11431,7 +11493,7 @@ dependencies = [ name = "subkey" version = "3.0.0" dependencies = [ - "clap 4.3.19", + "clap 4.3.2", "sc-cli", ] @@ -11493,7 +11555,7 @@ dependencies = [ name = "substrate-frame-cli" version = "4.0.0-dev" dependencies = [ - "clap 4.3.19", + "clap 4.3.2", "frame-support", "frame-system", "sc-cli", @@ -11708,7 +11770,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -11732,7 +11794,7 @@ dependencies = [ "sp-maybe-compressed-blob", "strum", "tempfile", - "toml 0.7.6", + "toml 0.7.4", "walkdir", "wasm-opt", ] @@ -11756,9 +11818,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.28" +version = "2.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04361975b3f5e348b2189d8dc55bc942f278b2d482a6a0365de5bdd62d351567" +checksum = "32d41677bcbe24c20c52e7c70b0d8db04134c5d1066bf98662e2871ad200ea3e" dependencies = [ "proc-macro2", "quote", @@ -11783,7 +11845,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" dependencies = [ - "bitflags 1.3.2", + "bitflags", "core-foundation", "system-configuration-sys", ] @@ -11806,9 +11868,9 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tar" -version = "0.4.39" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec96d2ffad078296368d46ff1cb309be1c23c513b4ab0e22a45de0185275ac96" +checksum = "4b55807c0344e1e6c04d7c965f5289c39a8d94ae23ed5c0b57aabac549f871c6" dependencies = [ "filetime", "libc", @@ -11817,20 +11879,21 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.12.11" +version = "0.12.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d0e916b1148c8e263850e1ebcbd046f333e0683c724876bb0da63ea4373dc8a" +checksum = "fd1ba337640d60c3e96bc6f0638a939b9c9a7f2c316a1598c279828b3d1dc8c5" [[package]] name = "tempfile" -version = "3.7.0" +version = "3.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5486094ee78b2e5038a6382ed7645bc084dc2ec433426ca4c3cb61e2007b8998" +checksum = "31c0432476357e58790aaa47a8efb0c5138f137343f3b5f23bd36a27e3b0a6d6" dependencies = [ + "autocfg", "cfg-if", - "fastrand 2.0.0", + "fastrand", "redox_syscall 0.3.5", - "rustix 0.38.6", + "rustix 0.37.19", "windows-sys 0.48.0", ] @@ -11857,22 +11920,22 @@ checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" [[package]] name = "thiserror" -version = "1.0.44" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "611040a08a0439f8248d1990b111c95baa9c704c805fa1f62104b39655fd7f90" +checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.44" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "090198534930841fab3a5d1bb637cde49e339654e606195f8d9c76eeb081dc96" +checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -11902,9 +11965,9 @@ dependencies = [ [[package]] name = "tikv-jemalloc-sys" -version = "0.5.4+5.3.0-patched" +version = "0.5.3+5.3.0-patched" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9402443cb8fd499b6f327e40565234ff34dbda27460c5b47db0db77443dd85d1" +checksum = "a678df20055b43e57ef8cddde41cdfda9a3c1a060b67f4c5836dfb1d78543ba8" dependencies = [ "cc", "libc", @@ -11987,7 +12050,7 @@ dependencies = [ "mio", "num_cpus", "parking_lot 0.12.1", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.9", "signal-hook-registry", "socket2 0.4.9", "tokio-macros", @@ -12002,7 +12065,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -12029,11 +12092,11 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.24.1" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" +checksum = "e0d409377ff5b1e3ca6437aa86c1eb7d40c134bfec254e44c830defa92669db5" dependencies = [ - "rustls 0.21.6", + "rustls 0.21.1", "tokio", ] @@ -12044,7 +12107,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" dependencies = [ "futures-core", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.9", "tokio", "tokio-util", ] @@ -12072,7 +12135,7 @@ dependencies = [ "futures-core", "futures-io", "futures-sink", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.9", "tokio", "tracing", ] @@ -12088,9 +12151,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.7.6" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c17e963a819c331dcacd7ab957d80bc2b9a9c1e71c804826d2f283dd65306542" +checksum = "d6135d499e69981f9ff0ef2167955a5333c35e36f6937d382974566b3d5b94ec" dependencies = [ "serde", "serde_spanned", @@ -12100,20 +12163,20 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.3" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" +checksum = "5a76a9312f5ba4c2dec6b9161fdf25d87ad8a09256ccea5a556fef03c706a10f" dependencies = [ "serde", ] [[package]] name = "toml_edit" -version = "0.19.14" +version = "0.19.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8123f27e969974a3dfba720fdb560be359f57b44302d280ba72e76a74480e8a" +checksum = "2380d56e8670370eee6566b0bfd4265f65b3f432e8c6d85623f728d4fa31f739" dependencies = [ - "indexmap 2.0.0", + "indexmap", "serde", "serde_spanned", "toml_datetime", @@ -12133,18 +12196,18 @@ dependencies = [ [[package]] name = "tower-http" -version = "0.4.3" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55ae70283aba8d2a8b411c695c437fe25b8b5e44e23e780662002fc72fb47a82" +checksum = "5d1d42a9b3f3ec46ba828e8d376aec14592ea199f70a06a548587ecd1c4ab658" dependencies = [ - "bitflags 2.3.3", + "bitflags", "bytes", "futures-core", "futures-util", "http", "http-body", "http-range-header", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.9", "tower-layer", "tower-service", ] @@ -12169,20 +12232,20 @@ checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" dependencies = [ "cfg-if", "log", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.9", "tracing-attributes", "tracing-core", ] [[package]] name = "tracing-attributes" -version = "0.1.26" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" +checksum = "0f57e3ca2a01450b1a921183a9c9cbfda207fd822cef4ccb00a65402cbba7a74" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -12373,7 +12436,7 @@ version = "0.10.0-dev" dependencies = [ "assert_cmd", "async-trait", - "clap 4.3.19", + "clap 4.3.2", "frame-remote-externalities", "frame-try-runtime", "hex", @@ -12405,14 +12468,14 @@ dependencies = [ "substrate-rpc-client", "tempfile", "tokio", - "zstd 0.12.4", + "zstd 0.12.3+zstd.1.5.2", ] [[package]] name = "trybuild" -version = "1.0.82" +version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a84e0202ea606ba5ebee8507ab2bfbe89b98551ed9b8f0be198109275cff284b" +checksum = "501dbdbb99861e4ab6b60eb6a7493956a9defb644fd034bc4a5ef27c693c8a3a" dependencies = [ "basic-toml", "dissimilar", @@ -12450,9 +12513,9 @@ checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" [[package]] name = "ucd-trie" -version = "0.1.6" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" +checksum = "9e79c4d996edb816c91e4308506774452e55e95c3c9de07b6729e17e15a5ef81" [[package]] name = "uint" @@ -12474,9 +12537,9 @@ checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" -version = "1.0.11" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" +checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" [[package]] name = "unicode-normalization" @@ -12629,10 +12692,11 @@ dependencies = [ [[package]] name = "want" -version = "0.3.1" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" dependencies = [ + "log", "try-lock", ] @@ -12656,9 +12720,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.87" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" +checksum = "5bba0e8cb82ba49ff4e229459ff22a191bbe9a1cb3a341610c9c33efc27ddf73" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -12666,24 +12730,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.87" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" +checksum = "19b04bc93f9d6bdee709f6bd2118f57dd6679cf1176a1af464fca3ab0d66d8fb" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.37" +version = "0.4.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03" +checksum = "2d1985d03709c53167ce907ff394f5316aa22cb4e12761295c5dc57dacb6297e" dependencies = [ "cfg-if", "js-sys", @@ -12693,9 +12757,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.87" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" +checksum = "14d6b024f1a526bb0234f52840389927257beb670610081360e5a03c5df9c258" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -12703,28 +12767,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.87" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" +checksum = "e128beba882dd1eb6200e1dc92ae6c5dbaa4311aa7bb211ca035779e5efc39f8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.87" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" +checksum = "ed9d5b4305409d1fc9482fee2d7f9bcbf24b3972bf59817ef757e23982242a93" [[package]] name = "wasm-encoder" -version = "0.31.1" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41763f20eafed1399fff1afb466496d3a959f58241436cfdc17e3f5ca954de16" +checksum = "18c41dbd92eaebf3612a39be316540b8377c871cb9bde6b064af962984912881" dependencies = [ "leb128", ] @@ -12840,7 +12904,7 @@ version = "0.102.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48134de3d7598219ab9eaf6b91b15d8e50d31da76b8519fe4ecfcec2cf35104b" dependencies = [ - "indexmap 1.9.3", + "indexmap", "url", ] @@ -12862,10 +12926,10 @@ dependencies = [ "anyhow", "bincode", "cfg-if", - "indexmap 1.9.3", + "indexmap", "libc", "log", - "object 0.30.4", + "object", "once_cell", "paste", "psm", @@ -12902,7 +12966,7 @@ dependencies = [ "directories-next", "file-per-thread-logger", "log", - "rustix 0.36.15", + "rustix 0.36.14", "serde", "sha2 0.10.7", "toml 0.5.11", @@ -12924,7 +12988,7 @@ dependencies = [ "cranelift-wasm", "gimli", "log", - "object 0.30.4", + "object", "target-lexicon", "thiserror", "wasmparser", @@ -12942,7 +13006,7 @@ dependencies = [ "cranelift-codegen", "cranelift-native", "gimli", - "object 0.30.4", + "object", "target-lexicon", "wasmtime-environ", ] @@ -12956,9 +13020,9 @@ dependencies = [ "anyhow", "cranelift-entity", "gimli", - "indexmap 1.9.3", + "indexmap", "log", - "object 0.30.4", + "object", "serde", "target-lexicon", "thiserror", @@ -12972,14 +13036,14 @@ version = "8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0de48df552cfca1c9b750002d3e07b45772dd033b0b206d5c0968496abf31244" dependencies = [ - "addr2line 0.19.0", + "addr2line", "anyhow", "bincode", "cfg-if", "cpp_demangle", "gimli", "log", - "object 0.30.4", + "object", "rustc-demangle", "serde", "target-lexicon", @@ -12996,9 +13060,9 @@ version = "8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e0554b84c15a27d76281d06838aed94e13a77d7bf604bbbaf548aa20eb93846" dependencies = [ - "object 0.30.4", + "object", "once_cell", - "rustix 0.36.15", + "rustix 0.36.14", ] [[package]] @@ -13021,7 +13085,7 @@ dependencies = [ "anyhow", "cc", "cfg-if", - "indexmap 1.9.3", + "indexmap", "libc", "log", "mach", @@ -13029,7 +13093,7 @@ dependencies = [ "memoffset 0.8.0", "paste", "rand 0.8.5", - "rustix 0.36.15", + "rustix 0.36.14", "wasmtime-asm-macros", "wasmtime-environ", "wasmtime-jit-debug", @@ -13050,9 +13114,9 @@ dependencies = [ [[package]] name = "wast" -version = "62.0.1" +version = "60.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8ae06f09dbe377b889fbd620ff8fa21e1d49d1d9d364983c0cdbf9870cb9f1f" +checksum = "bd06cc744b536e30387e72a48fdd492105b9c938bb4f415c39c616a7a0a697ad" dependencies = [ "leb128", "memchr", @@ -13062,18 +13126,18 @@ dependencies = [ [[package]] name = "wat" -version = "1.0.69" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "842e15861d203fb4a96d314b0751cdeaf0f6f8b35e8d81d2953af2af5e44e637" +checksum = "5abe520f0ab205366e9ac7d3e6b2fc71de44e32a2b58f2ec871b6b575bdcea3b" dependencies = [ "wast", ] [[package]] name = "web-sys" -version = "0.3.64" +version = "0.3.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" +checksum = "3bdd9ef4e984da1187bf8110c5cf5b845fbc87a23602cdf912386a76fcd3a7c2" dependencies = [ "js-sys", "wasm-bindgen", @@ -13085,7 +13149,7 @@ version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd" dependencies = [ - "ring", + "ring 0.16.20", "untrusted", ] @@ -13104,7 +13168,7 @@ version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b03058f88386e5ff5310d9111d53f48b17d732b401aeb83a8d5190f2ac459338" dependencies = [ - "rustls-webpki 0.100.1", + "rustls-webpki", ] [[package]] @@ -13120,9 +13184,9 @@ dependencies = [ [[package]] name = "wide" -version = "0.7.11" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa469ffa65ef7e0ba0f164183697b89b854253fd31aeb92358b7b6155177d62f" +checksum = "5cd0496a71f3cc6bc4bf0ed91346426a5099e93d89807e663162dc5a1069ff65" dependencies = [ "bytemuck", "safe_arch", @@ -13130,9 +13194,9 @@ dependencies = [ [[package]] name = "widestring" -version = "1.0.2" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "653f141f39ec16bba3c5abe400a0c60da7468261cc2cbf36805022876bc721a8" +checksum = "17882f045410753661207383517a6f62ec3dbeb6a4ed2acce01f0728238d1983" [[package]] name = "winapi" @@ -13184,7 +13248,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" dependencies = [ - "windows-targets 0.48.1", + "windows-targets 0.48.0", ] [[package]] @@ -13202,7 +13266,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets 0.48.1", + "windows-targets 0.48.0", ] [[package]] @@ -13222,9 +13286,9 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.48.1" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" +checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" dependencies = [ "windows_aarch64_gnullvm 0.48.0", "windows_aarch64_msvc 0.48.0", @@ -13351,21 +13415,20 @@ checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" [[package]] name = "winnow" -version = "0.5.4" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acaaa1190073b2b101e15083c38ee8ec891b5e05cbee516521e94ec008f61e64" +checksum = "61de7bac303dc551fe038e2b3cef0f571087a47571ea6e79a87692ac99b99699" dependencies = [ "memchr", ] [[package]] name = "winreg" -version = "0.50.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" +checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" dependencies = [ - "cfg-if", - "windows-sys 0.48.0", + "winapi", ] [[package]] @@ -13445,7 +13508,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -13459,11 +13522,11 @@ dependencies = [ [[package]] name = "zstd" -version = "0.12.4" +version = "0.12.3+zstd.1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a27595e173641171fc74a1232b7b1c7a7cb6e18222c11e9dfb9888fa424c53c" +checksum = "76eea132fb024e0e13fd9c2f5d5d595d8a967aa72382ac2f9d39fcc95afd0806" dependencies = [ - "zstd-safe 6.0.6", + "zstd-safe 6.0.5+zstd.1.5.4", ] [[package]] @@ -13478,9 +13541,9 @@ dependencies = [ [[package]] name = "zstd-safe" -version = "6.0.6" +version = "6.0.5+zstd.1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee98ffd0b48ee95e6c5168188e44a54550b1564d9d530ee21d5f0eaed1069581" +checksum = "d56d9e60b4b1758206c238a10165fbcae3ca37b01744e394c463463f6529d23b" dependencies = [ "libc", "zstd-sys",