contract holmes {
error InvalidState();
function active() public view returns (bool) {
return true;
}
function coba() public {
if (active() == false) revert InvalidState();
}
}
to :
contract holmes {
error InvalidState();
function active() public view returns (bool) {
return true;
}
function coba() public {
if (!active()) revert InvalidState();
}
}
Handle
Fitraldys
Vulnerability details
Impact
in line https://github.com/code-423n4/2022-01-sherlock/blob/main/contracts/SherBuy.sol#L126 is cheaper ~20 gas to use !active() than using active() == false.
Proof of Concept
https://github.com/code-423n4/2022-01-sherlock/blob/main/contracts/SherBuy.sol#L126
to :