Skip to content

test_worst_extcodecopy_warm()

Documentation for tests/benchmark/test_worst_stateful_opcodes.py::test_worst_extcodecopy_warm@v5.0.0.

Generate fixtures for these test cases for Osaka with:

fill -v tests/benchmark/test_worst_stateful_opcodes.py::test_worst_extcodecopy_warm --fork Osaka

Test running a block with as many wamr EXTCODECOPY work as possible.

Source code in tests/benchmark/test_worst_stateful_opcodes.py
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
@pytest.mark.valid_from("Cancun")
@pytest.mark.parametrize(
    "copied_size",
    [
        pytest.param(512, id="512"),
        pytest.param(1024, id="1KiB"),
        pytest.param(5 * 1024, id="5KiB"),
    ],
)
def test_worst_extcodecopy_warm(
    state_test: StateTestFiller,
    pre: Alloc,
    copied_size: int,
    gas_benchmark_value: int,
):
    """Test running a block with as many wamr EXTCODECOPY work as possible."""
    copied_contract_address = pre.deploy_contract(
        code=Op.JUMPDEST * copied_size,
    )

    execution_code = (
        Op.PUSH10(copied_size)
        + Op.PUSH20(copied_contract_address)
        + While(
            body=Op.EXTCODECOPY(Op.DUP4, 0, 0, Op.DUP2),
        )
    )
    execution_code_address = pre.deploy_contract(code=execution_code)
    tx = Transaction(
        to=execution_code_address,
        gas_limit=gas_benchmark_value,
        sender=pre.fund_eoa(),
    )

    state_test(
        pre=pre,
        post={},
        tx=tx,
    )

Parametrized Test Cases

The interactive table below is also available as a standalone page.

Test ID (Abbreviated) copied_size
...fork_Cancun-state_test-512 512
...fork_Cancun-state_test-1KiB 1024
...fork_Cancun-state_test-5KiB 5120
...fork_Cancun-blockchain_test_from_state_test-512 512
...fork_Cancun-blockchain_test_from_state_test-1KiB 1024
...fork_Cancun-blockchain_test_from_state_test-5KiB 5120
...fork_Prague-state_test-512 512
...fork_Prague-state_test-1KiB 1024
...fork_Prague-state_test-5KiB 5120
...fork_Prague-blockchain_test_from_state_test-512 512
...fork_Prague-blockchain_test_from_state_test-1KiB 1024
...fork_Prague-blockchain_test_from_state_test-5KiB 5120
...fork_Osaka-state_test-512 512
...fork_Osaka-state_test-1KiB 1024
...fork_Osaka-state_test-5KiB 5120
...fork_Osaka-blockchain_test_from_state_test-512 512
...fork_Osaka-blockchain_test_from_state_test-1KiB 1024
...fork_Osaka-blockchain_test_from_state_test-5KiB 5120