Skip to content

test_worst_blockhash()

Documentation for tests/zkevm/test_worst_stateful_opcodes.py::test_worst_blockhash@64f949d0.

Generate fixtures for these test cases for Prague with:

fill -v tests/zkevm/test_worst_stateful_opcodes.py::test_worst_blockhash --fork Prague

Test running a block with as many blockhash accessing oldest allowed block as possible.

Source code in tests/zkevm/test_worst_stateful_opcodes.py
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
@pytest.mark.valid_from("Cancun")
@pytest.mark.slow()
def test_worst_blockhash(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
):
    """Test running a block with as many blockhash accessing oldest allowed block as possible."""
    env = Environment()

    # Create 256 dummy blocks to fill the blockhash window.
    blocks = [Block()] * 256

    # Always ask for the oldest allowed BLOCKHASH block.
    execution_code = Op.PUSH1(1) + While(
        body=Op.POP(Op.BLOCKHASH(Op.DUP1)),
    )
    execution_code_address = pre.deploy_contract(code=execution_code)
    op_tx = Transaction(
        to=execution_code_address,
        gas_limit=env.gas_limit,
        sender=pre.fund_eoa(),
    )
    blocks.append(Block(txs=[op_tx]))

    blockchain_test(
        genesis_environment=env,
        pre=pre,
        post={},
        blocks=blocks,
    )

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