In the EggHuntGame
contract, the getGameStatus
function contains unreachable code due to logical contradictions between the game initialization in startGame
and the status checks in getGameStatus
. When a game is started, startTime
is set to the current timestamp, making it impossible for the condition block.timestamp < startTime
to ever be true while gameActive
is true.
The issue exists in the following code:
This unreachable condition occurs because of how the game is initialized in the startGame
function:
When startGame
is called, startTime
is set to the current timestamp (block.timestamp
), and gameActive
is set to true
. This means that once the game is active, it's impossible for block.timestamp
to be less than startTime
because:
startTime
is set to block.timestamp
at the moment of game activation
block.timestamp
can only increase in subsequent blocks
Therefore, block.timestamp < startTime
will always be false once gameActive
is true
This is a low-severity issue that does not pose a security risk, but it indicates a logical flaw in the contract design that could cause confusion for developers or users interacting with the contract. Specifically:
It represents dead code that will never be executed
It could cause confusion when reading or maintaining the code
It might lead to incorrect assumptions about the game state transitions
Gas is wasted on code evaluation that can never be reached
Manual code review
Logical flow analysis
Strategy to save gas and minimize transaction 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.