Add a bounded fallback on failed elections (#10988)

* Allow `pallet-election-provider` to accept smaller
solutions, issue #9478

* Fixing a typo

* Adding some more tests
Removing a seemingly outdated comment

* making it a URL

* Updating test name as per suggestion

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Updating documentation to be more explicit

And to follow the general guidelines

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Fixing formatting

* `Fallback` now of type `InstantElectionProvider`
Some cleanups

* Allow `pallet-election-provider` to accept smaller
solutions, issue #9478

* Fixing a typo

* Adding some more tests
Removing a seemingly outdated comment

* making it a URL

* Updating test name as per suggestion

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Updating documentation to be more explicit

And to follow the general guidelines

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Fixing formatting

* `Fallback` now of type `InstantElectionProvider`
Some cleanups

* Merging types into one type with generics

* Removing `ConstUSize` and use `ConstU32`

* cleaning up the code

* deprecating `OnChainSequentialPhragmen`
Renaming it to `UnboundedSequentialPhragmen` which should only be used
at genesis and for testing.
Use preferrably `BoundedOnChainSequentialPhragmen`

* Amending docs

* Adding some explicit imports

* Implementing generic `BoundedOnchainExecution`
Removing the deprecated `OnChainSequentialPhragmen`

* Use the right Balancing strategy

* Refactoring `onchain::Config`
Creating `onchain::ExecutionConfig`

* Merge master

* fmt

* Name cleanups after review suggestions

* cosmetics

* renaming `instant_elect` to `elect_with_bounds`
Other corresponding changes as per @kianenigma feedback

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

* feedback from kian

* fmt + unneeded import

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Co-authored-by: kianenigma <kian@parity.io>
This commit is contained in:
Georges
2022-03-25 20:15:50 +00:00
committed by GitHub
parent cbfb1f0e3b
commit e9bfdd9a0d
11 changed files with 225 additions and 137 deletions
@@ -18,7 +18,6 @@
//! A MMR storage implementations.
use codec::Encode;
use frame_support::log;
use mmr_lib::helper;
use sp_io::offchain_index;
use sp_std::iter::Peekable;
@@ -93,7 +92,7 @@ where
}
sp_std::if_std! {
log::trace!("elems: {:?}", elems.iter().map(|elem| elem.hash()).collect::<Vec<_>>());
frame_support::log::trace!("elems: {:?}", elems.iter().map(|elem| elem.hash()).collect::<Vec<_>>());
}
let leaves = NumberOfLeaves::<T, I>::get();
@@ -152,8 +151,8 @@ fn peaks_to_prune_and_store(
let peaks_before = if old_size == 0 { vec![] } else { helper::get_peaks(old_size) };
let peaks_after = helper::get_peaks(new_size);
sp_std::if_std! {
log::trace!("peaks_before: {:?}", peaks_before);
log::trace!("peaks_after: {:?}", peaks_after);
frame_support::log::trace!("peaks_before: {:?}", peaks_before);
frame_support::log::trace!("peaks_after: {:?}", peaks_after);
}
let mut peaks_before = peaks_before.into_iter().peekable();
let mut peaks_after = peaks_after.into_iter().peekable();