Closed caffeinum closed 1 year ago
If you store the PRNG.Source
then the next caller of the function knows with 100% certainty what _next()
will return. Although seeding for each use isn't perfect (see: Flashbot bundles) it's definitely less predictable / harder to manipulate than having full knowledge of the internal state of the PRNG before the call.
https://github.com/divergencetech/ethier/blob/43a72962eccf5b9c4b53e4d13cf1484663b47512/tests/random/TestableNextShuffler.sol#L18-L23
Probably the common pattern would be to initialize the shuffler once and then fetch
next()
on each user request. What's the reasoning to not store source as a storage variable inNextShuffler
?https://github.com/divergencetech/ethier/blob/43a72962eccf5b9c4b53e4d13cf1484663b47512/contracts/random/NextShuffler.sol#L69-L73