From cf4d5173b551b9de47da6319745a54b0c41513b2 Mon Sep 17 00:00:00 2001 From: Ermal Kaleci Date: Thu, 4 Jul 2024 18:03:38 +0200 Subject: [PATCH] add candidacy un-bonding period (#1281) --- .../collator-selection/src/benchmarking.rs | 19 + pallets/collator-selection/src/lib.rs | 174 ++++++--- pallets/collator-selection/src/mock.rs | 11 +- pallets/collator-selection/src/tests.rs | 172 +++++++-- pallets/collator-selection/src/weights.rs | 364 ++++++++++-------- runtime/astar/src/lib.rs | 1 + runtime/shibuya/src/lib.rs | 1 + runtime/shiden/src/lib.rs | 1 + 8 files changed, 500 insertions(+), 243 deletions(-) diff --git a/pallets/collator-selection/src/benchmarking.rs b/pallets/collator-selection/src/benchmarking.rs index 9d511faeda..c5103eb9b9 100644 --- a/pallets/collator-selection/src/benchmarking.rs +++ b/pallets/collator-selection/src/benchmarking.rs @@ -195,6 +195,25 @@ benchmarks! { assert_last_event::(Event::CandidateRemoved(leaving).into()); } + withdraw_bond { + use frame_support::traits::{EstimateNextSessionRotation, Hooks}; + + >::put(T::Currency::minimum_balance()); + >::put(T::MinCandidates::get() + 1); + register_validators::(T::MinCandidates::get() + 1); + register_candidates::(T::MinCandidates::get() + 1); + + let leaving = >::get().last().unwrap().who.clone(); + whitelist!(leaving); + assert_ok!(CollatorSelection::::leave_intent(RawOrigin::Signed(leaving.clone()).into())); + let session_length = ::NextSessionRotation::average_session_length(); + session::Pallet::::on_initialize(session_length); + assert_eq!(>::get(&leaving), (1u32, T::Currency::minimum_balance())); + }: _(RawOrigin::Signed(leaving.clone())) + verify { + assert_eq!(>::get(&leaving), (0u32, BalanceOf::::default())); + } + // worse case is paying a non-existing candidate account. note_author { >::put(T::Currency::minimum_balance()); diff --git a/pallets/collator-selection/src/lib.rs b/pallets/collator-selection/src/lib.rs index 04a6fd41ef..c160a3dee7 100644 --- a/pallets/collator-selection/src/lib.rs +++ b/pallets/collator-selection/src/lib.rs @@ -87,7 +87,7 @@ pub mod pallet { }, traits::{ Currency, EnsureOrigin, ExistenceRequirement::KeepAlive, ReservableCurrency, - ValidatorRegistration, + ValidatorRegistration, ValidatorSet, }, DefaultNoBound, PalletId, }; @@ -146,7 +146,7 @@ pub mod pallet { /// Used only for benchmarking. type MaxInvulnerables: Get; - // Will be kicked if block is not produced in threshold. + /// Will be kicked if block is not produced in threshold. type KickThreshold: Get>; /// A stable ID for a validator. @@ -160,6 +160,9 @@ pub mod pallet { /// Validate a user is registered type ValidatorRegistration: ValidatorRegistration; + /// Something that can give information about the current validator set. + type ValidatorSet: ValidatorSet; + /// How many in perc kicked collators should be slashed (set 0 to disable) type SlashRatio: Get; @@ -194,6 +197,11 @@ pub mod pallet { pub type Candidates = StorageValue<_, Vec>>, ValueQuery>; + /// Candidates who initiated leave intent or kicked. + #[pallet::storage] + pub type NonCandidates = + StorageMap<_, Twox64Concat, T::AccountId, (SessionIndex, BalanceOf), ValueQuery>; + /// Last block authored by collator. #[pallet::storage] #[pallet::getter(fn last_authored_block)] @@ -257,11 +265,17 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event { + /// New invulnerables candidates were set. NewInvulnerables(Vec), + /// The number of desired candidates was set. NewDesiredCandidates(u32), + /// The candidacy bond was set. NewCandidacyBond(BalanceOf), + /// A new candidate joined. CandidateAdded(T::AccountId, BalanceOf), + /// A candidate was removed. CandidateRemoved(T::AccountId), + /// A candidate was slashed. CandidateSlashed(T::AccountId), } @@ -288,6 +302,10 @@ pub mod pallet { ValidatorNotRegistered, /// Account is now allowed to be a candidate due to an external reason (e.g. it might be participating in dApp staking) NotAllowedCandidate, + /// The candidacy bond is currently in the un-bonding period. + BondStillLocked, + /// No candidacy bond available for withdrawal. + NoCandidacyBond, } #[pallet::hooks] @@ -388,6 +406,19 @@ pub mod pallet { Error::::ValidatorNotRegistered ); + // ensure candidacy has no previous locked un-bonding + >::try_mutate_exists(&who, |maybe| -> DispatchResult { + if let Some((index, deposit)) = maybe.take() { + ensure!( + T::ValidatorSet::session_index() >= index, + Error::::BondStillLocked + ); + // unreserve previous deposit and continue with registration + T::Currency::unreserve(&who, deposit); + } + Ok(()) + })?; + let deposit = Self::candidacy_bond(); // First authored block is current block plus kick threshold to handle session delay let incoming = CandidateInfo { @@ -403,7 +434,7 @@ pub mod pallet { T::Currency::reserve(&who, deposit)?; candidates.push(incoming); >::insert( - who.clone(), + &who, frame_system::Pallet::::block_number() + T::KickThreshold::get(), ); Ok(candidates.len()) @@ -415,7 +446,7 @@ pub mod pallet { } /// Deregister `origin` as a collator candidate. Note that the collator can only leave on - /// session change. The `CandidacyBond` will be unreserved immediately. + /// session change. The `CandidacyBond` will start un-bonding process. /// /// This call will fail if the total number of candidates would drop below `MinCandidates`. /// @@ -428,10 +459,33 @@ pub mod pallet { Self::candidates().len() as u32 > T::MinCandidates::get(), Error::::TooFewCandidates ); - let current_count = Self::try_remove_candidate(&who, false)?; - + let current_count = Self::try_remove_candidate(&who)?; Ok(Some(T::WeightInfo::leave_intent(current_count as u32)).into()) } + + /// Withdraw `CandidacyBond` after un-bonding period has finished. + /// This call will fail called during un-bonding or if there's no `CandidacyBound` reserved. + #[pallet::call_index(5)] + #[pallet::weight(T::WeightInfo::withdraw_bond())] + pub fn withdraw_bond(origin: OriginFor) -> DispatchResult { + let who = ensure_signed(origin)?; + + >::try_mutate_exists(&who, |maybe| -> DispatchResult { + if let Some((index, deposit)) = maybe.take() { + ensure!( + T::ValidatorSet::session_index() >= index, + Error::::BondStillLocked + ); + T::Currency::unreserve(&who, deposit); + >::remove(&who); + Ok(()) + } else { + Err(Error::::NoCandidacyBond.into()) + } + })?; + + Ok(()) + } } impl Pallet { @@ -439,73 +493,77 @@ pub mod pallet { pub fn account_id() -> T::AccountId { T::PotId::get().into_account_truncating() } - /// Removes a candidate if they exist and sends them back their deposit - /// If second argument is `true` then a candidate will be slashed - fn try_remove_candidate(who: &T::AccountId, slash: bool) -> Result { + + /// Removes a candidate if they exist. Start deposit un-bonding + fn try_remove_candidate(who: &T::AccountId) -> Result { let current_count = >::try_mutate(|candidates| -> Result { let index = candidates .iter() .position(|candidate| candidate.who == *who) .ok_or(Error::::NotCandidate)?; - let deposit = candidates[index].deposit; - - if slash { - let slash = T::SlashRatio::get() * deposit; - let remain = deposit - slash; - - let (imbalance, _) = T::Currency::slash_reserved(who, slash); - T::Currency::unreserve(who, remain); - if let Some(dest) = Self::slash_destination() { - T::Currency::resolve_creating(&dest, imbalance); - } - - Self::deposit_event(Event::CandidateSlashed(who.clone())); - } else { - T::Currency::unreserve(who, deposit); - } - candidates.remove(index); - >::remove(who.clone()); + let candidate = candidates.remove(index); + let session_index = T::ValidatorSet::session_index().saturating_add(1); + >::insert(&who, (session_index, candidate.deposit)); Ok(candidates.len()) })?; Self::deposit_event(Event::CandidateRemoved(who.clone())); Ok(current_count) } + /// Slash candidate deposit and return the rest of funds. + fn slash_non_candidate(who: &T::AccountId) { + NonCandidates::::mutate_exists(who, |maybe| { + if let Some((_index, deposit)) = maybe.take() { + let slash = T::SlashRatio::get() * deposit; + let remain = deposit.saturating_sub(slash); + + let (imbalance, _) = T::Currency::slash_reserved(who, slash); + T::Currency::unreserve(who, remain); + + if let Some(dest) = Self::slash_destination() { + T::Currency::resolve_creating(&dest, imbalance); + } + + >::remove(who); + + Self::deposit_event(Event::CandidateSlashed(who.clone())); + } + }); + } + /// Assemble the current set of candidates and invulnerables into the next collator set. /// /// This is done on the fly, as frequent as we are told to do so, as the session manager. pub fn assemble_collators(candidates: Vec) -> Vec { let mut collators = Self::invulnerables(); - collators.extend(candidates.into_iter().collect::>()); + collators.extend(candidates.into_iter()); collators } /// Kicks out and candidates that did not produce a block in the kick threshold. - pub fn kick_stale_candidates( - candidates: Vec>>, - ) -> Vec { + /// Return length of candidates before and number of kicked candidates. + pub fn kick_stale_candidates() -> (u32, u32) { let now = frame_system::Pallet::::block_number(); let kick_threshold = T::KickThreshold::get(); - candidates - .into_iter() - .filter_map(|c| { - let last_block = >::get(c.who.clone()); - let since_last = now.saturating_sub(last_block); - if since_last < kick_threshold - || Self::candidates().len() as u32 <= T::MinCandidates::get() - { - Some(c.who) - } else { - let outcome = Self::try_remove_candidate(&c.who, true); - if let Err(why) = outcome { - log::warn!("Failed to remove candidate {:?}", why); - debug_assert!(false, "failed to remove candidate {:?}", why); - } - None + let count = Self::candidates().len() as u32; + for (who, last_authored) in LastAuthoredBlock::::iter() { + if now.saturating_sub(last_authored) < kick_threshold { + continue; + } + // still candidate, kick and slash + if Self::is_account_candidate(&who) { + if Self::candidates().len() > T::MinCandidates::get() as usize { + // no error, who is a candidate + let _ = Self::try_remove_candidate(&who); + Self::slash_non_candidate(&who); } - }) - .collect::>() + } else { + // slash un-bonding candidate + Self::slash_non_candidate(&who); + } + } + (count, count.saturating_sub(Self::candidates().len() as u32)) } /// Check whether an account is a candidate. @@ -547,18 +605,18 @@ pub mod pallet { >::block_number(), ); - let candidates = Self::candidates(); - let candidates_len_before = candidates.len(); - let active_candidates = Self::kick_stale_candidates(candidates); - let active_candidates_len = active_candidates.len(); - let result = Self::assemble_collators(active_candidates); - let removed = candidates_len_before - active_candidates_len; - + let (candidates_len_before, removed) = Self::kick_stale_candidates(); frame_system::Pallet::::register_extra_weight_unchecked( - T::WeightInfo::new_session(candidates_len_before as u32, removed as u32), + T::WeightInfo::new_session(candidates_len_before, removed), DispatchClass::Mandatory, ); - Some(result) + + let active_candidates = Self::candidates() + .into_iter() + .map(|x| x.who) + .collect::>(); + + Some(Self::assemble_collators(active_candidates)) } fn start_session(_: SessionIndex) { // we don't care. diff --git a/pallets/collator-selection/src/mock.rs b/pallets/collator-selection/src/mock.rs index e113daa653..e2810c9bd2 100644 --- a/pallets/collator-selection/src/mock.rs +++ b/pallets/collator-selection/src/mock.rs @@ -146,7 +146,8 @@ impl From for MockSessionKeys { } parameter_types! { - pub static SessionHandlerCollators: Vec = Vec::new(); + pub static SessionCollators: Vec = Vec::new(); + pub static NextSessionCollators: Vec = Vec::new(); pub static SessionChangeBlock: u64 = 0; } @@ -154,12 +155,13 @@ pub struct TestSessionHandler; impl pallet_session::SessionHandler for TestSessionHandler { const KEY_TYPE_IDS: &'static [sp_runtime::KeyTypeId] = &[UintAuthorityId::ID]; fn on_genesis_session(keys: &[(u64, Ks)]) { - SessionHandlerCollators::set(keys.into_iter().map(|(a, _)| *a).collect::>()) + SessionCollators::set(keys.into_iter().map(|(a, _)| *a).collect::>()) } - fn on_new_session(_: bool, keys: &[(u64, Ks)], _: &[(u64, Ks)]) { + fn on_new_session(_: bool, keys: &[(u64, Ks)], next_keys: &[(u64, Ks)]) { SessionChangeBlock::set(System::block_number()); dbg!(keys.len()); - SessionHandlerCollators::set(keys.into_iter().map(|(a, _)| *a).collect::>()) + SessionCollators::set(keys.into_iter().map(|(a, _)| *a).collect::>()); + NextSessionCollators::set(next_keys.into_iter().map(|(a, _)| *a).collect::>()); } fn on_before_session_ending() {} fn on_disabled(_: u32) {} @@ -228,6 +230,7 @@ impl Config for Test { type ValidatorId = ::AccountId; type ValidatorIdOf = IdentityCollator; type ValidatorRegistration = IsRegistered; + type ValidatorSet = Session; type SlashRatio = SlashRatio; type AccountCheck = DummyAccountCheck; type WeightInfo = (); diff --git a/pallets/collator-selection/src/tests.rs b/pallets/collator-selection/src/tests.rs index 343e109607..099c46a1f5 100644 --- a/pallets/collator-selection/src/tests.rs +++ b/pallets/collator-selection/src/tests.rs @@ -16,7 +16,7 @@ // limitations under the License. use crate as collator_selection; -use crate::{mock::*, CandidateInfo, Error}; +use crate::{mock::*, CandidateInfo, Error, LastAuthoredBlock, NonCandidates}; use frame_support::{ assert_noop, assert_ok, traits::{Currency, OnInitialize}, @@ -265,6 +265,7 @@ fn leave_intent() { RuntimeOrigin::signed(5) )); assert_eq!(Balances::free_balance(5), 90); + assert_eq!(Balances::reserved_balance(3), 10); // cannot leave if not candidate. assert_noop!( @@ -272,13 +273,89 @@ fn leave_intent() { Error::::NotCandidate ); - // bond is returned + // candidacy removed and unbonding started assert_ok!(CollatorSelection::leave_intent(RuntimeOrigin::signed(3))); + assert_eq!(Balances::free_balance(3), 90); + assert_eq!(Balances::reserved_balance(3), 10); + assert_eq!(CollatorSelection::last_authored_block(3), 10); + // 10 unbonding from session 1 + assert_eq!(NonCandidates::::get(3), (1, 10)); + }); +} + +#[test] +fn withdraw_unbond() { + new_test_ext().execute_with(|| { + // register a candidate. + assert_ok!(CollatorSelection::register_as_candidate( + RuntimeOrigin::signed(3) + )); + // register too so can leave above min candidates + assert_ok!(CollatorSelection::register_as_candidate( + RuntimeOrigin::signed(5) + )); + assert_ok!(CollatorSelection::leave_intent(RuntimeOrigin::signed(3))); + + initialize_to_block(9); + + // cannot register again during un-bonding + assert_noop!( + CollatorSelection::register_as_candidate(RuntimeOrigin::signed(3)), + Error::::BondStillLocked + ); + assert_noop!( + CollatorSelection::withdraw_bond(RuntimeOrigin::signed(3)), + Error::::BondStillLocked + ); + + initialize_to_block(10); + assert_ok!(CollatorSelection::withdraw_bond(RuntimeOrigin::signed(3))); + assert_eq!(NonCandidates::::get(3), (0, 0)); assert_eq!(Balances::free_balance(3), 100); - assert_eq!(CollatorSelection::last_authored_block(3), 0); + assert_eq!(Balances::reserved_balance(3), 0); + + assert_noop!( + CollatorSelection::withdraw_bond(RuntimeOrigin::signed(3)), + Error::::NoCandidacyBond + ); }); } +#[test] +fn re_register_with_unbonding() { + new_test_ext().execute_with(|| { + // register a candidate. + assert_ok!(CollatorSelection::register_as_candidate( + RuntimeOrigin::signed(3) + )); + // register too so can leave above min candidates + assert_ok!(CollatorSelection::register_as_candidate( + RuntimeOrigin::signed(5) + )); + assert_eq!(Balances::free_balance(3), 90); + assert_eq!(Balances::reserved_balance(3), 10); + assert_ok!(CollatorSelection::leave_intent(RuntimeOrigin::signed(3))); + assert_eq!(Balances::free_balance(3), 90); + assert_eq!(Balances::reserved_balance(3), 10); + + // still on current session + initialize_to_block(9); + + // cannot register again during un-bonding + assert_noop!( + CollatorSelection::register_as_candidate(RuntimeOrigin::signed(3)), + Error::::BondStillLocked + ); + initialize_to_block(10); + assert_ok!(CollatorSelection::register_as_candidate( + RuntimeOrigin::signed(3) + )); + // previous bond is unreserved and reserved again + assert_eq!(Balances::free_balance(3), 90); + assert_eq!(Balances::reserved_balance(3), 10); + }) +} + #[test] fn authorship_event_handler() { new_test_ext().execute_with(|| { @@ -343,12 +420,12 @@ fn session_management_works() { initialize_to_block(1); assert_eq!(SessionChangeBlock::get(), 0); - assert_eq!(SessionHandlerCollators::get(), vec![1, 2]); + assert_eq!(SessionCollators::get(), vec![1, 2]); initialize_to_block(4); assert_eq!(SessionChangeBlock::get(), 0); - assert_eq!(SessionHandlerCollators::get(), vec![1, 2]); + assert_eq!(SessionCollators::get(), vec![1, 2]); // add a new collator assert_ok!(CollatorSelection::register_as_candidate( @@ -356,7 +433,7 @@ fn session_management_works() { )); // session won't see this. - assert_eq!(SessionHandlerCollators::get(), vec![1, 2]); + assert_eq!(SessionCollators::get(), vec![1, 2]); // but we have a new candidate. assert_eq!(CollatorSelection::candidates().len(), 1); @@ -367,12 +444,12 @@ fn session_management_works() { // queued ones are changed, and now we have 3. assert_eq!(Session::queued_keys().len(), 3); // session handlers (aura, et. al.) cannot see this yet. - assert_eq!(SessionHandlerCollators::get(), vec![1, 2]); + assert_eq!(SessionCollators::get(), vec![1, 2]); initialize_to_block(20); assert_eq!(SessionChangeBlock::get(), 20); // changed are now reflected to session handlers. - assert_eq!(SessionHandlerCollators::get(), vec![1, 2, 3]); + assert_eq!(SessionCollators::get(), vec![1, 2, 3]); }); } @@ -392,10 +469,11 @@ fn kick_and_slash_mechanism() { assert_eq!(CollatorSelection::candidates().len(), 2); initialize_to_block(20); assert_eq!(SessionChangeBlock::get(), 20); - // 4 authored this block, gets to stay 3 was kicked + // 4 authored this block, gets to stay. 3 was kicked assert_eq!(CollatorSelection::candidates().len(), 1); // 3 will be kicked after 1 session delay - assert_eq!(SessionHandlerCollators::get(), vec![1, 2, 3, 4]); + assert_eq!(SessionCollators::get(), vec![1, 2, 3, 4]); + assert_eq!(NextSessionCollators::get(), vec![1, 2, 4]); let collator = CandidateInfo { who: 4, deposit: 10, @@ -404,13 +482,59 @@ fn kick_and_slash_mechanism() { assert_eq!(CollatorSelection::last_authored_block(4), 20); initialize_to_block(30); // 3 gets kicked after 1 session delay - assert_eq!(SessionHandlerCollators::get(), vec![1, 2, 4]); + assert_eq!(SessionCollators::get(), vec![1, 2, 4]); // kicked collator gets funds back except slashed 10% (of 10 bond) assert_eq!(Balances::free_balance(3), 99); assert_eq!(Balances::free_balance(5), 101); }); } +#[test] +fn slash_mechanism_for_unbonding_candidates() { + new_test_ext().execute_with(|| { + // Define slash destination account + >::put(5); + // add a new collator + assert_ok!(CollatorSelection::register_as_candidate( + RuntimeOrigin::signed(3) + )); + assert_ok!(CollatorSelection::register_as_candidate( + RuntimeOrigin::signed(4) + )); + assert_eq!(CollatorSelection::last_authored_block(3), 10); + assert_eq!(CollatorSelection::last_authored_block(4), 10); + + initialize_to_block(10); + // gets included into next session, expected to build blocks + assert_eq!(NextSessionCollators::get(), vec![1, 2, 3, 4]); + // candidate left but still expected to produce blocks for current session + assert_ok!(CollatorSelection::leave_intent(RuntimeOrigin::signed(3))); + assert_eq!(Balances::free_balance(3), 90); // funds un-bonding + initialize_to_block(19); + // not there yet + assert_noop!( + CollatorSelection::withdraw_bond(RuntimeOrigin::signed(3)), + Error::::BondStillLocked + ); + // new session, candidate gets slashed + initialize_to_block(20); + assert_eq!(CollatorSelection::candidates().len(), 1); + assert_eq!(SessionChangeBlock::get(), 20); + assert_eq!(LastAuthoredBlock::::contains_key(3), false); + assert_eq!(CollatorSelection::last_authored_block(4), 20); + + // slashed, remaining bond was refunded + assert_noop!( + CollatorSelection::withdraw_bond(RuntimeOrigin::signed(3)), + Error::::NoCandidacyBond + ); + + // slashed collator gets funds back except slashed 10% (of 10 bond) + assert_eq!(Balances::free_balance(3), 99); + assert_eq!(Balances::free_balance(5), 101); + }); +} + #[test] fn should_not_kick_mechanism_too_few() { new_test_ext().execute_with(|| { @@ -425,21 +549,23 @@ fn should_not_kick_mechanism_too_few() { assert_eq!(CollatorSelection::candidates().len(), 2); initialize_to_block(20); assert_eq!(SessionChangeBlock::get(), 20); - // 4 authored this block, 5 gets to stay too few 3 was kicked + // 4 authored this block, 3 gets to stay too few, 5 was kicked assert_eq!(CollatorSelection::candidates().len(), 1); - // 3 will be kicked after 1 session delay - assert_eq!(SessionHandlerCollators::get(), vec![1, 2, 3, 5]); - let collator = CandidateInfo { - who: 5, - deposit: 10, - }; - assert_eq!(CollatorSelection::candidates(), vec![collator]); + // 5 will be kicked for next session + assert_eq!(NextSessionCollators::get(), vec![1, 2, 3]); + assert_eq!( + CollatorSelection::candidates(), + vec![CandidateInfo { + who: 3, + deposit: 10, + }] + ); assert_eq!(CollatorSelection::last_authored_block(4), 20); - initialize_to_block(30); - // 3 gets kicked after 1 session delay - assert_eq!(SessionHandlerCollators::get(), vec![1, 2, 5]); // kicked collator gets funds back (but slashed) - assert_eq!(Balances::free_balance(3), 99); + assert_eq!(Balances::free_balance(5), 99); + initialize_to_block(30); + // next session doesn't include 5 + assert_eq!(SessionCollators::get(), vec![1, 2, 3]); }); } diff --git a/pallets/collator-selection/src/weights.rs b/pallets/collator-selection/src/weights.rs index 7946818e8a..99b15232e6 100644 --- a/pallets/collator-selection/src/weights.rs +++ b/pallets/collator-selection/src/weights.rs @@ -2,27 +2,28 @@ // This file is part of Astar. // Copyright (C) Stake Technologies Pte.Ltd. -// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: GPL-3.0-or-later -// 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. +// Astar is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Astar is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Astar. If not, see . //! Autogenerated weights for pallet_collator_selection //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2024-02-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-06-26, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `gh-runner-01-ovh`, CPU: `Intel(R) Xeon(R) E-2236 CPU @ 3.40GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("shiden-dev"), DB CACHE: 1024 +//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: Some("shiden-dev"), DB CACHE: 1024 // Executed Command: // ./target/release/astar-collator @@ -31,12 +32,12 @@ // --chain=shiden-dev // --steps=50 // --repeat=20 -// --pallet=pallet_collator_selection +// --pallet=pallet-collator-selection // --extrinsic=* // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --output=./benchmark-results/shiden-dev/collator_selection_weights.rs +// --output=./benchmark-results/shiden-dev/pallet-collator-selection_weights.rs // --template=./scripts/templates/weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -53,6 +54,7 @@ pub trait WeightInfo { fn set_candidacy_bond() -> Weight; fn register_as_candidate(c: u32, ) -> Weight; fn leave_intent(c: u32, ) -> Weight; + fn withdraw_bond() -> Weight; fn note_author() -> Weight; fn new_session(r: u32, c: u32, ) -> Weight; } @@ -60,248 +62,294 @@ pub trait WeightInfo { /// Weights for pallet_collator_selection using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - /// Storage: Session NextKeys (r:48 w:0) - /// Proof Skipped: Session NextKeys (max_values: None, max_size: None, mode: Measured) - /// Storage: CollatorSelection Invulnerables (r:0 w:1) - /// Proof Skipped: CollatorSelection Invulnerables (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: `Session::NextKeys` (r:48 w:0) + /// Proof: `Session::NextKeys` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `CollatorSelection::Invulnerables` (r:0 w:1) + /// Proof: `CollatorSelection::Invulnerables` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) /// The range of component `b` is `[1, 48]`. fn set_invulnerables(b: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `204 + b * (79 ±0)` // Estimated: `1194 + b * (2554 ±0)` - // Minimum execution time: 13_733_000 picoseconds. - Weight::from_parts(14_576_858, 1194) - // Standard Error: 4_742 - .saturating_add(Weight::from_parts(2_507_115, 0).saturating_mul(b.into())) + // Minimum execution time: 11_169_000 picoseconds. + Weight::from_parts(11_917_783, 1194) + // Standard Error: 4_757 + .saturating_add(Weight::from_parts(2_433_455, 0).saturating_mul(b.into())) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(b.into()))) .saturating_add(T::DbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 2554).saturating_mul(b.into())) } - /// Storage: CollatorSelection DesiredCandidates (r:0 w:1) - /// Proof Skipped: CollatorSelection DesiredCandidates (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: `CollatorSelection::DesiredCandidates` (r:0 w:1) + /// Proof: `CollatorSelection::DesiredCandidates` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn set_desired_candidates() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_143_000 picoseconds. - Weight::from_parts(7_357_000, 0) + // Minimum execution time: 5_229_000 picoseconds. + Weight::from_parts(5_400_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } - /// Storage: CollatorSelection CandidacyBond (r:0 w:1) - /// Proof Skipped: CollatorSelection CandidacyBond (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: `CollatorSelection::CandidacyBond` (r:0 w:1) + /// Proof: `CollatorSelection::CandidacyBond` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn set_candidacy_bond() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_292_000 picoseconds. - Weight::from_parts(7_433_000, 0) + // Minimum execution time: 5_266_000 picoseconds. + Weight::from_parts(5_521_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } - /// Storage: CollatorSelection Candidates (r:1 w:1) - /// Proof Skipped: CollatorSelection Candidates (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: CollatorSelection DesiredCandidates (r:1 w:0) - /// Proof Skipped: CollatorSelection DesiredCandidates (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: CollatorSelection Invulnerables (r:1 w:0) - /// Proof Skipped: CollatorSelection Invulnerables (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: DappStaking Ledger (r:1 w:0) - /// Proof: DappStaking Ledger (max_values: None, max_size: Some(310), added: 2785, mode: MaxEncodedLen) - /// Storage: Session NextKeys (r:1 w:0) - /// Proof Skipped: Session NextKeys (max_values: None, max_size: None, mode: Measured) - /// Storage: CollatorSelection CandidacyBond (r:1 w:0) - /// Proof Skipped: CollatorSelection CandidacyBond (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: CollatorSelection LastAuthoredBlock (r:0 w:1) - /// Proof Skipped: CollatorSelection LastAuthoredBlock (max_values: None, max_size: None, mode: Measured) + /// Storage: `CollatorSelection::Candidates` (r:1 w:1) + /// Proof: `CollatorSelection::Candidates` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `CollatorSelection::DesiredCandidates` (r:1 w:0) + /// Proof: `CollatorSelection::DesiredCandidates` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `CollatorSelection::Invulnerables` (r:1 w:0) + /// Proof: `CollatorSelection::Invulnerables` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `DappStaking::Ledger` (r:1 w:0) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `Session::NextKeys` (r:1 w:0) + /// Proof: `Session::NextKeys` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `CollatorSelection::NonCandidates` (r:1 w:1) + /// Proof: `CollatorSelection::NonCandidates` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `CollatorSelection::CandidacyBond` (r:1 w:0) + /// Proof: `CollatorSelection::CandidacyBond` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `CollatorSelection::LastAuthoredBlock` (r:0 w:1) + /// Proof: `CollatorSelection::LastAuthoredBlock` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `c` is `[1, 148]`. fn register_as_candidate(c: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `962 + c * (50 ±0)` // Estimated: `4307 + c * (51 ±0)` - // Minimum execution time: 44_695_000 picoseconds. - Weight::from_parts(46_834_255, 4307) - // Standard Error: 586 - .saturating_add(Weight::from_parts(44_873, 0).saturating_mul(c.into())) - .saturating_add(T::DbWeight::get().reads(6_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) + // Minimum execution time: 38_433_000 picoseconds. + Weight::from_parts(40_514_505, 4307) + // Standard Error: 539 + .saturating_add(Weight::from_parts(48_079, 0).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(7_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 51).saturating_mul(c.into())) } - /// Storage: CollatorSelection Candidates (r:1 w:1) - /// Proof Skipped: CollatorSelection Candidates (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: CollatorSelection LastAuthoredBlock (r:0 w:1) - /// Proof Skipped: CollatorSelection LastAuthoredBlock (max_values: None, max_size: None, mode: Measured) + /// Storage: `CollatorSelection::Candidates` (r:1 w:1) + /// Proof: `CollatorSelection::Candidates` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Session::CurrentIndex` (r:1 w:0) + /// Proof: `Session::CurrentIndex` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `CollatorSelection::NonCandidates` (r:0 w:1) + /// Proof: `CollatorSelection::NonCandidates` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `c` is `[6, 148]`. fn leave_intent(c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `342 + c * (49 ±0)` - // Estimated: `1845 + c * (49 ±0)` - // Minimum execution time: 30_579_000 picoseconds. - Weight::from_parts(34_125_189, 1845) - // Standard Error: 1_048 - .saturating_add(Weight::from_parts(45_625, 0).saturating_mul(c.into())) - .saturating_add(T::DbWeight::get().reads(1_u64)) + // Measured: `734 + c * (48 ±0)` + // Estimated: `2178 + c * (49 ±0)` + // Minimum execution time: 16_910_000 picoseconds. + Weight::from_parts(17_595_269, 2178) + // Standard Error: 442 + .saturating_add(Weight::from_parts(38_279, 0).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) .saturating_add(Weight::from_parts(0, 49).saturating_mul(c.into())) } - /// Storage: System Account (r:2 w:2) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: CollatorSelection LastAuthoredBlock (r:0 w:1) - /// Proof Skipped: CollatorSelection LastAuthoredBlock (max_values: None, max_size: None, mode: Measured) + /// Storage: `CollatorSelection::NonCandidates` (r:1 w:1) + /// Proof: `CollatorSelection::NonCandidates` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Session::CurrentIndex` (r:1 w:0) + /// Proof: `Session::CurrentIndex` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `CollatorSelection::LastAuthoredBlock` (r:0 w:1) + /// Proof: `CollatorSelection::LastAuthoredBlock` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn withdraw_bond() -> Weight { + // Proof Size summary in bytes: + // Measured: `725` + // Estimated: `4190` + // Minimum execution time: 28_804_000 picoseconds. + Weight::from_parts(29_066_000, 4190) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: `System::Account` (r:2 w:2) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `CollatorSelection::LastAuthoredBlock` (r:0 w:1) + /// Proof: `CollatorSelection::LastAuthoredBlock` (`max_values`: None, `max_size`: None, mode: `Measured`) fn note_author() -> Weight { // Proof Size summary in bytes: // Measured: `226` // Estimated: `6196` - // Minimum execution time: 43_377_000 picoseconds. - Weight::from_parts(43_827_000, 6196) + // Minimum execution time: 35_307_000 picoseconds. + Weight::from_parts(35_803_000, 6196) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } - /// Storage: CollatorSelection Candidates (r:1 w:0) - /// Proof Skipped: CollatorSelection Candidates (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: CollatorSelection LastAuthoredBlock (r:148 w:0) - /// Proof Skipped: CollatorSelection LastAuthoredBlock (max_values: None, max_size: None, mode: Measured) - /// Storage: CollatorSelection Invulnerables (r:1 w:0) - /// Proof Skipped: CollatorSelection Invulnerables (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: System Account (r:143 w:143) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: CollatorSelection SlashDestination (r:1 w:0) - /// Proof Skipped: CollatorSelection SlashDestination (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: `CollatorSelection::Candidates` (r:1 w:0) + /// Proof: `CollatorSelection::Candidates` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `CollatorSelection::LastAuthoredBlock` (r:149 w:0) + /// Proof: `CollatorSelection::LastAuthoredBlock` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `CollatorSelection::Invulnerables` (r:1 w:0) + /// Proof: `CollatorSelection::Invulnerables` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Session::CurrentIndex` (r:1 w:0) + /// Proof: `Session::CurrentIndex` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:143 w:143) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `CollatorSelection::SlashDestination` (r:1 w:0) + /// Proof: `CollatorSelection::SlashDestination` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `CollatorSelection::NonCandidates` (r:0 w:143) + /// Proof: `CollatorSelection::NonCandidates` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[1, 148]`. /// The range of component `c` is `[1, 148]`. fn new_session(r: u32, c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `3902 + c * (97 ±0) + r * (112 ±0)` - // Estimated: `3818 + c * (2632 ±2) + r * (2599 ±0)` - // Minimum execution time: 17_957_000 picoseconds. - Weight::from_parts(18_201_000, 3818) - // Standard Error: 564_328 - .saturating_add(Weight::from_parts(18_024_338, 0).saturating_mul(c.into())) - .saturating_add(T::DbWeight::get().reads(3_u64)) + // Measured: `4554 + c * (97 ±0) + r * (112 ±0)` + // Estimated: `6296 + c * (2637 ±0) + r * (2599 ±0)` + // Minimum execution time: 20_506_000 picoseconds. + Weight::from_parts(20_755_000, 6296) + // Standard Error: 503_081 + .saturating_add(Weight::from_parts(16_868_215, 0).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(c.into()))) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(c.into()))) - .saturating_add(Weight::from_parts(0, 2632).saturating_mul(c.into())) + .saturating_add(Weight::from_parts(0, 2637).saturating_mul(c.into())) .saturating_add(Weight::from_parts(0, 2599).saturating_mul(r.into())) } } // For backwards compatibility and tests impl WeightInfo for () { - /// Storage: Session NextKeys (r:48 w:0) - /// Proof Skipped: Session NextKeys (max_values: None, max_size: None, mode: Measured) - /// Storage: CollatorSelection Invulnerables (r:0 w:1) - /// Proof Skipped: CollatorSelection Invulnerables (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: `Session::NextKeys` (r:48 w:0) + /// Proof: `Session::NextKeys` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `CollatorSelection::Invulnerables` (r:0 w:1) + /// Proof: `CollatorSelection::Invulnerables` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) /// The range of component `b` is `[1, 48]`. fn set_invulnerables(b: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `204 + b * (79 ±0)` // Estimated: `1194 + b * (2554 ±0)` - // Minimum execution time: 13_733_000 picoseconds. - Weight::from_parts(14_576_858, 1194) - // Standard Error: 4_742 - .saturating_add(Weight::from_parts(2_507_115, 0).saturating_mul(b.into())) + // Minimum execution time: 11_169_000 picoseconds. + Weight::from_parts(11_917_783, 1194) + // Standard Error: 4_757 + .saturating_add(Weight::from_parts(2_433_455, 0).saturating_mul(b.into())) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(b.into()))) .saturating_add(RocksDbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 2554).saturating_mul(b.into())) } - /// Storage: CollatorSelection DesiredCandidates (r:0 w:1) - /// Proof Skipped: CollatorSelection DesiredCandidates (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: `CollatorSelection::DesiredCandidates` (r:0 w:1) + /// Proof: `CollatorSelection::DesiredCandidates` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn set_desired_candidates() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_143_000 picoseconds. - Weight::from_parts(7_357_000, 0) + // Minimum execution time: 5_229_000 picoseconds. + Weight::from_parts(5_400_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } - /// Storage: CollatorSelection CandidacyBond (r:0 w:1) - /// Proof Skipped: CollatorSelection CandidacyBond (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: `CollatorSelection::CandidacyBond` (r:0 w:1) + /// Proof: `CollatorSelection::CandidacyBond` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn set_candidacy_bond() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_292_000 picoseconds. - Weight::from_parts(7_433_000, 0) + // Minimum execution time: 5_266_000 picoseconds. + Weight::from_parts(5_521_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } - /// Storage: CollatorSelection Candidates (r:1 w:1) - /// Proof Skipped: CollatorSelection Candidates (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: CollatorSelection DesiredCandidates (r:1 w:0) - /// Proof Skipped: CollatorSelection DesiredCandidates (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: CollatorSelection Invulnerables (r:1 w:0) - /// Proof Skipped: CollatorSelection Invulnerables (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: DappStaking Ledger (r:1 w:0) - /// Proof: DappStaking Ledger (max_values: None, max_size: Some(310), added: 2785, mode: MaxEncodedLen) - /// Storage: Session NextKeys (r:1 w:0) - /// Proof Skipped: Session NextKeys (max_values: None, max_size: None, mode: Measured) - /// Storage: CollatorSelection CandidacyBond (r:1 w:0) - /// Proof Skipped: CollatorSelection CandidacyBond (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: CollatorSelection LastAuthoredBlock (r:0 w:1) - /// Proof Skipped: CollatorSelection LastAuthoredBlock (max_values: None, max_size: None, mode: Measured) + /// Storage: `CollatorSelection::Candidates` (r:1 w:1) + /// Proof: `CollatorSelection::Candidates` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `CollatorSelection::DesiredCandidates` (r:1 w:0) + /// Proof: `CollatorSelection::DesiredCandidates` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `CollatorSelection::Invulnerables` (r:1 w:0) + /// Proof: `CollatorSelection::Invulnerables` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `DappStaking::Ledger` (r:1 w:0) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `Session::NextKeys` (r:1 w:0) + /// Proof: `Session::NextKeys` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `CollatorSelection::NonCandidates` (r:1 w:1) + /// Proof: `CollatorSelection::NonCandidates` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `CollatorSelection::CandidacyBond` (r:1 w:0) + /// Proof: `CollatorSelection::CandidacyBond` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `CollatorSelection::LastAuthoredBlock` (r:0 w:1) + /// Proof: `CollatorSelection::LastAuthoredBlock` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `c` is `[1, 148]`. fn register_as_candidate(c: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `962 + c * (50 ±0)` // Estimated: `4307 + c * (51 ±0)` - // Minimum execution time: 44_695_000 picoseconds. - Weight::from_parts(46_834_255, 4307) - // Standard Error: 586 - .saturating_add(Weight::from_parts(44_873, 0).saturating_mul(c.into())) - .saturating_add(RocksDbWeight::get().reads(6_u64)) - .saturating_add(RocksDbWeight::get().writes(2_u64)) + // Minimum execution time: 38_433_000 picoseconds. + Weight::from_parts(40_514_505, 4307) + // Standard Error: 539 + .saturating_add(Weight::from_parts(48_079, 0).saturating_mul(c.into())) + .saturating_add(RocksDbWeight::get().reads(7_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 51).saturating_mul(c.into())) } - /// Storage: CollatorSelection Candidates (r:1 w:1) - /// Proof Skipped: CollatorSelection Candidates (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: CollatorSelection LastAuthoredBlock (r:0 w:1) - /// Proof Skipped: CollatorSelection LastAuthoredBlock (max_values: None, max_size: None, mode: Measured) + /// Storage: `CollatorSelection::Candidates` (r:1 w:1) + /// Proof: `CollatorSelection::Candidates` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Session::CurrentIndex` (r:1 w:0) + /// Proof: `Session::CurrentIndex` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `CollatorSelection::NonCandidates` (r:0 w:1) + /// Proof: `CollatorSelection::NonCandidates` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `c` is `[6, 148]`. fn leave_intent(c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `342 + c * (49 ±0)` - // Estimated: `1845 + c * (49 ±0)` - // Minimum execution time: 30_579_000 picoseconds. - Weight::from_parts(34_125_189, 1845) - // Standard Error: 1_048 - .saturating_add(Weight::from_parts(45_625, 0).saturating_mul(c.into())) - .saturating_add(RocksDbWeight::get().reads(1_u64)) + // Measured: `734 + c * (48 ±0)` + // Estimated: `2178 + c * (49 ±0)` + // Minimum execution time: 16_910_000 picoseconds. + Weight::from_parts(17_595_269, 2178) + // Standard Error: 442 + .saturating_add(Weight::from_parts(38_279, 0).saturating_mul(c.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) .saturating_add(Weight::from_parts(0, 49).saturating_mul(c.into())) } - /// Storage: System Account (r:2 w:2) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: CollatorSelection LastAuthoredBlock (r:0 w:1) - /// Proof Skipped: CollatorSelection LastAuthoredBlock (max_values: None, max_size: None, mode: Measured) + /// Storage: `CollatorSelection::NonCandidates` (r:1 w:1) + /// Proof: `CollatorSelection::NonCandidates` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Session::CurrentIndex` (r:1 w:0) + /// Proof: `Session::CurrentIndex` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `CollatorSelection::LastAuthoredBlock` (r:0 w:1) + /// Proof: `CollatorSelection::LastAuthoredBlock` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn withdraw_bond() -> Weight { + // Proof Size summary in bytes: + // Measured: `725` + // Estimated: `4190` + // Minimum execution time: 28_804_000 picoseconds. + Weight::from_parts(29_066_000, 4190) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: `System::Account` (r:2 w:2) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `CollatorSelection::LastAuthoredBlock` (r:0 w:1) + /// Proof: `CollatorSelection::LastAuthoredBlock` (`max_values`: None, `max_size`: None, mode: `Measured`) fn note_author() -> Weight { // Proof Size summary in bytes: // Measured: `226` // Estimated: `6196` - // Minimum execution time: 43_377_000 picoseconds. - Weight::from_parts(43_827_000, 6196) + // Minimum execution time: 35_307_000 picoseconds. + Weight::from_parts(35_803_000, 6196) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } - /// Storage: CollatorSelection Candidates (r:1 w:0) - /// Proof Skipped: CollatorSelection Candidates (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: CollatorSelection LastAuthoredBlock (r:148 w:0) - /// Proof Skipped: CollatorSelection LastAuthoredBlock (max_values: None, max_size: None, mode: Measured) - /// Storage: CollatorSelection Invulnerables (r:1 w:0) - /// Proof Skipped: CollatorSelection Invulnerables (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: System Account (r:143 w:143) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: CollatorSelection SlashDestination (r:1 w:0) - /// Proof Skipped: CollatorSelection SlashDestination (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: `CollatorSelection::Candidates` (r:1 w:0) + /// Proof: `CollatorSelection::Candidates` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `CollatorSelection::LastAuthoredBlock` (r:149 w:0) + /// Proof: `CollatorSelection::LastAuthoredBlock` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `CollatorSelection::Invulnerables` (r:1 w:0) + /// Proof: `CollatorSelection::Invulnerables` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Session::CurrentIndex` (r:1 w:0) + /// Proof: `Session::CurrentIndex` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:143 w:143) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `CollatorSelection::SlashDestination` (r:1 w:0) + /// Proof: `CollatorSelection::SlashDestination` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `CollatorSelection::NonCandidates` (r:0 w:143) + /// Proof: `CollatorSelection::NonCandidates` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[1, 148]`. /// The range of component `c` is `[1, 148]`. fn new_session(r: u32, c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `3902 + c * (97 ±0) + r * (112 ±0)` - // Estimated: `3818 + c * (2632 ±2) + r * (2599 ±0)` - // Minimum execution time: 17_957_000 picoseconds. - Weight::from_parts(18_201_000, 3818) - // Standard Error: 564_328 - .saturating_add(Weight::from_parts(18_024_338, 0).saturating_mul(c.into())) - .saturating_add(RocksDbWeight::get().reads(3_u64)) + // Measured: `4554 + c * (97 ±0) + r * (112 ±0)` + // Estimated: `6296 + c * (2637 ±0) + r * (2599 ±0)` + // Minimum execution time: 20_506_000 picoseconds. + Weight::from_parts(20_755_000, 6296) + // Standard Error: 503_081 + .saturating_add(Weight::from_parts(16_868_215, 0).saturating_mul(c.into())) + .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(c.into()))) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(c.into()))) - .saturating_add(Weight::from_parts(0, 2632).saturating_mul(c.into())) + .saturating_add(Weight::from_parts(0, 2637).saturating_mul(c.into())) .saturating_add(Weight::from_parts(0, 2599).saturating_mul(r.into())) } } diff --git a/runtime/astar/src/lib.rs b/runtime/astar/src/lib.rs index 7f54a0add2..0a29385053 100644 --- a/runtime/astar/src/lib.rs +++ b/runtime/astar/src/lib.rs @@ -517,6 +517,7 @@ impl pallet_collator_selection::Config for Runtime { type ValidatorId = ::AccountId; type ValidatorIdOf = pallet_collator_selection::IdentityCollator; type ValidatorRegistration = Session; + type ValidatorSet = Session; type SlashRatio = SlashRatio; type AccountCheck = CollatorSelectionAccountCheck; type WeightInfo = pallet_collator_selection::weights::SubstrateWeight; diff --git a/runtime/shibuya/src/lib.rs b/runtime/shibuya/src/lib.rs index 88ff14c231..39520fc295 100644 --- a/runtime/shibuya/src/lib.rs +++ b/runtime/shibuya/src/lib.rs @@ -595,6 +595,7 @@ impl pallet_collator_selection::Config for Runtime { type ValidatorId = ::AccountId; type ValidatorIdOf = pallet_collator_selection::IdentityCollator; type ValidatorRegistration = Session; + type ValidatorSet = Session; type SlashRatio = SlashRatio; type AccountCheck = CollatorSelectionAccountCheck; type WeightInfo = pallet_collator_selection::weights::SubstrateWeight; diff --git a/runtime/shiden/src/lib.rs b/runtime/shiden/src/lib.rs index d30cb06bb4..230f75c64c 100644 --- a/runtime/shiden/src/lib.rs +++ b/runtime/shiden/src/lib.rs @@ -531,6 +531,7 @@ impl pallet_collator_selection::Config for Runtime { type ValidatorId = ::AccountId; type ValidatorIdOf = pallet_collator_selection::IdentityCollator; type ValidatorRegistration = Session; + type ValidatorSet = Session; type SlashRatio = SlashRatio; type AccountCheck = CollatorSelectionAccountCheck; type WeightInfo = pallet_collator_selection::weights::SubstrateWeight;