Skip to content

test_create_revert_no_code_deposit_state_gas()

Documentation for tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_create.py::test_create_revert_no_code_deposit_state_gas@c74f1a67.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_create.py::test_create_revert_no_code_deposit_state_gas --fork Amsterdam

Test reverted CREATE does not charge code deposit state gas.

When CREATE fails during init code execution (REVERT), the new account state gas is consumed but no code deposit state gas is charged because no code was deployed.

Source code in tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_create.py
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
@pytest.mark.valid_from("EIP8037")
def test_create_revert_no_code_deposit_state_gas(
    state_test: StateTestFiller,
    pre: Alloc,
) -> None:
    """
    Test reverted CREATE does not charge code deposit state gas.

    When CREATE fails during init code execution (REVERT), the new
    account state gas is consumed but no code deposit state gas is
    charged because no code was deployed.
    """
    init_code = Op.REVERT(0, 0)

    storage = Storage()
    contract = pre.deploy_contract(
        code=(
            Op.MSTORE(
                0,
                int.from_bytes(bytes(init_code), "big")
                << (256 - 8 * len(init_code)),
            )
            + Op.SSTORE(
                storage.store_next(0),  # CREATE returns 0 on failure
                Op.CREATE(0, 0, len(init_code)),
            )
        ),
    )

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

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

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.