Skip to content

Staking Async: Tolerant against block time changes #10142

@kianenigma

Description

@kianenigma

Currently, staking-asyncin AH starts the election at a specific session index being reported, based on:

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, StakingAhClient will 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 Forcing or a slash.
  • To mitigate this, the ValidatorSetReport needs to have an extra force: bool field in it.
    • if set to true, StakingAhClient should report it to session immediately
    • if set to false, StakingAhClient should report it to session at the normal cadence.

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions