substrate icon indicating copy to clipboard operation
substrate copied to clipboard

Staking: Introduce `MaxBackersPerWinner`

Open ggwpez opened this issue 3 years ago • 1 comments

Draft for @kianenigma
This is a preparation for bounding the Staking, eg https://github.com/paritytech/substrate/pull/11585

Changes:

  • Add MaxBackersPerWinner and Bounder
  • Use BoundedSupports in ReadySolution to make it a bit more bounded. The BoundedSupports is still an unbound vector though and would otherwise require a second Get<u32> bound.
  • Add TruncateIntoBoundedSupports
  • Feasibility check errors when the input is too long.
  • elect_with_bounds returns bounded supports.
  • set_emergency_election_result errors when the input is too long.

Open:

  • [ ] Check if the off-chain miner needs to trim.
  • [ ] Fix score function to not consume self
  • [ ] Tests for trimming in unsigned.rs
  • [ ] From @kianenigma: "[…] once we mine a solution (this code is used by both offchain workers, or by staking-miner binary), we want to do a trim_assignment_backers as well."

ggwpez avatar Jul 29 '22 12:07 ggwpez

From @kianenigma: "[…] once we mine a solution (this code is used by both offchain workers, or by staking-miner binary), we want to do a trim_assignment_backers as well."

This part of this work is quite nasty, deals with a lot of legacy code that I have admittedly not had the time to really re-think since years ago, so I decided to take a stab at it. Feel free to cherry pick this commit if it makes sense, else try your approach if you have one.

only checked things compile, without any test.

https://github.com/paritytech/substrate/compare/kiz-max-backers-per-winner...kiz-max-backers-per-winner-2?expand=1

PS. this is the same as what I meant by

Check if the off-chain miner needs to trim.

So these two TODOs are practically the same.

kianenigma avatar Jul 30 '22 16:07 kianenigma

cc @Ank4n

kianenigma avatar Sep 26 '22 09:09 kianenigma

Let's close this for now, and revisit later.

kianenigma avatar Dec 05 '22 14:12 kianenigma