The collectPresent
function contains unnecessary double checks that can be optimized to avoid potential bugs and reduce gas consumption.
The collectPresent
function has two conditional checks that verify the status of the caller in both s_theListCheckedOnce
and s_theListCheckedTwice
mappings. However, these double checks are redundant and can be simplified to improve efficiency.
The first issue is that the second check (s_theListCheckedTwice[msg.sender]
) is unnecessary because it can only be true if the first check (s_theListCheckedOnce[msg.sender]
) is already true. Therefore, the second check can be removed to simplify the logic and avoid potential bugs.
The second issue is that the first mapping can be changed even after the second mapping is set, leading to blocking a person to collect their present.
Could block any person if Santa change the first mapping after the second is set (or an other vulnerability is used to change the first mapping)
Useless gas consumption
Manual review
It is recommended to simplify the conditional checks and use only s_theListCheckedTwice
. Here is an updated version of the function:
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.