Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Limit the execution time of on-chain sequential phragmen  #8348

@kianenigma

Description

@kianenigma

We fallback to the on-chain election if nothing else works, which is okay, but we stall the chain for a long time. This is not good. We should try and somehow make the on-chain sequential run smoother, at the cost of not including all voters.

Some thoughts on the matter:

  1. we can and should sacrifice the small staked voters, but we always want to keep all candidates.
  2. Currently, we don't keep a sorted list of voters anywhere, so we need to take into account that we need to sort them, and then take the top x.
  3. We must first find the sweet spot where for any number of voters more than this, it is wroth it to first sort and then run phragmen.
  4. We must also measure exactly how much weight seq-phragmen is taking in Benchmark exactly how much weight on-chian seq-phragmen takes.  #8347, and then we need to alter Benchmark exactly how much weight on-chian seq-phragmen takes.  #8347 or generally make it suitable, so you can query the weight before executing anything. For example, assume pallet-multi-phase-election wants to fallback to on-chain election. Before actually calling onchain::elect(...), we ideally want to know how many voters we are allowed to pass in, in order for the weight of the elect call to be below a certain threshold t. This might make the API a bit messy, but we can add new functions to trait ElectionProvider to accommodate this, namely predict_elect_weight() -> Weight where this would return a best effort guess of how much weight is to be consumed, if we call elect, with exactly the same data.

@coriolinus I wonder if you have opinions on this, and the linked issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    J0-enhancementAn additional feature request.

    Type

    No type

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions