Last Man Standing

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

Incorrect Pot Value Logged in GameEnded Event

Root + Impact

GameEnded emits pot after it's reset to 0 (should capture pre-reset value), causing off-chain systems to log 0 instead of the actual distributed pot amount. No functional impact – winnings are correctly assigned to pendingWinnings, but event data misrepresents game outcomes.

Description

In declareWinner function, the pot is reset to 0 before emitting GameEnded:

pendingWinnings[currentKing] += pot;
pot = 0;
emit GameEnded(currentKing, pot, block.timestamp, gameRound); // Logs pot=0

This causes the event to log pot=0 instead of the actual distributed amount (the pre-reset value). While contract state is correctly updated (winnings secured in pendingWinnings), the event data becomes inaccurate for off-chain consumers (e.g., analytics dashboards, frontends).

Impact:

GameEnded logs pot as 0, causing off-chain misreporting of game results.

Recommended Mitigation

pendingWinnings[currentKing] = pendingWinnings[currentKing] + pot;
+ uint256 priceAmount = pot ;
pot = 0;
- emit GameEnded(currentKing, pot, block.timestamp, gameRound);
+ emit GameEnded(currentKing, priceAmount, 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.