40,000 USDC
View results
Submission Details
Severity: gas
Valid

Reentrancy guard and nonReentrant modifier not required.

Summary

The contract Escrow.sol uses reentrancy guard contract and nonReentrant modifier to not allow someone to reenter into the same function twice but it is not required as inState modifier ensures that a function can only be called by a particular State type. And all of these State types are updated before any external calls so, Reentrancy is not possible. So, they can be removed to save some gas.

Vulnerability Details

The contract Escrow inherits reentrancy guard and function resolveDispute uses nonReentrant modifier which is not necessary and can be removed. It can save up to 276 gas for resolveDispute function and 40525 gas in deployment cost.

Savings

Gas Savings for resolveDispute function:

Average Median Max
Before 27017 22342 62460
After 26794 22094 62184

Deployment cost and deployment size:

Deployment cost Deployment size
Before 591900 3666
After 551375 3569

Tools Used

Manual Analysis and Gas savings are calculated using $ forge test --gas-report

Recommendations

Don't inherit from reentrancy guard and don't use nonReentrant modifier in the resolveDispute function.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.