wise-foundation / lending-audit

5 stars 4 forks source link

[DFM-01C] Non-Standard Revert Patterns #65

Open vm06007 opened 11 months ago

vm06007 commented 11 months ago

DFM-01C: Non-Standard Revert Patterns

Type Severity Location
Gas Optimization DeclarationsFeeManager.sol:L180-L182, L184, L191-L193, L195, L202-L204, L206

Description:

The referenced functions will evaluate whether the msg.sender is an authorized member, return early in such a case and otherwise revert.

Example:

function _onlyWiseLending()
    private
    view
{
    if (msg.sender == address(WISE_LENDING)) {
        return;
    }

    revert NotWiseLending();
}

Recommendation:

We advise the functions to inverse their if conditions and revert in their case, reducing the bytecode signature as well as common-case gas cost of the functions.

vm06007 commented 11 months ago

Team decided not to address this information, as it is not a security concern and a matter of style preference. Team finds this optimization not worth the effort amount of gas/bytecode it allows to save is extremely negligeble and would like to maintain code with using strict comparison such as == instead of != without using require (if statement is cheaper)