Skip to content

fix(vrf): replace mutable default RNG with per-call generator - #1736

Open
Sertug17 wants to merge 2 commits into
genlayerlabs:v0.123-devfrom
Sertug17:fix/vrf-mutable-default-rng-1733
Open

fix(vrf): replace mutable default RNG with per-call generator#1736
Sertug17 wants to merge 2 commits into
genlayerlabs:v0.123-devfrom
Sertug17:fix/vrf-mutable-default-rng-1733

Conversation

@Sertug17

@Sertug17 Sertug17 commented Aug 15, 2026

Copy link
Copy Markdown

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.py rng default changed to None, fresh np.random.default_rng() created per call inside the function body. Unused datetime import removed.
  • tests/unit/test_vrf.py regression test verifies 200 independent calls produce varied results

Test plan

  • pytest tests/unit/test_vrf.py passes including new regression test

@github-actions
github-actions Bot changed the base branch from main to v0.123-dev August 15, 2026 10:43
@github-actions

Copy link
Copy Markdown
Contributor

This PR targeted main, which is only the default/static branch.

I retargeted it to v0.123-dev, the active development branch. Pushes to v0.123-dev automatically fast-forward main.

@coderabbitai

coderabbitai Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ae613dec-81d2-476b-ad26-7529e4244f3e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

bug: VRF RNG shared across all calls due to mutable default argument validator selection is predictable

1 participant