Skip to content

test_legacy_initcode_eof_contract_fails()

Documentation for tests/osaka/eip7692_eof_v1/eip7620_eof_create/test_legacy_eof_creates.py::test_legacy_initcode_eof_contract_fails@bc691d13.

Generate fixtures for these test cases for Osaka with:

fill -v tests/osaka/eip7692_eof_v1/eip7620_eof_create/test_legacy_eof_creates.py::test_legacy_initcode_eof_contract_fails --fork Osaka

Verifies that legacy initcode cannot create EOF.

This tests only ensures EIP-3541 behavior is kept, not altered by EIP-7620.

Source code in tests/osaka/eip7692_eof_v1/eip7620_eof_create/test_legacy_eof_creates.py
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
@pytest.mark.parametrize(
    "legacy_create_opcode",
    [
        pytest.param(Op.CREATE, id="CREATE"),
        pytest.param(Op.CREATE2, id="CREATE2"),
    ],
)
@pytest.mark.parametrize(
    "deploy_code",
    [
        Bytes("0xEF"),
        Bytes("0xEF00"),
        Bytes("0xEF0001"),
        Bytes("0xEF01"),
        pytest.param(smallest_initcode_subcontainer, id="deploy_eof_initcontainer"),
        pytest.param(smallest_runtime_subcontainer, id="deploy_eof_container"),
    ],
)
def test_legacy_initcode_eof_contract_fails(
    state_test: StateTestFiller,
    pre: Alloc,
    legacy_create_opcode: Opcodes,
    deploy_code: Bytes | Container,
):
    """
    Verifies that legacy initcode cannot create EOF.

    This tests only ensures EIP-3541 behavior is kept, not altered by EIP-7620.
    """
    env = Environment()
    init_code = LegacyInitcode(deploy_code=deploy_code)
    salt_param = [0] if legacy_create_opcode == Op.CREATE2 else []
    factory_code = (
        Op.CALLDATACOPY(0, 0, Op.CALLDATASIZE)
        + Op.SSTORE(slot_create_address, legacy_create_opcode(0, 0, Op.CALLDATASIZE, *salt_param))
        + Op.SSTORE(slot_code_worked, value_code_worked)
    )

    sender = pre.fund_eoa()
    contract_address = pre.deploy_contract(code=factory_code)

    # Storage in 0 should be empty as the final CREATE filed
    # and 1 in 1 to show execution continued and did not halt
    post = {
        contract_address: Account(
            storage={slot_create_address: EOFCREATE_FAILURE, slot_code_worked: value_code_worked}
        )
    }
    tx = Transaction(
        to=contract_address,
        gas_limit=10_000_000,
        data=init_code,
        sender=sender,
    )

    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) deploy_code legacy_create_opcode
...fork_Osaka-state_test-deploy_code_0xef-CREATE 0xef CREATE
...fork_Osaka-state_test-deploy_code_0xef-CREATE2 0xef CREATE2
...fork_Osaka-state_test-deploy_code_0xef00-CREATE 0xef00 CREATE
...fork_Osaka-state_test-deploy_code_0xef00-CREATE2 0xef00 CREATE2
...fork_Osaka-state_test-deploy_code_0xef0001-CREATE 0xef0001 CREATE
...fork_Osaka-state_test-deploy_code_0xef0001-CREATE2 0xef0001 CREATE2
...fork_Osaka-state_test-deploy_code_0xef01-CREATE 0xef01 CREATE
...fork_Osaka-state_test-deploy_code_0xef01-CREATE2 0xef01 CREATE2
...fork_Osaka-state_test-deploy_eof_initcontainer-CREATE Initcode Subcontainer CREATE
...fork_Osaka-state_test-deploy_eof_initcontainer-CREATE2 Initcode Subcontainer CREATE2
...fork_Osaka-state_test-deploy_eof_container-CREATE b'\xef\x00\x01\x01\x00\x04\x02\x00\x01\x00\x01\xff\x00\x00\x00\x00\x80\x00\x00\x00' CREATE
...fork_Osaka-state_test-deploy_eof_container-CREATE2 b'\xef\x00\x01\x01\x00\x04\x02\x00\x01\x00\x01\xff\x00\x00\x00\x00\x80\x00\x00\x00' CREATE2
...fork_Osaka-blockchain_test_from_state_test-deploy_code_0xef-CREATE 0xef CREATE
...fork_Osaka-blockchain_test_from_state_test-deploy_code_0xef-CREATE2 0xef CREATE2
...fork_Osaka-blockchain_test_from_state_test-deploy_code_0xef00-CREATE 0xef00 CREATE
...fork_Osaka-blockchain_test_from_state_test-deploy_code_0xef00-CREATE2 0xef00 CREATE2
...fork_Osaka-blockchain_test_from_state_test-deploy_code_0xef0001-CREATE 0xef0001 CREATE
...fork_Osaka-blockchain_test_from_state_test-deploy_code_0xef0001-CREATE2 0xef0001 CREATE2
...fork_Osaka-blockchain_test_from_state_test-deploy_code_0xef01-CREATE 0xef01 CREATE
...fork_Osaka-blockchain_test_from_state_test-deploy_code_0xef01-CREATE2 0xef01 CREATE2
...fork_Osaka-blockchain_test_from_state_test-deploy_eof_initcontainer-CREATE Initcode Subcontainer CREATE
...fork_Osaka-blockchain_test_from_state_test-deploy_eof_initcontainer-CREATE2 Initcode Subcontainer CREATE2
...fork_Osaka-blockchain_test_from_state_test-deploy_eof_container-CREATE b'\xef\x00\x01\x01\x00\x04\x02\x00\x01\x00\x01\xff\x00\x00\x00\x00\x80\x00\x00\x00' CREATE
...fork_Osaka-blockchain_test_from_state_test-deploy_eof_container-CREATE2 b'\xef\x00\x01\x01\x00\x04\x02\x00\x01\x00\x01\xff\x00\x00\x00\x00\x80\x00\x00\x00' CREATE2