Struct pallet_collator_selection::pallet::Pallet
source · pub struct Pallet<T>(/* private fields */);Expand description
The Pallet struct, the main type that implements traits and standalone
functions within the pallet.
Implementations§
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn set_invulnerables(
origin: OriginFor<T>,
new: Vec<T::AccountId>
) -> DispatchResult
pub fn set_invulnerables( origin: OriginFor<T>, new: Vec<T::AccountId> ) -> DispatchResult
Set the list of invulnerable (fixed) collators. These collators must do some preparation, namely to have registered session keys.
The call will remove any accounts that have not registered keys from the set. That is,
it is non-atomic; the caller accepts all AccountIds passed in new individually as
acceptable Invulnerables, and is not proposing a set of new Invulnerables.
This call does not maintain mutual exclusivity of Invulnerables and Candidates. It
is recommended to use a batch of add_invulnerable and remove_invulnerable instead. A
batch_all can also be used to enforce atomicity. If any candidates are included in
new, they should be removed with remove_invulnerable_candidate after execution.
Must be called by the UpdateOrigin.
sourcepub fn set_desired_candidates(
origin: OriginFor<T>,
max: u32
) -> DispatchResultWithPostInfo
pub fn set_desired_candidates( origin: OriginFor<T>, max: u32 ) -> DispatchResultWithPostInfo
Set the ideal number of non-invulnerable collators. If lowering this number, then the number of running collators could be higher than this figure. Aside from that edge case, there should be no other way to have more candidates than the desired number.
The origin for this call must be the UpdateOrigin.
sourcepub fn set_candidacy_bond(
origin: OriginFor<T>,
bond: <<T as Config>::Currency as Currency<<T as SystemConfig>::AccountId>>::Balance
) -> DispatchResultWithPostInfo
pub fn set_candidacy_bond( origin: OriginFor<T>, bond: <<T as Config>::Currency as Currency<<T as SystemConfig>::AccountId>>::Balance ) -> DispatchResultWithPostInfo
Set the candidacy bond amount.
If the candidacy bond is increased by this call, all current candidates which have a deposit lower than the new bond will be kicked from the list and get their deposits back.
The origin for this call must be the UpdateOrigin.
sourcepub fn register_as_candidate(origin: OriginFor<T>) -> DispatchResultWithPostInfo
pub fn register_as_candidate(origin: OriginFor<T>) -> DispatchResultWithPostInfo
Register this account as a collator candidate. The account must (a) already have
registered session keys and (b) be able to reserve the CandidacyBond.
This call is not available to Invulnerable collators.
sourcepub fn leave_intent(origin: OriginFor<T>) -> DispatchResultWithPostInfo
pub fn leave_intent(origin: OriginFor<T>) -> DispatchResultWithPostInfo
Deregister origin as a collator candidate. Note that the collator can only leave on
session change. The CandidacyBond will be unreserved immediately.
This call will fail if the total number of candidates would drop below
MinEligibleCollators.
sourcepub fn add_invulnerable(
origin: OriginFor<T>,
who: T::AccountId
) -> DispatchResultWithPostInfo
pub fn add_invulnerable( origin: OriginFor<T>, who: T::AccountId ) -> DispatchResultWithPostInfo
Add a new account who to the list of Invulnerables collators. who must have
registered session keys. If who is a candidate, they will be removed.
The origin for this call must be the UpdateOrigin.
sourcepub fn remove_invulnerable(
origin: OriginFor<T>,
who: T::AccountId
) -> DispatchResult
pub fn remove_invulnerable( origin: OriginFor<T>, who: T::AccountId ) -> DispatchResult
Remove an account who from the list of Invulnerables collators. Invulnerables must
be sorted.
The origin for this call must be the UpdateOrigin.
sourcepub fn update_bond(
origin: OriginFor<T>,
new_deposit: <<T as Config>::Currency as Currency<<T as SystemConfig>::AccountId>>::Balance
) -> DispatchResultWithPostInfo
pub fn update_bond( origin: OriginFor<T>, new_deposit: <<T as Config>::Currency as Currency<<T as SystemConfig>::AccountId>>::Balance ) -> DispatchResultWithPostInfo
Update the candidacy bond of collator candidate origin to a new amount new_deposit.
Setting a new_deposit that is lower than the current deposit while origin is
occupying a top-DesiredCandidates slot is not allowed.
This call will fail if origin is not a collator candidate, the updated bond is lower
than the minimum candidacy bond, and/or the amount cannot be reserved.
sourcepub fn take_candidate_slot(
origin: OriginFor<T>,
deposit: <<T as Config>::Currency as Currency<<T as SystemConfig>::AccountId>>::Balance,
target: T::AccountId
) -> DispatchResultWithPostInfo
pub fn take_candidate_slot( origin: OriginFor<T>, deposit: <<T as Config>::Currency as Currency<<T as SystemConfig>::AccountId>>::Balance, target: T::AccountId ) -> DispatchResultWithPostInfo
The caller origin replaces a candidate target in the collator candidate list by
reserving deposit. The amount deposit reserved by the caller must be greater than
the existing bond of the target it is trying to replace.
This call will fail if the caller is already a collator candidate or invulnerable, the
caller does not have registered session keys, the target is not a collator candidate,
and/or the deposit amount cannot be reserved.
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn account_id() -> T::AccountId
pub fn account_id() -> T::AccountId
Get a unique, inaccessible account ID from the PotId.
sourcepub fn assemble_collators() -> Vec<T::AccountId>
pub fn assemble_collators() -> Vec<T::AccountId>
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.
sourcepub fn kick_stale_candidates(
candidates: impl IntoIterator<Item = T::AccountId>
) -> u32
pub fn kick_stale_candidates( candidates: impl IntoIterator<Item = T::AccountId> ) -> u32
Kicks out candidates that did not produce a block in the kick threshold and refunds their deposits.
Return value is the number of candidates left in the list.
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn invulnerables() -> BoundedVec<T::AccountId, T::MaxInvulnerables>
pub fn invulnerables() -> BoundedVec<T::AccountId, T::MaxInvulnerables>
An auto-generated getter for Invulnerables.
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn candidate_list(
) -> BoundedVec<CandidateInfo<T::AccountId, <<T as Config>::Currency as Currency<<T as SystemConfig>::AccountId>>::Balance>, T::MaxCandidates>
pub fn candidate_list( ) -> BoundedVec<CandidateInfo<T::AccountId, <<T as Config>::Currency as Currency<<T as SystemConfig>::AccountId>>::Balance>, T::MaxCandidates>
An auto-generated getter for CandidateList.
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
An auto-generated getter for LastAuthoredBlock.
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn desired_candidates() -> u32
pub fn desired_candidates() -> u32
An auto-generated getter for DesiredCandidates.
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn candidacy_bond(
) -> <<T as Config>::Currency as Currency<<T as SystemConfig>::AccountId>>::Balance
pub fn candidacy_bond( ) -> <<T as Config>::Currency as Currency<<T as SystemConfig>::AccountId>>::Balance
An auto-generated getter for CandidacyBond.
Trait Implementations§
source§impl<T: Config> BeforeAllRuntimeMigrations for Pallet<T>
impl<T: Config> BeforeAllRuntimeMigrations for Pallet<T>
source§fn before_all_runtime_migrations() -> Weight
fn before_all_runtime_migrations() -> Weight
source§impl<T: Config + Config> EventHandler<<T as Config>::AccountId, <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
impl<T: Config + Config> EventHandler<<T as Config>::AccountId, <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
Keep track of number of authored blocks per authority, uncles are counted as well since they’re a valid proof of being online.
source§impl<T: Config> GetStorageVersion for Pallet<T>
impl<T: Config> GetStorageVersion for Pallet<T>
source§fn in_code_storage_version() -> Self::InCodeStorageVersion
fn in_code_storage_version() -> Self::InCodeStorageVersion
storage_version attribute, or
NoStorageVersionSet if the attribute is missing.source§fn on_chain_storage_version() -> StorageVersion
fn on_chain_storage_version() -> StorageVersion
source§fn current_storage_version() -> Self::InCodeStorageVersion
fn current_storage_version() -> Self::InCodeStorageVersion
in_code_storage_version and will be removed after March 2024.Self::current_storage_version instead. Read moresource§impl<T: Config> Hooks<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
impl<T: Config> Hooks<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
source§fn integrity_test()
fn integrity_test()
source§fn on_initialize(_n: BlockNumber) -> Weight
fn on_initialize(_n: BlockNumber) -> Weight
source§fn on_finalize(_n: BlockNumber)
fn on_finalize(_n: BlockNumber)
source§fn on_idle(_n: BlockNumber, _remaining_weight: Weight) -> Weight
fn on_idle(_n: BlockNumber, _remaining_weight: Weight) -> Weight
Hooks::on_finalize). Read moresource§fn on_poll(_n: BlockNumber, _weight: &mut WeightMeter)
fn on_poll(_n: BlockNumber, _weight: &mut WeightMeter)
source§fn on_runtime_upgrade() -> Weight
fn on_runtime_upgrade() -> Weight
Executive pallet. Read moresource§fn offchain_worker(_n: BlockNumber)
fn offchain_worker(_n: BlockNumber)
source§impl<T: Config> IntegrityTest for Pallet<T>
impl<T: Config> IntegrityTest for Pallet<T>
source§impl<T: Config> OffchainWorker<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
impl<T: Config> OffchainWorker<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
source§fn offchain_worker(n: BlockNumberFor<T>)
fn offchain_worker(n: BlockNumberFor<T>)
source§impl<T: Config> OnFinalize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
impl<T: Config> OnFinalize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
source§fn on_finalize(n: BlockNumberFor<T>)
fn on_finalize(n: BlockNumberFor<T>)
Hooks::on_finalize.source§impl<T: Config> OnGenesis for Pallet<T>
impl<T: Config> OnGenesis for Pallet<T>
source§fn on_genesis()
fn on_genesis()
source§impl<T: Config> OnIdle<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
impl<T: Config> OnIdle<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
source§fn on_idle(n: BlockNumberFor<T>, remaining_weight: Weight) -> Weight
fn on_idle(n: BlockNumberFor<T>, remaining_weight: Weight) -> Weight
Hooks::on_idle.source§impl<T: Config> OnInitialize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
impl<T: Config> OnInitialize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
source§fn on_initialize(n: BlockNumberFor<T>) -> Weight
fn on_initialize(n: BlockNumberFor<T>) -> Weight
Hooks::on_initialize.source§impl<T: Config> OnPoll<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
impl<T: Config> OnPoll<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
source§fn on_poll(n: BlockNumberFor<T>, weight: &mut WeightMeter)
fn on_poll(n: BlockNumberFor<T>, weight: &mut WeightMeter)
source§impl<T: Config> OnRuntimeUpgrade for Pallet<T>
impl<T: Config> OnRuntimeUpgrade for Pallet<T>
source§fn on_runtime_upgrade() -> Weight
fn on_runtime_upgrade() -> Weight
source§impl<T: Config> PalletInfoAccess for Pallet<T>
impl<T: Config> PalletInfoAccess for Pallet<T>
source§fn module_name() -> &'static str
fn module_name() -> &'static str
source§fn crate_version() -> CrateVersion
fn crate_version() -> CrateVersion
source§impl<T: Config> PalletsInfoAccess for Pallet<T>
impl<T: Config> PalletsInfoAccess for Pallet<T>
source§impl<T> PartialEq for Pallet<T>
impl<T> PartialEq for Pallet<T>
source§impl<T: Config> SessionManager<<T as Config>::AccountId> for Pallet<T>
impl<T: Config> SessionManager<<T as Config>::AccountId> for Pallet<T>
Play the role of the session manager.
source§fn new_session(index: SessionIndex) -> Option<Vec<T::AccountId>>
fn new_session(index: SessionIndex) -> Option<Vec<T::AccountId>>
source§fn start_session(_: SessionIndex)
fn start_session(_: SessionIndex)
source§fn end_session(_: SessionIndex)
fn end_session(_: SessionIndex)
source§impl<T: Config> StorageInfoTrait for Pallet<T>
impl<T: Config> StorageInfoTrait for Pallet<T>
fn storage_info() -> Vec<StorageInfo>
source§impl<T: Config> WhitelistedStorageKeys for Pallet<T>
impl<T: Config> WhitelistedStorageKeys for Pallet<T>
source§fn whitelisted_storage_keys() -> Vec<TrackedStorageKey>
fn whitelisted_storage_keys() -> Vec<TrackedStorageKey>
Vec<TrackedStorageKey> indicating the storage keys that
should be whitelisted during benchmarking. This means that those keys
will be excluded from the benchmarking performance calculation.impl<T> Eq for Pallet<T>
Auto Trait Implementations§
impl<T> Freeze for Pallet<T>
impl<T> RefUnwindSafe for Pallet<T>where
T: RefUnwindSafe,
impl<T> Send for Pallet<T>where
T: Send,
impl<T> Sync for Pallet<T>where
T: Sync,
impl<T> Unpin for Pallet<T>where
T: Unpin,
impl<T> UnwindSafe for Pallet<T>where
T: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T, Outer> IsWrappedBy<Outer> for T
impl<T, Outer> IsWrappedBy<Outer> for T
source§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
source§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
source§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
T. Read moresource§impl<T, U> TryIntoKey<U> for Twhere
U: TryFromKey<T>,
impl<T, U> TryIntoKey<U> for Twhere
U: TryFromKey<T>,
type Error = <U as TryFromKey<T>>::Error
fn try_into_key(self) -> Result<U, <U as TryFromKey<T>>::Error>
source§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from.source§impl<T, S> UniqueSaturatedInto<T> for S
impl<T, S> UniqueSaturatedInto<T> for S
source§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T.