Skip to content

test_create_state_gas_scales_with_cpsb()

Documentation for tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_pricing.py::test_create_state_gas_scales_with_cpsb@2119b382.

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

Test CREATE new-account state gas scales with block gas limit.

State gas for a CREATE is 120 * cpsb (new account) plus code_size * cpsb (code deposit).

Source code in tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_pricing.py
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
@pytest.mark.parametrize("block_gas_limit", BLOCK_GAS_LIMITS)
@pytest.mark.valid_from("EIP8037")
def test_create_state_gas_scales_with_cpsb(
    state_test: StateTestFiller,
    pre: Alloc,
    block_gas_limit: int,
    fork: Fork,
) -> None:
    """
    Test CREATE new-account state gas scales with block gas limit.

    State gas for a CREATE is 120 * cpsb (new account) plus
    code_size * cpsb (code deposit).
    """
    gas_limit_cap = fork.transaction_gas_limit_cap()
    assert gas_limit_cap is not None
    env = Environment(gas_limit=block_gas_limit)
    create_state_gas = fork.create_state_gas(code_size=1)

    storage = Storage()
    contract = pre.deploy_contract(
        code=(
            Op.SSTORE(
                storage.store_next(1, "create_success"),
                Op.GT(Op.CREATE(0, 0, 1), 0),
            )
        ),
    )

    tx_gas = min(gas_limit_cap + create_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.