I noticed the following peculiarity:

CALL opcode

vm trace step: 1122
execution step: 1122
add memory:
gas: 3859834
remaining gas: 3921090
loaded address: 0xa7913fc3e4dbf3d8caca06e1c2da85ed838e150f

0: 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
1: 0x6
2: 0x
3: 0x800
4: 0x80
5: 0x7c0
6: 0x40
7: 0x
8: 0x800
9: 0x7c0
10: 0x780
11: 0x300
12: 0x891

It used 3.8 Million gas, in a single call? You can see the call was to 0x6, which is a precompile. However, it should cost a flat-rate 500 gas. I believe it's draining the gas because the arguments I gave didn't lie on the curve, by why wouldn't it simply return false? Or if the precompile doesn't like it, simply revert the transaction. I'm calling it like so:

        if iszero(call(not(0), 0x06, 0, input, 0x80, ret, 0x40)) {
            failed := 1

I expect it to simply return false and set the "failed" variable, still using 500 gas. If my assumption is incorrect, I expected it to revert. Is there documentation for the 3.8 Million gas that it's consuming?


EIP-196, the EIP that defines the ECADD/ECMUL precompiles, states that both precompiles "Fails on invalid input and consumes all gas provided." You're providing all the remaining gas, so it consumes all the gas available in the call frame when calling the precompile.

| improve this answer | |
  • Ah, I was looking at a draft, and assumed a falsy return value was what "Failed" meant. Thanks! – Nicholas Pipitone Nov 24 '18 at 6:00
  • Since ecadd always costs 500, you can just pass in 500 gas instead of MAX_UINT and it'll work as you expect. It'll just Use the 500 gas and return false meaning it reverted. – flygoing Nov 24 '18 at 13:44

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.