-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Currently, staking-asyncin AH starts the election at a specific session index being reported, based on:
polkadot-sdk/cumulus/parachains/runtimes/assets/asset-hub-westend/src/staking.rs
Lines 296 to 297 in 18f6251
| type PlanningEraOffset = | |
| pallet_staking_async::PlanningEraOffsetOf<Runtime, RelaySessionDuration, ConstU32<5>>; |
Once this election is computed, it is reported to RC.On the next session change in RC, it is queued in the session pallet. On the next session change in RC, it is activate in the session pallet, and reported back to AH.
The limiting part of this is that once RC receives a validator set from AH, it will immediately queue it in the session pallet, without any thinking involved. This limits how we can configure the above PlanningEraOffset:
- It doesn't have to be too early, or else an era ends up being 5 sessions.
- It doesn't have to be too late, or else an era ends up being 7 sessions.
This is rather simplistic, and we can do better.
- StakingAhClient in RC should keep track of when it last reported a validator set to session pallet.
- When a new validator set comes from RC,
StakingAhClientwill report it to the session pallet exactly 6 session after it last reported it.
Consideration for ForcingEra:
- staking-async in AH might legitimately want to force a new validator set sooner than scheduled, due to
Forcingor a slash. - To mitigate this, the
ValidatorSetReportneeds to have an extraforce: boolfield in it.- if set to
true,StakingAhClientshould report it to session immediately - if set to
false,StakingAhClientshould report it to session at the normal cadence.
- if set to
This will significantly help us with async backing, which can alter the block times of AH, and mess with the scheduling of the election.
Once we have the above implemented, we can start the election safely much much before the desired time, knowing that the relay chain won't queue it in the session pallet sooner than expected. This will also help us be resilient against block time fluctuation.