Skip to content

test_worst_depth_get_deepest()

Documentation for tests/benchmark/stateful/bloatnet/depth_benchmarks/test_deep_branch.py::test_worst_depth_get_deepest@892e6d1e.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/benchmark/stateful/bloatnet/depth_benchmarks/test_deep_branch.py::test_worst_depth_get_deepest --gas-benchmark-values 1

BloatNet worst-case SLOAD benchmark with deep CREATE2-derived contracts.

This benchmark calls getDeepest() on pre-mined contracts and validates inside the orchestrator that every call succeeds and returns the expected value. Fill mode requires the exact constructor-initialized value 1, while execute mode only requires a non-zero value to tolerate reused deterministic deployments on a dirty chain.

Source code in tests/benchmark/stateful/bloatnet/depth_benchmarks/test_deep_branch.py
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
@pytest.mark.parametrize(
    "storage_depth,account_depth",
    DEPTH_BENCHMARK_CASES,
)
def test_worst_depth_get_deepest(
    benchmark_test: BenchmarkTestFiller,
    fork: Fork,
    pre: Alloc,
    request: pytest.FixtureRequest,
    gas_benchmark_value: int,
    storage_depth: int,
    account_depth: int,
) -> None:
    """
    BloatNet worst-case SLOAD benchmark with deep CREATE2-derived contracts.

    This benchmark calls ``getDeepest()`` on pre-mined contracts and validates
    inside the orchestrator that every call succeeds and returns the expected
    value. Fill mode requires the exact constructor-initialized value ``1``,
    while execute mode only requires a non-zero value to tolerate reused
    deterministic deployments on a dirty chain.
    """
    mined_contract_file = MinedContractFile.load(storage_depth, account_depth)
    exact_expected_value = not is_execute_mode(request)
    get_deepest_orchestrator_bytecode = (
        build_get_deepest_orchestrator_bytecode(
            get_factory_address(fork),
            exact_expected_value=exact_expected_value,
        )
    )

    orchestrator_address = pre.deterministic_deploy_contract(
        deploy_code=get_deepest_orchestrator_bytecode
    )
    print(f"  Read orchestrator will be deployed at: {orchestrator_address}")

    def calldata(iteration_count: int, start_iteration: int) -> bytes:
        end_iteration = start_iteration + iteration_count
        return (
            Hash(start_iteration)
            + Hash(end_iteration)
            + mined_contract_file.initcode_hash
        )

    contracts_required = sum(
        get_deepest_orchestrator_bytecode.tx_iterations_by_gas_limit(
            fork=fork,
            gas_limit=gas_benchmark_value,
            start_iteration=0,
            calldata=calldata,
        )
    )

    deploy_required_mined_contracts(
        pre=pre,
        mined_contract_file=mined_contract_file,
        contracts_required=contracts_required,
        storage_depth=storage_depth,
        account_depth=account_depth,
    )

    sender = pre.fund_eoa()
    read_txs: list[TransactionWithCost] = list(
        get_deepest_orchestrator_bytecode.transactions_by_gas_limit(
            fork=fork,
            gas_limit=gas_benchmark_value,
            start_iteration=0,
            sender=sender,
            to=orchestrator_address,
            calldata=calldata,
        )
    )

    total_gas_cost = sum(tx.gas_cost for tx in read_txs)

    benchmark_test(
        pre=pre,
        blocks=[Block(txs=read_txs)],
        expected_benchmark_gas_used=total_gas_cost,
        expected_receipt_status=1,
    )

Parametrized Test Cases

This test generates 13 parametrized test cases across 3 forks.