Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…3150) * - Fix failure to generate all possible combinations 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. [discovery] chaincodeQuery -> ERRO 13a Failed constructing descriptor for chaincode chaincodes:<name:"XXXX" > ,: no peer combination can satisfy the endorsement policy To fix it, the last line of choose() should be changed to pass a copy of "currentSubGroup" to the recursive call instead, i.e. choose(n, targetAmount, i+1, append(make([]int, 0), currentSubGroup...), subGroups) 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]> * - Fix failure to generate all possible combinations 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. [discovery] chaincodeQuery -> ERRO 13a Failed constructing descriptor for chaincode chaincodes:<name:"XXXX" > ,: no peer combination can satisfy the endorsement policy To fix it, the last line of choose() should be changed to pass a copy of "currentSubGroup" to the recursive call instead, i.e. choose(n, targetAmount, i+1, append(make([]int, 0), currentSubGroup...), subGroups) 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]> * - Update choose_test.go Signed-off-by: Tim <[email protected]> * - Fix build error Signed-off-by: Tim <[email protected]> Signed-off-by: David Enyeart <[email protected]> Co-authored-by: Tim <[email protected]>
- Loading branch information