Skip to content

Commit c63a447

Browse files
committed
Revert "[AHM] Multi-block staking election pallet (#7282)"
This reverts commit a025562.
1 parent 60045b7 commit c63a447

File tree

117 files changed

+1884
-19030
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+1884
-19030
lines changed

.github/workflows/runtimes-matrix.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"header": "substrate/HEADER-APACHE2",
77
"template": "substrate/.maintain/frame-weight-template.hbs",
88
"bench_features": "runtime-benchmarks",
9-
"bench_flags": "--exclude-pallets=pallet_xcm,pallet_xcm_benchmarks::fungible,pallet_xcm_benchmarks::generic,pallet_nomination_pools,pallet_remark,pallet_transaction_storage,pallet_election_provider_multi_block,pallet_election_provider_multi_block::signed,pallet_election_provider_multi_block::unsigned,pallet_election_provider_multi_block::verifier",
9+
"bench_flags": "--exclude-pallets=pallet_xcm,pallet_xcm_benchmarks::fungible,pallet_xcm_benchmarks::generic,pallet_nomination_pools,pallet_remark,pallet_transaction_storage",
1010
"uri": null,
1111
"is_relay": false
1212
},

.github/workflows/tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
- name: Checkout
3636
uses: actions/checkout@v4
3737
- name: script
38-
run: forklift cargo run --locked --release -p staging-node-cli --bin substrate-node --features runtime-benchmarks --quiet -- benchmark pallet --chain dev --pallet "*" --exclude-pallets=pallet_election_provider_multi_block,pallet_election_provider_multi_block::signed,pallet_election_provider_multi_block::unsigned,pallet_election_provider_multi_block::verifier --extrinsic "*" --steps 2 --repeat 1 --quiet
38+
run: forklift cargo run --locked --release -p staging-node-cli --bin substrate-node --features runtime-benchmarks --quiet -- benchmark pallet --chain dev --pallet "*" --extrinsic "*" --steps 2 --repeat 1 --quiet
3939

4040
# cf https://github.com/paritytech/polkadot-sdk/issues/1652
4141
test-syscalls:

Cargo.lock

