Skip to content

test_creating_delegation_designation_contract()

Documentation for tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_creating_delegation_designation_contract@0f77f07a.

Generate fixtures for these test cases for Prague with:

fill -v tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_creating_delegation_designation_contract --fork Prague

Tx -> create -> pointer bytecode Attempt to deploy contract with magic bytes result in no contract being created.

Source code in tests/prague/eip7702_set_code_tx/test_set_code_txs.py
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
@pytest.mark.parametrize(
    "initcode_is_delegation_designation",
    [
        pytest.param(True, id="initcode_deploys_delegation_designation"),
        pytest.param(False, id="initcode_is_delegation_designation"),
    ],
)
@pytest.mark.parametrize("create_opcode", [Op.CREATE, Op.CREATE2])
def test_creating_delegation_designation_contract(
    state_test: StateTestFiller,
    pre: Alloc,
    create_opcode: Op,
    initcode_is_delegation_designation: bool,
):
    """
    Tx -> create -> pointer bytecode
    Attempt to deploy contract with magic bytes result in no contract being created.
    """
    env = Environment()

    storage: Storage = Storage()

    sender = pre.fund_eoa()

    # An attempt to deploy code starting with ef01 result in no
    # contract being created as it is prohibited

    create_init: Bytes | Bytecode
    if initcode_is_delegation_designation:
        create_init = Spec.delegation_designation(sender)
    else:
        create_init = Initcode(deploy_code=Spec.delegation_designation(sender))
    contract_a = pre.deploy_contract(
        balance=100,
        code=Op.MSTORE(0, Op.CALLDATALOAD(0))
        + Op.SSTORE(
            storage.store_next(0, "contract_a_create_result"),
            create_opcode(value=1, offset=0, size=Op.CALLDATASIZE()),
        )
        + Op.STOP,
    )

    tx = Transaction(
        to=contract_a,
        gas_limit=1_000_000,
        data=create_init,
        value=0,
        sender=sender,
    )

    create_address = compute_create_address(
        address=contract_a, nonce=1, initcode=create_init, opcode=create_opcode
    )
    post = {
        contract_a: Account(balance=100, storage=storage),
        create_address: Account.NONEXISTENT,
    }
    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) create_opcode initcode_is_delegation_designation
...fork_Prague-state_test-create_opcode_CREATE-initcode_deploys_delegation_designation CREATE True
...fork_Prague-state_test-create_opcode_CREATE-initcode_is_delegation_designation CREATE False
...fork_Prague-state_test-create_opcode_CREATE2-initcode_deploys_delegation_designation CREATE2 True
...fork_Prague-state_test-create_opcode_CREATE2-initcode_is_delegation_designation CREATE2 False
...fork_Prague-blockchain_test_from_state_test-create_opcode_CREATE-initcode_deploys_delegation_designation CREATE True
...fork_Prague-blockchain_test_from_state_test-create_opcode_CREATE-initcode_is_delegation_designation CREATE False
...fork_Prague-blockchain_test_from_state_test-create_opcode_CREATE2-initcode_deploys_delegation_designation CREATE2 True
...fork_Prague-blockchain_test_from_state_test-create_opcode_CREATE2-initcode_is_delegation_designation CREATE2 False
...fork_Osaka-state_test-create_opcode_CREATE-initcode_deploys_delegation_designation CREATE True
...fork_Osaka-state_test-create_opcode_CREATE-initcode_is_delegation_designation CREATE False
...fork_Osaka-state_test-create_opcode_CREATE2-initcode_deploys_delegation_designation CREATE2 True
...fork_Osaka-state_test-create_opcode_CREATE2-initcode_is_delegation_designation CREATE2 False
...fork_Osaka-blockchain_test_from_state_test-create_opcode_CREATE-initcode_deploys_delegation_designation CREATE True
...fork_Osaka-blockchain_test_from_state_test-create_opcode_CREATE-initcode_is_delegation_designation CREATE False
...fork_Osaka-blockchain_test_from_state_test-create_opcode_CREATE2-initcode_deploys_delegation_designation CREATE2 True
...fork_Osaka-blockchain_test_from_state_test-create_opcode_CREATE2-initcode_is_delegation_designation CREATE2 False