Skip to content

test_bal_call_no_delegation_oog_after_target_access()

Documentation for tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_opcodes.py::test_bal_call_no_delegation_oog_after_target_access@2119b382.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_opcodes.py::test_bal_call_no_delegation_oog_after_target_access --fork Amsterdam

CALL without 7702 delegation - OOG after state access.

When target_is_warm=True, uses EIP-2930 tx access list to warm the target. Access list warming does NOT add targets to BAL - only EVM access does.

This test is only meaningful when there's a gap between gas check before state access and after state access. This only happens if create cost (empty target) and value transfer cost are both non-zero.

Note
  • target is always empty - required for create cost
  • value=1 (greater than 0) - required for create cost

The create_cost (NEW_ACCOUNT = 25000) is charged only for value transfers to empty accounts, creating the gap tested here.

Memory expansion is parametrized independently for args (insize) and ret (outsize) per #1910.

Source code in tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_opcodes.py
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
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
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
@pytest.mark.parametrize(
    "target_is_warm", [False, True], ids=["cold_target", "warm_target"]
)
@pytest.mark.parametrize(
    "args_size,ret_size",
    [
        pytest.param(0, 0, id="no_memory"),
        pytest.param(4096, 0, id="args_large"),
        pytest.param(0, 4096, id="ret_large"),
        pytest.param(32, 32, id="both_small"),
    ],
)
@pytest.mark.eels_base_coverage
def test_bal_call_no_delegation_oog_after_target_access(
    pre: Alloc,
    blockchain_test: BlockchainTestFiller,
    fork: Fork,
    target_is_warm: bool,
    args_size: int,
    ret_size: int,
) -> None:
    """
    CALL without 7702 delegation - OOG after state access.

    When target_is_warm=True, uses EIP-2930 tx access list to warm the target.
    Access list warming does NOT add targets to BAL - only EVM access does.

    This test is only meaningful when there's a gap between gas check before
    state access and after state access. This only happens if create cost
    (empty target) and value transfer cost are both non-zero.

    Note:
        - target is always empty - required for create cost
        - value=1 (greater than 0) - required for create cost

    The create_cost (NEW_ACCOUNT = 25000) is charged only for value
    transfers to empty accounts, creating the gap tested here.

    Memory expansion is parametrized independently for args (insize) and
    ret (outsize) per #1910.

    """
    alice = pre.fund_eoa()

    # empty target required for create_cost gap
    target = pre.nonexistent_account()
    # value > 0 required for create_cost
    value = 1

    new_memory_size = max(args_size, ret_size)

    # Static gas (before state access): no create_cost
    # Pass static check, fail at second check due to create cost
    call_code = Op.CALL(
        gas=0,
        address=target,
        value=value,
        args_size=args_size,
        args_offset=0,
        ret_size=ret_size,
        ret_offset=0,
        address_warm=target_is_warm,
        value_transfer=True,
        account_new=False,
        new_memory_size=new_memory_size,
    )
    caller = pre.deploy_contract(code=call_code, balance=value)

    # Access list for warming target (if needed)
    access_list = (
        [AccessList(address=target, storage_keys=[])]
        if target_is_warm
        else None
    )

    intrinsic_cost = fork.transaction_intrinsic_cost_calculator()(
        access_list=access_list
    )

    gas_limit = intrinsic_cost + call_code.gas_cost(fork)

    tx = Transaction(
        sender=alice,
        to=caller,
        gas_limit=gas_limit,
        access_list=access_list,
    )

    # Target is always in BAL after state access but value transfer fails
    # (no balance changes)
    account_expectations: Dict[Address, BalAccountExpectation | None] = {
        caller: BalAccountExpectation.empty(),
        target: BalAccountExpectation.empty(),
    }

    post_state = {
        alice: Account(nonce=1),
        caller: Account(balance=value),
        target: Account.NONEXISTENT,
    }

    blockchain_test(
        pre=pre,
        blocks=[
            Block(
                txs=[tx],
                expected_block_access_list=BlockAccessListExpectation(
                    account_expectations=account_expectations
                ),
            )
        ],
        post=post_state,
    )

Parametrized Test Cases

This test generates 8 parametrized test cases across 1 fork.