Skip to content

test_legacy_create_edge_code_size()

Documentation for tests/shanghai/eip3860_initcode/test_with_eof.py::test_legacy_create_edge_code_size@b48d1dc8.

Generate fixtures for these test cases for Prague with:

fill -v tests/shanghai/eip3860_initcode/test_with_eof.py::test_legacy_create_edge_code_size --fork Prague

Verifies that legacy initcode/deploycode having 0 or max size continues to work in the fork where EOF is enabled. Handling of EOF magic prefix and version interferes with the handling of legacy creation, so a specific test was proposed to test behavior doesn't change.

Source code in tests/shanghai/eip3860_initcode/test_with_eof.py
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
@pytest.mark.parametrize(
    "opcode",
    [
        Op.CREATE,
        Op.CREATE2,
    ],
)
@pytest.mark.parametrize(
    "init_code",
    [
        pytest.param(Bytecode(), id="empty_initcode"),
        pytest.param(Initcode(initcode_length=MAX_INITCODE_SIZE), id="max_initcode"),
        pytest.param(Initcode(deploy_code=Bytecode()), id="empty_code"),
        pytest.param(Initcode(deploy_code=Op.STOP * MAX_BYTECODE_SIZE), id="max_code"),
    ],
)
def test_legacy_create_edge_code_size(
    state_test: StateTestFiller,
    pre: Alloc,
    opcode: Op,
    init_code: Bytecode,
):
    """
    Verifies that legacy initcode/deploycode having 0 or max size continues to work in the fork
    where EOF is enabled. Handling of EOF magic prefix and version interferes with the handling
    of legacy creation, so a specific test was proposed to test behavior doesn't change.
    """
    env = Environment()

    salt_param = [0] if opcode == Op.CREATE2 else []
    factory_code = (
        Op.CALLDATACOPY(0, 0, Op.CALLDATASIZE)
        + Op.SSTORE(slot_create_address, opcode(0, 0, Op.CALLDATASIZE, *salt_param))
        + Op.SSTORE(slot_code_worked, value_code_worked)
    )

    contract_address = pre.deploy_contract(code=factory_code)

    new_address = compute_create_address(
        address=contract_address, initcode=init_code, nonce=1, opcode=opcode
    )

    post = {
        contract_address: Account(
            storage={slot_create_address: new_address, slot_code_worked: value_code_worked}
        )
    }
    tx = Transaction(
        to=contract_address,
        gas_limit=10_000_000,
        data=init_code,
        sender=pre.fund_eoa(),
    )

    state_test(env=env, pre=pre, post=post, tx=tx)

Parametrized Test Cases

The interactive table below is also available as a standalone page.

