The claimThrone()
function in Game.sol contains a critical logic error in its access control mechanism that prevents any player from successfully claiming the throne, effectively making the entire game non-functional.
The function implements a require statement that checks if the caller is the current king, but the logic is completely backwards:
This condition prevents the intended behavior because:
Initially, currentKing = address(0)
(zero address)
When a player calls claimThrone()
, msg.sender
will never equal address(0)
The require statement fails, preventing any throne claims
The game becomes completely unusable
Likelihood:
HIGH - This bug affects every single call to claimThrone()
without exception
The bug is triggered immediately upon any attempt to claim the throne
Rendering the game unusable
Impact:
CRITICAL - The entire game functionality is rendered in an unusable state
All ETH sent to the contract becomes permanently locked
The following test demonstrates that no player can claim the throne due to the backwards logic in the require statement.
Test Explanation:
Initial State: The game starts with currentKing = address(0)
and pot = 0
Claim Attempt: Player1 tries to claim the throne with the required ETH fee
Expected Behavior: The claim should succeed and Player1 should become the new king
Actual Behavior: The transaction reverts with "Game: You are already the king. No need to re-claim."
State Verification: The game state remains unchanged - no king is set and no ETH is added to the pot
The core issue is a fundamental logic error in the function control mechanism. The current implementation prevents the intended behavior by requiring the caller to BE the current king, when it should prevent the current king from re-claiming.
The require statement should be corrected to:
This ensures that:
The current king cannot re-claim the throne
New players can successfully claim the throne
The game functions as intended
This fix is critical for the game to function at all and should be implemented immediately.
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.