pot is reset before GameEnded emitNormal behavior: When a winner is declared via the declareWinner() function, their prize (stored in the pot) is added to their pendingWinnings, and a GameEnded event is emitted to signal the end of the round. The event is expected to include accurate information about the prize amount won (prizeAmount), which can be used by off-chain services (UIs, indexers, explorers) to reflect the outcome of the game.
Issue: The GameEnded event is emitted after the pot has already been reset to zero. As a result, the prizeAmount field in the event always emits 0, even when the winner has won a substantial amount. This creates a discrepancy between the actual contract state and what is communicated through the event.
Likelihood:
This will occur every time a winner is declared using declareWinner(), since the pot is reset before the event is emitted.
Off-chain systems and users relying on GameEnded event logs will consistently receive incorrect prize information.
Impact:
The GameEnded event will always show prizeAmount = 0, even when the winner has earned a large amount, leading to broken or misleading UI, analytics, or historical data tracking.
This discrepancy may reduce player trust and interfere with third-party integrations (e.g., The Graph, block explorers, or dApp frontends relying on emitted data instead of state reads).
Deploy the Game contract with valid parameters.
Call claimThrone() from any player with enough ETH.
Fast-forward time beyond the gracePeriod.
Call declareWinner().
Observe the GameEnded event that is emitted.
Even though the pot contained a non-zero amount before the call, the emitted prizeAmount will always be 0.
You can verify this by:
Checking the value of pendingWinnings[currentKing] before and after the call (should be > 0).
Comparing it to the prizeAmount emitted in the event (will be 0).
Emit the GameEnded event before resetting the pot to ensure the prizeAmount reflects the actual amount won.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.