Skip to content

test_call_to_precompile_in_pointer_context()

Documentation for tests/prague/eip7702_set_code_tx/test_set_code_txs_2.py::test_call_to_precompile_in_pointer_context@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_call_to_precompile_in_pointer_context --fork Prague

Tx -> call -> pointer A -> precompile contract Make sure that gas consumed when calling precompiles in normal call are the same As from inside the pointer context call.

Source code in tests/prague/eip7702_set_code_tx/test_set_code_txs_2.py
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
@pytest.mark.with_all_precompiles
@pytest.mark.valid_from("Prague")
def test_call_to_precompile_in_pointer_context(
    state_test: StateTestFiller, pre: Alloc, precompile: int
):
    """
    Tx -> call -> pointer A -> precompile contract
    Make sure that gas consumed when calling precompiles in normal call are the same
    As from inside the pointer context call.
    """
    env = Environment()

    storage: Storage = Storage()

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

    contract_test = pre.deploy_contract(
        code=Op.MSTORE(1000, Op.GAS())
        + Op.CALL(gas=100_000, address=precompile, args_size=Op.CALLDATASIZE())
        + Op.MSTORE(0, Op.SUB(Op.MLOAD(1000), Op.GAS()))
        + Op.RETURN(0, 32)
    )
    normal_call_gas = 2000
    pointer_call_gas = 3000
    contract_a = pre.deploy_contract(
        code=Op.CALL(
            gas=1_000_000,
            address=contract_test,
            args_size=Op.CALLDATASIZE(),
            ret_offset=1000,
            ret_size=32,
        )
        + Op.MSTORE(normal_call_gas, Op.MLOAD(1000))
        + Op.CALL(
            gas=1_000_000,
            address=pointer_a,
            args_size=Op.CALLDATASIZE(),
            ret_offset=1000,
            ret_size=32,
        )
        + Op.MSTORE(pointer_call_gas, Op.MLOAD(1000))
        + Op.SSTORE(
            storage.store_next(0, "call_gas_diff"),
            Op.SUB(Op.MLOAD(normal_call_gas), Op.MLOAD(pointer_call_gas)),
        )
        + Op.SSTORE(storage.store_next(1, "tx_worked"), 1)
    )

    tx = Transaction(
        to=contract_a,
        gas_limit=3_000_000,
        data=[0x11] * 256,
        value=0,
        sender=sender,
        authorization_list=[
            AuthorizationTuple(
                address=contract_test,
                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