Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Committee can be smaller than CommitteeMembersCount #2706

Closed
roman-khimov opened this issue Apr 27, 2022 · 0 comments
Closed

Committee can be smaller than CommitteeMembersCount #2706

roman-khimov opened this issue Apr 27, 2022 · 0 comments

Comments

@roman-khimov
Copy link
Contributor

Describe the bug
#2695 introduced a policy check for committee members and while it solves the main problem there is one potential problem with it.

var candidates = GetCandidates(snapshot);
if (voterTurnout < EffectiveVoterTurnout || candidates.Length < settings.CommitteeMembersCount)
return settings.StandbyCommittee.Select(p => (p, candidates.FirstOrDefault(k => k.PublicKey.Equals(p)).Votes));
return candidates
.OrderByDescending(p => p.Votes)
.ThenBy(p => p.PublicKey)
.Where(p => !Policy.IsBlocked(snapshot, Contract.CreateSignatureRedeemScript(p.PublicKey).ToScriptHash()))
.Take(settings.CommitteeMembersCount);

If we're to have X CommitteeMembersCount with X candidates we'll get past the check on line 405, but some candidates can now be kicked out of the list at line 410. IIUC in this case we'll end up with a committee that is smaller than intended (and potentially even lower number of CNs than intended. It's hard to predict how this will affect node's behavior.

This is not likely to happen in reality, but still should be taken into account.

Potential solution
Filter out bad keys right after GetCandidates. I doubt we can change GetCandidates itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants