Skip to content

test_pointer_to_precompile()

Documentation for tests/prague/eip7702_set_code_tx/test_set_code_txs_2.py::test_pointer_to_precompile@01f496f4.

Generate fixtures for these test cases for Prague with:

fill -v tests/prague/eip7702_set_code_tx/test_set_code_txs_2.py::test_pointer_to_precompile --fork Prague

Tx -> call -> pointer A -> precompile contract.

In case a delegation designator points to a precompile address, retrieved code is considered empty and CALL, CALLCODE, STATICCALL, DELEGATECALL instructions targeting this account will execute empty code, i.e. succeed with no execution given enough gas.

So call to a pointer that points to a precompile is like call to an empty account

Source code in tests/prague/eip7702_set_code_tx/test_set_code_txs_2.py
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
@pytest.mark.with_all_precompiles
@pytest.mark.valid_from("Prague")
def test_pointer_to_precompile(state_test: StateTestFiller, pre: Alloc, precompile: int):
    """
    Tx -> call -> pointer A -> precompile contract.

    In case a delegation designator points to a precompile address, retrieved code is considered
    empty and CALL, CALLCODE, STATICCALL, DELEGATECALL instructions targeting this account will
    execute empty code, i.e. succeed with no execution given enough gas.

    So call to a pointer that points to a precompile is like call to an empty account
    """
    env = Environment()

    storage: Storage = Storage()

    sender = pre.fund_eoa()
    pointer_a = pre.fund_eoa()

    contract_test_normal = pre.deploy_contract(
        code=Op.MSTORE(0, Op.CALL(gas=0, address=precompile, args_size=Op.CALLDATASIZE()))
        + Op.RETURN(0, 32)
    )

    contract_test_pointer = pre.deploy_contract(
        code=Op.MSTORE(0, Op.CALL(gas=0, address=pointer_a, args_size=Op.CALLDATASIZE()))
        + Op.RETURN(0, 32)
    )

    contract_a = pre.deploy_contract(
        code=Op.CALL(
            gas=1_000_000,
            address=contract_test_normal,
            args_size=Op.CALLDATASIZE(),
            ret_offset=1000,
            ret_size=32,
        )
        # direct call to a precompile with 0 gas always return 0
        + Op.SSTORE(storage.store_next(0, "direct_call_result"), Op.MLOAD(1000))
        + Op.CALL(
            gas=1_000_000,
            address=contract_test_pointer,
            args_size=Op.CALLDATASIZE(),
            ret_offset=1000,
            ret_size=32,
        )
        # pointer call to a precompile with 0 gas always return 1 as if calling empty address
        + Op.SSTORE(storage.store_next(1, "pointer_call_result"), Op.MLOAD(1000))
    )

    tx = Transaction(
        to=contract_a,
        gas_limit=3_000_000,
        data=[0x11] * 256,
        value=0,
        sender=sender,
        authorization_list=[
            AuthorizationTuple(
                address=precompile,
                nonce=0,
                signer=pointer_a,
            )
        ],
    )

    post = {contract_a: Account(storage=storage)}
    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) precompile
