Fix coordinator lottery fairness#2507
Open
alicecoordinator wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes the fairness in the coordinator lottery.
The goal of the lottery was to give each coordinator a chance to be the first in the coordinator list proportional to their donation to the dev fund, but the current logic doesn't do that.
It fails because using random inside the comparison function ends up favoring the elements in specific positions in the initial order.
For example:
With the configuration above (a reduced version of the actual federation.json), the results are always close to this:
Notice how "temple" comes way more often as the first, even though it has the same contribution as "lake" and "bazaar". Also, even though "moon" has a slightly higher contribution than "temple" it still gets first less often.
With the new implementation the results are as follows:
Notice how "moon" got a slight advantage now, and how the chances are actually proportional to the contributions: "temple", "lake" and "bazaar" got first roughly 50% more often than "veneto", "freedomsats", "whiteyesats", and "alice", because the first group contributes 50% more than the second group (30% versus 20%).