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

STR-722: refactor random generation to CryptoRngCore #539

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

AaronFeickert
Copy link
Contributor

Description

This PR refactors the trait bound CryptoRng + RngCore to CryptoRngCore from rand_core and performs associated import cleanup.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature/Enhancement (non-breaking change which adds functionality or enhances an existing one)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactor
  • New or updated tests
  • Dependency Update

Notes to Reviewers

None.

Checklist

  • I have performed a self-review of my code.
  • I have commented my code where necessary.
  • I have updated the documentation if needed.
  • My changes do not introduce new warnings.
  • I have added tests that prove my changes are effective or that my feature works.
  • New and existing tests pass with my changes.

Related Issues

None.

@AaronFeickert AaronFeickert requested review from a team as code owners December 13, 2024 20:07
@storopoli
Copy link
Member

storopoli commented Dec 13, 2024

The idea is to break up STR-722 into small easy-to-review PRs?
Then in the final one remove rand altogether for rand_core?

@AaronFeickert
Copy link
Contributor Author

The idea is to break up STR-722 into small easy-to-review PRs? Then in the final one remove rand altogether for rand_core?

The primary goal is to use CryptoRngCore instead of CryptoRng + RngCore to reduce the likelihood of missing CryptoRng. However, CryptoRngCore is only provided by rand_core, whereas CryptoRng and RngCore are also provided by rand. With a few small extra import updates, it happened to be possible to swap out rand for rand_core as a dependency in a couple of crates, so I went ahead and did that to clean things up a bit.

There are a few places where we really do need rand to get access to sampling and shuffling, so it will stick around. Initially, I went a bit wild with swapping out to rand_core, but realized that's out of scope here and not the intent of the issue.

storopoli

This comment was marked as outdated.

Copy link
Member

@storopoli storopoli left a comment

Choose a reason for hiding this comment

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

ACK 4605cf3

Copy link

codecov bot commented Dec 13, 2024

Codecov Report

Attention: Patch coverage is 42.85714% with 4 lines in your changes missing coverage. Please review.

Project coverage is 56.67%. Comparing base (0011f19) to head (4605cf3).

Files with missing lines Patch % Lines
bin/strata-cli/src/cmd/faucet.rs 0.00% 3 Missing ⚠️
bin/datatool/src/util.rs 0.00% 1 Missing ⚠️
@@            Coverage Diff             @@
##             main     #539      +/-   ##
==========================================
+ Coverage   56.56%   56.67%   +0.11%     
==========================================
  Files         303      303              
  Lines       30999    31001       +2     
==========================================
+ Hits        17534    17571      +37     
+ Misses      13465    13430      -35     
Files with missing lines Coverage Δ
bin/datatool/src/args.rs 0.00% <ø> (ø)
bin/datatool/src/main.rs 0.00% <ø> (ø)
bin/strata-cli/src/cmd/change_pwd.rs 0.00% <ø> (ø)
bin/strata-cli/src/recovery.rs 0.00% <ø> (ø)
bin/strata-cli/src/seed.rs 57.20% <100.00%> (ø)
crates/test-utils/src/lib.rs 87.50% <100.00%> (ø)
bin/datatool/src/util.rs 0.00% <0.00%> (ø)
bin/strata-cli/src/cmd/faucet.rs 0.00% <0.00%> (ø)

... and 4 files with indirect coverage changes

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.

2 participants