...fork_Prague-precompile_0x000000000000000000000000000000000000000b-state_test 0x000000000000000000000000000000 000000000b
...fork_Prague-precompile_0x000000000000000000000000000000000000000b-blockchain_test_from_state_test 0x000000000000000000000000000000 000000000b
...fork_Prague-precompile_0x000000000000000000000000000000000000000c-state_test 0x000000000000000000000000000000 000000000c
...fork_Prague-precompile_0x000000000000000000000000000000000000000c-blockchain_test_from_state_test 0x000000000000000000000000000000 000000000c
...fork_Prague-precompile_0x000000000000000000000000000000000000000d-state_test 0x000000000000000000000000000000 000000000d
...fork_Prague-precompile_0x000000000000000000000000000000000000000d-blockchain_test_from_state_test 0x000000000000000000000000000000 000000000d
...fork_Prague-precompile_0x000000000000000000000000000000000000000e-state_test 0x000000000000000000000000000000 000000000e
...fork_Prague-precompile_0x000000000000000000000000000000000000000e-blockchain_test_from_state_test 0x000000000000000000000000000000 000000000e
...fork_Prague-precompile_0x000000000000000000000000000000000000000f-state_test 0x000000000000000000000000000000 000000000f
...fork_Prague-precompile_0x000000000000000000000000000000000000000f-blockchain_test_from_state_test 0x000000000000000000000000000000 000000000f
...fork_Prague-precompile_0x0000000000000000000000000000000000000010-state_test 0x000000000000000000000000000000 0000000010
...fork_Prague-precompile_0x0000000000000000000000000000000000000010-blockchain_test_from_state_test 0x000000000000000000000000000000 0000000010
...fork_Prague-precompile_0x0000000000000000000000000000000000000011-state_test 0x000000000000000000000000000000 0000000011
...fork_Prague-precompile_0x0000000000000000000000000000000000000011-blockchain_test_from_state_test 0x000000000000000000000000000000 0000000011
...fork_Prague-precompile_0x000000000000000000000000000000000000000a-state_test 0x000000000000000000000000000000 000000000a
...fork_Prague-precompile_0x000000000000000000000000000000000000000a-blockchain_test_from_state_test 0x000000000000000000000000000000 000000000a
...fork_Prague-precompile_0x0000000000000000000000000000000000000009-state_test 0x000000000000000000000000000000 0000000009
...fork_Prague-precompile_0x0000000000000000000000000000000000000009-blockchain_test_from_state_test 0x000000000000000000000000000000 0000000009
...fork_Prague-precompile_0x0000000000000000000000000000000000000005-state_test 0x000000000000000000000000000000 0000000005
...fork_Prague-precompile_0x0000000000000000000000000000000000000005-blockchain_test_from_state_test 0x000000000000000000000000000000 0000000005
...fork_Prague-precompile_0x0000000000000000000000000000000000000006-state_test 0x000000000000000000000000000000 0000000006
...fork_Prague-precompile_0x0000000000000000000000000000000000000006-blockchain_test_from_state_test 0x000000000000000000000000000000 0000000006
...fork_Prague-precompile_0x0000000000000000000000000000000000000007-state_test 0x000000000000000000000000000000 0000000007
...fork_Prague-precompile_0x0000000000000000000000000000000000000007-blockchain_test_from_state_test 0x000000000000000000000000000000 0000000007
...fork_Prague-precompile_0x0000000000000000000000000000000000000008-state_test 0x000000000000000000000000000000 0000000008
...fork_Prague-precompile_0x0000000000000000000000000000000000000008-blockchain_test_from_state_test 0x000000000000000000000000000000 0000000008
...fork_Prague-precompile_0x0000000000000000000000000000000000000001-state_test 0x000000000000000000000000000000 0000000001
...fork_Prague-precompile_0x0000000000000000000000000000000000000001-blockchain_test_from_state_test 0x000000000000000000000000000000 0000000001
...fork_Prague-precompile_0x0000000000000000000000000000000000000002-state_test 0x000000000000000000000000000000 0000000002
...fork_Prague-precompile_0x0000000000000000000000000000000000000002-blockchain_test_from_state_test 0x000000000000000000000000000000 0000000002
...fork_Prague-precompile_0x0000000000000000000000000000000000000003-state_test 0x000000000000000000000000000000 0000000003
...fork_Prague-precompile_0x0000000000000000000000000000000000000003-blockchain_test_from_state_test 0x000000000000000000000000000000 0000000003
...fork_Prague-precompile_0x0000000000000000000000000000000000000004-state_test 0x000000000000000000000000000000 0000000004
...fork_Prague-precompile_0x0000000000000000000000000000000000000004-blockchain_test_from_state_test 0x000000000000000000000000000000 0000000004
...fork_Osaka-precompile_0x000000000000000000000000000000000000000b-state_test 0x000000000000000000000000000000 000000000b
...fork_Osaka-precompile_0x000000000000000000000000000000000000000b-blockchain_test_from_state_test 0x000000000000000000000000000000 000000000b
...fork_Osaka-precompile_0x000000000000000000000000000000000000000c-state_test 0x000000000000000000000000000000 000000000c
...fork_Osaka-precompile_0x000000000000000000000000000000000000000c-blockchain_test_from_state_test 0x000000000000000000000000000000 000000000c
...fork_Osaka-precompile_0x000000000000000000000000000000000000000d-state_test 0x000000000000000000000000000000 000000000d
...fork_Osaka-precompile_0x000000000000000000000000000000000000000d-blockchain_test_from_state_test 0x000000000000000000000000000000 000000000d
...fork_Osaka-precompile_0x000000000000000000000000000000000000000e-state_test 0x000000000000000000000000000000 000000000e
...fork_Osaka-precompile_0x000000000000000000000000000000000000000e-blockchain_test_from_state_test 0x000000000000000000000000000000 000000000e
...fork_Osaka-precompile_0x000000000000000000000000000000000000000f-state_test 0x000000000000000000000000000000 000000000f
...fork_Osaka-precompile_0x000000000000000000000000000000000000000f-blockchain_test_from_state_test 0x000000000000000000000000000000 000000000f
...fork_Osaka-precompile_0x0000000000000000000000000000000000000010-state_test 0x000000000000000000000000000000 0000000010
...fork_Osaka-precompile_0x0000000000000000000000000000000000000010-blockchain_test_from_state_test 0x000000000000000000000000000000 0000000010
...fork_Osaka-precompile_0x0000000000000000000000000000000000000011-state_test 0x000000000000000000000000000000 0000000011
...fork_Osaka-precompile_0x0000000000000000000000000000000000000011-blockchain_test_from_state_test 0x000000000000000000000000000000 0000000011
...fork_Osaka-precompile_0x000000000000000000000000000000000000000a-state_test 0x000000000000000000000000000000 000000000a
...fork_Osaka-precompile_0x000000000000000000000000000000000000000a-blockchain_test_from_state_test 0x000000000000000000000000000000 000000000a
...fork_Osaka-precompile_0x0000000000000000000000000000000000000009-state_test 0x000000000000000000000000000000 0000000009
...fork_Osaka-precompile_0x0000000000000000000000000000000000000009-blockchain_test_from_state_test 0x000000000000000000000000000000 0000000009
...fork_Osaka-precompile_0x0000000000000000000000000000000000000005-state_test 0x000000000000000000000000000000 0000000005
...fork_Osaka-precompile_0x0000000000000000000000000000000000000005-blockchain_test_from_state_test 0x000000000000000000000000000000 0000000005
...fork_Osaka-precompile_0x0000000000000000000000000000000000000006-state_test 0x000000000000000000000000000000 0000000006
...fork_Osaka-precompile_0x0000000000000000000000000000000000000006-blockchain_test_from_state_test 0x000000000000000000000000000000 0000000006
...fork_Osaka-precompile_0x0000000000000000000000000000000000000007-state_test 0x000000000000000000000000000000 0000000007
...fork_Osaka-precompile_0x0000000000000000000000000000000000000007-blockchain_test_from_state_test 0x000000000000000000000000000000 0000000007
...fork_Osaka-precompile_0x0000000000000000000000000000000000000008-state_test 0x000000000000000000000000000000 0000000008
...fork_Osaka-precompile_0x0000000000000000000000000000000000000008-blockchain_test_from_state_test 0x000000000000000000000000000000 0000000008
...fork_Osaka-precompile_0x0000000000000000000000000000000000000001-state_test 0x000000000000000000000000000000 0000000001
...fork_Osaka-precompile_0x0000000000000000000000000000000000000001-blockchain_test_from_state_test 0x000000000000000000000000000000 0000000001
...fork_Osaka-precompile_0x0000000000000000000000000000000000000002-state_test 0x000000000000000000000000000000 0000000002
...fork_Osaka-precompile_0x0000000000000000000000000000000000000002-blockchain_test_from_state_test 0x000000000000000000000000000000 0000000002
...fork_Osaka-precompile_0x0000000000000000000000000000000000000003-state_test 0x000000000000000000000000000000 0000000003
...fork_Osaka-precompile_0x0000000000000000000000000000000000000003-blockchain_test_from_state_test 0x000000000000000000000000000000 0000000003
...fork_Osaka-precompile_0x0000000000000000000000000000000000000004-state_test 0x000000000000000000000000000000 0000000004
...fork_Osaka-precompile_0x0000000000000000000000000000000000000004-blockchain_test_from_state_test 0x000000000000000000000000000000 0000000004