-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Description
See:
polkadot-sdk/substrate/frame/election-provider-multi-block/src/lib.rs
Lines 605 to 658 in 18f6251
| /// Manage this pallet. | |
| /// | |
| /// The origin of this call must be [`Config::AdminOrigin`]. | |
| /// | |
| /// See [`AdminOperation`] for various operations that are possible. | |
| #[pallet::weight(T::WeightInfo::manage())] | |
| #[pallet::call_index(0)] | |
| pub fn manage(origin: OriginFor<T>, op: AdminOperation<T>) -> DispatchResultWithPostInfo { | |
| use crate::verifier::Verifier; | |
| use sp_npos_elections::EvaluateSupport; | |
| let _ = T::AdminOrigin::ensure_origin(origin); | |
| match op { | |
| AdminOperation::EmergencyFallback => { | |
| ensure!(Self::current_phase() == Phase::Emergency, Error::<T>::UnexpectedPhase); | |
| // note: for now we run this on the msp, but we can make it configurable if need | |
| // be. | |
| let voters = Snapshot::<T>::voters(Self::msp()).ok_or(Error::<T>::Snapshot)?; | |
| let targets = Snapshot::<T>::targets().ok_or(Error::<T>::Snapshot)?; | |
| let desired_targets = | |
| Snapshot::<T>::desired_targets().ok_or(Error::<T>::Snapshot)?; | |
| let fallback = T::Fallback::instant_elect( | |
| voters.into_inner(), | |
| targets.into_inner(), | |
| desired_targets, | |
| ) | |
| .map_err(|e| { | |
| log!(warn, "Fallback failed: {:?}", e); | |
| Error::<T>::Fallback | |
| })?; | |
| let score = fallback.evaluate(); | |
| T::Verifier::force_set_single_page_valid(fallback, 0, score); | |
| Ok(().into()) | |
| }, | |
| AdminOperation::EmergencySetSolution(supports, score) => { | |
| ensure!(Self::current_phase() == Phase::Emergency, Error::<T>::UnexpectedPhase); | |
| // TODO: hardcoding zero here doesn't make a lot of sense | |
| T::Verifier::force_set_single_page_valid(*supports, 0, score); | |
| Ok(().into()) | |
| }, | |
| AdminOperation::ForceSetPhase(phase) => { | |
| Self::phase_transition(phase); | |
| Ok(().into()) | |
| }, | |
| AdminOperation::ForceRotateRound => { | |
| Self::rotate_round(); | |
| Ok(().into()) | |
| }, | |
| AdminOperation::SetMinUntrustedScore(score) => { | |
| T::Verifier::set_minimum_score(score); | |
| Ok(().into()) | |
| }, | |
| } | |
| } |
Some initial code is here, but it is not very well thought out.
The main scenario that we should be able to support is:
- Election is not succeeding for whatever reason.
- Governance wants to set a manual solution, and make it go through.
- They would have to:
ForceSetPhase(Emergency)EmergencySetSolutionfor multiple pages (not possible now)ForceSetPhase(Done)(signaling staking to be complete)
- This scenario should be well tested.
- If the rest of the scenarios remain, they should also be fully tested and their side effects understood. e.g. Fix origin check in EPMB's manage extrinsic #10248 (comment)
sigurpol
Metadata
Metadata
Assignees
Labels
No labels