Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: medium
Valid

Incorrect calculation of the time remaining to make predictions for a specific match.

Summary

When making a prediction using the function ThePredicter::makePrediction, it ensures that the time limit for making predictions for the given match is not exceeded.

function makePrediction(
uint256 matchNumber,
ScoreBoard.Result prediction
) public payable {
if (msg.value != predictionFee) {
revert ThePredicter__IncorrectPredictionFee();
}
@> if (block.timestamp > START_TIME + matchNumber * 68400 - 68400) {
revert ThePredicter__PredictionsAreClosed();
}
scoreBoard.confirmPredictionPayment(msg.sender, matchNumber);
scoreBoard.setPrediction(msg.sender, matchNumber, prediction);
}

The value 68,400 represents 19 hours. The allowed time for predictions is up to 19:00:00 on the day of the match. Calculating in this way results in completely incorrect time limits.

Impact

Incorrect time limits will affect the ability to make predictions for the matches.

PoC

For example, the time for predicting the ninth match, whose matchNumber is 8, would be 478,800 seconds after the tournament starts according to this formula. However, according to the rule, it should be 687,600 seconds, which is a difference of 208,800 seconds. Therefore, the time allowed for predicting the last match is short by 208,800 seconds.

Recommendations

Change the specified line of code as follows:

if (block.timestamp > START_TIME + matchNumber *86400 - 3600) //START_TIME + matchNumber *86400(24h) - 3600*(1h);
Updates

Lead Judging Commences

NightHawK Lead Judge about 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

Match timestamps are incorrect

In both contracts there is a similar error in the computation of the timestamps of the matches.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.