The Solidity contracts ScoreBoard.sol
and ThePredicter.sol
contain a time calculation error that affects the timing of predictions. This error can result in users being unable to set their predictions correctly.
In both contracts, the time calculations use the value 68400
as a time interval, but the correct value should be 86400
(the number of seconds in a day). This discrepancy impacts the time window during which predictions can be set.
In the setPrediction
function:
if (block.timestamp <= START_TIME + matchNumber * 68400 - 68400)
The calculation should be:
if (block.timestamp <= START_TIME + matchNumber * 86400 - 3600)
In the makePrediction
function:
if (block.timestamp > START_TIME + matchNumber * 68400 - 68400)
The calculation should be:
if (block.timestamp > START_TIME + matchNumber * 86400 - 3600)
This is the test code of Thu Aug 15 2024 18:00:00 GMT+0000
.
To test this code:
Input this code to new test solidity file: test/Checktime.test.sol
.
Then run this command:
forge test --match-path test/Checktime.test.sol --match-test testtime -vvvv
The result is:
As you can see, player set first match prediction in right time but that prediction is reverted.
The incorrect time calculation results in:
Users may be unable to set their predictions if the time window is incorrectly calculated.
Predictions might be rejected or accepted outside the intended time frame, leading to potential inaccuracies in the prediction system.
Manual code review
Correct the time calculation in both ScoreBoard.sol
and ThePredicter.sol
and ensure that adjustments for the prediction window are made correctly.
In both contracts there is a similar error in the computation of the timestamps of the matches.
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.