Skip to content

test_blobhash_opcode_contexts_tx_types()

Documentation for tests/cancun/eip4844_blobs/test_blobhash_opcode_contexts.py::test_blobhash_opcode_contexts_tx_types@64f949d0.

Generate fixtures for these test cases for Prague with:

fill -v tests/cancun/eip4844_blobs/test_blobhash_opcode_contexts.py::test_blobhash_opcode_contexts_tx_types --fork Prague

Tests that the BLOBHASH opcode functions correctly when called in different contexts.

  • BLOBHASH opcode on the top level of the call stack.
  • BLOBHASH opcode on the max value.
  • BLOBHASH opcode on CALL, DELEGATECALL, STATICCALL, and CALLCODE.
  • BLOBHASH opcode on Initcode.
  • BLOBHASH opcode on CREATE and CREATE2.
  • BLOBHASH opcode on transaction types 0, 1 and 2.
Source code in tests/cancun/eip4844_blobs/test_blobhash_opcode_contexts.py
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
@pytest.mark.with_all_tx_types(selector=lambda x: x != 3)
def test_blobhash_opcode_contexts_tx_types(
    pre: Alloc,
    tx_type: int,
    state_test: StateTestFiller,
):
    """
    Tests that the `BLOBHASH` opcode functions correctly when called in different contexts.

    - `BLOBHASH` opcode on the top level of the call stack.
    - `BLOBHASH` opcode on the max value.
    - `BLOBHASH` opcode on `CALL`, `DELEGATECALL`, `STATICCALL`, and `CALLCODE`.
    - `BLOBHASH` opcode on Initcode.
    - `BLOBHASH` opcode on `CREATE` and `CREATE2`.
    - `BLOBHASH` opcode on transaction types 0, 1 and 2.
    """
    blobhash_sstore_address = BlobhashContext.BLOBHASH_SSTORE.deploy_contract(pre=pre, indexes=[0])
    tx_kwargs = {
        "ty": tx_type,
        "to": blobhash_sstore_address,
        "sender": pre.fund_eoa(),
        "gas_limit": 500_000,
    }
    if tx_type == 4:
        signer = pre.fund_eoa(amount=0)
        tx_kwargs["authorization_list"] = [
            AuthorizationTuple(
                signer=signer,
                address=Address(0),
                nonce=0,
            )
        ]

    state_test(
        pre=pre,
        tx=Transaction(**tx_kwargs),
        post={
            blobhash_sstore_address: Account(storage={0: 0}),
        },
    )

Parametrized Test Cases

The interactive table below is also available as a standalone page.

Test ID (Abbreviated) tx_type
...fork_Cancun-tx_type_2-state_test 2
...fork_Cancun-tx_type_2-blockchain_test_from_state_test 2
...fork_Cancun-tx_type_1-state_test 1
...fork_Cancun-tx_type_1-blockchain_test_from_state_test 1
...fork_Cancun-tx_type_0-state_test 0
...fork_Cancun-tx_type_0-blockchain_test_from_state_test 0
...fork_Prague-tx_type_4-state_test 4
...fork_Prague-tx_type_4-blockchain_test_from_state_test 4
...fork_Prague-tx_type_2-state_test 2
...fork_Prague-tx_type_2-blockchain_test_from_state_test 2
...fork_Prague-tx_type_1-state_test 1
...fork_Prague-tx_type_1-blockchain_test_from_state_test 1
...fork_Prague-tx_type_0-state_test 0
...fork_Prague-tx_type_0-blockchain_test_from_state_test 0
...fork_Osaka-tx_type_4-state_test 4
...fork_Osaka-tx_type_4-blockchain_test_from_state_test 4
...fork_Osaka-tx_type_2-state_test 2
...fork_Osaka-tx_type_2-blockchain_test_from_state_test 2
...fork_Osaka-tx_type_1-state_test 1
...fork_Osaka-tx_type_1-blockchain_test_from_state_test 1
...fork_Osaka-tx_type_0-state_test 0
...fork_Osaka-tx_type_0-blockchain_test_from_state_test 0