The declareWinner
function is designed to finalize the game by marking it as ended, assigning the current pot to the pendingWinnings
of the currentKing
, and emitting a GameEnded
event to log the winner and prize amount. However, the pot
is reset to 0
before emitting the GameEnded
event, causing the event to incorrectly log a prizeAmount of 0
instead of the actual pot value.
}
Likelihood :
Occurs every time the declareWinner function is called after the grace period expires, as the pot is always reset before the GameEnded event is emitted.
Affects all game rounds where a winner is declared, since the event emission logic is part of the function’s core execution path.
Impact :
Misleads users and frontend applications by logging a prizeAmount of 0 in the GameEnded event, despite the actual pot being transferred to the winner’s pendingWinnings
.
The contract has a bug that causes the emitted prize to always be 0
So, to confirm the buggy behavior, we explicitly expect the event to log 0
At the same time, we assert that the real reward was added to the winner’s balance:
This proves that the winner got paid internally, but the event tells a misleading story — which can break off-chain indexing, analytics, or user UIs relying on the event logs.
This proof illustrates a mismatch between the internal contract state and the publicly emitted event data. While the correct balance is assigned internally, the external-facing event tells a different and incorrect story.
This change ensures that the GameEnded
event accurately reflects the prize awarded at the time of emission. Capturing the pot value in a local variable before resetting it allows the event to log correct and reliable data.
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.