Declaring 3 bool variable is quite expensive for gas usage. Here the better implementation:
bool private _status = true;
modifier nonReentrant() {
// On the first call to nonReentrant, _notEntered will be true
require(_status, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = false;
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = true;
}
// save a lot of gas
Handle
Funen
Vulnerability details
Impact
Expensive gas
Proof of Concept
https://github.com/code-423n4/2022-01-yield/blob/main/contracts/ConvexStakingWrapper.sol#L52-L55
Declaring 3 bool variable is quite expensive for gas usage. Here the better implementation: