Last Man Standing

First Flight #45
Beginner FriendlyFoundrySolidity
100 EXP
View results
Submission Details
Impact: low
Likelihood: low
Invalid

[O-2] Modifier invoked only once.

Root + Impact

[O-2] Modifier invoked only once.

Description

The Game::gameEndedOnly modifier is invoked only once, the logic of it can be moved to the Game::resetGame function since it is the only one requiring the modifier logic.

modifier gameEndedOnly() {
require(gameEnded, "Game: Game has not ended yet.");
_;
}

Risk

Likelihood: Low

Impact: None

Proof of Concept

The original Game::resetGame function has a single invocation of the gameEndedOnly modifier.

function resetGame() external onlyOwner gameEndedOnly {
currentKing = address(0);
lastClaimTime = block.timestamp;
pot = 0;
claimFee = initialClaimFee;
gracePeriod = initialGracePeriod;
gameEnded = false;
gameRound = gameRound + 1;
// totalClaims is cumulative across rounds, not reset here, but could be if desired.
emit GameReset(gameRound, block.timestamp);
}

Recommended Mitigation

Consider removing the modifier or inlining the logic into the Game::resetGame function.

- modifier gameEndedOnly() {
- require(gameEnded, "Game: Game has not ended yet.");
- _;
- }
- function resetGame() external onlyOwner gameEndedOnly {
+ function resetGame() external onlyOwner {
+ require(gameEnded, "Game: Game has not ended yet.");
currentKing = address(0);
lastClaimTime = block.timestamp;
pot = 0;
claimFee = initialClaimFee;
gracePeriod = initialGracePeriod;
gameEnded = false;
gameRound = gameRound + 1;
// totalClaims is cumulative across rounds, not reset here, but could be if desired.
emit GameReset(gameRound, block.timestamp);
}
Updates

Appeal created

inallhonesty Lead Judge about 2 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.