Skip to content

Commit b82ef54

Browse files
Ank4ntdimitrovOverkillus
authored
[AHM] Revert multi-block election, slashing and staking client pallets (#7939)
Revert the following PRs which we are pulling from release stable2503: - #7582 - #7424 - #7282 and leave pallet-staking in its pre-AHM state. ## Context We are forking pallet-staking into `pallet-staking` (also referred as staking-classic, this is the version that will stay on RC) and `pallet-staking-next` which will live on AH post AHM. Additional context: #7858 (comment) These changes in crate `pallet-staking` will become the staking classic. The staking next version is worked in the PR #7601. ## For AHM migration The `UnappliedSlashes` storage will need to be translated from `rc::staking-classic` to `ah::staking-next`. [Bookmarking](https://github.com/paritytech/polkadot-sdk/blob/master/substrate/frame/staking/src/migrations.rs#L91) the code that can be referred for this. ## Follow ups (cc: @tdimitrov and @seadanda ) 1) Revert pallet-staking v17 migration in westend. - Update `in code storage version` of pallet-staking storage from 17 to 16 (separate PR). - Update `on chain storage version` of pallet-staking storage from 17 to 16. The storage key for pallet-staking on chain version is `0x5f3e4907f716ac89b6347d15ececedca4e7b9012096b41c4eb3aaf947f6ea429` which should be set currently to `0x1100`, and needs to be updated to `0x1000`. - After the runtime upgrade with the code from this PR is deployed on Westend, kill the following storage prefixes under the Pallet prefix `Staking`: - OffenceQueue - OffenceQueueEras - ProcessingOffence - UnappliedSlashes: This also exists in staking-classic as a storage map (one key) and in pre-revert code as double storage map (two keys). Killing with prefix `UnappliedSlashes` may kill the ones created post upgrade (but that's okay for westend). - VoterSnapshotStatus - NextElectionPage - ElectableStashes 2) Remove exposure dependency Worked in the PR: #7936. --------- Co-authored-by: Tsvetomir Dimitrov <[email protected]> Co-authored-by: Maciej <[email protected]>
1 parent b252690 commit b82ef54

File tree

101 files changed

+2362
-17934
lines changed

Some content is hidden

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

101 files changed

+2362
-17934
lines changed

.github/workflows/runtimes-matrix.json

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 0 additions & 66 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 5 deletions
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",
@@ -422,8 +421,6 @@ members = [
422421
"substrate/frame/session/benchmarking",
423422
"substrate/frame/society",
424423
"substrate/frame/staking",
425-
"substrate/frame/staking/ah-client",
426-
"substrate/frame/staking/rc-client",
427424
"substrate/frame/staking/reward-curve",
428425
"substrate/frame/staking/reward-fn",
429426
"substrate/frame/staking/runtime-api",
@@ -1005,8 +1002,6 @@ pallet-session-benchmarking = { path = "substrate/frame/session/benchmarking", d
10051002
pallet-skip-feeless-payment = { path = "substrate/frame/transaction-payment/skip-feeless-payment", default-features = false }
10061003
pallet-society = { path = "substrate/frame/society", default-features = false }
10071004
pallet-staking = { path = "substrate/frame/staking", default-features = false }
1008-
pallet-staking-ah-client = { path = "substrate/frame/staking/ah-client", default-features = false }
1009-
pallet-staking-rc-client = { path = "substrate/frame/staking/rc-client", default-features = false }
10101005
pallet-staking-reward-curve = { path = "substrate/frame/staking/reward-curve", default-features = false }
10111006
pallet-staking-reward-fn = { path = "substrate/frame/staking/reward-fn", default-features = false }
10121007
pallet-staking-runtime-api = { path = "substrate/frame/staking/runtime-api", default-features = false }

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

Lines changed: 2 additions & 8 deletions
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/parachains/src/disputes/slashing/benchmarking.rs

Lines changed: 0 additions & 4 deletions
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

Lines changed: 3 additions & 8 deletions
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.
@@ -402,9 +400,6 @@ impl pallet_staking::Config for Runtime {
402400
type BenchmarkingConfig = polkadot_runtime_common::StakingBenchmarkingConfig;
403401
type EventListeners = ();
404402
type WeightInfo = ();
405-
type MaxValidatorSet = MaxAuthorities;
406-
type MaxInvulnerables = ConstU32<20>;
407-
type MaxDisabledValidators = ConstU32<100>;
408403
type Filter = frame_support::traits::Nothing;
409404
}
410405

polkadot/runtime/westend/src/genesis_config_presets.rs

Lines changed: 3 additions & 9 deletions
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

Lines changed: 6 additions & 18 deletions
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,16 +754,13 @@ 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>;
769760
type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch;
770761
type BenchmarkingConfig = polkadot_runtime_common::StakingBenchmarkingConfig;
771762
type EventListeners = (NominationPools, DelegatedStaking);
772763
type WeightInfo = weights::pallet_staking::WeightInfo<Runtime>;
773-
type MaxInvulnerables = frame_support::traits::ConstU32<20>;
774-
type MaxDisabledValidators = ConstU32<100>;
775764
type Filter = Nothing;
776765
}
777766

@@ -1909,7 +1898,6 @@ pub mod migrations {
19091898
parachains_shared::migration::MigrateToV1<Runtime>,
19101899
parachains_scheduler::migration::MigrateV2ToV3<Runtime>,
19111900
pallet_staking::migrations::v16::MigrateV15ToV16<Runtime>,
1912-
pallet_staking::migrations::v17::MigrateV16ToV17<Runtime>,
19131901
pallet_session::migrations::v1::MigrateV0ToV1<
19141902
Runtime,
19151903
pallet_staking::migrations::v17::MigrateDisabledToSession<Runtime>,

0 commit comments

Comments
 (0)