Eggstravaganza

First Flight #37
Beginner FriendlySolidity
100 EXP
View results
Submission Details
Severity: low
Invalid

Redundant Line of Code

Summary

The check

if (block.timestamp < startTime)
return "Game not started yet";

inside gameActive == true is indeed redundant

Vulnerability Details

  • If gameActive == true, the game should already be past its startTime by definition

  • There's no scenario where gameActive is true but block.timestamp < startTime

/// @notice Returns a human-readable status of the game.
function getGameStatus() external view returns (string memory) {
if (gameActive) {
if (block.timestamp < startTime) {
return "Game not started yet";
} else if (block.timestamp >= startTime && block.timestamp <= endTime) {
return "Game is active";
} else {
return "Game time elapsed";
}
} else {
return "Game is not active";
}
}

Impact

  • increases gas cost by introducing unnecessary checks

Tools Used

mannual review

Recommendations

The testGameStartAndEnd function still passes

function getGameStatus() external view returns (string memory) {
if (!gameActive) {
return "Game is not active";
}
// Only these checks are needed when gameActive == true
if (block.timestamp <= endTime) {
return "Game is active";
} else {
return "Game time elapsed";
}
}
Updates

Lead Judging Commences

m3dython Lead Judge 3 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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