-
Notifications
You must be signed in to change notification settings - Fork 15
Potential User-Defined Value Type #311
Comments
The compiler is complaining about this when it comes to do math with reports like:
for function tierAtBlockFromReport(Report report_, uint256 blockNumber_)
internal
pure
returns (uint256)
{
unchecked {
for (uint256 i_ = 0; i_ < 8; i_++) {
if (uint32(uint256(report_ >> (i_ * 32))) > blockNumber_) {
return i_;
}
}
return TierConstants.MAX_TIER;
}
} If I can't even explicitly cast from |
|
I'm concerned that if we go as far as to add wrapper functions then there will be additional gas cost, but maybe that is optimized away by the compiler. I also think if we go down this road then this kind of handling of Either way it is not urgent so I think we come back to it after the next audit. |
|
TCE-01C: Potential User-Defined Value Type
Description:
Given that the "report" type is a special purpose
uint256
value, the legibility of the codebase and library usages can be optimized by defining a custom user-value type.Example:
Recommendation:
We advise one to be defined for the "report" data type (i.e.
type Report is uint256;
) to optimize library usages and permit statements such asusing TierReport for Report;
without affecting the functions exposed by the "basic" data types (i.e. avoidusing TierReport for uint256;
). This finding will not be replicated across the codebase, however, it is applicable to many instances.The text was updated successfully, but these errors were encountered: