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

nonReentrant modifier is not necessary.

Summary

Usage of nonReentrant modifier adds a lot of gas costs. Consider removing the modifier since the only party that can call the function the arbiter, which is a trusted party.

Vulnerability Details

resolveDispute() can only be called by the arbiter. The arbiter is a trusted party, therefor, you can remove the nonReentrant guard since the arbiter won't be wearing his black hat on.

File: 2023-07-escrow/src/Escrow.sol
109: function resolveDispute(uint256 buyerAward) external onlyArbiter nonReentrant inState(State.Disputed) {

Function gas savings:

Function Name min avg median max # calls
resolveDispute 383 27017 22342 62460 8
resolveDisputeOptimized 383 26794 22094 62184 8

Deployment gas savings:

Contract Name Deployment Cost Deployment Size
Escrow 591900 3666
EscrowOptimized 551375 3569
EscrowFactory.sol 1720616 8622
EscrowFactoryOptimized.sol 1681774 8482

Impact

Gas Optimization

Tools Used

Manual review.

Recommendations

File: 2023-07-escrow/src/Escrow.sol
- function resolveDispute(uint256 buyerAward) external onlyArbiter nonReentrant inState(State.Disputed) {
+ function resolveDispute(uint256 buyerAward) external onlyArbiter inState(State.Disputed) {

Support

FAQs

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