Skip to content

test_call_value_precompile_halt_refunds_new_account_state_gas()

Documentation for tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_call.py::test_call_value_precompile_halt_refunds_new_account_state_gas@87aba1a3.

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

Refill NEW_ACCOUNT state gas on a value CALL to an unfunded precompile that halts in the child frame.

Source code in tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_call.py
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
@pytest.mark.valid_from("EIP8037")
def test_call_value_precompile_halt_refunds_new_account_state_gas(
    state_test: StateTestFiller,
    pre: Alloc,
    fork: Fork,
) -> None:
    """
    Refill NEW_ACCOUNT state gas on a value CALL to an unfunded
    precompile that halts in the child frame.
    """
    gas_costs = fork.gas_costs()
    sstore_state_gas = Op.SSTORE(new_value=1).state_cost(fork)
    new_account_state_gas = gas_costs.NEW_ACCOUNT

    probe_storage = Storage()
    probe_code = Op.SSTORE(probe_storage.store_next(1, "probe_ran"), 1)
    probe = pre.deploy_contract(probe_code)

    probe_stipend = probe_code.regular_cost(fork)

    ecpairing = 0x08

    parent = pre.deploy_contract(
        code=(
            Op.POP(Op.CALL(1, ecpairing, 1, 0, 0, 0, 0))
            + Op.POP(Op.CALL(gas=probe_stipend, address=probe))
        ),
        balance=1,
    )

    assert new_account_state_gas >= sstore_state_gas
    reservoir = new_account_state_gas

    tx = Transaction(
        to=parent,
        state_gas_reservoir=reservoir,
        sender=pre.fund_eoa(),
    )

    post = {probe: Account(storage=probe_storage)}
    state_test(pre=pre, post=post, tx=tx)

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.