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 and slashing from staking-classic #7939

Open
wants to merge 22 commits into
base: master
Choose a base branch
from

Conversation

Ank4n
Copy link
Contributor

@Ank4n Ank4n commented Mar 16, 2025

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.

Reverted PRs

Westend Migration

pallet-staking on Westend migrated to v17 with the following changes

  • New:

    • OffenceQueue (StorageDoubleMap)
      • K1: Era
      • K2: Offending validator account
      • V: OffenceRecord
    • OffenceQueueEras (StorageValue)
      • V: BoundedVec<EraIndex, BoundingDuration>
    • ProcessingOffence (StorageValue)
      • V: (Era, offending validator account, OffenceRecord)
  • Changed:

    • UnappliedSlashes:
      • Old: StorageMap<K -> Era, V -> Vec<UnappliedSlash>>
      • New: StorageDoubleMap<K1 -> Era, K2 -> (validator_acc, perbill, page_index), V -> UnappliedSlash>

To revert these changes on Westend, since this is a testnet, we can simply drop any keys if present associated with the above storages, and reset storage version of pallet-staking to 16.

For AHM migration

The UnappliedSlashes storage will need to be translated from rc::staking-classic to ah::staking-next. Bookmarking the code that can be referred for this.

TODO

Sorry, something went wrong.

@@ -1874,7 +1863,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.

@Ank4n Ank4n added I4-refactor Code needs refactoring. T2-pallets This PR/Issue is related to a particular pallet. labels Mar 17, 2025
@Ank4n Ank4n marked this pull request as ready for review March 17, 2025 06:42
@Ank4n Ank4n requested review from acatangiu and a team as code owners March 17, 2025 06:42
@Ank4n Ank4n changed the title Revert the multiblock changes to staking [AHM] Revert multi-block election and slashing from staking-classic Mar 17, 2025
@paritytech-workflow-stopper
Copy link

All GitHub workflows were cancelled due to failure one of the required jobs.
Failed workflow url: https://github.com/paritytech/polkadot-sdk/actions/runs/13904309471
Failed job name: test-linux-stable-int

