referrerpolicy=no-referrer-when-downgrade
westend_runtime

Type Alias ElectionProviderMultiPhase

Source
pub type ElectionProviderMultiPhase = Pallet<Runtime>;

Aliased Type§

struct ElectionProviderMultiPhase(/* private fields */);

Implementations

Source§

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

Source

pub fn round() -> u32

Internal counter for the number of rounds.

This is useful for de-duplication of transactions submitted to the pool, and general diagnostics of the pallet.

This is merely incremented once per every time that an upstream elect is called.

Source

pub fn current_phase() -> Phase<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number>

Current phase.

Source

pub fn queued_solution() -> Option<ReadySolution<<<T as Config>::MinerConfig as MinerConfig>::AccountId, <<T as Config>::MinerConfig as MinerConfig>::MaxWinners, <<T as Config>::MinerConfig as MinerConfig>::MaxBackersPerWinner>>

Current best solution, signed or unsigned, queued to be returned upon elect.

Always sorted by score.

Source

pub fn snapshot() -> Option<RoundSnapshot<<T as Config>::AccountId, (<<T as Config>::DataProvider as ElectionDataProvider>::AccountId, u64, BoundedVec<<<T as Config>::DataProvider as ElectionDataProvider>::AccountId, <<T as Config>::DataProvider as ElectionDataProvider>::MaxVotesPerVoter>)>>

Snapshot data of the round.

This is created at the beginning of the signed phase and cleared upon calling elect. Note: This storage type must only be mutated through SnapshotWrapper.

Source

pub fn desired_targets() -> Option<u32>

Desired number of targets to elect for this round.

Only exists when Snapshot is present. Note: This storage type must only be mutated through SnapshotWrapper.

Source

pub fn snapshot_metadata() -> Option<SolutionOrSnapshotSize>

The metadata of the RoundSnapshot

Only exists when Snapshot is present. Note: This storage type must only be mutated through SnapshotWrapper.

Source

pub fn minimum_untrusted_score() -> Option<ElectionScore>

The minimum score that each ‘untrusted’ solution must attain in order to be considered feasible.

Can be set via set_minimum_untrusted_score.

Source

pub fn create_snapshot() -> Result<(), ElectionError<T>>

Creates the snapshot. Writes new data to:

  1. SnapshotMetadata
  2. RoundSnapshot
  3. DesiredTargets

Returns Ok(()) if operation is okay.

This is a self-weighing function, it will register its own extra weight as DispatchClass::Mandatory with the system pallet.

Source

pub fn feasibility_check( raw_solution: RawSolution<<<T as Config>::MinerConfig as MinerConfig>::Solution>, compute: ElectionCompute, ) -> Result<ReadySolution<<<T as Config>::MinerConfig as MinerConfig>::AccountId, <<T as Config>::MinerConfig as MinerConfig>::MaxWinners, <<T as Config>::MinerConfig as MinerConfig>::MaxBackersPerWinner>, FeasibilityError>

Checks the feasibility of a solution.

Source§

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

Source

pub fn submit_unsigned( origin: <T as Config>::RuntimeOrigin, raw_solution: Box<RawSolution<<<T as Config>::MinerConfig as MinerConfig>::Solution>>, witness: SolutionOrSnapshotSize, ) -> Result<(), DispatchError>

Submit a solution for the unsigned phase.

The dispatch origin fo this call must be none.

This submission is checked on the fly. Moreover, this unsigned solution is only validated when submitted to the pool from the local node. Effectively, this means that only active validators can submit this transaction when authoring a block (similar to an inherent).

To prevent any incorrect solution (and thus wasted time/weight), this transaction will panic if the solution submitted by the validator is invalid in any way, effectively putting their authoring reward at risk.

No deposit or reward is associated with this submission.

Source

pub fn set_minimum_untrusted_score( origin: <T as Config>::RuntimeOrigin, maybe_next_score: Option<ElectionScore>, ) -> Result<(), DispatchError>

Set a new value for MinimumUntrustedScore.

Dispatch origin must be aligned with T::ForceOrigin.

This check can be turned off by setting the value to None.

Source

