Skip to content

test_callf_stack_overflow_by_height()

Documentation for tests/osaka/eip7692_eof_v1/eip4750_functions/test_code_validation.py::test_callf_stack_overflow_by_height@3719e927.

Generate fixtures for these test cases for Osaka with:

fill -v tests/osaka/eip7692_eof_v1/eip4750_functions/test_code_validation.py::test_callf_stack_overflow_by_height --fork Osaka

Test for invalid EOF code containing CALLF instruction exceeding the runtime stack height limit by calling a function with 2+ maximum stack height. The callee with the maximum stack height of 1 is valid because runtime limit (1024) is 1 bigger than the EOF limit (1023).

Source code in tests/osaka/eip7692_eof_v1/eip4750_functions/test_code_validation.py
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
@pytest.mark.parametrize(
    "callee_stack_height",
    [2, 3, MAX_STACK_INCREASE_LIMIT - 1, MAX_STACK_INCREASE_LIMIT],
)
def test_callf_stack_overflow_by_height(eof_test, callee_stack_height):
    """
    Test for invalid EOF code containing CALLF instruction exceeding the runtime stack height limit
    by calling a function with 2+ maximum stack height.
    The callee with the maximum stack height of 1 is valid because runtime limit (1024)
    is 1 bigger than the EOF limit (1023).
    """
    container = Container(
        sections=[
            Section.Code(
                Op.PUSH0 * MAX_STACK_INCREASE_LIMIT + Op.CALLF[1] + Op.STOP,
                max_stack_height=MAX_STACK_INCREASE_LIMIT,
            ),
            Section.Code(
                Op.PUSH0 * callee_stack_height + Op.POP * callee_stack_height + Op.RETF,
                code_outputs=0,
                max_stack_height=callee_stack_height,
            ),
        ],
    )
    eof_test(container=container, expect_exception=EOFException.STACK_OVERFLOW)

Parametrized Test Cases

The interactive table below is also available as a standalone page.

Test ID (Abbreviated) callee_stack_height
...fork_Osaka-eof_test-callee_stack_height_2 2
...fork_Osaka-eof_test-callee_stack_height_3 3
...fork_Osaka-eof_test-callee_stack_height_1022 1022
...fork_Osaka-eof_test-callee_stack_height_1023 1023
...fork_Osaka-state_test_from_eof_test-callee_stack_height_2 2
...fork_Osaka-state_test_from_eof_test-callee_stack_height_3 3
...fork_Osaka-state_test_from_eof_test-callee_stack_height_1022 1022
...fork_Osaka-state_test_from_eof_test-callee_stack_height_1023 1023
...fork_Osaka-blockchain_test_from_eof_test-callee_stack_height_2 2
...fork_Osaka-blockchain_test_from_eof_test-callee_stack_height_3 3
...fork_Osaka-blockchain_test_from_eof_test-callee_stack_height_1022 1022
...fork_Osaka-blockchain_test_from_eof_test-callee_stack_height_1023 1023