Last Man Standing

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

GameEnded Event Emits Wrong Prize Amount (Always 0)

Root + Impact

Description

  • In the declareWinner() function:


emit GameEnded(currentKing, pot, block.timestamp, gameRound);
// But just above that, the pot is set to 0:
pendingWinnings[currentKing] = pendingWinnings[currentKing] + pot;
pot = 0;

So the emitted event always shows prizeAmount = 0, even though the winner is being awarded ETH. This breaks frontend dashboards, analytics, and off-chain integrations.

Proof of Concept

Call declareWinner() with 5 ETH in the pot:

  • Pot before call = 5 ETH

  • Event emits: GameEnded(winner, 0, ...) ← WRONG

Risk

Impact

  1. Trust issue

  2. Incorrect analytics

  3. Subgraph desync


Recommended Mitigation

Store the pot in a temp variable before zeroing:

uint256 prize = pot;
pendingWinnings[currentKing] += prize;
pot = 0;
emit GameEnded(currentKing, prize, 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.