pot To Zero In declareWinner() Results In Misleading Event LogWhen the game ends, the contract is expected to emit a GameEnded event containing the address of the winner and the prize amount they won from the pot. This event helps off-chain systems and users track who won and how much.
However, the pot is reset to zero before emitting the GameEnded event, which results in a prize amount of 0 being logged. This creates misleading historical records and makes it appear as though the winner received no reward, even though the pot may have been correctly transferred to pendingWinnings.
Likelihood:
This will occur every time a winner is declared through declareWinner(), because the pot is reset to 0 before the GameEnded event is emitted.
It will affect all rounds across the entire lifecycle of the contract.
Impact:
Off-chain systems and user interfaces relying on event logs will display inaccurate or misleading prize data.
Winners may appear to have won nothing, which damages the credibility of the contract and reduces confidence in its transparency.
Add this test to Game.t.sol and run with forge test —mt testGameEndedEmitsZeroPot
Emit the value of pot by creating a prize variable, setting it to the value of pot, and emitting it in the GameEnded event
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.