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.
Use
bytes.concat()
on bytes instead ofabi.encodePacked()
for clearer semantic meaningSeverity
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 ofabi.encodePacked()
for clearer semantic meaningVulnerability 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 thanabi.encodePacked()
makes the intended operation more clear, leading to less reviewer confusion.Instances (2):
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 ofabi.encodePacked()
for clearer semantic meaning