@@ -182,9 +182,6 @@ try-runtime = [
"polkadot-sdk/try-runtime",
"substrate-cli-test-utils/try-runtime",
]
staking-playground = [
Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, glad to see this stuff reverted. I now have a better dual rutnime setup to test staking-next.

@@ -58,7 +58,7 @@ pub fn kitchensink_genesis(
stakers: Vec<Staker>,
staking_playground_config: Option<StakingPlaygroundConfig>,
) -> serde_json::Value {
let (validator_count, min_validator_count, dev_stakers) = match staking_playground_config {
let (validator_count, min_validator_count, _dev_stakers) = match staking_playground_config {
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm I don't remember this code, or how it has gotten to master :))

I thought we would revert all things related to this taking playground idea in substrate node.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah it was done here:

https://github.com/paritytech/polkadot-sdk/pull/7741/files#diff-098d0b6ca72ffb6df6091f5b5433fa7131326bd062e911133e12ce323213dd58R318

Since pallet-staking has no dev-stakers, you should remove that. The rest is harmless.

@@ -29,125 +29,6 @@ use frame_system::RawOrigin as SystemOrigin;
use sp_runtime::traits::One;

benchmarks_instance_pallet! {
// iteration of any number of items should only touch that many nodes and bags.
Copy link
Contributor

Choose a reason for hiding this comment

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

These are useful, we can keep them.

@@ -84,8 +84,6 @@ pub(crate) fn generate(def: crate::SolutionDef) -> Result<TokenStream2> {
Eq,
Copy link
Contributor

Choose a reason for hiding this comment

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

Please undo this revert, it is harmless elsewhere and needed later.

@@ -33,7 +33,6 @@ pub(crate) fn codec_and_info_impl(
let scale_info = scale_info_impl(&ident, &voter_type, &target_type, &weight_type, count);

quote! {
impl _fepsp::codec::EncodeLike for #ident {}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can be kept

@@ -155,15 +154,6 @@ impl DataProviderBounds {
self.size_exhausted(given_size.unwrap_or(SizeBound::zero()))
}

/// Ensures the given encode-able slice meets both the length and count bounds.
Copy link
Contributor

Choose a reason for hiding this comment

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

also seems useful and harmless to keep

<E as ElectionProvider>::MaxWinnersPerPage,
<E as ElectionProvider>::MaxBackersPerWinner,
<E as ElectionProviderBase>::AccountId,
<E as ElectionProviderBase>::MaxWinners,
Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, at first I was against this revert.

My idea was that we keep these traits multi-page + capable of being bounded (having things like MaxWinners etc), but now I now see that this can cause too much headache to get this revert done.

This will totally fuck me when I merge master, as I do need to bring a lot of it back, but I think it can be useful.

pallet-staking + pallet-epm + frame-ep-support atm work together, and they are: unbounded, and single page

I will add a new mod multi_page here later, which would bring in the traits needed for bounded + multi-page support.

A bit redundant code, but I can see now that it is a safe choice.

Copy link
Contributor

Choose a reason for hiding this comment

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

but, I think we could have also kept the current version. I don't think there is time for it now anymore though..

@@ -127,23 +123,4 @@ where
voter_at: impl Fn(Self::VoterIndex) -> Option<A>,
target_at: impl Fn(Self::TargetIndex) -> Option<A>,
) -> Result<Vec<Assignment<A, Self::Accuracy>>, Error>;

/// Sort self by the means of the given function.
Copy link
Contributor

Choose a reason for hiding this comment

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

Same, please undo the revert here. 100% harmless and just less merge aissues later.

@@ -58,7 +58,6 @@ mod benchmarks {
false,
true,
RewardDestination::Staked,
pallet_staking::CurrentEra::<T>::get().unwrap_or_default(),
Copy link
Contributor

Choose a reason for hiding this comment

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

A follow-up: we need to re-benchmark the session pallet. Atm the benchmarking is tightly coupled with pallet-staking.

Can you please make an issue for this and add to our board?

}
Ok(ratio)
}

/// Convert some [`Supports`]s into vector of [`StakedAssignment`]
pub fn supports_to_staked_assignment<A: IdentifierT>(
Copy link
Contributor

Choose a reason for hiding this comment

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

Also useful, please keep.


ElectionScore { minimal_stake, sum_stake, sum_stake_squared }
ElectionScore { minimal_stake, sum_stake, sum_stake_squared }
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Similarly, this file can be kept in the new format.

@@ -523,42 +486,6 @@ pub struct PagedExposureMetadata<Balance: HasCompact + codec::MaxEncodedLen> {
pub page_count: Page,
}

impl<Balance> PagedExposureMetadata<Balance>
Copy link
Contributor

Choose a reason for hiding this comment

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

I am surprised we don't need these things? @Ank4n you would know better, they are related to paged exposures.

include == "*" ||
include == "all" ||
include.as_bytes() == pallet;
let included = include.is_empty() || include == "*" || include.as_bytes() == pallet;
Copy link
Contributor

Choose a reason for hiding this comment

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

can be kept, it is quite useful for benchmarking.

Copy link
Contributor

@kianenigma kianenigma left a comment

Choose a reason for hiding this comment

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

Okay, as noted, my origina, idea was to keep the additional traits and types in frame-election-provider-support, but I am okay to fuly revert them.

I will re-create them from the staking-next PR, as new traits, leaving everything as-is.

I have pointed out a few changes to sp-npos-elections and solution-type macro that can stay and are harmless.

A bit of a compromise, but since we need this by end of month, happy to go down this path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I4-refactor Code needs refactoring. T2-pallets This PR/Issue is related to a particular pallet.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants