code-423n4 / 2022-01-insure-findings

2 stars 0 forks source link

Gas: Cache `_min[_target]` in `Parameters.sol:getMinDate()` #326

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Handle

Dravee

Vulnerability details

Impact

SLOADs are expensive

Proof of Concept

Here, _min[_target] can be loaded twice from storage:

379:     function getMinDate(address _target)
380:         external
381:         view
382:         override
383:         returns (uint256)
384:     {
385:         if (_min[_target] == 0) {
386:             return _min[address(0)];
387:         } else {
388:             return _min[_target];
389:         }
390:     }

Tools Used

VS Code

Recommended Mitigation Steps

Cache the storage reading in a memory variable

oishun1112 commented 2 years ago

https://github.com/code-423n4/2022-01-insure-findings/issues/320