pub fn set_emergency_election_result( origin: <T as Config>::RuntimeOrigin, supports: Vec<(<T as Config>::AccountId, Support<<T as Config>::AccountId>)>, ) -> Result<(), DispatchError>

Set a solution in the queue, to be handed out to the client of this pallet in the next call to ElectionProvider::elect.

This can only be set by T::ForceOrigin, and only when the phase is Emergency.

The solution is not checked for any feasibility and is assumed to be trustworthy, as any feasibility check itself can in principle cause the election process to fail (due to memory/weight constrains).

Source

pub fn submit( origin: <T as Config>::RuntimeOrigin, raw_solution: Box<RawSolution<<<T as Config>::MinerConfig as MinerConfig>::Solution>>, ) -> Result<(), DispatchError>

Submit a solution for the signed phase.

The dispatch origin fo this call must be signed.

The solution is potentially queued, based on the claimed score and processed at the end of the signed phase.

A deposit is reserved and recorded for the solution. Based on the outcome, the solution might be rewarded, slashed, or get all or a part of the deposit back.

Source

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

Trigger the governance fallback.

This can only be called when Phase::Emergency is enabled, as an alternative to calling Call::set_emergency_election_result.

Source§

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

Source

pub fn signed_submissions() -> SignedSubmissions<T>

Self accessor for SignedSubmission<T>.

Source

pub fn finalize_signed_phase() -> bool

Finish the signed phase. Process the signed submissions from best to worse until a valid one is found, rewarding the best one and slashing the invalid ones along the way.

Returns true if we have a good solution in the signed phase.

This drains the SignedSubmissions, potentially storing the best valid one in QueuedSolution.

This is a self-weighing function, it automatically registers its weight internally when being called.

Source

pub fn finalize_signed_phase_accept_solution( ready_solution: ReadySolution<<<T as Config>::MinerConfig as MinerConfig>::AccountId, <<T as Config>::MinerConfig as MinerConfig>::MaxWinners, <<T as Config>::MinerConfig as MinerConfig>::MaxBackersPerWinner>, who: &<T as Config>::AccountId, deposit: <<T as Config>::Currency as Currency<<T as Config>::AccountId>>::Balance, call_fee: <<T as Config>::Currency as Currency<<T as Config>::AccountId>>::Balance, )

Helper function for the case where a solution is accepted in the signed phase.

Extracted to facilitate with weight calculation.

Infallible

Source

pub fn finalize_signed_phase_reject_solution( who: &<T as Config>::AccountId, deposit: <<T as Config>::Currency as Currency<<T as Config>::AccountId>>::Balance, )

Helper function for the case where a solution is accepted in the rejected phase.

Extracted to facilitate with weight calculation.

Infallible

Source

pub fn solution_weight_of( raw_solution: &RawSolution<<<T as Config>::MinerConfig as MinerConfig>::Solution>, size: SolutionOrSnapshotSize, ) -> Weight

The weight of the given raw solution.

Source

pub fn deposit_for( raw_solution: &RawSolution<<<T as Config>::MinerConfig as MinerConfig>::Solution>, size: SolutionOrSnapshotSize, ) -> <<T as Config>::Currency as Currency<<T as Config>::AccountId>>::Balance

Collect a sufficient deposit to store this solution.

The deposit is composed of 3 main elements:

  1. base deposit, fixed for all submissions.
  2. a per-byte deposit, for renting the state usage.
  3. a per-weight deposit, for the potential weight usage in an upcoming on_initialize
Source§

impl<T> Pallet<T>
where T: Config + CreateInherent<Call<T>>,

Source

pub fn mine_solution() -> Result<(RawSolution<<<T as Config>::MinerConfig as MinerConfig>::Solution>, SolutionOrSnapshotSize, TrimmingStatus), MinerError>

Mine a new npos solution.

The Npos Solver type, S, must have the same AccountId and Error type as the crate::Config::Solver in order to create a unified return type.

Source

pub fn restore_or_compute_then_maybe_submit() -> Result<(), MinerError>

Attempt to restore a solution from cache. Otherwise, compute it fresh. Either way, submit if our call’s score is greater than that of the cached solution.

Source

pub fn mine_check_save_submit() -> Result<(), MinerError>

