Skip to content

test_mixed_auths_header_gas_used()

Documentation for tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_set_code.py::test_mixed_auths_header_gas_used@26332146.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_set_code.py::test_mixed_auths_header_gas_used --fork Amsterdam

Verify the header gas_used across a mix of existing and new authorities.

Existing authorities pay only AUTH_BASE; new (nonexistent) authorities additionally pay NEW_ACCOUNT (state) + ACCOUNT_WRITE (execution) for the created leaf. The header gas_used is max(block_execution, block_state) over the summed top-frame charges, with no refund term.

Source code in tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_set_code.py
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
@pytest.mark.parametrize(
    "num_existing,num_new",
    [
        pytest.param(1, 1, id="one_existing_one_new"),
        pytest.param(2, 2, id="two_existing_two_new"),
    ],
)
@pytest.mark.valid_from("EIP8037")
def test_mixed_auths_header_gas_used(
    state_test: StateTestFiller,
    pre: Alloc,
    fork: Fork,
    num_existing: int,
    num_new: int,
) -> None:
    """
    Verify the header ``gas_used`` across a mix of existing and new
    authorities.

    Existing authorities pay only ``AUTH_BASE``; new (nonexistent)
    authorities additionally pay ``NEW_ACCOUNT`` (state) + ``ACCOUNT_WRITE``
    (execution) for the created leaf. The header ``gas_used`` is
    ``max(block_execution, block_state)`` over the summed top-frame charges,
    with no refund term.
    """
    contract = pre.deploy_contract(code=Op.STOP)

    existing_signers = [pre.fund_eoa() for _ in range(num_existing)]
    new_signers = [pre.fund_eoa(amount=0) for _ in range(num_new)]

    authorization_list = [
        AuthorizationTuple(
            address=contract,
            nonce=0,
            signer=signer,
            creates_account=False,
            writes_delegation=True,
        )
        for signer in existing_signers
    ] + [
        AuthorizationTuple(
            address=contract,
            nonce=0,
            signer=signer,
            creates_account=True,
            writes_delegation=True,
        )
        for signer in new_signers
    ]

    intrinsic_execution, top_frame_execution, top_frame_state = _auth_gas(
        fork, authorization_list
    )
    _, header_gas_used = _receipt_and_header(
        intrinsic_execution, top_frame_execution, top_frame_state
    )

    tx = Transaction(
        to=contract,
        authorization_list=authorization_list,
        sender=pre.fund_eoa(),
    )

    post = {
        signer: Account(code=Spec7702.delegation_designation(contract))
        for signer in existing_signers
    }
    for signer in new_signers:
        post[signer] = Account(
            nonce=1,
            balance=0,
            code=Spec7702.delegation_designation(contract),
        )

    state_test(
        pre=pre,
        post=post,
        tx=tx,
        blockchain_test_header_verify=Header(gas_used=header_gas_used),
    )

Parametrized Test Cases

This test generates 2 parametrized test cases across 1 fork.