Remove dependency on rand's SliceRandom shuffle implementation in gossip-support (#2555)

In gossip-support, we shuffled the list of authorities using the
`rand::seq::SliceRandom::shuffle`. This function's behavior is
unspecified beyond being `O(n)` and could change in the future, leading
to network issues between nodes using different shuffling algorithms. In
practice, the implementation was a Fisher-Yates shuffle. This PR
replaces the call with a re-implementation of Fisher-Yates and adds a
test to ensure the behavior is the same between the two at the moment.
This commit is contained in:
asynchronous rob
2023-11-30 11:55:33 -06:00
committed by GitHub
parent 6742aba05f
commit 1f2ccaea05
4 changed files with 48 additions and 2 deletions
Generated
+13
View File
@@ -4844,6 +4844,16 @@ dependencies = [
"syn 2.0.38",
]
[[package]]
name = "env_logger"
version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a19187fea3ac7e84da7dacf48de0c45d63c6a76f9490dae389aead16c243fce3"
dependencies = [
"log",
"regex",
]
[[package]]
name = "env_logger"
version = "0.9.3"
@@ -11905,6 +11915,7 @@ dependencies = [
"polkadot-node-subsystem-test-helpers",
"polkadot-node-subsystem-util",
"polkadot-primitives",
"quickcheck",
"rand 0.8.5",
"rand_chacha 0.3.1",
"sc-network",
@@ -13731,6 +13742,8 @@ version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "588f6378e4dd99458b60ec275b4477add41ce4fa9f64dcba6f15adccb19b50d6"
dependencies = [
"env_logger 0.8.4",
"log",
"rand 0.8.5",
]