pub type CollatorSelection = Pallet<Runtime>;

Aliased Type§

struct CollatorSelection(/* private fields */);

Implementations

§

impl<T> Pallet<T>
where T: Config,

pub fn set_invulnerables( origin: <T as Config>::RuntimeOrigin, new: Vec<<T as Config>::AccountId> ) -> Result<(), DispatchError>

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.

pub fn set_desired_candidates( origin: <T as Config>::RuntimeOrigin, max: u32 ) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>

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.

pub fn set_candidacy_bond( origin: <T as Config>::RuntimeOrigin, bond: <<T as Config>::Currency as Currency<<T as Config>::AccountId>>::Balance ) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>

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.

pub fn register_as_candidate( origin: <T as Config>::RuntimeOrigin ) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>

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.

pub fn leave_intent( origin: <T as Config>::RuntimeOrigin ) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>

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.

pub fn add_invulnerable( origin: <T as Config>::RuntimeOrigin, who: <T as Config>::AccountId ) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>

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.

pub fn remove_invulnerable( origin: <T as Config>::RuntimeOrigin, who: <T as Config>::AccountId ) -> Result<(), DispatchError>

Remove an account who from the list of Invulnerables collators. Invulnerables must be sorted.

The origin for this call must be the UpdateOrigin.

pub fn update_bond( origin: <T as Config>::RuntimeOrigin, new_deposit: <<T as Config>::Currency as Currency<<T as Config>::AccountId>>::Balance ) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>

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.

pub fn take_candidate_slot( origin: <T as Config>::RuntimeOrigin, deposit: <<T as Config>::Currency as Currency<<T as Config>::AccountId>>::Balance, target: <T as Config>::AccountId ) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>

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.

§

impl<T> Pallet<T>
where T: Config,

pub fn account_id() -> <T as Config>::AccountId

Get a unique, inaccessible account ID from the PotId.

pub fn assemble_collators() -> Vec<<T as Config>::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.

