Last Man Standing

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

Incorrect pot Value Emitted in GameEnded Event


Description

In the declareWinner() function, the GameEnded event is emitted after the pot has already been reset to zero:

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

As a result, the event always emits pot = 0, which is incorrect and misleading. The actual amount the winner receives is not reflected in the event logs.

This breaks off-chain indexing and creates confusion for anyone relying on emitted data to determine the size of the pot or payouts.

Risk :

  • LOW

Likelihood:

  • Occurs every time declareWinner() is called.

Impact:

  • Off-chain services will display incorrect information about the winner's reward.

  • Makes auditing and verifying payouts from logs impossible.

Proof of Concept

  • wrong event emitted every time

// pot = 5 ether
declareWinner();
// emits: GameEnded(currentKing, 0, timestamp, round) // wrong

Recommended Mitigation

  • Move the emit line before the pot is zeroed out:


Updates

Appeal created

inallhonesty Lead Judge 18 days 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.