code-423n4 / 2021-10-tally-findings

0 stars 0 forks source link

Lower than uint256 types are not more efficient #54

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Handle

pauliax

Vulnerability details

Impact

Lower than uint256 size variables are less gas efficient. E.g. using uint8 does not give any efficiency, actually, it is the opposite as EVM operates on default of 256-bit values so uint8 is more expensive in this case as it needs a conversion. It only gives improvements in cases where you can pack variables together, e.g. structs. Here is the example where uint256 would be more efficient: for (uint8 i = 0; i<tokens.length; i++)

Recommended Mitigation Steps

for (uint256 i = 0; i<tokens.length; i++)

Shadowfiend commented 2 years ago

Duplicate of #7.