Open code423n4 opened 2 years ago
As per eip-2929 the cost of reading a cold storage slot is 2100, the cost of reading from a hot storage slot (already read once) is 100
While apparently minor, storing the result of the read in memory will end up saving 94 gas (3 gas to MSTORE, 3 gas to MLOAD) when compared to re-reading from Storage
The sponsor has applied the improvement
Handle
WatchPug
Vulnerability details
For the storage variables that will be accessed multiple times, cache them in the stack can save ~100 gas from each extra read (
SLOAD
after Berlin).For example:
scheduled[hashTx]
inQuickAccManager.sol#cancel()
https://github.com/code-423n4/2021-10-ambire/blob/bc01af4df3f70d1629c4e22a72c19e6a814db70d/contracts/wallet/QuickAccManager.sol#L92-L92scheduled[hash]
inQuickAccManager.sol#execScheduled()
https://github.com/code-423n4/2021-10-ambire/blob/bc01af4df3f70d1629c4e22a72c19e6a814db70d/contracts/wallet/QuickAccManager.sol#L102-L102