code-423n4 / 2022-01-notional-findings

1 stars 3 forks source link

gas optimisation on nonReentant() modifier #207

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Handle

rfa

Vulnerability details

Impact

Detailed description of the impact of this finding.

Proof of Concept

https://github.com/code-423n4/2022-01-notional/blob/main/contracts/ActionGuards.so its not the effective way to make 'nonreentran' because its declare 3 vars and importing StorageLayoutV1.sol.

Recommended Mitigation Steps

    bool private reentrancyStatus = true;

    modifier nonReentrant() {

        require(reentrancyStatus, "Reentrant call");

        reentrancyStatus = false;

        _;

        reentrancyStatus = true;
    }
// 19567 gas save per call (or even more)
jeffywu commented 2 years ago

2 of the variables are constants which are compiled inline, this optimization does not make sense to me.

pauliax commented 2 years ago

How it could be done better? No suggested improvement.