A rounding error in the ETH tie game resolution logic causes small amounts of ETH (up to 1 wei per tied game) to become permanently stuck in the contract. This occurs due to integer division truncation when splitting refunds between players.
Root Cause:
In RockPaperScissors::_handleTie
, the contract calculates player refunds as:
When (totalPot - fee)
is an odd number, 1 wei remains unallocated and stays locked in the contract.
Proof of Concept:
Add this function test:
run the test: forge test --match-test test_TieGameNoStuckEth -vvv
Stuck Funds: Repeated tied games cause accumulation of dust ETH (1 wei per occurrence).
Manual Recovery Required: Admin must manually recover these funds, adding operational overhead.
Protocol Integrity: Unaccounted ETH may lead to accounting discrepancies over time.
Add the leftover wei to the protocol fees to ensure no ETH is stranded:
Ensures 100% of ETH is either refunded or collected as fees.
Eliminates need for manual recovery.
Maintains precise financial tracking.
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.