Skip to content

release: upgrade rand crate version#14194

Open
dorimedini-starkware wants to merge 1 commit into
05-25-starknet_patricia_change_test_util_random_u256from
05-25-release_upgrade_rand_crate_version
Open

release: upgrade rand crate version#14194
dorimedini-starkware wants to merge 1 commit into
05-25-starknet_patricia_change_test_util_random_u256from
05-25-release_upgrade_rand_crate_version

Conversation

@dorimedini-starkware
Copy link
Copy Markdown
Collaborator

No description provided.

@reviewable-StarkWare
Copy link
Copy Markdown

This change is Reviewable

Copy link
Copy Markdown
Collaborator Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@cursor
Copy link
Copy Markdown

cursor Bot commented May 25, 2026

PR Summary

Medium Risk
Wide dependency and API churn with a few production RNG usages (mempool eviction, propeller shuffle, OS/committer helpers); behavior should stay equivalent if the migration is complete.

Overview
This PR upgrades the workspace from rand 0.8 to 0.9 (rand, rand_chacha, rand_distr in Cargo.toml) and refreshes Cargo.lock so dependents pick up the new stack (including transitive bumps like windows-sys, colored, toml, and deduplicated ahash entries).

Call sites are migrated to the 0.9 API: thread_rng()rng(), gen / gen_range / gen_boolrandom / random_range / random_bool, SliceRandom::chooseIndexedRandom, and rand::distributions::Uniformrand::distr::Uniform (with unwrap() where construction can fail). Test helpers that sampled via num-bigint now use fixed-size byte arrays where appropriate; OS output hashing uses OsRng + TryRngCore::try_fill_bytes.

Production paths touched include mempool gap-account eviction (get_evictable_account), propeller peer broadcast ordering (shuffled with rng()), and committer CLI benchmark interference sampling—not consensus or crypto protocol logic beyond RNG plumbing.

Reviewed by Cursor Bugbot for commit fb6172a. Bugbot is set up for automated code reviews on this repo. Configure here.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 6a94bb1. Configure here.

Comment thread crates/starknet_os/src/hints/hint_implementation/bls_field/tests.rs Outdated
Copy link
Copy Markdown
Contributor

@nimrod-starkware nimrod-starkware left a comment

Choose a reason for hiding this comment

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

@nimrod-starkware reviewed 28 files and all commit messages, and made 2 comments.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on ArielElp, dorimedini-starkware, and yoavGrs).


crates/starknet_os/src/hints/hint_implementation/output.rs line 152 at r1 (raw file):

    // Generate a cryptographically secure random seed.
    let mut random_bytes = [0u8; 32];
    OsRng.try_fill_bytes(&mut random_bytes).expect("OS RNG should not fail");

Doesnt it work? (probably need to import different trait)
I see it here

Suggestion:

OsRng.fill_bytes(&mut random_bytes);

Comment thread crates/starknet_os/src/hints/hint_implementation/bls_field/tests.rs Outdated
@dorimedini-starkware dorimedini-starkware force-pushed the 05-25-starknet_patricia_change_test_util_random_u256 branch from c99e594 to ac88b7c Compare May 25, 2026 14:50
@dorimedini-starkware dorimedini-starkware force-pushed the 05-25-release_upgrade_rand_crate_version branch 2 times, most recently from c0150e2 to c7d12ae Compare May 25, 2026 15:04
@dorimedini-starkware dorimedini-starkware force-pushed the 05-25-release_upgrade_rand_crate_version branch from c7d12ae to fb6172a Compare May 25, 2026 15:09
Copy link
Copy Markdown
Collaborator Author

@dorimedini-starkware dorimedini-starkware left a comment

Choose a reason for hiding this comment

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

@dorimedini-starkware made 1 comment.
Reviewable status: 26 of 28 files reviewed, 1 unresolved discussion (waiting on ArielElp, nimrod-starkware, and yoavGrs).


crates/starknet_os/src/hints/hint_implementation/output.rs line 152 at r1 (raw file):

Previously, nimrod-starkware wrote…

Doesnt it work? (probably need to import different trait)
I see it here

that's the deterministic_rand crate, not sure what that is, but OsRng no longer has a fill_bytes. from the docstring:

/// It is possible that when used during early boot the first call to `OsRng`
/// will block until the system's RNG is initialised. It is also possible
/// (though highly unlikely) for `OsRng` to fail on some platforms, most
/// likely due to system mis-configuration.
///
/// After the first successful call, it is highly unlikely that failures or
/// significant delays will occur (although performance should be expected to
/// be much slower than a user-space
/// [PRNG](https://rust-random.github.io/book/guide-gen.html#pseudo-random-number-generators)).

Copy link
Copy Markdown
Contributor

@nimrod-starkware nimrod-starkware left a comment

Choose a reason for hiding this comment

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

:lgtm:

@nimrod-starkware reviewed 2 files and all commit messages, made 1 comment, and resolved 1 discussion.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on ArielElp and yoavGrs).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants