Closed sherlock-admin3 closed 4 months ago
1 comment(s) were left on this issue during the judging contest.
0xmystery commented:
Code snippets (
stdDev.Lt(epsilon)
andM(T) = φ_p (abs[ T / σ(T) + ɛ])
) given can't be found in rewards_internal.go
Minato7namikazi
High
Inconsistent Handling of Zero Standard Deviation in
rewards_internal.go
Vulnerability Detail
In the
GetMappingFunctionValues
function, there's an issue with how the code handles situations where the standard deviation (stdDev
) of thelatestTimeStepsScores
is less thanepsilon
(or zero).The problematic section is:
In this case, the function returns an array filled with
alloraMath.OneDec()
, essentially assigning the same score to every worker. However, this doesn't accurately reflect the formula in the comment:If
stdDev
is zero (or very close to zero), the divisionT / σ(T)
becomes undefined or extremely large, leading to a result that doesn't align with the intended mapping.Consequences
This can skew the reward calculations significantly, as the mapping function values won't be accurately reflecting the worker scores relative to the standard deviation. This can lead to:
The Fix: Correct Mapping Function Calculation
To address this, we need to modify the
GetMappingFunctionValues
function to handle the case of low or zero standard deviation more gracefully.Code Snippet
https://github.com/sherlock-audit/2024-06-allora/blob/main/allora-chain/x/emissions/module/rewards/rewards_internal.go#L54
Tool used
Manual Review