Gas Optimizations #212
Labels
bug
Something isn't working
G (Gas Optimization)
resolved
Finding has been patched by sponsor (sponsor pls link to PR containing fix)
sponsor acknowledged
Technically the issue is correct, but we're not going to resolve it for XYZ reasons
1. Save gas by keeping track of
nextEpochDate
instead of reading from storage.Details
In
AuraLocker._checkpointEpoch()
, there is a while loop to fill epoch gaps until the next epoch date. Each iter, it reads from storage 4 times (2 in the while condition, 2 when calculatenextEpochDate
).In fact,
nextEpochDate
can be kept track simply by addingrewardsDuration
each epoch.Proof of concept
https://github.com/code-423n4/2022-05-aura/blob/4989a2077546a5394e3650bf3c224669a0f7e690/contracts/AuraLocker.sol#L334-L335
Recommended Mitigation Steps
Use variable
nextEpochDate
to cache like thisThe text was updated successfully, but these errors were encountered: