Dria

Swan
NFTHardhat
21,000 USDC
View results
Submission Details
Severity: high
Invalid

The current validation logic will always favor low scores due to division rounding down.

Summary

In the validation logic (function validate), the mean and variance will be calculated. When the score is within the range of the mean +- variance, the validator will receive a reward. However, The current validation logic will always favor low scores due to division rounding down.

Vulnerability Details

// compute the mean and standard deviation
(uint256 _stddev, uint256 _mean) = Statistics.stddev(scores);
// compute the score for this generation as the "inner-mean"
// and send rewards to validators that are within the range
uint256 innerSum = 0;
uint256 innerCount = 0;
for (uint256 v_i = 0; v_i < task.parameters.numValidations; ++v_i) {
uint256 score = scores[v_i];
if ((score >= _mean - _stddev) && (score <= _mean + _stddev)) {
innerSum += score;
innerCount++;
// send validation fee to the validator
_increaseAllowance(validations[taskId][v_i].validator, task.validatorFee);
}
}

For example, when the number of validators is 2, one validator has a score of 100 and the other has a score of 101. Under normal verification logic, both validators should receive rewards. The mean is 100.5 and the variance is greater than 0.5. However, due to rounding, the mean will be 100 and the ariance will be 0. This will result in validators with high scores being unable to obtain rewards, which is an unreasonable verification algorithm.

Please note that when the number of validators is 2, as long as the sum of the scores of two validators is an odd number, only the validator with the lower score will receive rewards.

Impact

The current validation logic is no proper, since it always favor low scores due to division rounding down.

Tools Used

VSCode

Recommendations

if ((score >= _mean - _stddev) && (score <= _mean + _stddev + 1)) {
Updates

Lead Judging Commences

inallhonesty Lead Judge 12 months ago
Submission Judgement Published
Invalidated
Reason: Known issue

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.