Test ID (Abbreviated) init_code opcode
...fork_Shanghai-state_test-empty_initcode-opcode_CREATE CREATE
...fork_Shanghai-state_test-empty_initcode-opcode_CREATE2 CREATE2
...fork_Shanghai-state_test-max_initcode-opcode_CREATE CREATE
...fork_Shanghai-state_test-max_initcode-opcode_CREATE2 CREATE2
...fork_Shanghai-state_test-empty_code-opcode_CREATE CREATE
...fork_Shanghai-state_test-empty_code-opcode_CREATE2 CREATE2
...fork_Shanghai-state_test-max_code-opcode_CREATE CREATE
...fork_Shanghai-state_test-max_code-opcode_CREATE2 CREATE2
...fork_Shanghai-blockchain_test_from_state_test-empty_initcode-opcode_CREATE CREATE
...fork_Shanghai-blockchain_test_from_state_test-empty_initcode-opcode_CREATE2 CREATE2
...fork_Shanghai-blockchain_test_from_state_test-max_initcode-opcode_CREATE CREATE
...fork_Shanghai-blockchain_test_from_state_test-max_initcode-opcode_CREATE2 CREATE2
...fork_Shanghai-blockchain_test_from_state_test-empty_code-opcode_CREATE CREATE
...fork_Shanghai-blockchain_test_from_state_test-empty_code-opcode_CREATE2 CREATE2
...fork_Shanghai-blockchain_test_from_state_test-max_code-opcode_CREATE CREATE
...fork_Shanghai-blockchain_test_from_state_test-max_code-opcode_CREATE2 CREATE2
...fork_Cancun-state_test-empty_initcode-opcode_CREATE CREATE
...fork_Cancun-state_test-empty_initcode-opcode_CREATE2 CREATE2
...fork_Cancun-state_test-max_initcode-opcode_CREATE CREATE
...fork_Cancun-state_test-max_initcode-opcode_CREATE2 CREATE2
...fork_Cancun-state_test-empty_code-opcode_CREATE CREATE
...fork_Cancun-state_test-empty_code-opcode_CREATE2 CREATE2
...fork_Cancun-state_test-max_code-opcode_CREATE CREATE
...fork_Cancun-state_test-max_code-opcode_CREATE2 CREATE2
...fork_Cancun-blockchain_test_from_state_test-empty_initcode-opcode_CREATE CREATE
...fork_Cancun-blockchain_test_from_state_test-empty_initcode-opcode_CREATE2 CREATE2
...fork_Cancun-blockchain_test_from_state_test-max_initcode-opcode_CREATE CREATE
...fork_Cancun-blockchain_test_from_state_test-max_initcode-opcode_CREATE2 CREATE2
...fork_Cancun-blockchain_test_from_state_test-empty_code-opcode_CREATE CREATE
...fork_Cancun-blockchain_test_from_state_test-empty_code-opcode_CREATE2 CREATE2
...fork_Cancun-blockchain_test_from_state_test-max_code-opcode_CREATE CREATE
...fork_Cancun-blockchain_test_from_state_test-max_code-opcode_CREATE2 CREATE2
...fork_Prague-state_test-empty_initcode-opcode_CREATE CREATE
...fork_Prague-state_test-empty_initcode-opcode_CREATE2 CREATE2
...fork_Prague-state_test-max_initcode-opcode_CREATE CREATE
...fork_Prague-state_test-max_initcode-opcode_CREATE2 CREATE2
...fork_Prague-state_test-empty_code-opcode_CREATE CREATE
...fork_Prague-state_test-empty_code-opcode_CREATE2 CREATE2
...fork_Prague-state_test-max_code-opcode_CREATE CREATE
...fork_Prague-state_test-max_code-opcode_CREATE2 CREATE2
...fork_Prague-blockchain_test_from_state_test-empty_initcode-opcode_CREATE CREATE
...fork_Prague-blockchain_test_from_state_test-empty_initcode-opcode_CREATE2 CREATE2
...fork_Prague-blockchain_test_from_state_test-max_initcode-opcode_CREATE CREATE
...fork_Prague-blockchain_test_from_state_test-max_initcode-opcode_CREATE2 CREATE2
...fork_Prague-blockchain_test_from_state_test-empty_code-opcode_CREATE CREATE
...fork_Prague-blockchain_test_from_state_test-empty_code-opcode_CREATE2 CREATE2
...fork_Prague-blockchain_test_from_state_test-max_code-opcode_CREATE CREATE
...fork_Prague-blockchain_test_from_state_test-max_code-opcode_CREATE2 CREATE2
...fork_Osaka-state_test-empty_initcode-opcode_CREATE CREATE
...fork_Osaka-state_test-empty_initcode-opcode_CREATE2 CREATE2
...fork_Osaka-state_test-max_initcode-opcode_CREATE CREATE
...fork_Osaka-state_test-max_initcode-opcode_CREATE2 CREATE2
...fork_Osaka-state_test-empty_code-opcode_CREATE CREATE
...fork_Osaka-state_test-empty_code-opcode_CREATE2 CREATE2
...fork_Osaka-state_test-max_code-opcode_CREATE CREATE
...fork_Osaka-state_test-max_code-opcode_CREATE2 CREATE2
...fork_Osaka-blockchain_test_from_state_test-empty_initcode-opcode_CREATE CREATE
...fork_Osaka-blockchain_test_from_state_test-empty_initcode-opcode_CREATE2 CREATE2
...fork_Osaka-blockchain_test_from_state_test-max_initcode-opcode_CREATE CREATE
...fork_Osaka-blockchain_test_from_state_test-max_initcode-opcode_CREATE2 CREATE2
...fork_Osaka-blockchain_test_from_state_test-empty_code-opcode_CREATE CREATE
...fork_Osaka-blockchain_test_from_state_test-empty_code-opcode_CREATE2 CREATE2
...fork_Osaka-blockchain_test_from_state_test-max_code-opcode_CREATE CREATE
...fork_Osaka-blockchain_test_from_state_test-max_code-opcode_CREATE2 CREATE2