Skip to content

test_blobhash_multiple_txs_in_block()

Documentation for tests/cancun/eip4844_blobs/test_blobhash_opcode.py::test_blobhash_multiple_txs_in_block@0f7c73a7.

Generate fixtures for these test cases for Prague with:

fill -v tests/cancun/eip4844_blobs/test_blobhash_opcode.py::test_blobhash_multiple_txs_in_block --fork Prague

Tests that the BLOBHASH opcode returns the appropriate values when there is more than 1 blob tx type within a block (for tx types 2 and 3).

Scenarios involve tx type 3 followed by tx type 2 running the same code within a block, including the opposite.

Source code in tests/cancun/eip4844_blobs/test_blobhash_opcode.py
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
393
394
395
396
397
398
399
400
401
402
def test_blobhash_multiple_txs_in_block(
    pre: Alloc,
    fork: Fork,
    blockchain_test: BlockchainTestFiller,
    max_blobs_per_block: int,
):
    """
    Tests that the `BLOBHASH` opcode returns the appropriate values when there
    is more than 1 blob tx type within a block (for tx types 2 and 3).

    Scenarios involve tx type 3 followed by tx type 2 running the same code
    within a block, including the opposite.
    """
    blobhash_bytecode = BlobhashScenario.generate_blobhash_bytecode(
        scenario_name="single_valid", max_blobs_per_block=max_blobs_per_block
    )
    addresses = [pre.deploy_contract(blobhash_bytecode) for _ in range(4)]
    sender = pre.fund_eoa()

    def blob_tx(address: Address, tx_type: int):
        return Transaction(
            ty=tx_type,
            sender=sender,
            to=address,
            data=Hash(0),
            gas_limit=500_000,
            access_list=[] if tx_type >= 1 else None,
            max_fee_per_blob_gas=(fork.min_base_fee_per_blob_gas() * 10) if tx_type >= 3 else None,
            blob_versioned_hashes=random_blob_hashes[0:max_blobs_per_block]
            if tx_type >= 3
            else None,
        )

    blocks = [
        Block(
            txs=[
                blob_tx(address=addresses[0], tx_type=3),
                blob_tx(address=addresses[0], tx_type=2),
            ]
        ),
        Block(
            txs=[
                blob_tx(address=addresses[1], tx_type=2),
                blob_tx(address=addresses[1], tx_type=3),
            ]
        ),
        Block(
            txs=[
                blob_tx(address=addresses[2], tx_type=2),
                blob_tx(address=addresses[3], tx_type=3),
            ],
        ),
    ]
    post = {
        Address(address): Account(
            storage={i: random_blob_hashes[i] for i in range(max_blobs_per_block)}
        )
        if address in (addresses[1], addresses[3])
        else Account(storage={i: 0 for i in range(max_blobs_per_block)})
        for address in addresses
    }
    blockchain_test(
        pre=pre,
        blocks=blocks,
        post=post,
    )

Parametrized Test Cases

This test case is only parametrized by fork.

Test ID (Abbreviated)
...fork_Cancun-blockchain_test
...fork_Prague-blockchain_test
...fork_Osaka-blockchain_test