SNARKeling Treasure Hunt

First Flight #59
Beginner FriendlyGameFiFoundry
100 EXP
Submission Details
Impact: low
Likelihood: low

Ten custom errors declared but never emitted

Author Revealed upon completion

Description

contracts/src/TreasureHunt.sol:14-25 declares seventeen custom errors; only nine are used with revert ErrorName(). The other ten are shadowed by string-based requires in the admin functions.

Risk

Dead ABI entries. Revert-path gas for the ten string requires is higher than the custom-error equivalent. Consumers must handle two revert formats.

PoC

The ten unused errors and their shadows:

Error Line Shadowed by
OwnerCannotBeRecipient 14 InvalidRecipient (L86)
HuntNotOver 16 "HUNT_NOT_OVER" (L224)
NoFundsToWithdraw 17 "NO_FUNDS_TO_WITHDRAW" (L227)
OnlyOwnerCanFund 18 "ONLY_OWNER_CAN_FUND" (L237)
OnlyOwnerCanPause 19 "ONLY_OWNER_CAN_PAUSE" (L246)
OnlyOwnerCanUnpause 20 "ONLY_OWNER_CAN_UNPAUSE" (L255)
TheContractMustBePaused 22 "THE_CONTRACT_MUST_BE_PAUSED" (L264, L274)
OnlyOwnerCanUpdateVerifier 23 "ONLY_OWNER_CAN_UPDATE_VERIFIER" (L265)
OnlyOwnerCanEmergencyWithdraw 24 "ONLY_OWNER_CAN_EMERGENCY_WITHDRAW" (L275)
InvalidAmount 25 "INVALID_AMOUNT" (L277)

Mitigation

Replace each require(cond, "...") with if (!cond) revert ErrorName();, or delete the unused declarations.

Support

FAQs

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

Give us feedback!