The _updateWeights function in BaseGauge.sol does not handle the initial period differently from subsequent periods, despite an if-else clause intended to do so. Both branches of the conditional statement execute the same logic, making the distinction redundant and potentially misleading.
In BaseGauge.sol#L185, the _updateWeights function contains an if-else clause that appears to differentiate between the initial period and subsequent periods. However, both branches execute identical logic, as seen in the code snippet below:
Both the if and else branches compute nextPeriodStart using the same formula and call TimeWeightedAverage.createPeriod with identical parameters. This redundancy suggests either an incorrect implementation or unnecessary complexity.
Code Maintainability: The redundant if-else structure makes the code harder to understand and maintain, as it suggests a distinction that does not actually exist.
Potential Logic Error: If different logic is required for the initial period, the current implementation fails to account for it, which could lead to unintended behavior.
Gas Inefficiency: The extra condition check adds a minor but unnecessary computational cost to function execution.
Manual code review.
If there is no actual difference between the initial and subsequent periods, remove the redundant if-else clause and simplify the function:
If the intention was to handle the initial period differently, introduce logic that truly differentiates between the two cases. For example, the initial period might require an immediate start rather than waiting for the next period boundary.
Conduct further testing to confirm whether the intended behavior aligns with the actual implementation.
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.