Skip to content

Conversation

@Ank4n
Copy link
Contributor

@Ank4n Ank4n commented Nov 13, 2025

closes #10142

Context

Era rotation in pallet-staking-async coordinates validator set changes between Asset Hub and Relay Chain. Currently:

Happy Era Lifecycle (On Polkadot):

  • Session 0-4: Idle
  • Start of Session 5: Election starts for era N+1
  • At some point in Session 5: Election completes → validators sent to RC
  • End of Session 5: AH Client on RC queues validators to session pallet
  • End of Session 6: Queued validator set gets activated. RC returns activation timestamp to AH, and AH rotates active era to N+1.

Issue with current approach

  1. If election takes longer than a session: Active Era will become longer than 6 sessions.
  2. If we allow two sessions for election, and election completes faster: Active Era will be shorter than 6 sessions.

These issues are currently unlikely, but with elastic scaling (multiple cores in AH), they become more probable.

Solution

  1. Start the election as soon as Era N starts for Era N+1.
  2. Buffer elected validators in RC Client pallet and send them after the start of Session 5.

Result

This ensures we send elected validators for the next era always at the right time. It also has two good side effects:

  1. Election can run for longer and do less work per block than it is doing currently. We can split the work well across the whole lifecycle of the era instead of very compute heavy election session blocks.
  2. Validator/nominator snapshot for the era election has a much cleaner boundary.

Note for Reviewers

  • This test demonstrates the change from older configuration to new.

Open Questions

  • Should we get rid of PlanningEraOffset completely and make election start asap (not configurable)

TODO

  • Early exit signed validation (in separate PR)
  • Two equivalent test with different configurations of PlanningEraOffset and ValidatorSetExportSession, demonstrating same outcome except election timings.
  • Documentation

Update:
I have removed the new storage LastEraActivationSessionReportEndingIndex and instead rely only on session index from staking. I guess there is some tiny bit value in creating this new storage since:
– this pallet already knows everything it needs to know via session reports,
– keeping its logic lean and self-contained, without adding a dependency on the staking pallet.

But the pallets already talk via AHStakingInterface and so I don't think above reason holds.

@Ank4n Ank4n marked this pull request as ready for review November 19, 2025 20:12
@Ank4n Ank4n requested a review from a team as a code owner November 19, 2025 20:12
@Ank4n Ank4n added the T2-pallets This PR/Issue is related to a particular pallet. label Nov 19, 2025
@Ank4n
Copy link
Contributor Author

Ank4n commented Nov 20, 2025

/cmd fmt

@Ank4n
Copy link
Contributor Author

Ank4n commented Nov 20, 2025

/cmd prdoc --force

@sigurpol sigurpol added the A4-backport-stable2512 Pull request must be backported to the stable2512 release branch label Nov 25, 2025
@Ank4n Ank4n requested a review from kianenigma November 25, 2025 12:43
@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/19857945333
Failed job name: check-runtime-migration

@Ank4n Ank4n added this pull request to the merge queue Dec 3, 2025
@Ank4n Ank4n added A4-backport-stable2509 Pull request must be backported to the stable2509 release branch A4-backport-stable2512 Pull request must be backported to the stable2512 release branch and removed A4-backport-stable2509 Pull request must be backported to the stable2509 release branch A4-backport-stable2512 Pull request must be backported to the stable2512 release branch labels Dec 3, 2025
Merged via the queue into master with commit 90b7caf Dec 3, 2025
279 of 288 checks passed
@Ank4n Ank4n deleted the ankn-deterministic-era-rotation branch December 3, 2025 17:28
@paritytech-release-backport-bot

Created backport PR for unstable2507:

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin backport-10311-to-unstable2507
git worktree add --checkout .worktree/backport-10311-to-unstable2507 backport-10311-to-unstable2507
cd .worktree/backport-10311-to-unstable2507
git reset --hard HEAD^
git cherry-pick -x 90b7cafd8cfba509cc0f6ea476acc1a8c9ad0c11
git push --force-with-lease

@paritytech-release-backport-bot

Created backport PR for stable2509:

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin backport-10311-to-stable2509
git worktree add --checkout .worktree/backport-10311-to-stable2509 backport-10311-to-stable2509
cd .worktree/backport-10311-to-stable2509
git reset --hard HEAD^
git cherry-pick -x 90b7cafd8cfba509cc0f6ea476acc1a8c9ad0c11
git push --force-with-lease

@paritytech-release-backport-bot

Created backport PR for stable2512:

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin backport-10311-to-stable2512
git worktree add --checkout .worktree/backport-10311-to-stable2512 backport-10311-to-stable2512
cd .worktree/backport-10311-to-stable2512
git reset --hard HEAD^
git cherry-pick -x 90b7cafd8cfba509cc0f6ea476acc1a8c9ad0c11
git push --force-with-lease

EgorPopelyaev added a commit that referenced this pull request Dec 9, 2025
Backport #10311 into `stable2509` from Ank4n.

See the
[documentation](https://github.com/paritytech/polkadot-sdk/blob/master/docs/BACKPORT.md)
on how to use this bot.

<!--
  # To be used by other automation, do not modify:
  original-pr-number: #${pull_number}
-->

---------

Co-authored-by: Ankan <[email protected]>
Co-authored-by: Ankan <[email protected]>
Co-authored-by: Egor_P <[email protected]>
EgorPopelyaev added a commit that referenced this pull request Dec 9, 2025
Backport #10311 into `stable2512` from Ank4n.

See the
[documentation](https://github.com/paritytech/polkadot-sdk/blob/master/docs/BACKPORT.md)
on how to use this bot.

<!--
  # To be used by other automation, do not modify:
  original-pr-number: #${pull_number}
-->

---------

Co-authored-by: Ankan <[email protected]>
Co-authored-by: Ankan <[email protected]>
Co-authored-by: Egor_P <[email protected]>
lexnv pushed a commit that referenced this pull request Dec 11, 2025
…10526)

Backport #10311 into `unstable2507` from Ank4n.

See the
[documentation](https://github.com/paritytech/polkadot-sdk/blob/master/docs/BACKPORT.md)
on how to use this bot.

<!--
  # To be used by other automation, do not modify:
  original-pr-number: #${pull_number}
-->

---------

Co-authored-by: Ankan <[email protected]>
Co-authored-by: Ankan <[email protected]>
Co-authored-by: BDevParity <[email protected]>
@rachsrl rachsrl moved this from Scheduled to In progress in Security Audit (PRs) - SRLabs Jan 7, 2026
@rachsrl rachsrl moved this from In progress to Audited in Security Audit (PRs) - SRLabs Jan 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A4-backport-stable2509 Pull request must be backported to the stable2509 release branch A4-backport-stable2512 Pull request must be backported to the stable2512 release branch A4-backport-unstable2507 Pull request must be backported to the unstable2507 release branch T2-pallets This PR/Issue is related to a particular pallet.

Projects

Status: Audited

Development

Successfully merging this pull request may close these issues.

Staking Async: Tolerant against block time changes

4 participants