Skip to content

test_worst_mcopy()

Documentation for tests/benchmark/test_worst_memory.py::test_worst_mcopy@88e9fb8f.

Generate fixtures for these test cases for Osaka with:

fill -v tests/benchmark/test_worst_memory.py::test_worst_mcopy -m benchmark

Test running a block filled with MCOPY executions.

Source code in tests/benchmark/test_worst_memory.py
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
@pytest.mark.parametrize(
    "size",
    [
        pytest.param(0, id="0 bytes"),
        pytest.param(100, id="100 bytes"),
        pytest.param(10 * 1024, id="10KiB"),
        pytest.param(1024 * 1024, id="1MiB"),
    ],
)
@pytest.mark.parametrize(
    "fixed_src_dst",
    [
        True,
        False,
    ],
)
def test_worst_mcopy(
    benchmark_test: BenchmarkTestFiller,
    size: int,
    fixed_src_dst: bool,
) -> None:
    """Test running a block filled with MCOPY executions."""
    src_dst = 0 if fixed_src_dst else Op.MOD(Op.GAS, 7)
    attack_block = Op.MCOPY(src_dst, src_dst, size)

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

Parametrized Test Cases

This test case is only parametrized by fork.

Test ID (Abbreviated) fixed_src_dst size
...fork_Prague-blockchain_test-fixed_src_dst_True-0 bytes True 0
...fork_Prague-blockchain_test-fixed_src_dst_True-100 bytes True 100
...fork_Prague-blockchain_test-fixed_src_dst_True-10KiB True 10240
...fork_Prague-blockchain_test-fixed_src_dst_True-1MiB True 1048576
...fork_Prague-blockchain_test-fixed_src_dst_False-0 bytes False 0
...fork_Prague-blockchain_test-fixed_src_dst_False-100 bytes False 100
...fork_Prague-blockchain_test-fixed_src_dst_False-10KiB False 10240
...fork_Prague-blockchain_test-fixed_src_dst_False-1MiB False 1048576
...fork_Osaka-blockchain_test-fixed_src_dst_True-0 bytes True 0
...fork_Osaka-blockchain_test-fixed_src_dst_True-100 bytes True 100
...fork_Osaka-blockchain_test-fixed_src_dst_True-10KiB True 10240
...fork_Osaka-blockchain_test-fixed_src_dst_True-1MiB True 1048576
...fork_Osaka-blockchain_test-fixed_src_dst_False-0 bytes False 0
...fork_Osaka-blockchain_test-fixed_src_dst_False-100 bytes False 100
...fork_Osaka-blockchain_test-fixed_src_dst_False-10KiB False 10240
...fork_Osaka-blockchain_test-fixed_src_dst_False-1MiB False 1048576