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
Type
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
Type
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
Type
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
Type
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
Type
Storage
currentPhase
Current phase.
Namespace
Type
desiredTargets
Desired number of targets to elect for this round.
Only exists when [Snapshot
] is present.
Namespace
Type
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
Type
queuedSolution
Current best solution, signed or unsigned, queued to be returned upon elect
.
Namespace
Type
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
Type
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
Type
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
Type
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
Type
snapshot
Snapshot data of the round.
This is created at the beginning of the signed phase and cleared upon calling elect
.
Namespace
Type
snapshotMetadata
The metadata of the [RoundSnapshot
]
Only exists when [Snapshot
] is present.
Namespace
Type
Events
ElectionFailed
An election failed.
Not much can be said about which computes failed in the process.
Namespace
Type
ElectionFinalized
The election has been finalized, with the given computation and score.
Namespace
Type
Rewarded
An account has been rewarded for their signed submission being finalized.
Namespace
Type
SignedPhaseStarted
The signed phase of the given round has started.
Namespace
Type
Slashed
An account has been slashed for submitting an invalid signed submission.
Namespace
Type
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
Type
UnsignedPhaseStarted
The unsigned phase of the given round has started.
Namespace
Type
Errors
CallNotAllowed
The call is not allowed at this point.
Namespace
FallbackFailed
The fallback failed
Namespace
InvalidSubmissionIndex
Self::insert_submission
returned an invalid index.
Namespace
MissingSnapshotMetadata
Snapshot metadata should exist but didn't.
Namespace
OcwCallWrongEra
OCW submitted solution for wrong round
Namespace
PreDispatchEarlySubmission
Submission was too early.
Namespace
PreDispatchWeakSubmission
Submission was too weak, score-wise.
Namespace
PreDispatchWrongWinnerCount
Wrong number of winners presented.
Namespace
SignedCannotPayDeposit
The origin failed to pay the deposit.
Namespace
SignedInvalidWitness
Witness data to dispatchable is invalid.
Namespace
SignedQueueFull
The queue was full, and the solution was not better than any of the existing ones.
Namespace
SignedTooMuchWeight
The signed submission consumes too much weight
Namespace
Constants
betterSignedThreshold
The minimum amount of improvement to the solution score that defines a solution as "better" in the Signed phase.
Namespace
Type
betterUnsignedThreshold
The minimum amount of improvement to the solution score that defines a solution as "better" in the Unsigned phase.
Namespace
Type
maxElectableTargets
The maximum number of electable targets to put in the snapshot.
Namespace
Type
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
Type
minerMaxLength
Namespace
Type
minerMaxVotesPerVoter
Namespace
Type
minerMaxWeight
Namespace
Type
minerTxPriority
The priority of the unsigned transaction submitted in the unsigned-phase
Namespace
Type
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
Type
signedDepositBase
Base deposit for a signed solution.
Namespace
Type
signedDepositByte
Per-byte deposit for a signed solution.
Namespace
Type
signedDepositWeight
Per-weight deposit for a signed solution.
Namespace
Type
signedMaxRefunds
The maximum amount of unchecked solutions to refund the call fee for.
Namespace
Type
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
Type
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
Type
signedPhase
Duration of the signed phase.
Namespace
Type
signedRewardBase
Base reward for a signed solution
Namespace
Type
unsignedPhase
Duration of the unsigned phase.
Namespace
Type
Last updated