Mine a new solution, cache it, and submit it back to the chain as an unsigned transaction.

Source

pub fn mine_checked_call() -> Result<Call<T>, MinerError>

Mine a new solution as a call. Performs all checks.

Source

pub fn basic_checks( raw_solution: &RawSolution<<<T as Config>::MinerConfig as MinerConfig>::Solution>, solution_type: &str, ) -> Result<(), MinerError>

Source

pub fn mine_and_check() -> Result<(RawSolution<<<T as Config>::MinerConfig as MinerConfig>::Solution>, SolutionOrSnapshotSize, TrimmingStatus), MinerError>

Mine a new npos solution, with all the relevant checks to make sure that it will be accepted to the chain.

If you want an unchecked solution, use Pallet::mine_solution. If you want a checked solution and submit it at the same time, use Pallet::mine_check_save_submit.

Source

pub fn ensure_offchain_repeat_frequency( now: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number, ) -> Result<(), MinerError>

Checks if an execution of the offchain worker is permitted at the given block number, or not.

This makes sure that

  1. we don’t run on previous blocks in case of a re-org
  2. we don’t run twice within a window of length T::OffchainRepeat.

Returns Ok(()) if offchain worker limit is respected, Err(reason) otherwise. If Ok() is returned, now is written in storage and will be used in further calls as the baseline.

Source

pub fn unsigned_pre_dispatch_checks( raw_solution: &RawSolution<<<T as Config>::MinerConfig as MinerConfig>::Solution>, ) -> Result<(), DispatchError>

Do the basics checks that MUST happen during the validation and pre-dispatch of an unsigned transaction.

Can optionally also be called during dispatch, if needed.

NOTE: Ideally, these tests should move more and more outside of this and more to the miner’s code, so that we do less and less storage reads here.

Trait Implementations

Source§

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

Source§

fn before_all_runtime_migrations() -> Weight

Something that should happen before runtime migrations are executed.
Source§

impl<T> Benchmarking for Pallet<T>
where T: Config + Config,

Source§

fn benchmarks(extra: bool) -> Vec<BenchmarkMetadata>

Get the benchmarks available for this pallet. Generally there is one benchmark per extrinsic, so these are sometimes just called “extrinsics”. Read more
Source§

fn run_benchmark( extrinsic: &[u8], c: &[(BenchmarkParameter, u32)], whitelist: &[TrackedStorageKey], verify: bool, internal_repeats: u32, ) -> Result<Vec<BenchmarkResult>, BenchmarkError>

Run the benchmarks for this pallet.
Source§

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

Source§

impl<T> Clone for Pallet<T>

Source§

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
Source§

impl<T> Debug for Pallet<T>

Source§

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

Formats the value using the given formatter. Read more
Source§

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

Source§

fn dispatch_view_function<O>( id: &ViewFunctionId, input: &mut &[u8], output: &mut O, ) -> Result<(), ViewFunctionDispatchError>
where O: Output,

Source§

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

Source§

type AccountId = <T as Config>::AccountId

The account ID identifier;
Source§

type BlockNumber = <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number

The block number type.
Source§

type Error = ElectionError<T>

The error type returned by the provider;
Source§

type MaxWinnersPerPage = <T as Config>::MaxWinners

The maximum number of winners per page in results returned by this election provider. Read more
Source§

type MaxBackersPerWinner = <T as Config>::MaxBackersPerWinner

The maximum number of backers that a single page may have in results returned by this election provider. Read more
Source§

type Pages = ConstU32<1>

The number of pages that this election provider supports.
Source§

type DataProvider = <T as Config>::DataProvider

The data provider of the election.
Source§

fn elect( page: u32, ) -> Result<BoundedSupports<<Pallet<T> as ElectionProvider>::AccountId, <Pallet<T> as ElectionProvider>::MaxWinnersPerPage, <Pallet<T> as ElectionProvider>::MaxBackersPerWinner>, <Pallet<T> as ElectionProvider>::Error>

Elect a new set of winners. Read more
Source§

fn ongoing() -> bool

Indicate whether this election provider is currently ongoing an asynchronous election.
Source§

