noReenter
Can Be Optimised Better
#31
Labels
bug
Something isn't working
duplicate
This issue or pull request already exists
G (Gas Optimization)
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Handle
leastwood
Vulnerability details
Impact
The
noReenter
modifier can be done more efficiently by using1
and2
to represent unlocked and locked states respectively. This is due to the fact that there are additional gas costs when updating a slow from a zero value to a non-zero value. The gas refunded when resetting the slot back to its zero value does not cover the cost of the initial change.Proof of Concept
Tools Used
Manual code review.
Recommended Mitigation Steps
Consider using
1
and2
to represent the unlocked and locked states respectively.The text was updated successfully, but these errors were encountered: