Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Prev Previous commit
Next Next commit
Adding BoundedOnchainExecution
after changes in substrate
  • Loading branch information
Georges Dib committed Mar 18, 2022
commit 6f7736e65457e45e1f000f8fb34d6ac94a3f1a42
2 changes: 1 addition & 1 deletion runtime/common/src/elections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ pub type OnOnChainAccuracy = sp_runtime::Perbill;

/// The election provider of the genesis
pub type GenesisElectionOf<T> =
frame_election_provider_support::onchain::UnboundedSequentialPhragmen<T>;
frame_election_provider_support::onchain::UnboundedOnchainExecution<T>;

/// 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
Expand Down
24 changes: 13 additions & 11 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ use runtime_parachains::{

use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
use beefy_primitives::crypto::AuthorityId as BeefyId;
use frame_election_provider_support::{
generate_solution_type, onchain::BoundedOnchainExecution, NposSolution, SequentialPhragmen,
};
use frame_support::{
construct_runtime, parameter_types,
traits::{
Expand Down Expand Up @@ -412,7 +415,7 @@ parameter_types! {
pub const VoterSnapshotPerBlock: u32 = 22_500;
}

frame_election_provider_support::generate_solution_type!(
generate_solution_type!(
#[compact]
pub struct NposCompactSolution24::<
VoterIndex = u32,
Expand Down Expand Up @@ -442,18 +445,17 @@ impl pallet_election_provider_multi_phase::Config for Runtime {
type MinerTxPriority = NposSolutionPriority;
type DataProvider = Staking;
type Solution = NposCompactSolution24;
type Fallback = frame_election_provider_support::onchain::BoundedOnChainSequentialPhragmen<
type Fallback = BoundedOnchainExecution<
Self,
frame_support::traits::ConstU32<20_000>,
frame_support::traits::ConstU32<2_000>,
>;
type GovernanceFallback = BoundedOnchainExecution<
Self,
frame_support::traits::ConstU32<20_000>,
frame_support::traits::ConstU32<2_000>,
>;
type GovernanceFallback =
frame_election_provider_support::onchain::BoundedOnChainSequentialPhragmen<
Self,
frame_support::traits::ConstU32<20_000>,
frame_support::traits::ConstU32<2_000>,
>;
type Solver = frame_election_provider_support::SequentialPhragmen<
type Solver = SequentialPhragmen<
AccountId,
pallet_election_provider_multi_phase::SolutionAccuracyOf<Self>,
(),
Expand Down Expand Up @@ -551,7 +553,7 @@ parameter_types! {
pub const MaxNominatorRewardedPerValidator: u32 = 256;
pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17);
// 24
pub const MaxNominations: u32 = <NposCompactSolution24 as frame_election_provider_support::NposSolution>::LIMIT as u32;
pub const MaxNominations: u32 = <NposCompactSolution24 as NposSolution>::LIMIT as u32;
}

type SlashCancelOrigin = EnsureOneOf<
Expand All @@ -560,7 +562,7 @@ type SlashCancelOrigin = EnsureOneOf<
>;

impl frame_election_provider_support::onchain::Config for Runtime {
type Accuracy = runtime_common::elections::OnOnChainAccuracy;
type Solver = SequentialPhragmen<AccountId, runtime_common::elections::OnOnChainAccuracy>;
type DataProvider = Staking;
}

Expand Down
22 changes: 12 additions & 10 deletions runtime/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ use runtime_parachains::{

use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
use beefy_primitives::crypto::AuthorityId as BeefyId;
use frame_election_provider_support::{
generate_solution_type, onchain::BoundedOnchainExecution, SequentialPhragmen,
};
use frame_support::{
construct_runtime, parameter_types,
traits::{
Expand Down Expand Up @@ -455,7 +458,7 @@ parameter_types! {
pub const VoterSnapshotPerBlock: u32 = 22_500;
}

frame_election_provider_support::generate_solution_type!(
generate_solution_type!(
#[compact]
pub struct NposCompactSolution16::<
VoterIndex = u32,
Expand Down Expand Up @@ -485,18 +488,17 @@ impl pallet_election_provider_multi_phase::Config for Runtime {
type MinerTxPriority = NposSolutionPriority;
type DataProvider = Staking;
type Solution = NposCompactSolution16;
type Fallback = frame_election_provider_support::onchain::BoundedOnChainSequentialPhragmen<
type Fallback = BoundedOnchainExecution<
Self,
frame_support::traits::ConstU32<20_000>,
frame_support::traits::ConstU32<2_000>,
>;
type GovernanceFallback = BoundedOnchainExecution<
Self,
frame_support::traits::ConstU32<20_000>,
frame_support::traits::ConstU32<2_000>,
>;
type GovernanceFallback =
frame_election_provider_support::onchain::BoundedOnChainSequentialPhragmen<
Self,
frame_support::traits::ConstU32<20_000>,
frame_support::traits::ConstU32<2_000>,
>;
type Solver = frame_election_provider_support::SequentialPhragmen<
type Solver = SequentialPhragmen<
AccountId,
pallet_election_provider_multi_phase::SolutionAccuracyOf<Self>,
(),
Expand Down Expand Up @@ -557,7 +559,7 @@ type SlashCancelOrigin = EnsureOneOf<
>;

impl frame_election_provider_support::onchain::Config for Runtime {
type Accuracy = runtime_common::elections::OnOnChainAccuracy;
type Solver = SequentialPhragmen<AccountId, runtime_common::elections::OnOnChainAccuracy>;
type DataProvider = Staking;
}

Expand Down
9 changes: 6 additions & 3 deletions runtime/test-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,10 @@ parameter_types! {
}

impl frame_election_provider_support::onchain::Config for Runtime {
type Accuracy = runtime_common::elections::OnOnChainAccuracy;
type Solver = frame_election_provider_support::SequentialPhragmen<
AccountId,
runtime_common::elections::OnOnChainAccuracy,
>;
type DataProvider = Staking;
}

Expand All @@ -343,9 +346,9 @@ impl pallet_staking::Config for Runtime {
type OffendingValidatorsThreshold = OffendingValidatorsThreshold;
type NextNewSession = Session;
type ElectionProvider =
frame_election_provider_support::onchain::UnboundedSequentialPhragmen<Self>;
frame_election_provider_support::onchain::UnboundedOnchainExecution<Self>;
type GenesisElectionProvider =
frame_election_provider_support::onchain::UnboundedSequentialPhragmen<Self>;
frame_election_provider_support::onchain::UnboundedOnchainExecution<Self>;
// Use the nominator map to iter voter AND no-ops for all SortedListProvider hooks. The migration
// to bags-list is a no-op, but the storage version will be updated.
type SortedListProvider = pallet_staking::UseNominatorsMap<Runtime>;
Expand Down
18 changes: 9 additions & 9 deletions runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
use beefy_primitives::crypto::AuthorityId as BeefyId;
use frame_election_provider_support::{onchain::BoundedOnchainExecution, SequentialPhragmen};
use frame_support::{
construct_runtime, parameter_types,
traits::{Contains, InstanceFilter, KeyOwnerProofSystem, OnRuntimeUpgrade},
Expand Down Expand Up @@ -387,18 +388,17 @@ impl pallet_election_provider_multi_phase::Config for Runtime {
type MinerTxPriority = NposSolutionPriority;
type DataProvider = Staking;
type Solution = NposCompactSolution16;
type Fallback = frame_election_provider_support::onchain::BoundedOnChainSequentialPhragmen<
type Fallback = BoundedOnchainExecution<
Self,
frame_support::traits::ConstU32<20_000>,
frame_support::traits::ConstU32<2_000>,
>;
type GovernanceFallback =
frame_election_provider_support::onchain::BoundedOnChainSequentialPhragmen<
Self,
frame_support::traits::ConstU32<20_000>,
frame_support::traits::ConstU32<2_000>,
>;
type Solver = frame_election_provider_support::SequentialPhragmen<
type GovernanceFallback = BoundedOnchainExecution<
Self,
frame_support::traits::ConstU32<20_000>,
frame_support::traits::ConstU32<2_000>,
>;
type Solver = SequentialPhragmen<
AccountId,
pallet_election_provider_multi_phase::SolutionAccuracyOf<Self>,
(),
Expand Down Expand Up @@ -446,7 +446,7 @@ parameter_types! {
}

impl frame_election_provider_support::onchain::Config for Runtime {
type Accuracy = runtime_common::elections::OnOnChainAccuracy;
type Solver = SequentialPhragmen<AccountId, runtime_common::elections::OnOnChainAccuracy>;
type DataProvider = Staking;
}

Expand Down