substrate
substrate copied to clipboard
Staking: Introduce `MaxBackersPerWinner`
Draft for @kianenigma
This is a preparation for bounding the Staking, eg https://github.com/paritytech/substrate/pull/11585
Changes:
- Add
MaxBackersPerWinnerandBounder - Use
BoundedSupportsinReadySolutionto make it a bit more bounded. TheBoundedSupportsis still an unbound vector though and would otherwise require a secondGet<u32>bound. - Add
TruncateIntoBoundedSupports - Feasibility check errors when the input is too long.
elect_with_boundsreturns bounded supports.set_emergency_election_resulterrors when the input is too long.
Open:
- [ ] Check if the off-chain miner needs to trim.
- [ ] Fix
scorefunction to not consumeself - [ ] 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_backersas well."
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.
cc @Ank4n
Let's close this for now, and revisit later.