transferFrom gas improvement #187
Labels
bug
Something isn't working
G (Gas Optimization)
resolved
Finding has been patched by sponsor (sponsor pls link to PR containing fix)
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Handle
sirhashalot
Vulnerability details
Impact
The ERC20Burnable.sol file has code copied from the OpenZeppelin ERC20.sol contract. The Behodler code
transferFrom()
function does use the latest version of the OpenZeppelin code, modified earlier in Jan 2022 in PR 3085, which can save gas if currentAllowance == type(uint256).max.A second gas savings that has been present in OpenZeppelin for some time but is not in the Behodler code is to add an unchecked clause around the
approve()
call.Proof of Concept
The Behodler
transferFrom()
function doesn't use the latest edits from OZ or the unchecked clause on the approve call. In contrast, the OZ code does use these edits for gas savings.Recommended Mitigation Steps
Use the latest OZ edits and the unchecked clause for gas savings if it doesn't introduce overflow or underflow conditions.
The text was updated successfully, but these errors were encountered: