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@83970623.

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
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
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
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=3_000_000,
            gas_price=10 if tx_type < 2 else None,
            access_list=[] if tx_type >= 1 else None,
            max_fee_per_gas=10,
            max_priority_fee_per_gas=10,
            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