Skip to content

test_calldataload_chained()

Documentation for tests/benchmark/compute/instruction/test_call_context.py::test_calldataload_chained@02aafd78.

Generate fixtures for these test cases for Bogota with:

fill -v tests/benchmark/compute/instruction/test_call_context.py::test_calldataload_chained --gas-benchmark-values 1

Benchmark CALLDATALOAD taking its offset from the previous load.

The calldata is all zeros, so every load reads offset 0. An input of 1 to 31 bytes makes every load a partial, zero-padded word.

Source code in tests/benchmark/compute/instruction/test_call_context.py
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
@pytest.mark.repricing(calldata_size=31)
@pytest.mark.parametrize("calldata_size", [0, 31, 32])
def test_calldataload_chained(
    benchmark_test: BenchmarkTestFiller, calldata_size: int
) -> None:
    """
    Benchmark CALLDATALOAD taking its offset from the previous load.

    The calldata is all zeros, so every load reads offset 0. An input of 1
    to 31 bytes makes every load a partial, zero-padded word.
    """
    benchmark_test(
        target_opcode=Op.CALLDATALOAD,
        code_generator=JumpLoopGenerator(
            setup=Op.PUSH0,
            attack_block=Op.CALLDATALOAD,
            tx_kwargs={"data": b"\x00" * calldata_size},
        ),
    )

Parametrized Test Cases

This test generates 3 parametrized test cases across 4 forks.