fn msp() -> u32

The index of the most significant page that this election provider supports.
Source§

fn lsp() -> u32

The index of the least significant page that this election provider supports.
Source§

fn desired_targets_checked() -> Result<u32, &'static str>

checked call to Self::DataProvider::desired_targets() ensuring the value never exceeds Self::MaxWinnersPerPage.
Source§

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

Source§

type InCodeStorageVersion = StorageVersion

This type is generated by the pallet macro. Read more
Source§

fn in_code_storage_version() -> <Pallet<T> as GetStorageVersion>::InCodeStorageVersion

Returns the in-code storage version as specified in the storage_version attribute, or NoStorageVersionSet if the attribute is missing.
Source§

fn on_chain_storage_version() -> StorageVersion

Returns the storage version of the pallet as last set in the actual on-chain storage.
Source§

fn current_storage_version() -> Self::InCodeStorageVersion

👎Deprecated: This method has been renamed to in_code_storage_version and will be removed after March 2024.
DEPRECATED: Use Self::current_storage_version instead. Read more
Source§

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

Source§

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

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

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

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 blockchain execution. Read more
Source§

fn integrity_test()

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

fn try_state( _n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number, ) -> Result<(), DispatchError>

Execute the sanity checks of this pallet, per block. Read more
Source§

fn on_finalize(_n: BlockNumber)

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

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
Source§

fn on_poll(_n: BlockNumber, _weight: &mut WeightMeter)

A hook to run logic after inherent application. Read more
Source§

fn on_runtime_upgrade() -> Weight

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

fn pre_upgrade() -> Result<Vec<u8>, DispatchError>

Execute some pre-checks prior to a runtime upgrade. Read more
Source§

fn post_upgrade(_state: Vec<u8>) -> Result<(), DispatchError>

Execute some post-checks after a runtime upgrade. Read more
Source§

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,

Source§

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
Source§

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, )

Source§

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

Source§

fn on_genesis()

Something that should happen at genesis.
Source§

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

Source§

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

Source§

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

Source§

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

Source§

fn on_poll( n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number, weight: &mut WeightMeter, )

Code to execute every now and then at the beginning of the block after inherent application. Read more
Source§

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

Source§

fn on_runtime_upgrade() -> Weight

Source§

fn pre_upgrade() -> Result<Vec<u8>, DispatchError>

Source§

fn post_upgrade(state: Vec<u8>) -> Result<(), DispatchError>

Source§

fn try_on_runtime_upgrade(checks: bool) -> Result<Weight, DispatchError>

The expected and default behavior of this method is to handle executing pre_upgrade -> on_runtime_upgrade -> post_upgrade hooks for a migration. Read more
Source§

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

Source§

fn index() -> usize

Index of the pallet as configured in the runtime.
Source§

fn name() -> &'static str

Name of the pallet as configured in the runtime.
Source§

fn name_hash() -> [u8; 16]

Two128 hash of name.
Source§

fn module_name() -> &'static str

Name of the Rust module containing the pallet.
Source§

fn crate_version() -> CrateVersion

Version of the crate containing the pallet.
Source§

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

Source§

fn count() -> usize

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

fn infos() -> Vec<PalletInfoData>

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

impl<T> PartialEq for Pallet<T>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

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

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

Source§

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

Source§

fn try_decode_entire_state() -> Result<usize, Vec<TryDecodeEntireStorageError>>

Decode the entire data under the given storage, returning 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,

Source§

fn try_state( n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number, _s: Select, ) -> Result<(), DispatchError>

Execute the state checks.
Source§

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

Source§

type Call = Call<T>

The call to validate
Source§

fn validate_unsigned( source: TransactionSource, call: &<Pallet<T> as ValidateUnsigned>::Call, ) -> Result<ValidTransaction, TransactionValidityError>

Return the validity of the call Read more
Source§

fn pre_dispatch( call: &<Pallet<T> as ValidateUnsigned>::Call, ) -> Result<(), TransactionValidityError>

Validate the call right before dispatch. Read more
Source§

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

Source§

fn prefix() -> [u8; 16]

Source§

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

Source§

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.
Source§

impl<T> Eq for Pallet<T>