Normal behavior:
When the game ends after the grace period, the declareWinner()
function should emit the GameEnded
event with accurate details: the winner’s address, the total prize amount (the pot), the timestamp, and the game round.
Issue:
Due to the ordering of operations in declareWinner()
, the pot
is set to 0
before it is emitted in the GameEnded
event. This causes the event to always report a prize amount of 0
, even when the winner has received a non-zero payout. This misleads users, explorers, and off-chain indexers about actual winnings and can make it appear that the winner received nothing.
Likelihood:
Happens every time declareWinner()
is called and the pot > 0
.
Will always occur because pot = 0
is set before the event emission.
Impact:
All GameEnded
events on-chain will misrepresent the prize amount as 0
.
Reduces transparency and trust in the game contract, especially from off-chain UIs, analytics platforms, and players relying on event logs.
Makes post-mortem accounting and leaderboard logic unreliable.
Move the pot
value into a local variable before zeroing it, and emit that in the event:
This ensures accurate logging and restores event consistency for external users and platforms.
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.