Cache storage variables to local variables to save gas #75
Labels
bug
Something isn't working
G (Gas Optimization)
sponsor confirmed
Yes, this is a problem and we intend to fix it.
Handle
shw
Vulnerability details
Impact
In general, if a state variable is read more than once, caching its value to a local variable and reusing it will save gas since a storage read spends more gas than a memory write plus a memory read.
Proof of Concept
Referenced code:
TransactionManager.sol#L122-L125
TransactionManager.sol#L254-L260
Recommended Mitigation Steps
Rewrite #L122-L125 as follows:
Rewrite #L254-L260 as follows:
The text was updated successfully, but these errors were encountered: