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@01f496f4.

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
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
@pytest.mark.parametrize(
    "callee_stack_height",
    [2, 3, MAX_OPERAND_STACK_HEIGHT - 1, MAX_OPERAND_STACK_HEIGHT],
)
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_OPERAND_STACK_HEIGHT + Op.CALLF[1] + Op.STOP,
                max_stack_height=MAX_OPERAND_STACK_HEIGHT,
            ),
            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