Skip to content

test_call_new_account_state_gas_scales_with_cpsb()

Documentation for tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_pricing.py::test_call_new_account_state_gas_scales_with_cpsb@c74f1a67.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_pricing.py::test_call_new_account_state_gas_scales_with_cpsb --fork Amsterdam

Test CALL value transfer to empty account scales with block gas limit.

Sending value to a non-existent account charges 120 * cpsb of state gas for account creation.

Source code in tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_pricing.py
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
@pytest.mark.parametrize("block_gas_limit", BLOCK_GAS_LIMITS)
@pytest.mark.valid_from("EIP8037")
def test_call_new_account_state_gas_scales_with_cpsb(
    state_test: StateTestFiller,
    pre: Alloc,
    block_gas_limit: int,
    fork: Fork,
) -> None:
    """
    Test CALL value transfer to empty account scales with block gas limit.

    Sending value to a non-existent account charges 120 * cpsb
    of state gas for account creation.
    """
    gas_limit_cap = fork.transaction_gas_limit_cap()
    assert gas_limit_cap is not None
    env = Environment(gas_limit=block_gas_limit)
    gas_costs = fork.gas_costs()
    new_account_state_gas = gas_costs.NEW_ACCOUNT

    empty = pre.fund_eoa(0)
    storage = Storage()
    contract = pre.deploy_contract(
        code=(
            Op.SSTORE(
                storage.store_next(1, "call_success"),
                Op.CALL(gas=100_000, address=empty, value=1),
            )
        ),
        balance=1,
    )

    tx_gas = min(gas_limit_cap + new_account_state_gas, block_gas_limit)
    tx = Transaction(
        to=contract,
        gas_limit=tx_gas,
        sender=pre.fund_eoa(),
    )

    post = {contract: Account(storage=storage)}
    state_test(env=env, pre=pre, post=post, tx=tx)

Parametrized Test Cases

This test generates 10 parametrized test cases across 1 fork.