Repository navigation
fix(consensus): guard against zero total stake in VRF validator selection - #1794
HusseinAdeiza wants to merge 1 commit into
Conversation
…tion get_validators_for_transaction divided each validator's stake by the total stake without checking for zero. When all validators have stake=0 (e.g. internally-created validators in protocol_rpc/endpoints.py), this raised ZeroDivisionError and crashed the consensus worker, halting transaction processing. Fall back to a uniform probability distribution when the total stake is zero; non-zero totals are unaffected. Adds a unit test covering the zero-stake path. Closes genlayerlabs#1732 Signed-off-by: HusseinAdeiza <HusseinAdeiza@users.noreply.github.com>
|
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 configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches
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 |
|
Closing in favor of the upstream fix that landed on v0.123-dev: |
Summary
Closes #1732.
get_validators_for_transactiondivided each validator's stake by the total stake with no zero check. When all validators havestake=0(e.g. the internally-created validators inprotocol_rpc/endpoints.py), this raisedZeroDivisionErrorand crashed the consensus worker, halting transaction processing.Change
Fall back to a uniform probability distribution when
total_stake == 0; non-zero totals are unaffected. Adds a unit test (test_get_validators_for_transaction_all_zero_stake) covering the zero-stake path.Testing
vrf↔basecircular import blocks importingvrffirst, on pristinemaintoo): zero-stake →[1/3,1/3,1/3], normal stakes →[1/6,2/6,3/6], mixed → stake weights.Summary by CodeRabbit