code-423n4 / 2021-11-overlay-findings

1 stars 0 forks source link

Cache storage access #123

Open code423n4 opened 3 years ago

code423n4 commented 3 years ago

Handle

pauliax

Vulnerability details

Impact

There are places where the same storage variable is accessed multiple times in the same function. It would be more gas efficient to cache these variables and re-use them where necessary. E.g. functions initializeCollateral, enableCollateral, disableCollateral access ovl 4 times, function fetchPricePoint accesses macroWindow 4 times and microWindow 3 times. There are many more places where repeated storage access can be cached.

mesozoic-technology commented 2 years ago

We are not very interested in saving gas on governance functions that will only be used once in a blue moon. Furthermore, micro and macro window are immutables - so there is no read cost for them.

dmvt commented 2 years ago

Whether you want to save gas here or not, the report is valid.