Closed totomanov closed 8 months ago
@hoytech
I replaced EulerRouter and ChainlinkAdapter's calls with low-level staticcall
. Could not see gas savings in tests, even after controlling for foundry's "make everything one tx" mechanics by wrapping the call in the test with gasleft
and measuring it myself + cooling down warm slots.
It turns out we pay the 2600 gas either way. Looking at evm.codes, both STATICCALL and EXTCODESIZE will charge 2600 gas on cold and 100 gas on warm access.
A Solidity higher-level external call inserts EXTCODESIZE then STATICALL: 2600 + 100 = 2700 gas for access.
A Yul low-level staticall
inserts STATICCALL: 2600 gas for access. Saving 100 gas IMO is not worth it, and in practice we pay more runtime gas for the additional logic that the low-level call incurs. So it actually charges more gas.