Skip to content

test_call_new_account_no_regular_account_creation_cost()

Documentation for tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_call.py::test_call_new_account_no_regular_account_creation_cost@5c024cbb.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_call.py::test_call_new_account_no_regular_account_creation_cost --fork Amsterdam

Verify CALL with value to a non-existent account does not charge a regular account-creation cost on top of state gas.

Source code in tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_call.py
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
@pytest.mark.valid_from("EIP8037")
def test_call_new_account_no_regular_account_creation_cost(
    state_test: StateTestFiller,
    pre: Alloc,
    fork: Fork,
) -> None:
    """
    Verify CALL with value to a non-existent account does not
    charge a regular account-creation cost on top of state gas.
    """
    gas_costs = fork.gas_costs()
    new_account_state_gas = gas_costs.NEW_ACCOUNT

    target = pre.fund_eoa(amount=0)

    caller_code = Op.POP(Op.CALL(gas=0, address=target, value=1)) + Op.STOP
    caller = pre.deploy_contract(code=caller_code, balance=1)

    # Tight budget: slack is less than the old pre-Amsterdam regular
    # account-creation cost, so any extra regular draw would OOG.
    intrinsic = fork.transaction_intrinsic_cost_calculator()()
    tx = Transaction(
        to=caller,
        gas_limit=(
            intrinsic
            + caller_code.gas_cost(fork)
            + gas_costs.CALL_VALUE
            + new_account_state_gas
            + 20_000
        ),
        sender=pre.fund_eoa(),
    )

    state_test(pre=pre, post={target: Account(balance=1)}, tx=tx)

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.