Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AHM] Revert multi-block election, slashing and staking client pallets #7939

Merged
merged 43 commits into from
Mar 24, 2025
Merged
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
e1629e7
Revert "Implementation of ah-client and rc-client staking pallets (#7…
Ank4n Mar 16, 2025
82513b0
Revert "[Staking] Bounded Slashing: Paginated Offence Processing & Sl…
Ank4n Mar 16, 2025
1ecb0c4
Revert "[AHM] Multi-block staking election pallet (#7282)"
Ank4n Mar 16, 2025
dcddac6
test compiles, 17 failure
Ank4n Mar 16, 2025
d4364a4
ensure offence is reported to session
Ank4n Mar 16, 2025
42a0b9d
fmt
Ank4n Mar 16, 2025
e14b22b
fix westend
Ank4n Mar 16, 2025
c15fb37
unrevert some stuff that we need
Ank4n Mar 16, 2025
e6fc0c1
bring back some more changes
Ank4n Mar 17, 2025
755aacb
fmt
Ank4n Mar 17, 2025
667d059
fix manual slash test
Ank4n Mar 17, 2025
781e565
fix some more tests
Ank4n Mar 17, 2025
d9ccb91
Fix the failing staking tests
tdimitrov Mar 17, 2025
2721167
Merge branch 'master' into ankn/staking-classic
Ank4n Mar 17, 2025
3ce2484
Fix a compilation error in benchmarks
tdimitrov Mar 17, 2025
f3c83b7
Fix a compilation warning
tdimitrov Mar 17, 2025
82d58e3
fix bench
Ank4n Mar 17, 2025
0f7a0f4
fix root offences
Ank4n Mar 17, 2025
aaa9fea
fix kitchensink genesis
Ank4n Mar 17, 2025
e9a04a6
taplo
Ank4n Mar 17, 2025
202138e
update storage version
Ank4n Mar 17, 2025
e80b05c
node cli
Ank4n Mar 17, 2025
d67bbde
Merge remote-tracking branch 'origin/master' into ankn/staking-classic
tdimitrov Mar 19, 2025
0600e8d
Add `staking-playground` feature to `staging-node-cli` tu suppress a …
tdimitrov Mar 19, 2025
0caa4ac
Fix a warning
tdimitrov Mar 19, 2025
d8619fe
prdoc - initial
tdimitrov Mar 19, 2025
c20653e
Add `pallet-assets-holder` to umbrella
tdimitrov Mar 19, 2025
202ca82
Merge remote-tracking branch 'origin/master' into ankn/staking-classic
tdimitrov Mar 19, 2025
39b755d
no new lines in umbrella's cargo file!!!
tdimitrov Mar 19, 2025
ad6c73f
taplo
tdimitrov Mar 19, 2025
419c265
Code review feedback
tdimitrov Mar 19, 2025
400933e
fix compilation errors
tdimitrov Mar 19, 2025
083679a
Remove `get_staking_playground_config`
tdimitrov Mar 19, 2025
7c19410
Remove unused import
tdimitrov Mar 19, 2025
5e3ea96
newline at the end of the prdoc will make the semver check pass?
tdimitrov Mar 20, 2025
2e03823
Merge branch 'master' into ankn/staking-classic
tdimitrov Mar 20, 2025
e156b2b
Update substrate/frame/staking/src/migrations.rs
Ank4n Mar 24, 2025
0449188
add a note to reverted PR docs.
Ank4n Mar 24, 2025
bf189db
Merge branch 'master' into ankn/staking-classic
Ank4n Mar 24, 2025
ac255e2
fix prdoc bumps
Ank4n Mar 24, 2025
f49e2e4
fix election provider
Ank4n Mar 24, 2025
2340bb9
undo bounds
Ank4n Mar 24, 2025
670b95c
re-prdoc
Ank4n Mar 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/runtimes-matrix.json
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
"header": "substrate/HEADER-APACHE2",
"template": "substrate/.maintain/frame-weight-template.hbs",
"bench_features": "runtime-benchmarks",
"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",
"bench_flags": "--exclude-pallets=pallet_xcm,pallet_xcm_benchmarks::fungible,pallet_xcm_benchmarks::generic,pallet_nomination_pools,pallet_remark,pallet_transaction_storage",
"uri": null,
"is_relay": false
},
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: script
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
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

