You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Modify the specification so that functions don't specify their max_stack_height but instead there is a single constant FUNC_STACK_LIMIT defined by the spec. The validation condition is: compute max stack height of a function must be within the limit
The max_stack_height of a function is not needed to be stored in the type section. This saves 2 bytes per function (i.e. it shrinks the type section by half).
The CALLF/JUMPF implementations don't need to read the callee's max_stack_height from the type section. And combined with Modify max_stack_height of type section #134 all need by the interpreter to access the type section is gone.
(weak) EVM assembly is easier for end users (e.g. they don't need to compute max_stack_height of an assembly snippet).
Cons
Limits the function recursion. A function cannot call other function (including itself) if the operand stack height reaches 1024 - FUNC_STACK_LIMIT even if in the reality the callee uses much less of the operand stack than FUNC_STACK_LIMIT.
Constant candidates
256: this plays nicely with SWAPN, DUPN limitations and still leaves significant "recursion" stack of 768 operands.
Mitigation for lower limit
I want to have 1024 operands on the stack as in legacy EVM.
For this we can allow code section 0 to have 1024 limit but we also need to forbid calling this section.
Do it later
Instead of the full deployment of the feature we can space for it and reconsider it in a future upgrade. The "space" is to limit max_stack_height to 256 (1 byte).
The text was updated successfully, but these errors were encountered:
Modify the specification so that functions don't specify their
max_stack_height
but instead there is a single constantFUNC_STACK_LIMIT
defined by the spec. The validation condition is: compute max stack height of a function must be within the limitPros
max_stack_height
of a function is not needed to be stored in the type section. This saves 2 bytes per function (i.e. it shrinks the type section by half).CALLF
/JUMPF
implementations don't need to read the callee'smax_stack_height
from the type section. And combined with Modifymax_stack_height
of type section #134 all need by the interpreter to access the type section is gone.max_stack_height
of an assembly snippet).Cons
1024 - FUNC_STACK_LIMIT
even if in the reality the callee uses much less of the operand stack thanFUNC_STACK_LIMIT
.Constant candidates
256
: this plays nicely withSWAPN
,DUPN
limitations and still leaves significant "recursion" stack of768
operands.Mitigation for lower limit
For this we can allow code section 0 to have 1024 limit but we also need to forbid calling this section.
Do it later
Instead of the full deployment of the feature we can space for it and reconsider it in a future upgrade. The "space" is to limit
max_stack_height
to 256 (1 byte).The text was updated successfully, but these errors were encountered: