Adding Fallback on election failure (#5093)

* Adding `Fallback` on election failure
Use the newly introduced `BoundedOnChainSequentialPhragmen`
and `UnboundedOnChainSequentialPhragmen`

* Adding `BoundedOnchainExecution`
after changes in substrate

* Introducing `ExecutionConfig`
from `frame_election_provider_support::onchain`

* `OnChainSequentialPhragmen` > `OnChainSeqPhragmen`
Renaming to have a shorter name

* `BoundedOnchainExecution` -> `BoundedExecution`
And `UnboundedOnchainExecution` -> `UnboundedExecution`

* `Fallback` back to `NoFallback`
`UnboundedExecution` for `GovernanceFallback`

* Update runtime/test-runtime/src/lib.rs

* update lockfile for {"substrate"}

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Co-authored-by: parity-processbot <>
This commit is contained in:
Georges
2022-03-26 14:27:39 +00:00
committed by GitHub
parent cbd6570c56
commit 7793796bd2
6 changed files with 219 additions and 211 deletions
+17 -3
View File
@@ -16,7 +16,10 @@
//! Code for elections.
use frame_election_provider_support::SortedListProvider;
use frame_election_provider_support::{
onchain::{ExecutionConfig, UnboundedExecution},
ElectionDataProvider, SequentialPhragmen, SortedListProvider,
};
use sp_std::{boxed::Box, marker::PhantomData};
/// Implements the weight types for the elections module and a specific
@@ -64,9 +67,20 @@ impl pallet_election_provider_multi_phase::BenchmarkingConfig for BenchmarkConfi
/// The accuracy type used for genesis election provider;
pub type OnOnChainAccuracy = sp_runtime::Perbill;
/// Election Configuration parameters
pub struct OnChainSeqPhragmen<T: frame_system::Config, S>(PhantomData<(T, S)>);
impl<
T: frame_system::Config,
S: ElectionDataProvider<AccountId = T::AccountId, BlockNumber = T::BlockNumber>,
> ExecutionConfig for OnChainSeqPhragmen<T, S>
{
type System = T;
type Solver = SequentialPhragmen<T::AccountId, OnOnChainAccuracy>;
type DataProvider = S;
}
/// The election provider of the genesis
pub type GenesisElectionOf<T> =
frame_election_provider_support::onchain::OnChainSequentialPhragmen<T>;
pub type GenesisElectionOf<T, S> = UnboundedExecution<OnChainSeqPhragmen<T, S>>;
/// Implementation of `frame_election_provider_support::SortedListProvider` that updates the
/// bags-list but uses [`pallet_staking::Nominators`] for `iter`. This is meant to be a transitionary