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

Fix random number generator conventions #369

Open
marsella opened this issue Apr 22, 2022 · 0 comments
Open

Fix random number generator conventions #369

marsella opened this issue Apr 22, 2022 · 0 comments
Assignees

Comments

@marsella
Copy link
Contributor

In the course of solving #351, we discovered some inappropriate RNG behavior: RNGs were clone when we spawn separate threads, but cloning doesn't reseed RNGs, so there are places with potentially matching randomness streams.

As a partial solution in #368 we reset the way that we pass around RNGs on the customer side. Instead of using one and passing it by value (and occasionally cloning it), we now just create the RNG at the top of a commend when we need it. This has the drawback of potentially creating too many RNGs (especially in a close flow), which could lead to them being seeded without enough entropy.

A proper solution to this problem should do the following

  1. Return to the convention of "create an RNG once and use it everywhere"
  2. Use a reseedable RNG with the convention of reseeding on clone.
  3. Decide whether it's best to pass mutable references to RNGs to each Command or give ownership (and require cloning).
  4. Apply these changes to both customer and merchant commands.
@marsella marsella self-assigned this Apr 22, 2022
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

No branches or pull requests

1 participant