DatingDapp

First Flight #33
Beginner FriendlyFoundrySolidityNFT
100 EXP
View results
Submission Details
Severity: low
Invalid

[G-2] Use of require statements instead of custom errors wastes gas (Error Handling + ~50 Gas Per Call)

Description: The codebase inconsistently uses require statements and custom errors. In all contracts, require statements are used instead of custom errors, only MultiSig.sol contract in some places uses custom errors but without a consistent naming convention.

Found in:

  1. LikeRegistry.sol:

require(msg.value >= 1 ether, "Must send at least 1 ETH");
require(!likes[msg.sender][liked], "Already liked");
require(msg.sender != liked, "Cannot like yourself");
require(profileNFT.profileToToken(msg.sender) != 0, "Must have a profile NFT");
require(profileNFT.profileToToken(liked) != 0, "Liked user must have a profile NFT");
  1. MultiSig.sol:

require(_owner1 != address(0) && _owner2 != address(0), "Invalid owner address");
require(_owner1 != _owner2, "Owners must be different");
require(_txId < transactions.length, "Invalid transaction ID");
require(!txn.executed, "Transaction already executed");
require(txn.approvedByOwner1 && txn.approvedByOwner2, "Not enough approvals");
error NotAnOwner(); // Should be MultiSigWallet__NotAnOwner
error AlreadyApproved(); // Should be MultiSigWallet__AlreadyApproved
error NotEnoughApprovals(); // Should be MultiSigWallet__NotEnoughApprovals
  1. SoulboundProfileNFT.sol

error ERC721Metadata__URI_QueryFor_NonExistentToken();
error SoulboundTokenCannotBeTransferred();
require(profileToToken[msg.sender] == 0, "Profile already exists");
require(tokenId != 0, "No profile found");
require(ownerOf(tokenId) == msg.sender, "Not profile owner");

Recommended Mitigation:

  1. Use custom errors instead of require statements:

error LikeRegistry__InsufficientValue();
error LikeRegistry__AlreadyLiked();
error LikeRegistry__CannotLikeSelf();
error LikeRegistry__NoProfileNFT();
  1. Follow consistent naming convention ContractName__ErrorName:

error MultiSigWallet__NotAnOwner();
error MultiSigWallet__AlreadyApproved();
error MultiSigWallet__NotEnoughApprovals();

Do the same for the others

Benefits:

  • Custom errors are more gas efficient

  • Better error handling and debugging

  • Consistent naming helps with code maintenance

Updates

Appeal created

n0kto Lead Judge 6 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Informational or Gas

Please read the CodeHawks documentation to know which submissions are valid. If you disagree, provide a coded PoC and explain the real likelyhood and the detailed impact on the mainnet without any supposition (if, it could, etc) to prove your point.

Support

FAQs

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