Companion for Adding benchmarking for new frame_election_provider_support #11149 (#5241)

* `GenesisElectionOf` after changes to substrate

* Benchmarking for `frame_election_provider_support`

* Introducing `OnChainSeqPhragmen` after changes
to substrate.
Pallet renaming in substrate

* Fixing `test-runtime`

* Use `UnboundedExecution` after change to substrate

* update lockfile for {"substrate"}

* cargo run --quiet --profile=production  --features=runtime-benchmarks -- benchmark pallet --chain=polkadot-dev --steps=50 --repeat=20 --pallet=frame_election_provider_support --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --header=./file_header.txt --output=./runtime/polkadot/src/weights/

* cargo run --quiet --profile=production  --features=runtime-benchmarks -- benchmark pallet --chain=kusama-dev --steps=50 --repeat=20 --pallet=frame_election_provider_support --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --header=./file_header.txt --output=./runtime/kusama/src/weights/

* cargo run --quiet --profile=production  --features=runtime-benchmarks -- benchmark pallet --chain=westend-dev --steps=50 --repeat=20 --pallet=frame_election_provider_support --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --header=./file_header.txt --output=./runtime/westend/src/weights/

Co-authored-by: parity-processbot <>
Co-authored-by: Parity Bot <admin@parity.io>
This commit is contained in:
Georges
2022-04-15 16:17:38 +01:00
committed by GitHub
parent e3326d26b3
commit a74c527d32
15 changed files with 435 additions and 211 deletions
+17 -6
View File
@@ -30,9 +30,8 @@ use primitives::v2::{
ValidationCodeHash, ValidatorId, ValidatorIndex,
};
use runtime_common::{
auctions, claims, crowdloan, elections::OnChainSeqPhragmen, impl_runtime_weights,
impls::DealWithFees, paras_registrar, prod_or_fast, slots, BlockHashCount, BlockLength,
CurrencyToVote, SlowAdjustingFeeUpdate,
auctions, claims, crowdloan, impl_runtime_weights, impls::DealWithFees, paras_registrar,
prod_or_fast, slots, BlockHashCount, BlockLength, CurrencyToVote, SlowAdjustingFeeUpdate,
};
use sp_std::{cmp::Ordering, collections::btree_map::BTreeMap, prelude::*};
@@ -48,7 +47,7 @@ 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::UnboundedExecution, NposSolution, SequentialPhragmen,
generate_solution_type, onchain, NposSolution, SequentialPhragmen,
};
use frame_support::{
construct_runtime, parameter_types,
@@ -430,6 +429,14 @@ generate_solution_type!(
>(24)
);
pub struct OnChainSeqPhragmen;
impl onchain::Config for OnChainSeqPhragmen {
type System = Runtime;
type Solver = SequentialPhragmen<AccountId, runtime_common::elections::OnChainAccuracy>;
type DataProvider = Staking;
type WeightInfo = weights::frame_election_provider_support::WeightInfo<Runtime>;
}
impl pallet_election_provider_multi_phase::Config for Runtime {
type Event = Event;
type Currency = Balances;
@@ -452,7 +459,7 @@ impl pallet_election_provider_multi_phase::Config for Runtime {
type DataProvider = Staking;
type Solution = NposCompactSolution24;
type Fallback = pallet_election_provider_multi_phase::NoFallback<Self>;
type GovernanceFallback = UnboundedExecution<OnChainSeqPhragmen<Self, Staking>>;
type GovernanceFallback = onchain::UnboundedExecution<OnChainSeqPhragmen>;
type Solver = SequentialPhragmen<
AccountId,
pallet_election_provider_multi_phase::SolutionAccuracyOf<Self>,
@@ -566,7 +573,7 @@ impl pallet_staking::Config for Runtime {
type UnixTime = Timestamp;
type CurrencyToVote = CurrencyToVote;
type ElectionProvider = ElectionProviderMultiPhase;
type GenesisElectionProvider = runtime_common::elections::GenesisElectionOf<Self, Staking>;
type GenesisElectionProvider = onchain::UnboundedExecution<OnChainSeqPhragmen>;
type RewardRemainder = Treasury;
type Event = Event;
type Slash = Treasury;
@@ -1582,6 +1589,7 @@ mod benches {
[pallet_democracy, Democracy]
[pallet_elections_phragmen, PhragmenElection]
[pallet_election_provider_multi_phase, ElectionProviderMultiPhase]
[frame_election_provider_support, ElectionProviderBench::<Runtime>]
[pallet_gilt, Gilt]
[pallet_identity, Identity]
[pallet_im_online, ImOnline]
@@ -1954,6 +1962,7 @@ sp_api::impl_runtime_apis! {
use pallet_session_benchmarking::Pallet as SessionBench;
use pallet_offences_benchmarking::Pallet as OffencesBench;
use pallet_election_provider_support_benchmarking::Pallet as ElectionProviderBench;
use frame_system_benchmarking::Pallet as SystemBench;
use frame_benchmarking::baseline::Pallet as Baseline;
@@ -1975,6 +1984,7 @@ sp_api::impl_runtime_apis! {
// To get around that, we separated the benchmarks into its own crate.
use pallet_session_benchmarking::Pallet as SessionBench;
use pallet_offences_benchmarking::Pallet as OffencesBench;
use pallet_election_provider_support_benchmarking::Pallet as ElectionProviderBench;
use frame_system_benchmarking::Pallet as SystemBench;
use frame_benchmarking::baseline::Pallet as Baseline;
use xcm::latest::prelude::*;
@@ -1982,6 +1992,7 @@ sp_api::impl_runtime_apis! {
impl pallet_session_benchmarking::Config for Runtime {}
impl pallet_offences_benchmarking::Config for Runtime {}
impl pallet_election_provider_support_benchmarking::Config for Runtime {}
impl frame_system_benchmarking::Config for Runtime {}
impl frame_benchmarking::baseline::Config for Runtime {}