Skip to content

test_recipient_new_account_refilled_on_dispatch_halt_with_reservoir()

Documentation for tests/amsterdam/eip2780_reduce_intrinsic_tx_gas/test_authorization_oog.py::test_recipient_new_account_refilled_on_dispatch_halt_with_reservoir@26332146.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip2780_reduce_intrinsic_tx_gas/test_authorization_oog.py::test_recipient_new_account_refilled_on_dispatch_halt_with_reservoir --fork Amsterdam

The recipient NEW_ACCOUNT charge is refilled when the dispatch fails, because the recipient's account creation rolls back with it -- unlike an authorization's state gas, whose delegation persists.

Value moves to an empty precompile (a recipient that is empty yet still executes): the top frame charges NEW_ACCOUNT, dispatch moves the value -- materializing the leaf -- and the precompile then halts (the bn254 pairing rejects a 1-byte input), rolling the leaf back. The state did not grow, so the charge refills.

The gas limit exceeds the EIP-7825 cap so the charge draws from a state-gas reservoir; the halt consumes the full execution budget (the cap) but the entire reservoir returns, pinning the refill in the receipt's gas used. This is the counterpart of test_auth_state_charges_survive_dispatch_halt_with_reservoir, which pins that an authorization's state gas does NOT return.

Source code in tests/amsterdam/eip2780_reduce_intrinsic_tx_gas/test_authorization_oog.py
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
def test_recipient_new_account_refilled_on_dispatch_halt_with_reservoir(
    fork: Fork,
    pre: Alloc,
    state_test: StateTestFiller,
) -> None:
    """
    The recipient ``NEW_ACCOUNT`` charge is refilled when the dispatch
    fails, because the recipient's account creation rolls back with it
    -- unlike an authorization's state gas, whose delegation persists.

    Value moves to an *empty precompile* (a recipient that is empty
    yet still executes): the top frame charges ``NEW_ACCOUNT``,
    dispatch moves the value -- materializing the leaf -- and the
    precompile then halts (the bn254 pairing rejects a 1-byte input),
    rolling the leaf back. The state did not grow, so the charge
    refills.

    The gas limit exceeds the EIP-7825 cap so the charge draws from a
    state-gas reservoir; the halt consumes the full execution budget (the
    cap) but the *entire* reservoir returns, pinning the refill in the
    receipt's gas used. This is the counterpart of
    ``test_auth_state_charges_survive_dispatch_halt_with_reservoir``,
    which pins that an authorization's state gas does NOT return.
    """
    cap = fork.transaction_gas_limit_cap()
    assert cap is not None, "EIP-7825 cap expected on this fork"

    sender = pre.fund_eoa()
    pairing_precompile = Address(0x08)

    value = 1
    new_account_state_gas = fork.transaction_top_frame_state_gas(
        sends_value=True,
        recipient_type=RecipientType.EMPTY_ACCOUNT,
    )
    assert new_account_state_gas > 0, (
        "an empty recipient receiving value must charge NEW_ACCOUNT"
    )

    reservoir = new_account_state_gas + 50_000

    # The halt consumes the full execution budget; the NEW_ACCOUNT drawn
    # from the reservoir is refilled (the account creation rolled
    # back), so the whole reservoir returns to the sender.
    gas_used = cap

    tx = Transaction(
        sender=sender,
        to=pairing_precompile,
        value=value,
        # One byte: not a multiple of 192, so the pairing precompile
        # exceptionally halts after the value has moved.
        data=b"\x00",
        state_gas_reservoir=reservoir,
        expected_receipt=TransactionReceipt(
            cumulative_gas_used=gas_used,
        ),
    )

    post = {
        pairing_precompile: None,
    }

    state_test(pre=pre, tx=tx, post=post)

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.