Cyfrin / 2023-07-escrow

17 stars 12 forks source link

Use `bytes.concat()` on bytes instead of `abi.encodePacked()` for clearer semantic meaning #866

Closed codehawks-bot closed 10 months ago

codehawks-bot commented 11 months ago

Use bytes.concat() on bytes instead of abi.encodePacked() for clearer semantic meaning

Severity

Gas Optimization / Informational

Relevant GitHub Links

https://github.com/Cyfrin/2023-07-escrow/tree/main/src/EscrowFactory.sol

Summary

Use bytes.concat() on bytes instead of abi.encodePacked() for clearer semantic meaning

Vulnerability Details

Starting with version 0.8.4, Solidity has the bytes.concat() function, which allows one to concatenate a list of bytes/strings, without extra padding. Using this function rather than abi.encodePacked() makes the intended operation more clear, leading to less reviewer confusion.

Instances (2):

File: src/EscrowFactory.sol

72:                         abi.encodePacked(

77:                                 abi.encodePacked(

Link to code - https://github.com/Cyfrin/2023-07-escrow/tree/main/src/EscrowFactory.sol

Tools Used

Manual Code Review

Recommendations

Use bytes.concat() on bytes instead of abi.encodePacked() for clearer semantic meaning

PatrickAlphaC commented 10 months ago

I prefer abi.encodePacked