Skip to content

test_extcodecopy_warm()

Documentation for tests/benchmark/compute/instruction/test_account_query.py::test_extcodecopy_warm@02aafd78.

Generate fixtures for these test cases for Bogota with:

fill -v tests/benchmark/compute/instruction/test_account_query.py::test_extcodecopy_warm --gas-benchmark-values 1

Benchmark EXTCODECOPY instruction.

Source code in tests/benchmark/compute/instruction/test_account_query.py
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
@pytest.mark.repricing(copy_size=512)
@pytest.mark.parametrize(
    "copy_size",
    [0, 32, 256, 512, 1024, pytest.param(None, id="copy_size_max")],
)
def test_extcodecopy_warm(
    benchmark_test: BenchmarkTestFiller,
    pre: Alloc,
    fork: Fork,
    copy_size: int | None,
) -> None:
    """Benchmark EXTCODECOPY instruction."""
    if copy_size is None:
        copy_size = fork.max_code_size()

    copied_contract_address = pre.deploy_contract(
        code=Op.JUMPDEST * copy_size,
    )

    benchmark_test(
        target_opcode=Op.EXTCODECOPY,
        code_generator=JumpLoopGenerator(
            setup=Op.PUSH10(copy_size) + Op.PUSH20(copied_contract_address),
            attack_block=Op.EXTCODECOPY(Op.DUP4, 0, 0, Op.DUP2),
        ),
    )

Parametrized Test Cases

This test generates 6 parametrized test cases across 4 forks.