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@bc691d13.

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
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
@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(), salt=0),
        )
        + 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, salt=0, 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