17

It seems that EIP-150 introduced a more expensive gas based restriction on the call stack and completely removed the previous 1024 hard stack limit. Is this true? It seems it took cues from EIP-90 & EIP-114, but not entirely sure what was implemented.

How does the new gas based limit work?

Paul Razvan Berg
  • 17,902
  • 6
  • 73
  • 143
Simon de la Rouviere
  • 1,224
  • 10
  • 18

1 Answers1

18

The previous limit has not been removed, it's just become practically unreachable.

With the new rules, the call cannot consume more than 63/64 of the gas of the parent. So if your gas is X, then N CALLs in, it will be max X * (63/64)^n.

And to be correct, the gas is even less than that, since 63/64 is defined as "all but one 64th" of N as N - floor(N / 64), so there's also a factor of flooring to integers which has an effect. Also, the actual CALL cost and PUSH operations required will also reduce the practical limit.

From the EIP:

Note that with the given parameters, the de-facto maximum call stack depth is limited to ~340 (down from ~1024), mitigating the harm caused by any further potential quadratic-complexity DoS attacks that rely on calls.

mhswende
  • 296
  • 2
  • 2
  • Thanks @mhswende! So the hard limit is still in there. It looks it will take a substantially high gas limit to even come close to 1024 right? – Simon de la Rouviere Oct 19 '16 at 09:20
  • 3
    Yes. I've seen a number that Vitalik calculated, but I'm not sure where to find it now. It's orders of magnitude above the limits used so far. – mhswende Oct 19 '16 at 09:34