substrate icon indicating copy to clipboard operation
substrate copied to clipboard

Max class voters for ranked collective vote tally

Open muharem opened this issue 2 years ago • 1 comments

The implementation of VoteTally trait, uses Rank type where Class is supposed. For Kusama runtime, this is not an issue. The Rank and Class is the same u16 type and mapped 1:1.

But if,

  • the mapping is not 1:1, the max voters count might be wrong;
  • Class is any other type (e.g. enum), it wont compile.

// TODO tests

muharem avatar Feb 05 '23 04:02 muharem

Looks ok in general, but are Rank and Class not already defined as equivalent within ranked-collective's VoteTally impl because its Class generic parameter is provided as Rank?

I see it now. It not simple to read it like that. Here for example we access Class type throughout Polling trait, signaling its generic for the pallet -
https://github.com/paritytech/substrate/blob/37e3abd96c8dffccef9156d2be9302d876a72d10/frame/ranked-collective/src/lib.rs#L343 The signatures of the VoteTally funcs impls becomes confusing to me, the name of the arg is class, the type is Rank, but docs will help - https://github.com/paritytech/substrate/blob/37e3abd96c8dffccef9156d2be9302d876a72d10/frame/ranked-collective/src/lib.rs#L140 I faced the issue, while trying to define the Class as enum.
We can go either way, generic class (like in the PR now) or class type is rank type, but I make it more explicit and add some docs.

muharem avatar Feb 25 '23 01:02 muharem

bot rebase

muharem avatar Mar 29 '23 11:03 muharem

Rebased

bot rebase

juangirini avatar May 16 '23 15:05 juangirini

Rebased

bot merge

muharem avatar May 17 '23 10:05 muharem

Waiting for commit status.