Closed sherlock-admin closed 5 months ago
1 comment(s) were left on this issue during the judging contest.
takarez commented:
invalid
Invalid, this is atmost a gas optimization finding. Additionally, agree with sponsors comments:
This is intentional for function getPrice() signature which has no params. This is called overloading.
Afriauditor
medium
Redundant validation maxAge < type(uint32).max in OracleModule:_getprice
Summary
The function _getPrice incurs unnecessary gas consumption due to a redundant check ensuring that the max age is not above type(uint32).max. This inefficiency is amplified as the function is repeatedly called by multiple modules throughout the protocol's operation.
Vulnerability Detail
The redundancy of this check arises from the fact that the Solidity compiler inherently includes a verification mechanism, preventing compilation if the value of maxAge exceeds type(uint32).max.
Impact
Frequent gas loss occurs every time the function is called throughout the protocol's lifetime, as it redundantly performs a manual check for maxAge < type(uint32).max, even though the compiler has already conducted this validation.
Code Snippet
https://github.com/sherlock-audit/2023-12-flatmoney/blob/main/flatcoin-v1/src/OracleModule.sol#L131
Tool used
Manual Review
Recommendation
remove the maxAge < type(uint32).max check from the
if
statement