pub type CollatorSelection = Pallet<Runtime>;
Aliased Type§
struct CollatorSelection(/* private fields */);
Implementations
Source§impl<T> Pallet<T>where
T: Config,
impl<T> Pallet<T>where
T: Config,
Sourcepub fn set_invulnerables(
origin: <T as Config>::RuntimeOrigin,
new: Vec<<T as Config>::AccountId>,
) -> Result<(), DispatchError>
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 AccountId
s 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: <T as Config>::RuntimeOrigin,
max: u32,
) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>
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
.
Sourcepub 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>>
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
.
Sourcepub fn register_as_candidate(
origin: <T as Config>::RuntimeOrigin,
) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>
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.
Sourcepub fn leave_intent(
origin: <T as Config>::RuntimeOrigin,
) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>
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
.
Sourcepub fn add_invulnerable(
origin: <T as Config>::RuntimeOrigin,
who: <T as Config>::AccountId,
) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>
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
.
Sourcepub fn remove_invulnerable(
origin: <T as Config>::RuntimeOrigin,
who: <T as Config>::AccountId,
) -> Result<(), DispatchError>
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
.
Sourcepub 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>>
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.
Sourcepub 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>>
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.
Source§impl<T> Pallet<T>where
T: Config,
impl<T> Pallet<T>where
T: Config,
Sourcepub fn account_id() -> <T as Config>::AccountId
pub fn account_id() -> <T as Config>::AccountId
Get a unique, inaccessible account ID from the PotId
.
Sourcepub fn assemble_collators() -> Vec<<T as Config>::AccountId>
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.
Sourcepub fn kick_stale_candidates(
candidates: impl IntoIterator<Item = <T as Config>::AccountId>,
) -> u32
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.
Sourcepub fn do_try_state() -> Result<(), DispatchError>
pub fn do_try_state() -> Result<(), DispatchError>
Ensure the correctness of the state of this pallet.
This should be valid before or after each state transition of this pallet.
§Invariants
§DesiredCandidates
- The current desired candidate count should not exceed the candidate list capacity.
- The number of selected candidates together with the invulnerables must be greater than or equal to the minimum number of eligible collators.
Trait Implementations
Source§impl<T> BeforeAllRuntimeMigrations for Pallet<T>where
T: Config,
impl<T> BeforeAllRuntimeMigrations for Pallet<T>where
T: Config,
Source§fn before_all_runtime_migrations() -> Weight
fn before_all_runtime_migrations() -> Weight
Source§impl<T> Benchmarking for Pallet<T>
impl<T> Benchmarking for Pallet<T>
Source§fn benchmarks(extra: bool) -> Vec<BenchmarkMetadata>
fn benchmarks(extra: bool) -> Vec<BenchmarkMetadata>
Source§fn run_benchmark(
extrinsic: &[u8],
c: &[(BenchmarkParameter, u32)],
whitelist: &[TrackedStorageKey],
verify: bool,
internal_repeats: u32,
) -> Result<Vec<BenchmarkResult>, BenchmarkError>
fn run_benchmark( extrinsic: &[u8], c: &[(BenchmarkParameter, u32)], whitelist: &[TrackedStorageKey], verify: bool, internal_repeats: u32, ) -> Result<Vec<BenchmarkResult>, BenchmarkError>
Source§impl<T> DispatchViewFunction for Pallet<T>where
T: Config,
impl<T> DispatchViewFunction for Pallet<T>where
T: Config,
fn dispatch_view_function<O>(
id: &ViewFunctionId,
input: &mut &[u8],
output: &mut O,
) -> Result<(), ViewFunctionDispatchError>where
O: Output,
Source§impl<T> EventHandler<<T as Config>::AccountId, <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
impl<T> 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> GetStorageVersion for Pallet<T>where
T: Config,
impl<T> GetStorageVersion for Pallet<T>where
T: Config,
Source§fn in_code_storage_version() -> <Pallet<T> as GetStorageVersion>::InCodeStorageVersion
fn in_code_storage_version() -> <Pallet<T> as GetStorageVersion>::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> Hooks<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
impl<T> Hooks<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
Source§fn integrity_test()
fn integrity_test()
Source§fn try_state(
_: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number,
) -> Result<(), DispatchError>
fn try_state( _: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number, ) -> Result<(), DispatchError>
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 pre_upgrade() -> Result<Vec<u8>, DispatchError>
fn pre_upgrade() -> Result<Vec<u8>, DispatchError>
Source§fn post_upgrade(_state: Vec<u8>) -> Result<(), DispatchError>
fn post_upgrade(_state: Vec<u8>) -> Result<(), DispatchError>
Source§fn offchain_worker(_n: BlockNumber)
fn offchain_worker(_n: BlockNumber)
Source§impl<T> IntegrityTest for Pallet<T>where
T: Config,
impl<T> IntegrityTest for Pallet<T>where
T: Config,
Source§impl<T> OffchainWorker<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
impl<T> OffchainWorker<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
Source§impl<T> OnFinalize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
impl<T> OnFinalize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
Source§fn on_finalize(
n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number,
)
fn on_finalize( n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number, )
Hooks::on_finalize
.Source§impl<T> OnGenesis for Pallet<T>where
T: Config,
impl<T> OnGenesis for Pallet<T>where
T: Config,
Source§fn on_genesis()
fn on_genesis()
Source§impl<T> OnIdle<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
impl<T> OnIdle<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
Source§impl<T> OnInitialize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
impl<T> OnInitialize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
Source§fn on_initialize(
n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number,
) -> Weight
fn on_initialize( n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number, ) -> Weight
Hooks::on_initialize
.Source§impl<T> OnPoll<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
impl<T> OnPoll<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
Source§impl<T> OnRuntimeUpgrade for Pallet<T>where
T: Config,
impl<T> OnRuntimeUpgrade for Pallet<T>where
T: Config,
Source§fn on_runtime_upgrade() -> Weight
fn on_runtime_upgrade() -> Weight
Source§fn pre_upgrade() -> Result<Vec<u8>, DispatchError>
fn pre_upgrade() -> Result<Vec<u8>, DispatchError>
Hooks::pre_upgrade
.Source§fn post_upgrade(state: Vec<u8>) -> Result<(), DispatchError>
fn post_upgrade(state: Vec<u8>) -> Result<(), DispatchError>
Hooks::post_upgrade
.Source§fn try_on_runtime_upgrade(checks: bool) -> Result<Weight, DispatchError>
fn try_on_runtime_upgrade(checks: bool) -> Result<Weight, DispatchError>
pre_upgrade
->
on_runtime_upgrade
-> post_upgrade
hooks for a migration. Read moreSource§impl<T> PalletInfoAccess for Pallet<T>where
T: Config,
impl<T> PalletInfoAccess for Pallet<T>where
T: Config,
Source§fn module_name() -> &'static str
fn module_name() -> &'static str
Source§fn crate_version() -> CrateVersion
fn crate_version() -> CrateVersion
Source§impl<T> PalletsInfoAccess for Pallet<T>where
T: Config,
impl<T> PalletsInfoAccess for Pallet<T>where
T: Config,
Source§impl<T> SessionManager<<T as Config>::AccountId> for Pallet<T>where
T: Config,
impl<T> SessionManager<<T as Config>::AccountId> for Pallet<T>where
T: Config,
Play the role of the session manager.
Source§impl<T> StorageInfoTrait for Pallet<T>where
T: Config,
impl<T> StorageInfoTrait for Pallet<T>where
T: Config,
fn storage_info() -> Vec<StorageInfo>
Source§impl<T> TryDecodeEntireStorage for Pallet<T>where
T: Config,
impl<T> TryDecodeEntireStorage for Pallet<T>where
T: Config,
Source§fn try_decode_entire_state() -> Result<usize, Vec<TryDecodeEntireStorageError>>
fn try_decode_entire_state() -> Result<usize, Vec<TryDecodeEntireStorageError>>
Ok(bytes_decoded)
if success.Source§impl<T> TryState<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
impl<T> TryState<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
Source§impl<T> WhitelistedStorageKeys for Pallet<T>where
T: Config,
impl<T> WhitelistedStorageKeys for Pallet<T>where
T: Config,
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.