# cf https://github.com/paritytech/polkadot-sdk/issues/1652
test-syscalls:
66 changes: 0 additions & 66 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -346,7 +346,6 @@ members = [
"substrate/frame/core-fellowship",
"substrate/frame/delegated-staking",
"substrate/frame/democracy",
"substrate/frame/election-provider-multi-block",
"substrate/frame/election-provider-multi-phase",
"substrate/frame/election-provider-multi-phase/test-staking-e2e",
"substrate/frame/election-provider-support",
@@ -422,8 +421,6 @@ members = [
"substrate/frame/session/benchmarking",
"substrate/frame/society",
"substrate/frame/staking",
"substrate/frame/staking/ah-client",
"substrate/frame/staking/rc-client",
"substrate/frame/staking/reward-curve",
"substrate/frame/staking/reward-fn",
"substrate/frame/staking/runtime-api",
@@ -1005,8 +1002,6 @@ pallet-session-benchmarking = { path = "substrate/frame/session/benchmarking", d
pallet-skip-feeless-payment = { path = "substrate/frame/transaction-payment/skip-feeless-payment", default-features = false }
pallet-society = { path = "substrate/frame/society", default-features = false }
pallet-staking = { path = "substrate/frame/staking", default-features = false }
pallet-staking-ah-client = { path = "substrate/frame/staking/ah-client", default-features = false }
pallet-staking-rc-client = { path = "substrate/frame/staking/rc-client", default-features = false }
pallet-staking-reward-curve = { path = "substrate/frame/staking/reward-curve", default-features = false }
pallet-staking-reward-fn = { path = "substrate/frame/staking/reward-fn", default-features = false }
pallet-staking-runtime-api = { path = "substrate/frame/staking/runtime-api", default-features = false }
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
use sp_consensus_babe::AuthorityId as BabeId;
use sp_consensus_beefy::ecdsa_crypto::AuthorityId as BeefyId;
use sp_core::storage::Storage;
use sp_runtime::{BoundedVec, Perbill};
use sp_runtime::Perbill;

// Polkadot
use polkadot_primitives::{AssignmentId, ValidatorId};
@@ -87,13 +87,7 @@ pub fn genesis() -> Storage {
.iter()
.map(|x| (x.0.clone(), x.1.clone(), STASH, pallet_staking::StakerStatus::Validator))
.collect(),
invulnerables: BoundedVec::try_from(
validators::initial_authorities()
.iter()
.map(|x| x.0.clone())
.collect::<Vec<_>>(),
)
.expect("Limit for staking invulnerables must be less than initial authorities."),
invulnerables: validators::initial_authorities().iter().map(|x| x.0.clone()).collect(),
force_era: pallet_staking::Forcing::ForceNone,
slash_reward_fraction: Perbill::from_percent(10),
..Default::default()
Original file line number Diff line number Diff line change
@@ -82,12 +82,8 @@ where

pallet_session::Pallet::<T>::on_initialize(BlockNumberFor::<T>::one());
initializer::Pallet::<T>::on_initialize(BlockNumberFor::<T>::one());

// skip sessions until the new validator set is enacted
while pallet_session::Pallet::<T>::validators().len() < n as usize {
// initialize stakers in pallet_staking. This is suboptimal, but an easy way to avoid this
// being an infinite loop.
pallet_staking::Pallet::<T>::populate_staking_election_testing_benchmarking_only().unwrap();
pallet_session::Pallet::<T>::rotate_session();
}
initializer::Pallet::<T>::on_finalize(BlockNumberFor::<T>::one());
11 changes: 3 additions & 8 deletions polkadot/runtime/test-runtime/src/lib.rs
Original file line number Diff line number Diff line change
@@ -79,7 +79,7 @@ use polkadot_runtime_common::{
use polkadot_runtime_parachains::reward_points::RewardValidatorsWithEraPoints;
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
use sp_consensus_beefy::ecdsa_crypto::{AuthorityId as BeefyId, Signature as BeefySignature};
use sp_core::{ConstBool, ConstU32, OpaqueMetadata};
use sp_core::{ConstU32, OpaqueMetadata};
use sp_mmr_primitives as mmr;
use sp_runtime::{
curve::PiecewiseLinear,
@@ -349,7 +349,7 @@ parameter_types! {
pub const MaxExposurePageSize: u32 = 64;
pub const MaxNominators: u32 = 256;
pub const MaxAuthorities: u32 = 100_000;
pub const OnChainMaxWinners: u32 = MaxAuthorities::get();
pub const OnChainMaxWinners: u32 = u32::MAX;
// Unbounded number of election targets and voters.
pub ElectionBoundsOnChain: ElectionBounds = ElectionBoundsBuilder::default().build();
}
@@ -362,9 +362,7 @@ impl onchain::Config for OnChainSeqPhragmen {
type DataProvider = Staking;
type WeightInfo = ();
type Bounds = ElectionBoundsOnChain;
type MaxWinnersPerPage = OnChainMaxWinners;
type MaxBackersPerWinner = ConstU32<{ u32::MAX }>;
type Sort = ConstBool<true>;
type MaxWinners = OnChainMaxWinners;
}

/// Upper limit on the number of NPOS nominations.
@@ -402,9 +400,6 @@ impl pallet_staking::Config for Runtime {
type BenchmarkingConfig = polkadot_runtime_common::StakingBenchmarkingConfig;
type EventListeners = ();
type WeightInfo = ();
type MaxValidatorSet = MaxAuthorities;
type MaxInvulnerables = ConstU32<20>;
type MaxDisabledValidators = ConstU32<100>;
type Filter = frame_support::traits::Nothing;
}

12 changes: 3 additions & 9 deletions polkadot/runtime/westend/src/genesis_config_presets.rs
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ use sp_consensus_grandpa::AuthorityId as GrandpaId;
use sp_core::{crypto::get_public_from_string_or_panic, sr25519};
use sp_genesis_builder::PresetId;
use sp_keyring::Sr25519Keyring;
use sp_runtime::{BoundedVec, Perbill};
use sp_runtime::Perbill;
use westend_runtime_constants::currency::UNITS as WND;

/// Helper function to generate stash, controller and session key from seed
@@ -202,10 +202,7 @@ fn westend_testnet_genesis(
.iter()
.map(|x| (x.0.clone(), x.0.clone(), STASH, StakerStatus::<AccountId>::Validator))
.collect::<Vec<_>>(),
invulnerables: BoundedVec::try_from(
initial_authorities.iter().map(|x| x.0.clone()).collect::<Vec<_>>()
)
.expect("Too many invulnerable validators: upper limit is MaxInvulnerables from pallet staking config"),
invulnerables: initial_authorities.iter().map(|x| x.0.clone()).collect::<Vec<_>>(),
force_era: Forcing::NotForcing,
slash_reward_fraction: Perbill::from_percent(10),
},
@@ -376,10 +373,7 @@ fn westend_staging_testnet_config_genesis() -> serde_json::Value {
.iter()
.map(|x| (x.0.clone(), x.0.clone(), STASH, StakerStatus::<AccountId>::Validator))
.collect::<Vec<_>>(),
invulnerables: BoundedVec::try_from(
initial_authorities.iter().map(|x| x.0.clone()).collect::<Vec<_>>()
)
.expect("Too many invulnerable validators: upper limit is MaxInvulnerables from pallet staking config"),
invulnerables: initial_authorities.iter().map(|x| x.0.clone()).collect::<Vec<_>>(),
force_era: Forcing::ForceNone,
slash_reward_fraction: Perbill::from_percent(10),
},
24 changes: 6 additions & 18 deletions polkadot/runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
@@ -96,7 +96,7 @@ use sp_consensus_beefy::{
ecdsa_crypto::{AuthorityId as BeefyId, Signature as BeefySignature},
mmr::{BeefyDataProvider, MmrLeafVersion},
};
use sp_core::{ConstBool, ConstU8, OpaqueMetadata, RuntimeDebug, H256};
use sp_core::{ConstU8, OpaqueMetadata, RuntimeDebug, H256};
use sp_runtime::{
generic, impl_opaque_keys,
traits::{
@@ -586,10 +586,7 @@ parameter_types! {
ElectionBoundsBuilder::default().voters_count(MaxElectingVoters::get().into()).build();
// Maximum winners that can be chosen as active validators
pub const MaxActiveValidators: u32 = 1000;
// One page only, fill the whole page with the `MaxActiveValidators`.
pub const MaxWinnersPerPage: u32 = MaxActiveValidators::get();
// Unbonded, thus the max backers per winner maps to the max electing voters limit.
pub const MaxBackersPerWinner: u32 = MaxElectingVoters::get();

}

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

pub struct OnChainSeqPhragmen;
impl onchain::Config for OnChainSeqPhragmen {
type Sort = ConstBool<true>;
type System = Runtime;
type Solver = SequentialPhragmen<AccountId, OnChainAccuracy>;
type DataProvider = Staking;
type WeightInfo = weights::frame_election_provider_support::WeightInfo<Runtime>;
type MaxWinners = MaxActiveValidators;
type Bounds = ElectionBounds;
type MaxBackersPerWinner = MaxBackersPerWinner;
type MaxWinnersPerPage = MaxWinnersPerPage;
}

impl pallet_election_provider_multi_phase::MinerConfig for Runtime {
@@ -624,8 +619,7 @@ impl pallet_election_provider_multi_phase::MinerConfig for Runtime {
as
frame_election_provider_support::ElectionDataProvider
>::MaxVotesPerVoter;
type MaxBackersPerWinner = MaxBackersPerWinner;
type MaxWinners = MaxWinnersPerPage;
type MaxWinners = MaxActiveValidators;

// The unsigned submissions have to respect the weight of the submit_unsigned call, thus their
// weight estimate function is wired to this call's weight.
@@ -659,8 +653,6 @@ impl pallet_election_provider_multi_phase::Config for Runtime {
type BetterSignedThreshold = ();
type OffchainRepeat = OffchainRepeat;
type MinerTxPriority = NposSolutionPriority;
type MaxWinners = MaxWinnersPerPage;
type MaxBackersPerWinner = MaxBackersPerWinner;
type DataProvider = Staking;
#[cfg(any(feature = "fast-runtime", feature = "runtime-benchmarks"))]
type Fallback = onchain::OnChainExecution<OnChainSeqPhragmen>;
@@ -669,8 +661,7 @@ impl pallet_election_provider_multi_phase::Config for Runtime {
AccountId,
BlockNumber,
Staking,
MaxWinnersPerPage,
MaxBackersPerWinner,
MaxActiveValidators,
)>;
type GovernanceFallback = onchain::OnChainExecution<OnChainSeqPhragmen>;
type Solver = SequentialPhragmen<
@@ -681,6 +672,7 @@ impl pallet_election_provider_multi_phase::Config for Runtime {
type BenchmarkingConfig = polkadot_runtime_common::elections::BenchmarkConfig;
type ForceOrigin = EnsureRoot<AccountId>;
type WeightInfo = weights::pallet_election_provider_multi_phase::WeightInfo<Self>;
type MaxWinners = MaxActiveValidators;
type ElectionBounds = ElectionBounds;
}

@@ -762,16 +754,13 @@ impl pallet_staking::Config for Runtime {
type GenesisElectionProvider = onchain::OnChainExecution<OnChainSeqPhragmen>;
type VoterList = VoterList;
type TargetList = UseValidatorsMap<Self>;
type MaxValidatorSet = MaxActiveValidators;
type NominationsQuota = pallet_staking::FixedNominationsQuota<{ MaxNominations::get() }>;
type MaxUnlockingChunks = frame_support::traits::ConstU32<32>;
type HistoryDepth = frame_support::traits::ConstU32<84>;
type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch;
type BenchmarkingConfig = polkadot_runtime_common::StakingBenchmarkingConfig;
type EventListeners = (NominationPools, DelegatedStaking);
type WeightInfo = weights::pallet_staking::WeightInfo<Runtime>;
type MaxInvulnerables = frame_support::traits::ConstU32<20>;
type MaxDisabledValidators = ConstU32<100>;
type Filter = Nothing;
}

@@ -1909,7 +1898,6 @@ pub mod migrations {
parachains_shared::migration::MigrateToV1<Runtime>,
parachains_scheduler::migration::MigrateV2ToV3<Runtime>,
pallet_staking::migrations::v16::MigrateV15ToV16<Runtime>,
pallet_staking::migrations::v17::MigrateV16ToV17<Runtime>,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In westend this has already been applied, but we can just sudo kill any storage keys created (if any). If there are any slashes it will be dropped, but for the testnet that's okay.

pallet_session::migrations::v1::MigrateV0ToV1<
Runtime,
pallet_staking::migrations::v17::MigrateDisabledToSession<Runtime>,
Loading