Struct pallet_committee_management::pallet::Pallet
source · pub struct Pallet<T>(PhantomData<T>);
Expand description
The Pallet
struct, the main type that implements traits and standalone
functions within the pallet.
Tuple Fields§
§0: PhantomData<T>
Implementations§
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
pub(crate) fn update_validator_total_rewards(era: EraIndex)
fn reward_for_session_non_committee( non_committee: Vec<T::AccountId>, nr_of_sessions: SessionIndex, blocks_per_session: u32, validator_totals: &BTreeMap<T::AccountId, u32>, threshold: Perquintill ) -> impl IntoIterator<Item = (T::AccountId, u32)> + '_
fn reward_for_session_committee( committee: Vec<T::AccountId>, nr_of_sessions: SessionIndex, blocks_per_session: u32, validator_totals: &BTreeMap<T::AccountId, u32>, threshold: Perquintill ) -> impl IntoIterator<Item = (T::AccountId, u32)> + '_
fn blocks_to_produce_per_session() -> u32
pub fn adjust_rewards_for_session()
fn store_session_validators( committee: &[T::AccountId], reserved: Vec<T::AccountId>, non_reserved: Vec<T::AccountId> )
pub(crate) fn select_committee( era_validators: &EraValidators<T::AccountId>, committee_seats: CommitteeSeats, current_session: SessionIndex ) -> Option<SessionCommittee<T::AccountId>>
pub(crate) fn rotate_committee( current_session: SessionIndex ) -> Option<SessionCommittee<T::AccountId>>
pub(crate) fn calculate_underperforming_validators()
fn mark_validator_underperformance( thresholds: &BanConfigStruct, validator: &T::AccountId )
pub(crate) fn clear_underperformance_session_counter(session: SessionIndex)
pub fn clear_expired_bans(active_era: EraIndex)
pub fn ban_validator(validator: &T::AccountId, reason: BanReason)
pub fn emit_fresh_bans_event()
sourcepub fn predict_session_committee_for_session(
session: SessionIndex
) -> Result<SessionCommittee<T::AccountId>, SessionValidatorError>
pub fn predict_session_committee_for_session( session: SessionIndex ) -> Result<SessionCommittee<T::AccountId>, SessionValidatorError>
Predict finality committee and block producers for the given session. session
must be
within the current era (current, in the staking context).
If the active era E
starts in the session a
, and ends in session b
then from session
a
to session b-1
this function can answer question who will be in the committee in the
era E
. In the last session of the era E
(b
) this can be used to determine all of the
sessions in the era E+1
.
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn set_ban_config(
origin: OriginFor<T>,
minimal_expected_performance: Option<u8>,
underperformed_session_count_threshold: Option<u32>,
clean_session_counter_delay: Option<u32>,
ban_period: Option<EraIndex>
) -> DispatchResult
pub fn set_ban_config( origin: OriginFor<T>, minimal_expected_performance: Option<u8>, underperformed_session_count_threshold: Option<u32>, clean_session_counter_delay: Option<u32>, ban_period: Option<EraIndex> ) -> DispatchResult
Sets ban config, it has an immediate effect
sourcepub fn ban_from_committee(
origin: OriginFor<T>,
banned: T::AccountId,
ban_reason: Vec<u8>
) -> DispatchResult
pub fn ban_from_committee( origin: OriginFor<T>, banned: T::AccountId, ban_reason: Vec<u8> ) -> DispatchResult
Schedule a non-reserved node to be banned out from the committee at the end of the era
sourcepub fn cancel_ban(origin: OriginFor<T>, banned: T::AccountId) -> DispatchResult
pub fn cancel_ban(origin: OriginFor<T>, banned: T::AccountId) -> DispatchResult
Cancel the ban of the node
sourcepub fn set_lenient_threshold(
origin: OriginFor<T>,
threshold_percent: u8
) -> DispatchResult
pub fn set_lenient_threshold( origin: OriginFor<T>, threshold_percent: u8 ) -> DispatchResult
Set lenient threshold
Trait Implementations§
source§impl<T: Config> BannedValidators for Pallet<T>
impl<T: Config> BannedValidators for Pallet<T>
source§impl<T> EventHandler<<T as Config>::AccountId, <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
impl<T> EventHandler<<T as Config>::AccountId, <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
We assume that block B
ends session nr S
, and current era index is E
.
- Block
B
initialized End_session(S)
is called
- Based on block count we might mark the session for a given validator as underperformed
- We update rewards and clear block count for the session
S
.
Start_session(S + 1)
is called.
- If session
S+1
starts a new era, we populate totals and unban all validators whose ban expired. - If session
S+1
%clean_session_counter_delay
== 0, we clean up underperformed session counter. Clean_session_counter_delay
is read from pallet’s storage
New_session(S + 2)
is called.
- If session
S+2
starts a new era, we emit fresh bans events - We rotate the validators for session
S + 2
using the information about reserved and non-reserved validators.
source§impl<T: Config> GetStorageVersion for Pallet<T>
impl<T: Config> GetStorageVersion for Pallet<T>
§type CurrentStorageVersion = StorageVersion
type CurrentStorageVersion = StorageVersion
source§fn current_storage_version() -> Self::CurrentStorageVersion
fn current_storage_version() -> Self::CurrentStorageVersion
source§fn on_chain_storage_version() -> StorageVersion
fn on_chain_storage_version() -> StorageVersion
source§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>
§fn on_initialize(_n: BlockNumber) -> Weight
fn on_initialize(_n: BlockNumber) -> Weight
§fn on_finalize(_n: BlockNumber)
fn on_finalize(_n: BlockNumber)
§fn on_idle(_n: BlockNumber, _remaining_weight: Weight) -> Weight
fn on_idle(_n: BlockNumber, _remaining_weight: Weight) -> Weight
Hooks::on_finalize
]). Read more§fn on_runtime_upgrade() -> Weight
fn on_runtime_upgrade() -> Weight
§fn offchain_worker(_n: BlockNumber)
fn offchain_worker(_n: BlockNumber)
§fn integrity_test()
fn integrity_test()
source§impl<T: Config> IntegrityTest for Pallet<T>
impl<T: Config> IntegrityTest for Pallet<T>
source§fn integrity_test()
fn integrity_test()
Hooks::integrity_test
].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§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> OnRuntimeUpgrade for Pallet<T>
impl<T: Config> OnRuntimeUpgrade for Pallet<T>
source§fn on_runtime_upgrade() -> Weight
fn on_runtime_upgrade() -> Weight
Hooks::on_runtime_upgrade
].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> PartialEq for Pallet<T>
impl<T> PartialEq for Pallet<T>
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> 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
§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
§fn checked_from<T>(t: T) -> Option<Self>where
Self: TryFrom<T>,
fn checked_from<T>(t: T) -> Option<Self>where
Self: TryFrom<T>,
§fn checked_into<T>(self) -> Option<T>where
Self: TryInto<T>,
fn checked_into<T>(self) -> Option<T>where
Self: TryInto<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.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<T> IsType<T> for T
impl<T> IsType<T> for T
§impl<T, Outer> IsWrappedBy<Outer> for T
impl<T, Outer> IsWrappedBy<Outer> for T
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
T
. Read more§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from
.§impl<T, S> UniqueSaturatedInto<T> for S
impl<T, S> UniqueSaturatedInto<T> for S
§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T
.