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@636b5f17.

Generate fixtures for these test cases for Bogota with:

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

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
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
@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 2 forks.