The declareWinner()
function uses a strict inequality (>
) instead of greater-than-or-equal (>=
) when checking if the grace period has expired:
This creates a timing issue where the winner cannot be declared at the exact moment the grace period expires, but only after at least one additional second has passed.
At the same time, the getRemainingTime
function uses the correct comparison
Example scenario:
lastClaimTime = 1000
(timestamp)
gracePeriod = 3600
(1 hour)
Grace period should end at timestamp 4600
Current behavior: Winner can only be declared at timestamp 4601
or later
Expected behavior: Winner should be declarable at timestamp 4600
(exactly when grace period ends)
This creates a 1-second window where the grace period has technically expired according to the game rules, but the contract still prevents winner declaration.
Creates unnecessary 1-second delay after grace period expiration
Game logic doesn't match expected timing semantics
The 1-second delay could allow last-second throne claims when they shouldn't be possible
Change this line in claimThore()
for sucessful test run
Put this into Game.t.sol
file and run forge test --mt testDeclareWinnerTheMomentGracePeriodIsOver -vvv
Change the strict inequality to greater-than-or-equal in the declareWinner()
function:
This ensures that the winner can be declared immediately when block.timestamp
equals lastClaimTime + gracePeriod
, which aligns with the natural expectation that the grace period ends (inclusively) at that exact timestamp.
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.