ElectionProviderMultiPhase
Calls
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.governanceFallback
Type
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.setEmergencyElectionResult
Type
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.setMinimumUntrustedScore
Type
function setMinimumUntrustedScore(
maybe_next_score: Option<SpNposElectionsElectionScore>
)
submit
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.
Namespace
api.tx.electionProviderMultiPhase.submit
Type
function submit(
raw_solution: PalletElectionProviderMultiPhaseRawSolution
)
submitUnsigned
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.
Namespace
api.tx.electionProviderMultiPhase.submitUnsigned
Type
function submitUnsigned(
raw_solution: PalletElectionProviderMultiPhaseRawSolution,
witness: PalletElectionProviderMultiPhaseSolutionOrSnapshotSize
)
Storage
currentPhase
Current phase.
Namespace
api.query.electionProviderMultiPhase.currentPhase
Type
function currentPhase(
): PalletElectionProviderMultiPhasePhase
desiredTargets
Desired number of targets to elect for this round.
Only exists when [Snapshot
] is present.
Namespace
api.query.electionProviderMultiPhase.desiredTargets
Type
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.minimumUntrustedScore
Type
function minimumUntrustedScore(
): Option<SpNposElectionsElectionScore>
queuedSolution
Current best solution, signed or unsigned, queued to be returned upon elect
.
Namespace
api.query.electionProviderMultiPhase.queuedSolution
Type
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 per every time that an upstream elect
is called.
Namespace
api.query.electionProviderMultiPhase.round
Type
function round(
): u32
signedSubmissionIndices
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.signedSubmissionIndices
Type
function signedSubmissionIndices(
): BTreeMap<SpNposElectionsElectionScore, u32>
signedSubmissionNextIndex
The next index 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.signedSubmissionNextIndex
Type
function signedSubmissionNextIndex(
): u32
signedSubmissionsMap
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.signedSubmissionsMap
Type
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.snapshot
Type
function snapshot(
): Option<PalletElectionProviderMultiPhaseRoundSnapshot>
snapshotMetadata
The metadata of the [RoundSnapshot
]
Only exists when [Snapshot
] is present.
Namespace
api.query.electionProviderMultiPhase.snapshotMetadata
Type
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.ElectionFailed
Type
type ElectionFailed = {
}
ElectionFinalized
The election has been finalized, with the given computation and score.
Namespace
api.events.electionProviderMultiPhase.ElectionFinalized
Type
type ElectionFinalized = {
compute: PalletElectionProviderMultiPhaseElectionCompute,
score: SpNposElectionsElectionScore
}
Rewarded
An account has been rewarded for their signed submission being finalized.
Namespace
api.events.electionProviderMultiPhase.Rewarded
Type
type Rewarded = {
account: SeedPrimitivesSignatureAccountId20,
value: u128
}
SignedPhaseStarted
The signed phase of the given round has started.
Namespace
api.events.electionProviderMultiPhase.SignedPhaseStarted
Type
type SignedPhaseStarted = {
round: u32
}
Slashed
An account has been slashed for submitting an invalid signed submission.
Namespace
api.events.electionProviderMultiPhase.Slashed
Type
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.SolutionStored
Type
type SolutionStored = {
compute: PalletElectionProviderMultiPhaseElectionCompute,
prev_ejected: bool
}
UnsignedPhaseStarted
The unsigned phase of the given round has started.
Namespace
api.events.electionProviderMultiPhase.UnsignedPhaseStarted
Type
type UnsignedPhaseStarted = {
round: u32
}
Errors
CallNotAllowed
The call is not allowed at this point.
Namespace
api.errors.electionProviderMultiPhase.CallNotAllowed
FallbackFailed
The fallback failed
Namespace
api.errors.electionProviderMultiPhase.FallbackFailed
InvalidSubmissionIndex
Self::insert_submission
returned an invalid index.
Namespace
api.errors.electionProviderMultiPhase.InvalidSubmissionIndex
MissingSnapshotMetadata
Snapshot metadata should exist but didn't.
Namespace
api.errors.electionProviderMultiPhase.MissingSnapshotMetadata
OcwCallWrongEra
OCW submitted solution for wrong round
Namespace
api.errors.electionProviderMultiPhase.OcwCallWrongEra
PreDispatchEarlySubmission
Submission was too early.
Namespace
api.errors.electionProviderMultiPhase.PreDispatchEarlySubmission
PreDispatchWeakSubmission
Submission was too weak, score-wise.
Namespace
api.errors.electionProviderMultiPhase.PreDispatchWeakSubmission
PreDispatchWrongWinnerCount
Wrong number of winners presented.
Namespace
api.errors.electionProviderMultiPhase.PreDispatchWrongWinnerCount
SignedCannotPayDeposit
The origin failed to pay the deposit.
Namespace
api.errors.electionProviderMultiPhase.SignedCannotPayDeposit
SignedInvalidWitness
Witness data to dispatchable is invalid.
Namespace
api.errors.electionProviderMultiPhase.SignedInvalidWitness
SignedQueueFull
The queue was full, and the solution was not better than any of the existing ones.
Namespace
api.errors.electionProviderMultiPhase.SignedQueueFull
SignedTooMuchWeight
The signed submission consumes too much weight
Namespace
api.errors.electionProviderMultiPhase.SignedTooMuchWeight
Constants
betterSignedThreshold
The minimum amount of improvement to the solution score that defines a solution as "better" in the Signed phase.
Namespace
api.consts.electionProviderMultiPhase.betterSignedThreshold
Type
type betterSignedThreshold = Perbill
betterUnsignedThreshold
The minimum amount of improvement to the solution score that defines a solution as "better" in the Unsigned phase.
Namespace
api.consts.electionProviderMultiPhase.betterUnsignedThreshold
Type
type betterUnsignedThreshold = Perbill
maxElectableTargets
The maximum number of electable targets to put in the snapshot.
Namespace
api.consts.electionProviderMultiPhase.maxElectableTargets
Type
type maxElectableTargets = u16
maxElectingVoters
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.maxElectingVoters
Type
type maxElectingVoters = u32
minerMaxLength
Namespace
api.consts.electionProviderMultiPhase.minerMaxLength
Type
type minerMaxLength = u32
minerMaxVotesPerVoter
Namespace
api.consts.electionProviderMultiPhase.minerMaxVotesPerVoter
Type
type minerMaxVotesPerVoter = u32
minerMaxWeight
Namespace
api.consts.electionProviderMultiPhase.minerMaxWeight
Type
type minerMaxWeight = WeightV1
minerTxPriority
The priority of the unsigned transaction submitted in the unsigned-phase
Namespace
api.consts.electionProviderMultiPhase.minerTxPriority
Type
type minerTxPriority = u64
offchainRepeat
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.offchainRepeat
Type
type offchainRepeat = u32
signedDepositBase
Base deposit for a signed solution.
Namespace
api.consts.electionProviderMultiPhase.signedDepositBase
Type
type signedDepositBase = u128
signedDepositByte
Per-byte deposit for a signed solution.
Namespace
api.consts.electionProviderMultiPhase.signedDepositByte
Type
type signedDepositByte = u128
signedDepositWeight
Per-weight deposit for a signed solution.
Namespace
api.consts.electionProviderMultiPhase.signedDepositWeight
Type
type signedDepositWeight = u128
signedMaxRefunds
The maximum amount of unchecked solutions to refund the call fee for.
Namespace
api.consts.electionProviderMultiPhase.signedMaxRefunds
Type
type signedMaxRefunds = u32
signedMaxSubmissions
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.signedMaxSubmissions
Type
type signedMaxSubmissions = u32
signedMaxWeight
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.signedMaxWeight
Type
type signedMaxWeight = WeightV1
signedPhase
Duration of the signed phase.
Namespace
api.consts.electionProviderMultiPhase.signedPhase
Type
type signedPhase = u32
signedRewardBase
Base reward for a signed solution
Namespace
api.consts.electionProviderMultiPhase.signedRewardBase
Type
type signedRewardBase = u128
unsignedPhase
Duration of the unsigned phase.
Namespace
api.consts.electionProviderMultiPhase.unsignedPhase
Type
type unsignedPhase = u32