The Game contract allows players to claim the throne by paying a claimFee, becoming the currentKing, with the game ending when the gracePeriod expires, awarding the pot to the currentKing via declareWinner. A miner participating as a player can front-run a winning player’s claimThrone transaction just before the gracePeriod expires by reordering transactions in a block they mine, stealing the pot. The contract’s reliance on block.timestamp for the gracePeriod check in declareWinner enables this, as miners control transaction inclusion and can slightly manipulate timestamps.
Likelihood:
Miners who are players can observe pending claimThrone transactions in the mempool near the gracePeriod end (e.g., block.timestamp ≈ lastClaimTime + gracePeriod).
Occurs when a miner mines a block and prioritizes their own claimThrone transaction over others.
Miners can consistenly steal the pot by becoming currentKing just before declareWinner, undermining game fairness.
Discourages player participation due to perceived unfairness, potentially stalling the game.
Scenario:
Grace period ends at block.timestamp = lastClaimTime + gracePeriod (e.g., 1086400).
Player A submits claimThrone at block.timestamp = 1086399 (1 second before expiration).
The miner, seeing Player A’s transaction, includes their own claimThrone in the same block, ordered first, becoming the currentKing.
When declareWinner is called at block.timestamp = 1086401, the miner wins the pot.
Use block.number instead of block.timestamp to track the gracePeriod, as block numbers are less susceptible to miner manipulation and provide a more deterministic measure. Convert gracePeriod to a number of blocks (e.g., assuming 12 seconds per block, 86400 seconds ≈ 7200 blocks) and update relevant functions.
Alternatvely,Consider using commit-reveal, VRF, or other forms of finality that can't be manipulated by ordering
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.