1

I know that max call stack depth is 1024. I want to know that if calling private function can increase the depth.

1 Answers1

3

As long as it's private/internal, no. It doesn't create a new message CALL between addresses, it just jumps around in the same context.

natewelch_
  • 12,021
  • 1
  • 29
  • 43
  • What if that function takes input arguments? Wouldn't pushing those arguments into the stack increase the stack usage? – goodvibration May 07 '18 at 12:37
  • The call stack and the actual operational stack are two separate things. The call stack is a stack of just message calls. Function arguments also aren't implicitly pushed to the stack, that is only done in the code. – natewelch_ May 07 '18 at 12:56
  • 1
    I believe there are two separate limits: 1024 is the maximum call depth, which only applies to things like CALL and CREATE opcodes. But the stack depth is also limited to 1024, and certainly in normal situations the parameters to functions need to be pushed on to the stack. (Perhaps functions are inlined and parameters are already on the stack, but that is probably the exception, not the rule.) – user19510 May 07 '18 at 14:12
  • I should add that I'm agreeing with @flygoing, just trying to clarify. – user19510 May 07 '18 at 14:15
  • 1
    @smarx thanks! Just double checked the yellow paper and you're correct, limit for both is 1024. Though this is practically impossible to reach for the call stack depth after EIP 150 since it added the limitation that CALLs can only use 63/64th of their parents gas. The practical limit is around 340: https://ethereum.stackexchange.com/questions/9398/how-does-eip-150-change-the-call-depth-attack – natewelch_ May 07 '18 at 14:31