Skip to content

test_delegatecall_staticcall()

Documentation for tests/benchmark/compute/instruction/test_system.py::test_delegatecall_staticcall@814481c0.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/benchmark/compute/instruction/test_system.py::test_delegatecall_staticcall --gas-benchmark-values 1

Benchmark a contract that STATICCALL/DELEGATECALL accounts.

Source code in tests/benchmark/compute/instruction/test_system.py
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
@pytest.mark.parametrize("opcode", [Op.DELEGATECALL, Op.STATICCALL])
@pytest.mark.parametrize(
    "warm_access",
    [True, False],
)
def test_delegatecall_staticcall(
    benchmark_test: BenchmarkTestFiller,
    pre: Alloc,
    opcode: Op,
    warm_access: bool,
) -> None:
    """Benchmark a contract that STATICCALL/DELEGATECALL accounts."""
    target = pre.deploy_contract(code=Op.STOP)
    address = target if warm_access else Op.GAS

    benchmark_test(
        target_opcode=opcode,
        code_generator=JumpLoopGenerator(
            attack_block=Op.POP(
                opcode(
                    gas=Op.GAS,
                    address=address,
                )
            ),
        ),
    )

Parametrized Test Cases

This test generates 4 parametrized test cases across 3 forks.