Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump rand to 0.8, rand_chacha to 0.3, getrandom to 0.2 #32871

Merged
merged 35 commits into from
Aug 21, 2023
Merged
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
7cb815a
sdk: Add concurrent support for rand 0.7 and 0.8
joncinque Aug 17, 2023
0821cb7
Update rand, rand_chacha, and getrandom versions
joncinque Aug 17, 2023
4c99792
Run command to replace `gen_range`
joncinque Aug 17, 2023
bdb5465
sdk: Fix users of older `gen_range`
joncinque Aug 17, 2023
2e9c550
Replace `hash::new_rand` with `hash::new_with_thread_rng`
joncinque Aug 17, 2023
9a0a8ec
perf: Use `Keypair::new()` instead of `generate`
joncinque Aug 17, 2023
5d67cfc
Use older rand version in zk-token-sdk
joncinque Aug 17, 2023
6b8f63e
program-runtime: Inline random key generation
joncinque Aug 17, 2023
d4a6f09
bloom: Fix clippy warnings in tests
joncinque Aug 17, 2023
53d12e3
streamer: Scope rng usage correctly
joncinque Aug 17, 2023
79fb8d3
perf: Fix clippy warning
joncinque Aug 17, 2023
c8c1059
accounts-db: Map to char to generate a random string
joncinque Aug 17, 2023
b87dd11
Remove `from_secret_key_bytes`, it's just `keypair_from_seed`
joncinque Aug 17, 2023
775da77
ledger: Generate keypairs by hand
joncinque Aug 17, 2023
cab9648
ed25519-tests: Use new rand
joncinque Aug 17, 2023
2c99f5f
runtime: Use new rand in all tests
joncinque Aug 17, 2023
05bb142
gossip: Clean up clippy and inline keypair generators
joncinque Aug 17, 2023
6bf9c1d
core: Inline keypair generation for tests
joncinque Aug 17, 2023
f21bd05
Push sbf lockfile change
joncinque Aug 17, 2023
0b10db3
sdk: Sort dependencies correctly
joncinque Aug 17, 2023
3b2597c
Remove `hash::new_with_thread_rng`, use `Hash::new_unique()`
joncinque Aug 17, 2023
37bb533
Use Keypair::new where chacha isn't used
joncinque Aug 17, 2023
147c1e9
sdk: Fix build by marking rand 0.7 optional
joncinque Aug 17, 2023
db48acc
Hardcode secret key length, add static assertion
joncinque Aug 17, 2023
39b5adf
Unify `getrandom` crate usage to fix linking errors
joncinque Aug 18, 2023
fd77bc2
bloom: Fix tests that require a random hash
joncinque Aug 18, 2023
884dc52
Remove some dependencies, try to unify others
joncinque Aug 18, 2023
2b45df5
Remove unnecessary uses of rand and rand_core
joncinque Aug 18, 2023
295023a
Update lockfiles
joncinque Aug 18, 2023
7099108
Add back some dependencies to reduce rebuilds
joncinque Aug 18, 2023
2e09e57
Increase max rebuilds from 14 to 15
joncinque Aug 18, 2023
9d44709
frozen-abi: Remove `getrandom`
joncinque Aug 18, 2023
2b00f23
Bump rebuilds to 17
joncinque Aug 18, 2023
4718c51
Remove getrandom from zk-token-proof
joncinque Aug 18, 2023
7054869
Merge branch 'master' into rand8
joncinque Aug 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions bloom/src/bloom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,16 @@ mod test {
);
}

fn generate_random_hash() -> Hash {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol... Hash::new_unique() is broken. it should be hashing the counter, not using it straight up 🙃

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can try changing it to that and see if the bloom filter test passes. On the flipside, and I might be understanding this wrong, but it seems like the test is meant for random hashes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nah don't mess with it here

let mut rng = rand::thread_rng();
let mut hash = [0u8; solana_sdk::hash::HASH_BYTES];
rng.fill(&mut hash);
Hash::new_from_array(hash)
}

#[test]
fn test_atomic_bloom() {
let hash_values: Vec<_> = std::iter::repeat_with(Hash::new_unique)
let hash_values: Vec<_> = std::iter::repeat_with(generate_random_hash)
.take(1200)
.collect();
let bloom: AtomicBloom<_> = Bloom::<Hash>::random(1287, 0.1, 7424).into();
Expand All @@ -327,7 +334,7 @@ mod test {
for hash_value in hash_values {
assert!(bloom.contains(&hash_value));
}
let false_positive = std::iter::repeat_with(Hash::new_unique)
let false_positive = std::iter::repeat_with(generate_random_hash)
.take(10_000)
.filter(|hash_value| bloom.contains(hash_value))
.count();
Expand All @@ -339,7 +346,7 @@ mod test {
let mut rng = rand::thread_rng();
let keys: Vec<_> = std::iter::repeat_with(|| rng.gen()).take(5).collect();
let mut bloom = Bloom::<Hash>::new(9731, keys.clone());
let hash_values: Vec<_> = std::iter::repeat_with(Hash::new_unique)
let hash_values: Vec<_> = std::iter::repeat_with(generate_random_hash)
.take(1000)
.collect();
for hash_value in &hash_values {
Expand Down Expand Up @@ -374,7 +381,7 @@ mod test {
assert!(bloom.contains(hash_value));
}
// Round trip, inserting new hash values.
let more_hash_values: Vec<_> = std::iter::repeat_with(Hash::new_unique)
let more_hash_values: Vec<_> = std::iter::repeat_with(generate_random_hash)
.take(1000)
.collect();
let bloom: AtomicBloom<_> = bloom.into();
Expand All @@ -389,7 +396,7 @@ mod test {
for hash_value in &more_hash_values {
assert!(bloom.contains(hash_value));
}
let false_positive = std::iter::repeat_with(Hash::new_unique)
let false_positive = std::iter::repeat_with(generate_random_hash)
.take(10_000)
.filter(|hash_value| bloom.contains(hash_value))
.count();
Expand All @@ -408,7 +415,7 @@ mod test {
for hash_value in &more_hash_values {
assert!(bloom.contains(hash_value));
}
let false_positive = std::iter::repeat_with(Hash::new_unique)
let false_positive = std::iter::repeat_with(generate_random_hash)
.take(10_000)
.filter(|hash_value| bloom.contains(hash_value))
.count();
Expand Down