fix: Adjust invariant checks when selecting participants#680
Merged
fix: Adjust invariant checks when selecting participants#680
Conversation
ghost
approved these changes
Jul 21, 2025
ghost
left a comment
There was a problem hiding this comment.
That's a very good catch. Thanks for fixing it.
Could you also add a unit test, so we have some regression test for this bug? It's not a hard requirement from my side if it's tedious to test.
4ea77bc to
648c171
Compare
ghost
suggested changes
Jul 21, 2025
netrome
approved these changes
Jul 21, 2025
Collaborator
netrome
left a comment
There was a problem hiding this comment.
Some suggestions, otherwise lgtm.
ghost
approved these changes
Jul 22, 2025
Collaborator
|
I assume this failed due to main being broken for a brief time. Taking the liberty to add it to the merge queue again. |
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.
Context
The function:
Should return
totalnumber of online participants amongstpeers_to_consider, including the caller participant.This function has two usages:
Bug
This function behaves incorrectly, when the size of
peers_to_consideris insufficient, to make up fortotalparticipants.Extrapolated example: if we pass empty
peers_to_consider. In that case[me]will be returned, becausemeis getting appended regardless. The error should be returned instead.IteratorRandom::choose_multiple(_, amount)silently returns less thanamountelements, if there are not enough.Solution
Make invariant check on return value
Effect
This has no practical effect at the moment, because
all_participants_from_configis being passed intoselect_random_active_participants_including_me