Skip to content

test_set_code_max_depth_call_stack()

Documentation for tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_set_code_max_depth_call_stack@88e9fb8f.

Generate fixtures for these test cases for Osaka with:

fill -v tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_set_code_max_depth_call_stack --fork Osaka

Test re-entry to delegated account until the max call stack depth possible in a transaction is reached.

Source code in tests/prague/eip7702_set_code_tx/test_set_code_txs.py
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
@pytest.mark.execute(pytest.mark.skip(reason="excessive gas"))
def test_set_code_max_depth_call_stack(
    state_test: StateTestFiller,
    pre: Alloc,
    fork: Fork,
) -> None:
    """
    Test re-entry to delegated account until the max call stack depth possible
    in a transaction is reached.
    """
    storage = Storage()
    auth_signer = pre.fund_eoa(auth_account_start_balance)
    tx_gas_limit_cap = fork.transaction_gas_limit_cap()
    match tx_gas_limit_cap:
        case None:
            gas_limit = 100_000_000_000_000
            max_depth = 1025
        case 16_777_216:
            gas_limit = tx_gas_limit_cap
            max_depth = 389
        case _:
            raise NotImplementedError(f"Unexpected transaction gas limit cap: {tx_gas_limit_cap}")

    set_code = Conditional(
        condition=Op.ISZERO(Op.TLOAD(0)),
        if_true=Op.TSTORE(0, 1)
        + Op.CALL(address=auth_signer)
        + Op.SSTORE(storage.store_next(max_depth), Op.TLOAD(0)),
        if_false=Op.TSTORE(0, Op.ADD(1, Op.TLOAD(0))) + Op.CALL(address=auth_signer),
    )
    set_code_to_address = pre.deploy_contract(set_code)

    tx = Transaction(
        gas_limit=gas_limit,
        to=auth_signer,
        authorization_list=[
            AuthorizationTuple(
                address=set_code_to_address,
                nonce=0,
                signer=auth_signer,
            ),
        ],
        sender=pre.fund_eoa(),
    )

    state_test(
        env=Environment(gas_limit=tx.gas_limit),
        pre=pre,
        tx=tx,
        post={
            set_code_to_address: Account(storage={}),
            auth_signer: Account(
                nonce=1,
                code=Spec.delegation_designation(set_code_to_address),
                storage=storage,
                balance=auth_account_start_balance,
            ),
        },
    )

Parametrized Test Cases

This test case is only parametrized by fork and fixture format.

Test ID (Abbreviated)
...fork_Prague-state_test
...fork_Prague-blockchain_test_from_state_test
...fork_Osaka-state_test
...fork_Osaka-blockchain_test_from_state_test