Skip to content

test_call_value_to_new_account_seam()

Documentation for tests/amsterdam/eip8038_state_access_gas_cost_increase/test_call_gas.py::test_call_value_to_new_account_seam@343274cc.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip8038_state_access_gas_cost_increase/test_call_gas.py::test_call_value_to_new_account_seam --fork Amsterdam

Verify the CALL value-to-new-account execution/state seam.

The EIP-8038 execution dimension is COLD_ACCOUNT_ACCESS + CALL_VALUE; the account creation charge GAS_NEW_ACCOUNT lands in the EIP-8037 state dimension. The block header reflects max(execution, state), which is dominated by the state charge.

Source code in tests/amsterdam/eip8038_state_access_gas_cost_increase/test_call_gas.py
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
@EIPChecklist.GasCostChanges.Test.GasUpdatesMeasurement()
def test_call_value_to_new_account_seam(
    state_test: StateTestFiller,
    pre: Alloc,
    fork: Fork,
) -> None:
    """
    Verify the CALL value-to-new-account execution/state seam.

    The EIP-8038 *execution* dimension is ``COLD_ACCOUNT_ACCESS`` +
    ``CALL_VALUE``; the account creation charge ``GAS_NEW_ACCOUNT``
    lands in the EIP-8037 *state* dimension. The block header reflects
    ``max(execution, state)``, which is dominated by the state charge.
    """
    intrinsic = fork.transaction_intrinsic_cost_calculator()()

    # Fresh, value-receiving target (state-empty, will be created).
    target = pre.fund_eoa(amount=0)

    # Metadata-bearing CALL so its cost splits into the execution
    # (access + value transfer) and state (NEW_ACCOUNT) dimensions.
    call = Op.CALL.with_metadata(
        address_warm=False, value_transfer=True, account_new=True
    )(
        gas=0,
        address=target,
        value=1,
        args_offset=0,
        args_size=0,
        ret_offset=0,
        ret_size=0,
    )
    caller_code = Op.POP(call) + Op.STOP
    caller = pre.deploy_contract(code=caller_code, balance=1)

    new_account_state_gas = call.state_cost(fork)

    # block_gas_used = max(block_execution, block_state). The CALL's
    # NEW_ACCOUNT lands on the state axis; the execution axis is the
    # access plus value-transfer cost.
    tx_execution = intrinsic + caller_code.execution_cost(fork)
    tx_state = caller_code.state_cost(fork)
    expected_gas_used = max(tx_execution, tx_state)
    # State must dominate here, proving NEW_ACCOUNT hit the state axis.
    assert expected_gas_used == new_account_state_gas

    tx = Transaction(
        to=caller,
        sender=pre.fund_eoa(),
        state_gas_reservoir=new_account_state_gas,
    )

    state_test(
        pre=pre,
        post={target: Account(balance=1)},
        tx=tx,
        blockchain_test_header_verify=Header(gas_used=expected_gas_used),
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.