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

Generate fixtures for these test cases for Osaka with:

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

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
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
@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,
) -> None:
    """
    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