Last Man Standing

First Flight #45
Beginner FriendlyFoundrySolidity
100 EXP
View results
Submission Details
Severity: low
Valid

Event emit in declareWinner always set the pot to 0

[I] Event emit in declareWinner always set the pot to 0

Description:
The emit event in Game::declareWinner is set as below :

pot = 0; // Reset pot after assigning to winner's pending winnings
emit GameEnded(currentKing, pot, block.timestamp, gameRound);

Impact:
The transaction log emitted by this event always has the pot data set to 0, so if we need to use the data for something else it will be always wrong.

Recommended Mitigation:

The function could be made like below :

function declareWinner() external gameNotEnded {
uint256 gamePot = pot;
require(currentKing != address(0), "Game: No one has claimed the throne yet.");
require(
block.timestamp > lastClaimTime + gracePeriod,
"Game: Grace period has not expired yet."
);
gameEnded = true;
pendingWinnings[currentKing] = pendingWinnings[currentKing] + gamePot;
pot = 0; // Reset pot after assigning to winner's pending winnings
emit GameEnded(currentKing, gamePot, block.timestamp, gameRound);
}
Updates

Appeal created

inallhonesty Lead Judge about 1 month ago
Submission Judgement Published
Validated
Assigned finding tags:

Game::declareWinner emits GameEnded event with pot = 0 always

Support

FAQs

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