Skip to content

test_worst_dup()

Documentation for tests/benchmark/test_worst_compute.py::test_worst_dup@e9958ed2.

Generate fixtures for these test cases for Osaka with:

fill -v tests/benchmark/test_worst_compute.py::test_worst_dup -m benchmark

Test running a block with as many DUP as possible.

Source code in tests/benchmark/test_worst_compute.py
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
@pytest.mark.parametrize(
    "opcode",
    [
        pytest.param(Op.DUP1),
        pytest.param(Op.DUP2),
        pytest.param(Op.DUP3),
        pytest.param(Op.DUP4),
        pytest.param(Op.DUP5),
        pytest.param(Op.DUP6),
        pytest.param(Op.DUP7),
        pytest.param(Op.DUP8),
        pytest.param(Op.DUP9),
        pytest.param(Op.DUP10),
        pytest.param(Op.DUP11),
        pytest.param(Op.DUP12),
        pytest.param(Op.DUP13),
        pytest.param(Op.DUP14),
        pytest.param(Op.DUP15),
        pytest.param(Op.DUP16),
    ],
)
def test_worst_dup(
    benchmark_test: BenchmarkTestFiller,
    pre: Alloc,
    fork: Fork,
    opcode: Op,
) -> None:
    """Test running a block with as many DUP as possible."""
    max_stack_height = fork.max_stack_height()

    min_stack_height = opcode.min_stack_height
    code = Op.PUSH0 * min_stack_height + opcode * (max_stack_height - min_stack_height)
    target_contract_address = pre.deploy_contract(code=code)

    attack_block = Op.POP(Op.STATICCALL(Op.GAS, target_contract_address, 0, 0, 0, 0))

    benchmark_test(
        code_generator=JumpLoopGenerator(attack_block=attack_block),
    )

Parametrized Test Cases

This test case is only parametrized by fork.

Test ID (Abbreviated) opcode
...fork_Prague-blockchain_test-opcode_DUP1 DUP1
...fork_Prague-blockchain_test-opcode_DUP2 DUP2
...fork_Prague-blockchain_test-opcode_DUP3 DUP3
...fork_Prague-blockchain_test-opcode_DUP4 DUP4
...fork_Prague-blockchain_test-opcode_DUP5 DUP5
...fork_Prague-blockchain_test-opcode_DUP6 DUP6
...fork_Prague-blockchain_test-opcode_DUP7 DUP7
...fork_Prague-blockchain_test-opcode_DUP8 DUP8
...fork_Prague-blockchain_test-opcode_DUP9 DUP9
...fork_Prague-blockchain_test-opcode_DUP10 DUP10
...fork_Prague-blockchain_test-opcode_DUP11 DUP11
...fork_Prague-blockchain_test-opcode_DUP12 DUP12
...fork_Prague-blockchain_test-opcode_DUP13 DUP13
...fork_Prague-blockchain_test-opcode_DUP14 DUP14
...fork_Prague-blockchain_test-opcode_DUP15 DUP15
...fork_Prague-blockchain_test-opcode_DUP16 DUP16
...fork_Osaka-blockchain_test-opcode_DUP1 DUP1
...fork_Osaka-blockchain_test-opcode_DUP2 DUP2
...fork_Osaka-blockchain_test-opcode_DUP3 DUP3
...fork_Osaka-blockchain_test-opcode_DUP4 DUP4
...fork_Osaka-blockchain_test-opcode_DUP5 DUP5
...fork_Osaka-blockchain_test-opcode_DUP6 DUP6
...fork_Osaka-blockchain_test-opcode_DUP7 DUP7
...fork_Osaka-blockchain_test-opcode_DUP8 DUP8
...fork_Osaka-blockchain_test-opcode_DUP9 DUP9
...fork_Osaka-blockchain_test-opcode_DUP10 DUP10
...fork_Osaka-blockchain_test-opcode_DUP11 DUP11
...fork_Osaka-blockchain_test-opcode_DUP12 DUP12
...fork_Osaka-blockchain_test-opcode_DUP13 DUP13
...fork_Osaka-blockchain_test-opcode_DUP14 DUP14
...fork_Osaka-blockchain_test-opcode_DUP15 DUP15
...fork_Osaka-blockchain_test-opcode_DUP16 DUP16