Here you can see that if the EVM stack gets larger than 1024, it results in an error:

enter image description here

  • Why is there this hard limit on the stack size?

  • What is the justification for this not being parametrizable?

  • Is 1024 particularly suitable? If so, why so?


1 Answer 1

  • Because if it was very large, then executing a contract would be more expensive (ie, require more memory). I think 1024 was a very conservative value to be as safe as possible
  • I think the justification is that if you need that much stack space, then you should be offloading some of it to memory (which is practically unlimited, though you must pay gas for using it). Other than that, having a fixed size makes the overall model of the EVM more simple and easy to implement
  • Personally, I think it could be even smaller, because of how the EVM is designed it tends to make a larger stack size useless. The EVM can only access items on the stack that are up to 16 slots away from the top-most slot. So, even if you had a stack of 4096, you could store everything in it, but only have direct access to data stored 16 slots down from the top. But I think that this is a design flaw in the EVM

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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