fix(vrf): replace mutable default RNG with per-call generator - #1736
fix(vrf): replace mutable default RNG with per-call generator#1736Sertug17 wants to merge 2 commits into
Conversation
|
This PR targeted I retargeted it to |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Fixes #1733
Summary
The previous signature used
rng=np.random.default_rng(seed=int(datetime.now().timestamp()))as a default argument evaluated once at module import time, shared across every call. This made validator selection entirely predictable after server startup.Changes
backend/consensus/vrf.pyrngdefault changed toNone, freshnp.random.default_rng()created per call inside the function body. Unuseddatetimeimport removed.tests/unit/test_vrf.pyregression test verifies 200 independent calls produce varied resultsTest plan
pytest tests/unit/test_vrf.pypasses including new regression test