Skip to content

test_mcopy()

Documentation for tests/benchmark/compute/instruction/test_memory.py::test_mcopy@8db70f93.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/benchmark/compute/instruction/test_memory.py::test_mcopy --gas-benchmark-values 1

Benchmark MCOPY instruction.

Source code in tests/benchmark/compute/instruction/test_memory.py
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
@pytest.mark.repricing(fixed_src_dst=True)
@pytest.mark.parametrize(
    "mem_size",
    [0, 32, 256, 1024, 10 * 1024, 1024 * 1024],
)
@pytest.mark.parametrize("copy_size", [0, 32, 256, 1024])
@pytest.mark.parametrize(
    "fixed_src_dst",
    [
        True,
        False,
    ],
)
def test_mcopy(
    benchmark_test: BenchmarkTestFiller,
    mem_size: int,
    copy_size: int,
    fixed_src_dst: bool,
) -> None:
    """Benchmark MCOPY instruction."""
    src_dst = 0 if fixed_src_dst else Op.MOD(Op.GAS, 7)
    attack_block = Op.MCOPY(src_dst, src_dst, copy_size)

    mem_touch = (
        Op.MSTORE8(0, Op.GAS)
        + Op.MSTORE8(mem_size // 2, Op.GAS)
        + Op.MSTORE8(mem_size - 1, Op.GAS)
        if mem_size > 0
        else Bytecode()
    )
    benchmark_test(
        target_opcode=Op.MCOPY,
        code_generator=JumpLoopGenerator(
            attack_block=attack_block, cleanup=mem_touch
        ),
    )

Parametrized Test Cases

This test generates 48 parametrized test cases across 3 forks.