GameEnded
Logs Zero Prize (Users & Indexers See 0 ETH Won)Expected behaviour: When declareWinner()
is called after the grace period, the GameEnded
event should emit the actual prize amount the winner is entitled to withdraw so that UIs, analytics dashboards and indexers can display accurate information.
Actual issue: The contract writes the winner’s pot to pendingWinnings
and then sets pot = 0
before emitting the GameEnded
event. Because the event arguments reference pot
, the logged prizeAmount
is always zero regardless of the real winnings.
Likelihood:
declareWinner()
will be called at the end of every successful game round, so the buggy event is emitted routinely.
Off-chain services (The Graph, Dune, custom front-ends) rely on events rather than storage reads, so they will almost always consume the incorrect value.
Impact:
Users and explorers display a prize of 0 ETH, misleading players and external observers.
Automated tooling that uses the event data for accounting or rewards distribution can malfunction or under-credit users.
The PoC below simulates a full game cycle: a player becomes king, the grace period elapses, and declareWinner()
is called. We record logs and assert that the prizeAmount
indexed in GameEnded
is 0 even though the true winnings are non-zero.
Emit the event before zeroing the pot or cache the pot value in a local variable and pass it to the event. The one-line diff below adopts the second approach, which avoids re-ordering storage writes and keeps semantics explicit.
This change ensures indexers receive the correct prize amount while leaving storage layout and external behaviour intact.
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.