Description
In neurons/validators/penalty/twitter_count_penalty.py, the penalty is calculated as:
penalties[index] = 1 - results_count / response.count
If response.count == 0, this raises ZeroDivisionError at runtime.
A miner responding with count=0 (intentionally or due to a bug) will crash the validator's penalty computation for that entire batch.
Steps to Reproduce
- Submit a
TwitterSearchSynapse response with count=0
- The penalty computation raises
ZeroDivisionError
Expected Behavior
When response.count == 0, the penalty should be 0.0 (no tweets expected, no penalty) and the loop should continue to the next response.
Actual Behavior
ZeroDivisionError: division by zero is raised, crashing the penalty loop.
Fix
Add a guard before the division: if response.count == 0, set penalties[index] = 0.0 and continue.
Description
In
neurons/validators/penalty/twitter_count_penalty.py, the penalty is calculated as:If
response.count == 0, this raisesZeroDivisionErrorat runtime.A miner responding with
count=0(intentionally or due to a bug) will crash the validator's penalty computation for that entire batch.Steps to Reproduce
TwitterSearchSynapseresponse withcount=0ZeroDivisionErrorExpected Behavior
When
response.count == 0, the penalty should be0.0(no tweets expected, no penalty) and the loop should continue to the next response.Actual Behavior
ZeroDivisionError: division by zerois raised, crashing the penalty loop.Fix
Add a guard before the division: if
response.count == 0, setpenalties[index] = 0.0andcontinue.