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

1 stars 0 forks source link

At `OverlayV1Comptroller.sol`, `_roller.time` shouldn't be cached #105

Open code423n4 opened 3 years ago

code423n4 commented 3 years ago

Handle

0x0x0x

Vulnerability details

Concept

_roller.time is cached, to use at roll function call. To save gas _roller.time can be cached after roll function call and avoid caching to save gas.

Tools Used

Manual

mesozoic-technology commented 2 years ago

There seems to be an optimization related to the roll function call in brrrr() but this is not it. The nature of the optimization is that should the conditions for roll were ever hit in the brrrr() function, the last moment will not be the same, therefore we can directly pass the number 0 as the "last moment" into our roll function. This will have the effect of writing into the next roller slot.