0
  {
    "pc": 4765,
    "op": "STATICCALL",
    "gas": 222711,
    "gasCost": 219243,
    "depth": 1,
    ...
  }

As above, Geth VM Trace (https://etherscan.io/vmtrace?txhash=0x457c267f3acea528fdf0159a05d0794270a858fed9ad71b96d6ad66b44975eec) shows that gas cost of "STATICCALL" is 219243, which seems impossible because it's even larger than the entire gas consumption of the transaction.

So, how to interpret this?

0

Gas , refers to the amount of gas remaining after the execution of the STATICCALL function while gasCost is the cost of static call. The former is available for other calls in the transaction and refunded if not used .

The cost of STATICCALL is 700 gas.

To verify, at step 323 , you have a STATICCALL

Gas: 222711 GasCost: 219243

But at the next step 324, the Gas available to that transaction is 218543.

219243 - 218543 = 700.

The documentation of this is sparse. The only reference I could find was in EIP 1380.

If block.number >= FORK_BLKNUM, then decrease the cost of CALL, DELEGATECALL, CALLCODE and STATICCALL from 700 to 40, if and only if, the destination address of the call equals to the address of the caller

References:

  • Thanks. But how much gas does STATICCALL cost in this case(0x457c267f3acea528fdf0159a05d0794270a858fed9ad71b96d6ad66b44975eec)? Apparently not 219243, right? – yiqi chen Dec 23 '19 at 8:29
  • Can you share you contract? What is happening is that STATICCALL is reading state from another contract, hence jumping out of the first and giving all the gas to the next contract; so its not use more like its work is done in that contract and allocatiing gas from the rest of the instructions – Samuel Dare Dec 23 '19 at 15:44
  • Thanks for your answer. So, can I calculate the gas cost of "STATICCALL" by subtracting "Gas" of the next opcode(say "PUSH1") from "Gas" of "STATICCALL". The difference between them should be the actual gasCost of "STATICCALL", right? – yiqi chen Dec 24 '19 at 2:09
  • Updating my answer – Samuel Dare Dec 27 '19 at 20:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.