40,000 USDC
View results
Submission Details
Severity: gas

Variable packing

Summary

Gas issue (Pack your variables to use less storage)

Vulnerability Details

In Escrow.sol, Pack your variables(move IERC20 private immutable i_tokenContract; under the addresses) because Small values are stored sequentially and use less storage space because they are packed together.

Impact

When processing data, the EVM adopts a novel approach: each contract has a storage location where data is kept permanently, as well as a persistent storage space where data can be read, written, and updated.

There are 2,256 slots in the storage, each of which holds 32 bytes. Depending on their particular nature, the "state variables," or variables declared in the Escrow contract that are not within any function, will be stored in these slots.

Smaller-sized state variables (i.e. variables with less than 32 bytes in size), are saved as index values in the sequence in which they were defined, with 0 for position 1, 1 for position 2, and so on. If small values are stated sequentially, they will be stored in the same slot, including very small values like uint64.

Tools Used

Manual review

Recommendations

'''
address private immutable i_buyer;
address private immutable i_seller;
address private immutable i_arbiter;
uint256 private immutable i_arbiterFee;
'''

Should be;
'''
address private immutable i_buyer;
address private immutable i_seller;
address private immutable i_arbiter;
IERC20 private immutable i_tokenContract;
uint256 private immutable i_arbiterFee;
'''

Support

FAQs

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