Skip to content

Test Blobhash Opcode Contexts

Documentation for tests/cancun/eip4844_blobs/test_blobhash_opcode_contexts.py.

Generate fixtures for these test cases for Cancun with:

Cancun only:

fill -v tests/cancun/eip4844_blobs/test_blobhash_opcode_contexts.py --fork=Cancun --evm-bin=/path/to/evm-tool-dev-version
For all forks up to and including Cancun:
fill -v tests/cancun/eip4844_blobs/test_blobhash_opcode_contexts.py --until=Cancun --evm-bin=/path/to/evm-tool-dev-version

abstract: Tests BLOBHASH opcode in EIP-4844: Shard Blob Transactions

Test case for `BLOBHASH` opcode calls across different contexts
in [EIP-4844: Shard Blob Transactions](https://eips.ethereum.org/EIPS/eip-4844).

test_blobhash_opcode_contexts(opcode_context, blockchain_test)

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

  • 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
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
@pytest.mark.compile_yul_with("Shanghai")
def test_blobhash_opcode_contexts(opcode_context, blockchain_test: BlockchainTestFiller):
    """
    Tests that the `BLOBHASH` opcode functions correctly when called in different
    contexts including:

    - `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.
    """
    blockchain_test(
        pre=opcode_context.get("pre"),
        blocks=[Block(txs=[opcode_context.get("tx")])],
        post=opcode_context.get("post"),
    )