pub fn kick_stale_candidates( candidates: impl IntoIterator<Item = <T as Config>::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.

§

impl<T> Pallet<T>
where T: Config,

pub fn invulnerables( ) -> BoundedVec<<T as Config>::AccountId, <T as Config>::MaxInvulnerables>

An auto-generated getter for [Invulnerables].

§

impl<T> Pallet<T>
where T: Config,

pub fn candidate_list( ) -> BoundedVec<CandidateInfo<<T as Config>::AccountId, <<T as Config>::Currency as Currency<<T as Config>::AccountId>>::Balance>, <T as Config>::MaxCandidates>

An auto-generated getter for [CandidateList].

§

impl<T> Pallet<T>
where T: Config,

pub fn last_authored_block<KArg>( k: KArg ) -> <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number
where KArg: EncodeLike<<T as Config>::AccountId>,

An auto-generated getter for [LastAuthoredBlock].

§

impl<T> Pallet<T>
where T: Config,

pub fn desired_candidates() -> u32

An auto-generated getter for [DesiredCandidates].

§

impl<T> Pallet<T>
where T: Config,

pub fn candidacy_bond( ) -> <<T as Config>::Currency as Currency<<T as Config>::AccountId>>::Balance

An auto-generated getter for [CandidacyBond].

Trait Implementations

§

impl<T> Callable<T> for Pallet<T>
where T: Config,

§

type RuntimeCall = Call<T>

§

impl<T> Hooks<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
where T: Config,

§

fn integrity_test()

Check the integrity of this pallet’s configuration. Read more
§

fn on_initialize(_n: BlockNumber) -> Weight

Block initialization hook. This is called at the very beginning of block execution. Read more
§

fn on_finalize(_n: BlockNumber)

Block finalization hook. This is called at the very end of block execution. Read more
§

fn on_idle(_n: BlockNumber, _remaining_weight: Weight) -> Weight

Hook to consume a block’s idle time. This will run when the block is being finalized (before [Hooks::on_finalize]). Read more
§

fn on_runtime_upgrade() -> Weight

Hook executed when a code change (aka. a “runtime upgrade”) is detected by FRAME. Read more
§

fn offchain_worker(_n: BlockNumber)

Implementing this function on a pallet allows you to perform long-running tasks that are dispatched as separate threads, and entirely independent of the main wasm runtime. Read more
§

impl<T> OnRuntimeUpgrade for Pallet<T>
where T: Config,

§

fn on_runtime_upgrade() -> Weight

See [Hooks::on_runtime_upgrade].
§

impl<T> IntegrityTest for Pallet<T>
where T: Config,

§

fn integrity_test()

See [Hooks::integrity_test].
§

impl<T> Debug for Pallet<T>

§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl<T> OnInitialize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
where T: Config,

§

fn on_initialize( n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number ) -> Weight

See [Hooks::on_initialize].
§

impl<T> StorageInfoTrait for Pallet<T>
where T: Config,

§

fn storage_info() -> Vec<StorageInfo>

§

impl<T> OffchainWorker<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
where T: Config,

§

fn offchain_worker( n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number )

This function is being called after every block import (when fully synced). Read more
§

impl<T> OnGenesis for Pallet<T>
where T: Config,

§

fn on_genesis()

Something that should happen at genesis.
§

impl<T> WhitelistedStorageKeys for Pallet<T>
where T: Config,

§

fn whitelisted_storage_keys() -> Vec<TrackedStorageKey>

Returns a 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> OnFinalize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
where T: Config,

§

fn on_finalize( n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number )

See [Hooks::on_finalize].
§

impl<T> PalletsInfoAccess for Pallet<T>
where T: Config,

§

fn count() -> usize

The number of pallets’ information that this type represents. Read more
§

fn infos() -> Vec<PalletInfoData>

All of the pallets’ information that this type represents.
§

impl<T> SessionManager<<T as Config>::AccountId> for Pallet<T>
where T: Config,

Play the role of the session manager.

§

fn new_session(index: u32) -> Option<Vec<<T as Config>::AccountId>>

Plan a new session, and optionally provide the new validator set. Read more
§

fn start_session(_: u32)

Start an already planned session. Read more
§

fn end_session(_: u32)

End the session. Read more
§

fn new_session_genesis(new_index: u32) -> Option<Vec<ValidatorId>>

Same as new_session, but it this should only be called at genesis. Read more
§

impl<T> BeforeAllRuntimeMigrations for Pallet<T>
where T: Config,

§

fn before_all_runtime_migrations() -> Weight

Something that should happen before runtime migrations are executed.
§

impl<T> PartialEq for Pallet<T>

§

fn eq(&self, other: &Pallet<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl<T> Eq for Pallet<T>

§

impl<T> PalletInfoAccess for Pallet<T>
where T: Config,

§

fn index() -> usize

Index of the pallet as configured in the runtime.
§

fn name() -> &'static str

Name of the pallet as configured in the runtime.
§

fn name_hash() -> [u8; 16]

Two128 hash of name.
§

fn module_name() -> &'static str

Name of the Rust module containing the pallet.
§

fn crate_version() -> CrateVersion

Version of the crate containing the pallet.
§

impl<T> OnIdle<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
where T: Config,

§

fn on_idle( n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number, remaining_weight: Weight ) -> Weight

See [Hooks::on_idle].
§

impl<T> Clone for Pallet<T>

§

fn clone(&self) -> Pallet<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl<T> GetStorageVersion for Pallet<T>
where T: Config,

§

type CurrentStorageVersion = StorageVersion

This will be filled out by the pallet macro. Read more
§

fn current_storage_version( ) -> <Pallet<T> as GetStorageVersion>::CurrentStorageVersion

Returns the current storage version as supported by the pallet.
§

fn on_chain_storage_version() -> StorageVersion

Returns the on-chain storage version of the pallet as stored in the storage.
§

impl<T> EventHandler<<T as Config>::AccountId, <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
where T: Config + Config,

Keep track of number of authored blocks per authority, uncles are counted as well since they’re a valid proof of being online.

§

fn note_author(author: <T as Config>::AccountId)

Note that the given account ID is the author of the current block.