ElectionProviderMultiPhase
constraintsCalls
governanceFallback
Trigger the governance fallback.
This can only be called when [Phase::Emergency] is enabled, as an alternative to calling [Call::set_emergency_election_result].
Namespace
api.tx.electionProviderMultiPhase.governanceFallbackType
function governanceFallback(
maybe_max_voters: Option<u32>,
maybe_max_targets: Option<u32>
)setEmergencyElectionResult
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).
Namespace
api.tx.electionProviderMultiPhase.setEmergencyElectionResultType
function setEmergencyElectionResult(
supports: Vec<(SeedPrimitivesSignatureAccountId20,SpNposElectionsSupport)>
)setMinimumUntrustedScore
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.
Namespace
api.tx.electionProviderMultiPhase.setMinimumUntrustedScoreType
function setMinimumUntrustedScore(
maybe_next_score: Option<SpNposElectionsElectionScore>
)submit
Submit a solution for the signed phase.
The dispatch origin for 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.
Namespace
api.tx.electionProviderMultiPhase.submitType
function submit(
raw_solution: PalletElectionProviderMultiPhaseRawSolution
)submitUnsigned
Submit a solution for the unsigned phase.
The dispatch origin for 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.
Namespace
api.tx.electionProviderMultiPhase.submitUnsignedType
function submitUnsigned(
raw_solution: PalletElectionProviderMultiPhaseRawSolution,
witness: PalletElectionProviderMultiPhaseSolutionOrSnapshotSize
)Storage
currentPhase
Current phase.
Namespace
api.query.electionProviderMultiPhase.currentPhaseType
function currentPhase(
): PalletElectionProviderMultiPhasePhasedesiredTargets
Desired number of targets to elect for this round.
Only exists when [Snapshot] is present.
Namespace
api.query.electionProviderMultiPhase.desiredTargetsType
function desiredTargets(
): Option<u32>minimumUntrustedScore
The minimum score that each 'untrusted' solution must attain in order to be considered feasible.
Can be set via set_minimum_untrusted_score.
Namespace
api.query.electionProviderMultiPhase.minimumUntrustedScoreType
function minimumUntrustedScore(
): Option<SpNposElectionsElectionScore>queuedSolution
Current best solution, signed or unsigned, queued to be returned upon elect.
Namespace
api.query.electionProviderMultiPhase.queuedSolutionType
function queuedSolution(
): Option<PalletElectionProviderMultiPhaseReadySolution>round
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 every time that an upstream elect is called.
Namespace
api.query.electionProviderMultiPhase.roundType
function round(
): u32signedSubmissionIndices
A sorted, bounded set of (score, index), where each index points to a value in SignedSubmissions.
We never need to process more than a single signed submission at a time. Signed submissions can be quite large, so we're willing to pay the cost of multiple database accesses to access them one at a time instead of reading and decoding all of them at once.
Namespace
api.query.electionProviderMultiPhase.signedSubmissionIndicesType
function signedSubmissionIndices(
): BTreeMap<SpNposElectionsElectionScore, u32>signedSubmissionNextIndex
The next index is to be assigned to an incoming signed submission.
Every accepted submission is assigned a unique index; that index is bound to that particular submission for the duration of the election. On election finalization, the next index is reset to 0.
We can't just use SignedSubmissionIndices.len(), because that's a bounded set; past its capacity, it will simply saturate. We can't just iterate over SignedSubmissionsMap, because iteration is slow. Instead, we store the value here.
Namespace
api.query.electionProviderMultiPhase.signedSubmissionNextIndexType
function signedSubmissionNextIndex(
): u32signedSubmissionsMap
Unchecked, signed solutions.
Together with SubmissionIndices, this stores a bounded set of SignedSubmissions while allowing us to keep only a single one in memory at a time.
Twox note: the key of the map is an auto-incrementing index which users cannot inspect or affect; we shouldn't need a cryptographically secure hasher.
Namespace
api.query.electionProviderMultiPhase.signedSubmissionsMapType
function signedSubmissionsMap(
u32
): Option<PalletElectionProviderMultiPhaseSignedSignedSubmission>snapshot
Snapshot data of the round.
This is created at the beginning of the signed phase and cleared upon calling elect.
Namespace
api.query.electionProviderMultiPhase.snapshotType
function snapshot(
): Option<PalletElectionProviderMultiPhaseRoundSnapshot>snapshotMetadata
The metadata of the [RoundSnapshot]
Only exists when [Snapshot] is present.
Namespace
api.query.electionProviderMultiPhase.snapshotMetadataType
function snapshotMetadata(
): Option<PalletElectionProviderMultiPhaseSolutionOrSnapshotSize>Events
ElectionFailed
An election failed.
Not much can be said about which computes failed in the process.
Namespace
api.events.electionProviderMultiPhase.ElectionFailedType
type ElectionFailed = {
}ElectionFinalized
The election has been finalized, with the given computation and score.
Namespace
api.events.electionProviderMultiPhase.ElectionFinalizedType
type ElectionFinalized = {
compute: PalletElectionProviderMultiPhaseElectionCompute,
score: SpNposElectionsElectionScore
}Rewarded
An account has been rewarded for their signed submission being finalized.
Namespace
api.events.electionProviderMultiPhase.RewardedType
type Rewarded = {
account: SeedPrimitivesSignatureAccountId20,
value: u128
}SignedPhaseStarted
The signed phase of the given round has started.
Namespace
api.events.electionProviderMultiPhase.SignedPhaseStartedType
type SignedPhaseStarted = {
round: u32
}Slashed
An account has been slashed for submitting an invalid signed submission.
Namespace
api.events.electionProviderMultiPhase.SlashedType
type Slashed = {
account: SeedPrimitivesSignatureAccountId20,
value: u128
}SolutionStored
A solution was stored with the given compute.
If the solution is signed, this means that it hasn't yet been processed. If the solution is unsigned, this means that it has also been processed.
The bool is true when a previous solution was ejected to make room for this one.
Namespace
api.events.electionProviderMultiPhase.SolutionStoredType
type SolutionStored = {
compute: PalletElectionProviderMultiPhaseElectionCompute,
prev_ejected: bool
}UnsignedPhaseStarted
The unsigned phase of the given round has started.
Namespace
api.events.electionProviderMultiPhase.UnsignedPhaseStartedType
type UnsignedPhaseStarted = {
round: u32
}Errors
CallNotAllowed
The call is not allowed at this point.
Namespace
api.errors.electionProviderMultiPhase.CallNotAllowedFallbackFailed
The fallback failed
Namespace
api.errors.electionProviderMultiPhase.FallbackFailedInvalidSubmissionIndex
Self::insert_submission returned an invalid index.
Namespace
api.errors.electionProviderMultiPhase.InvalidSubmissionIndexMissingSnapshotMetadata
Snapshot metadata should exist but didn't.
Namespace
api.errors.electionProviderMultiPhase.MissingSnapshotMetadataOcwCallWrongEra
OCW submitted solution for wrong round
Namespace
api.errors.electionProviderMultiPhase.OcwCallWrongEraPreDispatchEarlySubmission
Submission was too early.
Namespace
api.errors.electionProviderMultiPhase.PreDispatchEarlySubmissionPreDispatchWeakSubmission
Submission was too weak, score-wise.
Namespace
api.errors.electionProviderMultiPhase.PreDispatchWeakSubmissionPreDispatchWrongWinnerCount
Wrong number of winners presented.
Namespace
api.errors.electionProviderMultiPhase.PreDispatchWrongWinnerCountSignedCannotPayDeposit
The origin failed to pay the deposit.
Namespace
api.errors.electionProviderMultiPhase.SignedCannotPayDepositSignedInvalidWitness
Witness data to dispatchable is invalid.
Namespace
api.errors.electionProviderMultiPhase.SignedInvalidWitnessSignedQueueFull
The queue was full, and the solution was not better than any of the existing ones.
Namespace
api.errors.electionProviderMultiPhase.SignedQueueFullSignedTooMuchWeight
The signed submission consumes too much weight
Namespace
api.errors.electionProviderMultiPhase.SignedTooMuchWeightConstants
betterSignedThreshold
The minimum amount of improvement to the solution score that defines a solution as "better" in the Signed phase.
Namespace
api.consts.electionProviderMultiPhase.betterSignedThresholdType
type betterSignedThreshold = PerbillbetterUnsignedThreshold
The minimum amount of improvement to the solution score that defines a solution as "better" in the Unsigned phase.
Namespace
api.consts.electionProviderMultiPhase.betterUnsignedThresholdType
type betterUnsignedThreshold = PerbillmaxElectableTargets
The maximum number of electable targets to put in the snapshot.
Namespace
api.consts.electionProviderMultiPhase.maxElectableTargetsType
type maxElectableTargets = u16maxElectingVoters
The maximum number of electing voters to put in the snapshot. At the moment, snapshots are only over a single block, but once multi-block elections are introduced they will take place over multiple blocks.
Namespace
api.consts.electionProviderMultiPhase.maxElectingVotersType
type maxElectingVoters = u32minerMaxLength
Namespace
api.consts.electionProviderMultiPhase.minerMaxLengthType
type minerMaxLength = u32minerMaxVotesPerVoter
Namespace
api.consts.electionProviderMultiPhase.minerMaxVotesPerVoterType
type minerMaxVotesPerVoter = u32minerMaxWeight
Namespace
api.consts.electionProviderMultiPhase.minerMaxWeightType
type minerMaxWeight = WeightV1minerTxPriority
The priority of the unsigned transaction submitted in the unsigned-phase
Namespace
api.consts.electionProviderMultiPhase.minerTxPriorityType
type minerTxPriority = u64offchainRepeat
The repeat threshold of the offchain worker.
For example, if it is 5, that means that at least 5 blocks will elapse between attempts to submit the worker's solution.
Namespace
api.consts.electionProviderMultiPhase.offchainRepeatType
type offchainRepeat = u32signedDepositBase
Base deposit for a signed solution.
Namespace
api.consts.electionProviderMultiPhase.signedDepositBaseType
type signedDepositBase = u128signedDepositByte
Per-byte deposit for a signed solution.
Namespace
api.consts.electionProviderMultiPhase.signedDepositByteType
type signedDepositByte = u128signedDepositWeight
Per-weight deposit for a signed solution.
Namespace
api.consts.electionProviderMultiPhase.signedDepositWeightType
type signedDepositWeight = u128signedMaxRefunds
The maximum amount of unchecked solutions to refund the call fee for.
Namespace
api.consts.electionProviderMultiPhase.signedMaxRefundsType
type signedMaxRefunds = u32signedMaxSubmissions
Maximum number of signed submissions that can be queued.
It is best to avoid adjusting this during an election, as it impacts downstream data structures. In particular, SignedSubmissionIndices<T> is bounded on this value. If you update this value during an election, you must ensure that SignedSubmissionIndices.len() is less than or equal to the new value. Otherwise, attempts to submit new solutions may cause a runtime panic.
Namespace
api.consts.electionProviderMultiPhase.signedMaxSubmissionsType
type signedMaxSubmissions = u32signedMaxWeight
Maximum weight of a signed solution.
If [Config::MinerConfig] is being implemented to submit signed solutions (outside of this pallet), then [MinerConfig::solution_weight] is used to compare against this value.
Namespace
api.consts.electionProviderMultiPhase.signedMaxWeightType
type signedMaxWeight = WeightV1signedPhase
Duration of the signed phase.
Namespace
api.consts.electionProviderMultiPhase.signedPhaseType
type signedPhase = u32signedRewardBase
Base reward for a signed solution
Namespace
api.consts.electionProviderMultiPhase.signedRewardBaseType
type signedRewardBase = u128unsignedPhase
Duration of the unsigned phase.
Namespace
api.consts.electionProviderMultiPhase.unsignedPhaseType
type unsignedPhase = u32