15,000 USDC
View results
Submission Details
Severity: gas

Usage of `uints`/`ints` smaller than 32 bytes (256 bits) incurs overhead

Summary

Vulnerability Details

When using elements that are smaller than 32 bytes, your contract’s gas usage may be higher. This is because the EVM operates on 32 bytes at a time. Therefore, if the element is smaller than that, the EVM must use more operations in order to reduce the size of the element from 32 bytes to the desired size.

More detail see this.

Each operation involving a uint8 costs an extra 22-28 gas (depending on whether the other operand is also a variable of type uint8) as compared to ones involving uint256, due to the compiler having to clear the higher bits of the memory word before operating on the uint8, as well as the associated stack operations of doing so. Use a larger size then downcast where needed

There are 3 instances of this issue:

Impact

Tools Used

Recommendations

Using uint256/int256 replace uint128/uint64/uint32/uint16/uint8 or int128/int64/int32/int16/int8

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.