Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: low
Invalid

Duplicate condition for checking if a user can make a prediction due to datetime restrictions

Relevant GitHub Links

https://github.com/Cyfrin/2024-07-the-predicter/blob/main/src/ThePredicter.sol#L93

Summary

The condition in ThePredicter::makePrediction can be removed because there is a function call to ScoreBoard::setPrediction where the same condition is checked. Removing this duplicate condition doesn't change the code logic but saves gas by checking the datetime restriction once instead of twice.

Impact

The code is more gas expensive to execute when checking datetime restrictions twice instead of once.

Recommendations

Remove the datetime restriction condition in the ThePredicter::makePrediction function.

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);
}
Updates

Lead Judging Commences

NightHawK Lead Judge 11 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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