sherlock-audit / 2024-01-telcoin-judging

6 stars 5 forks source link

araj - Use if-revert instead of require statement to save gas #121

Closed sherlock-admin2 closed 9 months ago

sherlock-admin2 commented 9 months ago

araj

medium

Use if-revert instead of require statement to save gas

Summary

Use if-revert instead of require statement to save gas in all the functions for checks

Vulnerability Detail

If-revert is more gas efficient than require statement, protocol is heavily using require statement for checks, some examples are

 require(
            address(telcoin) != address(0) &&
                address(council) != address(0) &&
                period != 0,
            "TelcoinDistributor: cannot intialize to zero"
        );

Impact

If-revert will increase gas efficiency

Code Snippet

https://github.com/sherlock-audit/2024-01-telcoin/blob/main/telcoin-audit/contracts/protocol/core/TelcoinDistributor.sol#L61C9-L66C11

Tool used

Manual Review

Recommendation

Use If-revert

+  if(condition){
+        revert custom__error
+   }
sherlock-admin2 commented 9 months ago

1 comment(s) were left on this issue during the judging contest.

takarez commented:

invalid because { gas optimization is invalid/out-of scope}

nevillehuang commented 8 months ago

Invalid, gas optimization findings are not valid based on sherlock rules