pub struct Pallet<T>(_);
Expand description

The pallet implementing the on-chain logic.

Implementations§

Self accessor for SignedSubmission<T>.

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.

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

Extracted to facilitate with weight calculation.

Infallible

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

Extracted to facilitate with weight calculation.

Infallible

The weight of the given raw solution.

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

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.

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.

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

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

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.

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.

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.

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.

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.

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

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.

Trigger the governance fallback.

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

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.

Current phase.

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

Snapshot data of the round.

This is created at the beginning of the signed phase and cleared upon calling elect.

Desired number of targets to elect for this round.

Only exists when Snapshot is present.

The metadata of the RoundSnapshot

Only exists when Snapshot is present.

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

Can be set via set_minimum_untrusted_score.

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.

Kill everything created by Pallet::create_snapshot.

Checks the feasibility of a solution.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Indicate if this election provider is currently ongoing an asynchronous election or not.
Performs the election. This should be implemented as a self-weighing function. The implementor should register its appropriate weight at the end of execution with the system pallet directly. Read more
The account identifier type.
The block number type.
The error type that is returned by the provider.
The upper bound on election winners that can be returned. Read more
The data provider of the election.
checked call to Self::DataProvider::desired_targets() ensuring the value never exceeds Self::MaxWinners. Read more
Returns the current storage version as supported by the pallet.
Returns the on-chain storage version of the pallet as stored in the storage.
The block is being initialized. Implement to have something happen. Read more
Implementing this function on a module allows you to perform long-running tasks that make (by default) validators generate transactions that feed results of those long-running computations back on chain. Read more
Run integrity test. Read more
The block is being finalized. Implement to have something happen.
This will be run when the block is being finalized (before on_finalize). Implement to have something happen using the remaining weight. Will not fire if the remaining weight is 0. Return the weight used, the hook will subtract it from current weight used and pass the result to the next on_idle hook if it exists. Read more
Perform a module upgrade. Read more
Run integrity test. Read more
This function is being called after every block import (when fully synced). Read more
The block is being finalized. Implement to have something happen. Read more
Something that should happen at genesis.
The block is being finalized. Implement to have something happen in case there is leftover weight. Check the passed remaining_weight to make sure it is high enough to allow for your pallet’s extra computation. Read more
The block is being initialized. Implement to have something happen. Read more
Perform a module upgrade. Read more
Index of the pallet as configured in the runtime.
Name of the pallet as configured in the runtime.
Name of the Rust module containing the pallet.
Version of the crate containing the pallet.
The number of pallets’ information that this type represents. Read more
All of the pallets’ information that this type represents.
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
The call to validate
Return the validity of the call Read more
Validate the call right before dispatch. Read more
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. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Convert from a value of T into an equivalent instance of Option<Self>. Read more
Consume self to return Some equivalent value of Option<T>. Read more
Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait. Read more
Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more
Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s. Read more
Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s. Read more
Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait. Read more
Compare self to key and return true if they are equal.
Checks if this value is equivalent to the given key. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Cast reference.
Cast reference.
Cast mutable reference.
Cast mutable reference.

Get a reference to the inner from the outer.

Get a mutable reference to the inner from the outer.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
Should always be Self
Convert from a value of T into an equivalent instance of Self. Read more
Consume self to return an equivalent value of T. Read more
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
The counterpart to unchecked_from.
Consume self to return an equivalent value of T.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more