The updatePeriod
function updates the period, ensuring that the new period starts after the previous one has elapsed. However, the logic used to compute nextPeriodStart
incorrectly sets the new nextPeriodStart two periods ahead instead of one.
currentTime / periodDuration
determines the number of completed periods.
Adding 2
before multiplying by periodDuration
incorrectly pushes the next period two full periods ahead.
The correct formula should be:
uint256 nextPeriodStart = ((currentTime / periodDuration) + 1) * periodDuration;
The next period is delayed by an entire additional period.
Assume periodDuration = 30 days
.
Suppose currentTime = 31 days
(just after the previous period ended).
currentTime / periodDuration = 1
(completed periods count).
With the current implementation:
nextPeriodStart = (1 + 2) * 30 = 90 days
The next period incorrectly starts at day 90, instead of day 60.
The correct implementation:
nextPeriodStart = (1 + 1) * 30 = 60 days
The next period now correctly starts at day 60, immediately after the previous period.
Manual Review
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.