40,000 USDC
View results
Submission Details
Severity: gas

Functions guaranteed to revert when called by normal users can be marked `payable`

Summary

Functions guaranteed to revert when called by normal users can be marked payable

Vulnerability Details

If a function modifier such as onlyOwner is used, the function will revert if a normal user tries to pay the function. Marking the function as payable will lower the gas cost for legitimate callers because the compiler will not include checks for whether a payment was provided.The extra opcodes avoided are CALLVALUE(2), DUP1(3), ISZERO(3), PUSH2(3), JUMPI(10), PUSH1(3), DUP1(3), REVERT(0), JUMPDEST(1), POP(2), which costs an average of about ** 21 gas per call ** to the function, in addition to the extra deployment cost

File: /src/Escrow.sol
94: function confirmReceipt() external onlyBuyer inState(State.Created) {
102: function initiateDispute() external onlyBuyerOrSeller inState(State.Created) {
109: function resolveDispute(uint256 buyerAward) external onlyArbiter nonReentrant inState(State.Disputed) {

Impact

Save gas

Tools Used

Manual

Recommendations

Functions guaranteed to revert when called by normal users can be marked payable

Support

FAQs

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