- Fix failure to generate all possible combinations (backport #3132) #3150
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.
Bug happens when the endorsement policy is set to k-out-of-n where (n - k) > 1.
For example, when there are 6 organizations and the endorsement policy is set
to majority (i.e. 4-out-of-6). The combinations calculated by chooseKoutOfN()
in original code are as below.
[0 1 2 5], [0 1 2 5], [0 1 2 5], [0 1 3 5],
[0 1 3 5], [0 1 4 5], [0 2 3 5], [0 2 3 5],
[0 2 4 5], [0 3 4 5], [1 2 3 5], [1 2 3 5],
[1 2 4 5], [1 3 4 5], [2 3 4 5]
Obviously, the function fails to find out all the possible combinations. Some of
the combinations are overrided by child's call. This bug would trigger below
error sometimes when the alive peers are not within the above combinations.
To fix it, the last line of choose() should be changed to pass a copy of
"currentSubGroup" to the recursive call instead, i.e.
After applying the fix, the resulting combinations generated should be corrected
as below.
[0 1 2 3], [0 1 2 4], [0 1 2 5], [0 1 3 4],
[0 1 3 5], [0 1 4 5], [0 2 3 4], [0 2 3 5],
[0 2 4 5], [0 3 4 5], [1 2 3 4], [1 2 3 5],
[1 2 4 5], [1 3 4 5], [2 3 4 5]
Signed-off-by: Tim [email protected]
Bug happens when the endorsement policy is set to k-out-of-n where (n - k) > 1.
For example, when there are 6 organizations and the endorsement policy is set
to majority (i.e. 4-out-of-6). The combinations calculated by chooseKoutOfN()
in original code are as below.
[0 1 2 5], [0 1 2 5], [0 1 2 5], [0 1 3 5],
[0 1 3 5], [0 1 4 5], [0 2 3 5], [0 2 3 5],
[0 2 4 5], [0 3 4 5], [1 2 3 5], [1 2 3 5],
[1 2 4 5], [1 3 4 5], [2 3 4 5]
Obviously, the function fails to find out all the possible combinations. Some of
the combinations are overrided by child's call. This bug would trigger below
error sometimes when the alive peers are not within the above combinations.
To fix it, the last line of choose() should be changed to pass a copy of
"currentSubGroup" to the recursive call instead, i.e.
After applying the fix, the resulting combinations generated should be corrected
as below.
[0 1 2 3], [0 1 2 4], [0 1 2 5], [0 1 3 4],
[0 1 3 5], [0 1 4 5], [0 2 3 4], [0 2 3 5],
[0 2 4 5], [0 3 4 5], [1 2 3 4], [1 2 3 5],
[1 2 4 5], [1 3 4 5], [2 3 4 5]
Signed-off-by: Tim [email protected]
Signed-off-by: Tim [email protected]
Signed-off-by: Tim [email protected]
Signed-off-by: David Enyeart [email protected]