Normal behavior:
The game should allow the owner to reset the round after the grace period, even if no one has claimed the throne in the first round. If no one claims, the game should not become permanently stuck.
Specific issue:
In the constructor, lastClaimTime
is set to block.timestamp
even though currentKing
is address(0)
. If no one claims the throne, after the grace period expires:
declareWinner()
cannot be called (because currentKing == address(0)
).
resetGame()
cannot be called (because gameEnded
is still false
). The contract is now deadlocked: neither players nor the owner can progress the game or recover funds.
Likelihood:
This will occur every time the contract is deployed and no one claims the throne in the first round.
Impact:
The contract becomes permanently stuck and unusable.
The owner cannot reset the game or recover any ETH sent to the contract.
The following test script demonstrates the bug. It deploys the contract, fast-forwards time past the grace period, and shows that neither declareWinner() nor resetGame() can be called if no one has claimed the throne.
Set lastClaimTime = 0
in the constructor. Only set lastClaimTime
when the first successful claim is made.
And in claimThrone(), add:
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.