The graduateAndUpgrade function fails to enforce several critical invariants before processing wages and attempting an upgrade:
It does not check if the school session has actually ended (block.timestamp >= sessionEnd).
It does not verify that all students have received the required 4 reviews.
It lacks logic to prevent students who don't meet the cutOffScore from being considered "graduated" or carried over.
The README specifies these invariants:
"A school session lasts 4 weeks" and "System upgrade cannot take place unless school's sessionEnd has reached". The function graduateAndUpgrade does not check block.timestamp >= sessionEnd.
"Students must have gotten all reviews before system upgrade. System upgrade should not occur if any student has not gotten 4 reviews". The function does not iterate through listOfStudents to check reviewCount[student] == 4.
"Any student who doesn't meet the cutOffScore should not be upgraded". The function does not filter listOfStudents or pass information to LevelTwo to handle this.
Premature Upgrade/Payout: Wages can be paid and an upgrade attempted before the 4-week session is over.
Incomplete Reviews: The system can be upgraded even if students haven't received all their reviews, violating a core academic rule.
Ungraduated Students Carried Over: Students failing to meet the cutOffScore might be treated as graduated and carried over to LevelTwo by default due to shared storage, undermining the academic integrity of the system.
Manual Review, Comparison with README specifications.
Implement these checks at the beginning of graduateAndUpgrade:
Add require(block.timestamp >= sessionEnd, "HH__SessionNotEnded");.
Iterate through listOfStudents and verify reviewCount[student] == 4 (requires H-05 and M-01 to be fixed).
Ensure students not meeting cutOffScore are not considered "upgraded". This is best handled by LevelTwo's reinitializer by filtering the listOfStudents it inherits based on studentScore and the cutOffScore from LevelOne. LevelOne should pass the cutOffScore to LevelTwo's reinitializer.
Consolidated Code Modification for LevelOne.sol::graduateAndUpgrade (addressing H-02, H-03, H-04, L-03):
All students are graduated when the graduation function is called as the cut-off criteria is not applied.
`graduateAndUpgrade()` can be called successfully even when the school session has not ended
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.