When the grace period expires and a winner is declared, the declareWinner function should emit the GameEnded event with the correct prize amount representing the total pot awarded to the winner. This allows players and off-chain services to accurately track and verify the prize.
Currently, the declareWinner function sets the pot to zero before emitting the GameEnded event, causing the event to always report a prize amount of zero regardless of the actual winnings. This leads to incorrect and misleading event data, reducing transparency and potentially undermining player trust.
Likelihood:
This issue occurs every time the declareWinner() function is called after the grace period expires, as the contract always emits the GameEnded event immediately after resetting the pot to zero.
Since the event emission is part of the normal game flow to announce the winner, the bug will manifest consistently in all rounds where a winner is declared, making it very likely in regular usage.
Impact:
Off-chain services, explorers, and players relying on event logs will see the prize amount as zero, causing confusion and loss of transparency about the actual winnings.
This undermines trust in the game’s fairness and transparency, potentially damaging user confidence and discouraging participation, even though no funds are actually lost or stolen.
Explanation
The test simulates a player claiming the throne, waits until after the grace period, and calls declareWinner(). The GameEnded event incorrectly emits prizeAmount = 0 because pot is reset before the event is emitted, causing event data to not match actual winnings.
Explanation
Save the current pot into a local variable before resetting it, and use that variable when emitting the GameEnded event. This ensures the event reflects the true prize amount.
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.