Pieces Protocol

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

Unused Error Declaration Increases Code Size and Reduces Code Quality

Summary

Unused Error Declaration Increases Code Size and Reduces Code Quality

Vulnerability Details

In the TokenDivider smart contract, there is an unused error declaration TokenDivier__InvalidAmount() which not only increases the contract's bytecode size unnecessarily but also has a typo in its name ("TokenDivier" instead of "TokenDivider"). Unused code declarations in smart contracts are considered poor practice as they can lead to confusion, and increase gas costs during deployment.

A grep or search through the entire codebase shows that TokenDivier__InvalidAmount() is never used in any revert statement. Instead, amount validations use other error declarations like TokenDivider__AmountCantBeZero(), making this declaration redundant.

Impact

The presence of this unused error has several negative implications:

  • Increased deployment gas cost due to unnecessary bytecode

  • Reduced code quality and maintainability

  • Potential confusion for auditors and developers who may spend time trying to understand where this error is used

  • The typo in the name could lead to further confusion if someone attempts to use this error in future code additions

  • May indicate missing validation logic that was intended but never implemented

Tools Used

Foundry

Recommendations

Remove the unused error declaration to improve code quality and reduce deployment gas costs:

contract TokenDivider is IERC721Receiver, Ownable {
error TokenDivider__NotFromNftOwner();
error TokenDivider__NotEnoughErc20Balance();
error TokenDivider__NftTransferFailed();
error TokenDivider__InsuficientBalance();
error TokenDivider__CantTransferToAddressZero();
error TokenDivider__TransferFailed();
error TokenDivider__NftAddressIsZero();
error TokenDivider__AmountCantBeZero();
error TokenDivider__InvalidSeller();
- error TokenDivier__InvalidAmount();
error TokenDivider__IncorrectEtherAmount();
error TokenDivider__InsuficientEtherForFees();
// ... rest of the contract
}
Updates

Lead Judging Commences

fishy Lead Judge 5 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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