Modifiers are normally utilized to prevent code duplication by extracting reusable logic that applies to multiple functions across a contract.
The nonReentrant modifier in the TreasureHunt contract is defined but only utilized once within the claim function. This implementation creates unnecessary jumps during execution and increases the overall bytecode size without providing any reusability benefits.
Likelihood:
The modifier overhead is consistently applied every time the contract is compiled and deployed.
The extra jump instruction is executed every time the claim function is called.
Impact:
Increased deployment gas cost due to the larger contract bytecode size.
Marginally higher execution gas cost when calling the claim function.
Explanation: The nonReentrant modifier is exclusively attached to the claim function. Reviewing the entire contract confirms it is not reused in any other function. Therefore, the abstraction overhead provides zero reusability value.
Explanation: Remove the nonReentrant modifier declaration entirely and inline its logic (require check and locked boolean toggling) directly inside the claim function body. This approach maintains the exact same reentrancy protection while eliminating the modifier's jump overhead, which reduces both deployment and execution gas costs.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.
The contest is complete and the rewards are being distributed.