Skip to content

test_call_new_account_header_gas_used()

Documentation for tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_call.py::test_call_new_account_header_gas_used@c74f1a67.

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_header_gas_used --fork Amsterdam

Verify block gas accounting for CALL creating a new account.

A contract CALLs a non-existent address with value, charging GAS_NEW_ACCOUNT state gas. The block must be accepted with correct 2D max(regular, state) accounting in the header.

Source code in tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_call.py
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
@pytest.mark.valid_from("EIP8037")
def test_call_new_account_header_gas_used(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
    fork: Fork,
) -> None:
    """
    Verify block gas accounting for CALL creating a new account.

    A contract CALLs a non-existent address with value, charging
    GAS_NEW_ACCOUNT state gas. The block must be accepted with
    correct 2D max(regular, state) accounting in the header.
    """
    gas_costs = fork.gas_costs()
    new_account_state_gas = gas_costs.NEW_ACCOUNT

    target = pre.fund_eoa(amount=0)

    storage = Storage()
    contract = pre.deploy_contract(
        code=(
            Op.SSTORE(
                storage.store_next(1, "call_succeeds"),
                Op.CALL(gas=100_000, address=target, value=1),
            )
        ),
        balance=1,
    )

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

    blockchain_test(
        pre=pre,
        blocks=[
            Block(txs=[tx]),
        ],
        post={contract: Account(storage=storage)},
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.