Call Stack Depth
Call stack depth refers to the maximum number of nested function calls allowed within a single execution transaction. In many virtual machines, including the Ethereum Virtual Machine, there is a hard limit on the depth of the call stack to prevent stack overflow errors.
If an attacker can force a contract to exceed this limit, they can cause the transaction to fail or bypass certain security checks. This is a subtle attack vector that is often overlooked in contract design.
Understanding call stack depth is important for architects who build deeply nested protocols, such as recursive vaults or complex multi-hop swap routers. If the call stack is too shallow, the protocol may become brittle; if it is too deep, it may become susceptible to stack-related exploits.