mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 15:47:58 +00:00
Recursive election provider as fallback (#9648)
* Recursive election provider as fallback * minor fix * Fix integrity tests * Update frame/election-provider-multi-phase/src/lib.rs Co-authored-by: Zeke Mostov <32168567+emostov@users.noreply.github.com> * Fix everything * fmt again * Fix test * Fix state machine warning * Fix build Co-authored-by: Zeke Mostov <32168567+emostov@users.noreply.github.com>
This commit is contained in:
@@ -42,7 +42,6 @@ use frame_system::{
|
||||
pub use node_primitives::{AccountId, Signature};
|
||||
use node_primitives::{AccountIndex, Balance, BlockNumber, Hash, Index, Moment};
|
||||
use pallet_contracts::weights::WeightInfo;
|
||||
use pallet_election_provider_multi_phase::FallbackStrategy;
|
||||
use pallet_grandpa::{
|
||||
fg_primitives, AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList,
|
||||
};
|
||||
@@ -487,6 +486,11 @@ parameter_types! {
|
||||
}
|
||||
|
||||
use frame_election_provider_support::onchain;
|
||||
impl onchain::Config for Runtime {
|
||||
type Accuracy = Perbill;
|
||||
type DataProvider = Staking;
|
||||
}
|
||||
|
||||
impl pallet_staking::Config for Runtime {
|
||||
const MAX_NOMINATIONS: u32 = MAX_NOMINATIONS;
|
||||
type Currency = Balances;
|
||||
@@ -510,9 +514,7 @@ impl pallet_staking::Config for Runtime {
|
||||
type NextNewSession = Session;
|
||||
type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
|
||||
type ElectionProvider = ElectionProviderMultiPhase;
|
||||
type GenesisElectionProvider = onchain::OnChainSequentialPhragmen<
|
||||
pallet_election_provider_multi_phase::OnChainConfig<Self>,
|
||||
>;
|
||||
type GenesisElectionProvider = onchain::OnChainSequentialPhragmen<Self>;
|
||||
type WeightInfo = pallet_staking::weights::SubstrateWeight<Runtime>;
|
||||
}
|
||||
|
||||
@@ -527,9 +529,6 @@ parameter_types! {
|
||||
pub const SignedDepositBase: Balance = 1 * DOLLARS;
|
||||
pub const SignedDepositByte: Balance = 1 * CENTS;
|
||||
|
||||
// fallback: no on-chain fallback.
|
||||
pub const Fallback: FallbackStrategy = FallbackStrategy::Nothing;
|
||||
|
||||
pub SolutionImprovementThreshold: Perbill = Perbill::from_rational(1u32, 10_000);
|
||||
|
||||
// miner configs
|
||||
@@ -615,15 +614,14 @@ impl pallet_election_provider_multi_phase::Config for Runtime {
|
||||
type SlashHandler = (); // burn slashes
|
||||
type RewardHandler = (); // nothing to do upon rewards
|
||||
type DataProvider = Staking;
|
||||
type OnChainAccuracy = Perbill;
|
||||
type Solution = NposSolution16;
|
||||
type Fallback = Fallback;
|
||||
type Fallback = pallet_election_provider_multi_phase::NoFallback<Self>;
|
||||
type Solver = frame_election_provider_support::SequentialPhragmen<
|
||||
AccountId,
|
||||
pallet_election_provider_multi_phase::SolutionAccuracyOf<Runtime>,
|
||||
pallet_election_provider_multi_phase::SolutionAccuracyOf<Self>,
|
||||
OffchainRandomBalancing,
|
||||
>;
|
||||
type WeightInfo = pallet_election_provider_multi_phase::weights::SubstrateWeight<Runtime>;
|
||||
type WeightInfo = pallet_election_provider_multi_phase::weights::SubstrateWeight<Self>;
|
||||
type ForceOrigin = EnsureRootOrHalfCouncil;
|
||||
type BenchmarkingConfig = BenchmarkConfig;
|
||||
}
|
||||
@@ -1686,6 +1684,7 @@ impl_runtime_apis! {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use frame_system::offchain::CreateSignedTransaction;
|
||||
use sp_runtime::UpperOf;
|
||||
|
||||
#[test]
|
||||
fn validate_transaction_submitter_bounds() {
|
||||
@@ -1698,6 +1697,16 @@ mod tests {
|
||||
is_submit_signed_transaction::<Runtime>();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn perbill_as_onchain_accuracy() {
|
||||
type OnChainAccuracy = <Runtime as onchain::Config>::Accuracy;
|
||||
let maximum_chain_accuracy: Vec<UpperOf<OnChainAccuracy>> = (0..MAX_NOMINATIONS)
|
||||
.map(|_| <UpperOf<OnChainAccuracy>>::from(OnChainAccuracy::one().deconstruct()))
|
||||
.collect();
|
||||
let _: UpperOf<OnChainAccuracy> =
|
||||
maximum_chain_accuracy.iter().fold(0, |acc, x| acc.checked_add(*x).unwrap());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn call_size() {
|
||||
assert!(
|
||||
|
||||
Reference in New Issue
Block a user