code-423n4 / 2021-11-yaxis-findings

0 stars 0 forks source link

Unnecessary `SLOAD`s #86

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Handle

pants

Vulnerability details

Due to how the EVM natively works on 256 numbers, using a 8 bit number in loops introduces additional costs as the EVM has to properly enforce the limits of this smaller type.

GeneralConverter.sol line 189: for (uint8 i = 0; i < tokens.length; i++) GeneralConverter.sol line 137: for (uint8 i = 0; i < tokens.length; i++) GeneralConverter.sol line 109: for (uint8 i = 0; i < tokens.length; i++)

See the warning at this link: https://docs.soliditylang.org/en/v0.8.0/internals/layout_in_storage.html#layout-of-state-variables-in-storage

Impact

Increase GAS cost

Tool Used

Manual code review.

Recommended Mitigation Steps

Use uint256 instead

0xleastwood commented 2 years ago

Marked out of scope by sponsor.