-28
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,6 @@ members = [
346346
"substrate/frame/core-fellowship",
347347
"substrate/frame/delegated-staking",
348348
"substrate/frame/democracy",
349-
"substrate/frame/election-provider-multi-block",
350349
"substrate/frame/election-provider-multi-phase",
351350
"substrate/frame/election-provider-multi-phase/test-staking-e2e",
352351
"substrate/frame/election-provider-support",

cumulus/parachains/integration-tests/emulated/chains/relays/westend/src/genesis.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
1919
use sp_consensus_babe::AuthorityId as BabeId;
2020
use sp_consensus_beefy::ecdsa_crypto::AuthorityId as BeefyId;
2121
use sp_core::storage::Storage;
22-
use sp_runtime::{BoundedVec, Perbill};
22+
use sp_runtime::Perbill;
2323

2424
// Polkadot
2525
use polkadot_primitives::{AssignmentId, ValidatorId};
@@ -87,13 +87,7 @@ pub fn genesis() -> Storage {
8787
.iter()
8888
.map(|x| (x.0.clone(), x.1.clone(), STASH, pallet_staking::StakerStatus::Validator))
8989
.collect(),
90-
invulnerables: BoundedVec::try_from(
91-
validators::initial_authorities()
92-
.iter()
93-
.map(|x| x.0.clone())
94-
.collect::<Vec<_>>(),
95-
)
96-
.expect("Limit for staking invulnerables must be less than initial authorities."),
90+
invulnerables: validators::initial_authorities().iter().map(|x| x.0.clone()).collect(),
9791
force_era: pallet_staking::Forcing::ForceNone,
9892
slash_reward_fraction: Perbill::from_percent(10),
9993
..Default::default()

polkadot/runtime/common/src/try_runtime.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ where
3636

3737
let all_stakers = Ledger::<T>::iter().map(|(ctrl, l)| (ctrl, l.stash)).collect::<BTreeSet<_>>();
3838
let mut all_exposed = BTreeSet::new();
39-
ErasStakersPaged::<T>::iter().for_each(|((_era, val, _page), expo)| {
39+
ErasStakers::<T>::iter().for_each(|(_, val, expo)| {
4040
all_exposed.insert(val);
4141
all_exposed.extend(expo.others.iter().map(|ie| ie.who.clone()))
4242
});

polkadot/runtime/parachains/src/disputes/slashing/benchmarking.rs

-4
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,8 @@ where
8282

8383
pallet_session::Pallet::<T>::on_initialize(BlockNumberFor::<T>::one());
8484
initializer::Pallet::<T>::on_initialize(BlockNumberFor::<T>::one());
85-
8685
// skip sessions until the new validator set is enacted
8786
while pallet_session::Pallet::<T>::validators().len() < n as usize {
88-
// initialize stakers in pallet_staking. This is suboptimal, but an easy way to avoid this
89-
// being an infinite loop.
90-
pallet_staking::Pallet::<T>::populate_staking_election_testing_benchmarking_only().unwrap();
9187
pallet_session::Pallet::<T>::rotate_session();
9288
}
9389
initializer::Pallet::<T>::on_finalize(BlockNumberFor::<T>::one());

polkadot/runtime/test-runtime/src/lib.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ use polkadot_runtime_common::{
7979
use polkadot_runtime_parachains::reward_points::RewardValidatorsWithEraPoints;
8080
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
8181
use sp_consensus_beefy::ecdsa_crypto::{AuthorityId as BeefyId, Signature as BeefySignature};
82-
use sp_core::{ConstBool, ConstU32, OpaqueMetadata};
82+
use sp_core::{ConstU32, OpaqueMetadata};
8383
use sp_mmr_primitives as mmr;
8484
use sp_runtime::{
8585
curve::PiecewiseLinear,
@@ -349,7 +349,7 @@ parameter_types! {
349349
pub const MaxExposurePageSize: u32 = 64;
350350
pub const MaxNominators: u32 = 256;
351351
pub const MaxAuthorities: u32 = 100_000;
352-
pub const OnChainMaxWinners: u32 = MaxAuthorities::get();
352+
pub const OnChainMaxWinners: u32 = u32::MAX;
353353
// Unbounded number of election targets and voters.
354354
pub ElectionBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::default().build();
355355
}
@@ -362,9 +362,7 @@ impl onchain::Config for OnChainSeqPhragmen {
362362
type DataProvider = Staking;
363363
type WeightInfo = ();
364364
type Bounds = ElectionBoundsOnChain;
365-
type MaxWinnersPerPage = OnChainMaxWinners;
366-
type MaxBackersPerWinner = ConstU32<{ u32::MAX }>;
367-
type Sort = ConstBool<true>;
365+
type MaxWinners = OnChainMaxWinners;
368366
}
369367

370368
/// Upper limit on the number of NPOS nominations.

polkadot/runtime/westend/src/genesis_config_presets.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use sp_consensus_grandpa::AuthorityId as GrandpaId;
3333
use sp_core::{crypto::get_public_from_string_or_panic, sr25519};
3434
use sp_genesis_builder::PresetId;
3535
use sp_keyring::Sr25519Keyring;
36-
use sp_runtime::{BoundedVec, Perbill};
36+
use sp_runtime::Perbill;
3737
use westend_runtime_constants::currency::UNITS as WND;
3838

3939
/// Helper function to generate stash, controller and session key from seed
@@ -202,10 +202,7 @@ fn westend_testnet_genesis(
202202
.iter()
203203
.map(|x| (x.0.clone(), x.0.clone(), STASH, StakerStatus::<AccountId>::Validator))
204204
.collect::<Vec<_>>(),
205-
invulnerables: BoundedVec::try_from(
206-
initial_authorities.iter().map(|x| x.0.clone()).collect::<Vec<_>>()
207-
)
208-
.expect("Too many invulnerable validators: upper limit is MaxInvulnerables from pallet staking config"),
205+
invulnerables: initial_authorities.iter().map(|x| x.0.clone()).collect::<Vec<_>>(),
209206
force_era: Forcing::NotForcing,
210207
slash_reward_fraction: Perbill::from_percent(10),
211208
},
@@ -376,10 +373,7 @@ fn westend_staging_testnet_config_genesis() -> serde_json::Value {
376373
.iter()
377374
.map(|x| (x.0.clone(), x.0.clone(), STASH, StakerStatus::<AccountId>::Validator))
378375
.collect::<Vec<_>>(),
379-
invulnerables: BoundedVec::try_from(
380-
initial_authorities.iter().map(|x| x.0.clone()).collect::<Vec<_>>()
381-
)
382-
.expect("Too many invulnerable validators: upper limit is MaxInvulnerables from pallet staking config"),
376+
invulnerables: initial_authorities.iter().map(|x| x.0.clone()).collect::<Vec<_>>(),
383377
force_era: Forcing::ForceNone,
384378
slash_reward_fraction: Perbill::from_percent(10),
385379
},

polkadot/runtime/westend/src/lib.rs

+6-15
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ use sp_consensus_beefy::{
9696
ecdsa_crypto::{AuthorityId as BeefyId, Signature as BeefySignature},
9797
mmr::{BeefyDataProvider, MmrLeafVersion},
9898
};
99-
use sp_core::{ConstBool, ConstU8, OpaqueMetadata, RuntimeDebug, H256};
99+
use sp_core::{ConstU8, OpaqueMetadata, RuntimeDebug, H256};
100100
use sp_runtime::{
101101
generic, impl_opaque_keys,
102102
traits::{
@@ -586,10 +586,7 @@ parameter_types! {
586586
ElectionBoundsBuilder::default().voters_count(MaxElectingVoters::get().into()).build();
587587
// Maximum winners that can be chosen as active validators
588588
pub const MaxActiveValidators: u32 = 1000;
589-
// One page only, fill the whole page with the `MaxActiveValidators`.
590-
pub const MaxWinnersPerPage: u32 = MaxActiveValidators::get();
591-
// Unbonded, thus the max backers per winner maps to the max electing voters limit.
592-
pub const MaxBackersPerWinner: u32 = MaxElectingVoters::get();
589+
593590
}
594591

595592
frame_election_provider_support::generate_solution_type!(
@@ -604,14 +601,12 @@ frame_election_provider_support::generate_solution_type!(
604601

605602
pub struct OnChainSeqPhragmen;
606603
impl onchain::Config for OnChainSeqPhragmen {
607-
type Sort = ConstBool<true>;
608604
type System = Runtime;
609605
type Solver = SequentialPhragmen<AccountId, OnChainAccuracy>;
610606
type DataProvider = Staking;
611607
type WeightInfo = weights::frame_election_provider_support::WeightInfo<Runtime>;
608+
type MaxWinners = MaxActiveValidators;
612609
type Bounds = ElectionBounds;
613-
type MaxBackersPerWinner = MaxBackersPerWinner;
614-
type MaxWinnersPerPage = MaxWinnersPerPage;
615610
}
616611

617612
impl pallet_election_provider_multi_phase::MinerConfig for Runtime {
@@ -624,8 +619,7 @@ impl pallet_election_provider_multi_phase::MinerConfig for Runtime {
624619
as
625620
frame_election_provider_support::ElectionDataProvider
626621
>::MaxVotesPerVoter;
627-
type MaxBackersPerWinner = MaxBackersPerWinner;
628-
type MaxWinners = MaxWinnersPerPage;
622+
type MaxWinners = MaxActiveValidators;
629623

630624
// The unsigned submissions have to respect the weight of the submit_unsigned call, thus their
631625
// weight estimate function is wired to this call's weight.
@@ -659,8 +653,6 @@ impl pallet_election_provider_multi_phase::Config for Runtime {
659653
type BetterSignedThreshold = ();
660654
type OffchainRepeat = OffchainRepeat;
661655
type MinerTxPriority = NposSolutionPriority;
662-
type MaxWinners = MaxWinnersPerPage;
663-
type MaxBackersPerWinner = MaxBackersPerWinner;
664656
type DataProvider = Staking;
665657
#[cfg(any(feature = "fast-runtime", feature = "runtime-benchmarks"))]
666658
type Fallback = onchain::OnChainExecution<OnChainSeqPhragmen>;
@@ -669,8 +661,7 @@ impl pallet_election_provider_multi_phase::Config for Runtime {
669661
AccountId,
670662
BlockNumber,
671663
Staking,
672-
MaxWinnersPerPage,
673-
MaxBackersPerWinner,
664+
MaxActiveValidators,
674665
)>;
675666
type GovernanceFallback = onchain::OnChainExecution<OnChainSeqPhragmen>;
676667
type Solver = SequentialPhragmen<
@@ -681,6 +672,7 @@ impl pallet_election_provider_multi_phase::Config for Runtime {
681672
type BenchmarkingConfig = polkadot_runtime_common::elections::BenchmarkConfig;
682673
type ForceOrigin = EnsureRoot<AccountId>;
683674
type WeightInfo = weights::pallet_election_provider_multi_phase::WeightInfo<Self>;
675+
type MaxWinners = MaxActiveValidators;
684676
type ElectionBounds = ElectionBounds;
685677
}
686678

@@ -762,7 +754,6 @@ impl pallet_staking::Config for Runtime {
762754
type GenesisElectionProvider = onchain::OnChainExecution<OnChainSeqPhragmen>;
763755
type VoterList = VoterList;
764756
type TargetList = UseValidatorsMap<Self>;
765-
type MaxValidatorSet = MaxActiveValidators;
766757
type NominationsQuota = pallet_staking::FixedNominationsQuota<{ MaxNominations::get() }>;
767758
type MaxUnlockingChunks = frame_support::traits::ConstU32<32>;
768759
type HistoryDepth = frame_support::traits::ConstU32<84>;

0 commit comments

Comments
 (0)