Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: low
Invalid

No need for first Status check inside collectPresent function

Summary

Optimization (Gas)
Inside collectPresent there are Status checks for first Status and second Status connected with logical AND.
There is no need for first Status check because second status can't be NICE or EXTRA_NICE without first Status equal to NICE or EXTRA_NICE.

Vulnerability Details

  1. s_theListCheckedOnce - first Status

  2. s_theListCheckedTwice - second Status

There is no need for first Status check because second status can't be NICE or EXTRA_NICE without first Status equal to NICE or EXTRA_NICE.
https://github.com/Cyfrin/2023-11-Santas-List/blob/main/src/SantasList.sol#L154
https://github.com/Cyfrin/2023-11-Santas-List/blob/main/src/SantasList.sol#L158-L159

When Santa sets second Status with checkTwice function, there is a check for first Status to be the same value.
https://github.com/Cyfrin/2023-11-Santas-List/blob/main/src/SantasList.sol#L134-L135

Therefore, there are no need to check second AND first statuses. Only second status check would be enough.

One exclusion would be if Santa for some reason end with checkList function call, e.g:
checkList (NICE)
checkTwice (NICE)
checkList (NAUGHTY)
But this is invalid case and should not be taken into account.

Impact

Optimization (Gas)

Tools Used

Manual

Recommended Mitigation

Remove first Status checks.

Updates

Lead Judging Commences

inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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