Skip to content

test_worst_memory_access()

Documentation for tests/benchmark/test_worst_compute.py::test_worst_memory_access@88e9fb8f.

Generate fixtures for these test cases for Osaka with:

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

Test running a block with as many memory access instructions as possible.

Source code in tests/benchmark/test_worst_compute.py
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
@pytest.mark.parametrize("opcode", [Op.MLOAD, Op.MSTORE, Op.MSTORE8])
@pytest.mark.parametrize("offset", [0, 1, 31])
@pytest.mark.parametrize("offset_initialized", [True, False])
@pytest.mark.parametrize("big_memory_expansion", [True, False])
def test_worst_memory_access(
    benchmark_test: BenchmarkTestFiller,
    opcode: Op,
    offset: int,
    offset_initialized: bool,
    big_memory_expansion: bool,
) -> None:
    """
    Test running a block with as many memory access instructions as
    possible.
    """
    mem_exp_code = Op.MSTORE8(10 * 1024, 1) if big_memory_expansion else Bytecode()
    offset_set_code = Op.MSTORE(offset, 43) if offset_initialized else Bytecode()
    setup = mem_exp_code + offset_set_code + Op.PUSH1(42) + Op.PUSH1(offset)

    attack_block = Op.POP(Op.MLOAD(Op.DUP1)) if opcode == Op.MLOAD else opcode(Op.DUP2, Op.DUP2)

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

Parametrized Test Cases

This test case is only parametrized by fork.

Test ID (Abbreviated) big_memory_expansion offset_initialized offset opcode
...fork_Prague-blockchain_test-big_memory_expansion_True-offset_initialized_True-offset_0-opcode_MLOAD True True 0 MLOAD
...fork_Prague-blockchain_test-big_memory_expansion_True-offset_initialized_True-offset_0-opcode_MSTORE True True 0 MSTORE
...fork_Prague-blockchain_test-big_memory_expansion_True-offset_initialized_True-offset_0-opcode_MSTORE8 True True 0 MSTORE8
...fork_Prague-blockchain_test-big_memory_expansion_True-offset_initialized_True-offset_1-opcode_MLOAD True True 1 MLOAD
...fork_Prague-blockchain_test-big_memory_expansion_True-offset_initialized_True-offset_1-opcode_MSTORE True True 1 MSTORE
...fork_Prague-blockchain_test-big_memory_expansion_True-offset_initialized_True-offset_1-opcode_MSTORE8 True True 1 MSTORE8
...fork_Prague-blockchain_test-big_memory_expansion_True-offset_initialized_True-offset_31-opcode_MLOAD True True 31 MLOAD
...fork_Prague-blockchain_test-big_memory_expansion_True-offset_initialized_True-offset_31-opcode_MSTORE True True 31 MSTORE
...fork_Prague-blockchain_test-big_memory_expansion_True-offset_initialized_True-offset_31-opcode_MSTORE8 True True 31 MSTORE8
...fork_Prague-blockchain_test-big_memory_expansion_True-offset_initialized_False-offset_0-opcode_MLOAD True False 0 MLOAD
...fork_Prague-blockchain_test-big_memory_expansion_True-offset_initialized_False-offset_0-opcode_MSTORE True False 0 MSTORE
...fork_Prague-blockchain_test-big_memory_expansion_True-offset_initialized_False-offset_0-opcode_MSTORE8 True False 0 MSTORE8
...fork_Prague-blockchain_test-big_memory_expansion_True-offset_initialized_False-offset_1-opcode_MLOAD True False 1 MLOAD
...fork_Prague-blockchain_test-big_memory_expansion_True-offset_initialized_False-offset_1-opcode_MSTORE True False 1 MSTORE
...fork_Prague-blockchain_test-big_memory_expansion_True-offset_initialized_False-offset_1-opcode_MSTORE8 True False 1 MSTORE8
...fork_Prague-blockchain_test-big_memory_expansion_True-offset_initialized_False-offset_31-opcode_MLOAD True False 31 MLOAD
...fork_Prague-blockchain_test-big_memory_expansion_True-offset_initialized_False-offset_31-opcode_MSTORE True False 31 MSTORE
...fork_Prague-blockchain_test-big_memory_expansion_True-offset_initialized_False-offset_31-opcode_MSTORE8 True False 31 MSTORE8
...fork_Prague-blockchain_test-big_memory_expansion_False-offset_initialized_True-offset_0-opcode_MLOAD False True 0 MLOAD
...fork_Prague-blockchain_test-big_memory_expansion_False-offset_initialized_True-offset_0-opcode_MSTORE False True 0 MSTORE
...fork_Prague-blockchain_test-big_memory_expansion_False-offset_initialized_True-offset_0-opcode_MSTORE8 False True 0 MSTORE8
...fork_Prague-blockchain_test-big_memory_expansion_False-offset_initialized_True-offset_1-opcode_MLOAD False True 1 MLOAD
...fork_Prague-blockchain_test-big_memory_expansion_False-offset_initialized_True-offset_1-opcode_MSTORE False True 1 MSTORE
...fork_Prague-blockchain_test-big_memory_expansion_False-offset_initialized_True-offset_1-opcode_MSTORE8 False True 1 MSTORE8
...fork_Prague-blockchain_test-big_memory_expansion_False-offset_initialized_True-offset_31-opcode_MLOAD False True 31 MLOAD
...fork_Prague-blockchain_test-big_memory_expansion_False-offset_initialized_True-offset_31-opcode_MSTORE False True 31 MSTORE
...fork_Prague-blockchain_test-big_memory_expansion_False-offset_initialized_True-offset_31-opcode_MSTORE8 False True 31 MSTORE8
...fork_Prague-blockchain_test-big_memory_expansion_False-offset_initialized_False-offset_0-opcode_MLOAD False False 0 MLOAD
...fork_Prague-blockchain_test-big_memory_expansion_False-offset_initialized_False-offset_0-opcode_MSTORE False False 0 MSTORE
...fork_Prague-blockchain_test-big_memory_expansion_False-offset_initialized_False-offset_0-opcode_MSTORE8 False False 0 MSTORE8
...fork_Prague-blockchain_test-big_memory_expansion_False-offset_initialized_False-offset_1-opcode_MLOAD False False 1 MLOAD
...fork_Prague-blockchain_test-big_memory_expansion_False-offset_initialized_False-offset_1-opcode_MSTORE False False 1 MSTORE
...fork_Prague-blockchain_test-big_memory_expansion_False-offset_initialized_False-offset_1-opcode_MSTORE8 False False 1 MSTORE8
...fork_Prague-blockchain_test-big_memory_expansion_False-offset_initialized_False-offset_31-opcode_MLOAD False False 31 MLOAD
...fork_Prague-blockchain_test-big_memory_expansion_False-offset_initialized_False-offset_31-opcode_MSTORE False False 31 MSTORE
...fork_Prague-blockchain_test-big_memory_expansion_False-offset_initialized_False-offset_31-opcode_MSTORE8 False False 31 MSTORE8
...fork_Osaka-blockchain_test-big_memory_expansion_True-offset_initialized_True-offset_0-opcode_MLOAD True True 0 MLOAD
...fork_Osaka-blockchain_test-big_memory_expansion_True-offset_initialized_True-offset_0-opcode_MSTORE True True 0 MSTORE
...fork_Osaka-blockchain_test-big_memory_expansion_True-offset_initialized_True-offset_0-opcode_MSTORE8 True True 0 MSTORE8
...fork_Osaka-blockchain_test-big_memory_expansion_True-offset_initialized_True-offset_1-opcode_MLOAD True True 1 MLOAD
...fork_Osaka-blockchain_test-big_memory_expansion_True-offset_initialized_True-offset_1-opcode_MSTORE True True 1 MSTORE
...fork_Osaka-blockchain_test-big_memory_expansion_True-offset_initialized_True-offset_1-opcode_MSTORE8 True True 1 MSTORE8
...fork_Osaka-blockchain_test-big_memory_expansion_True-offset_initialized_True-offset_31-opcode_MLOAD True True 31 MLOAD
...fork_Osaka-blockchain_test-big_memory_expansion_True-offset_initialized_True-offset_31-opcode_MSTORE True True 31 MSTORE
...fork_Osaka-blockchain_test-big_memory_expansion_True-offset_initialized_True-offset_31-opcode_MSTORE8 True True 31 MSTORE8
...fork_Osaka-blockchain_test-big_memory_expansion_True-offset_initialized_False-offset_0-opcode_MLOAD True False 0 MLOAD
...fork_Osaka-blockchain_test-big_memory_expansion_True-offset_initialized_False-offset_0-opcode_MSTORE True False 0 MSTORE
...fork_Osaka-blockchain_test-big_memory_expansion_True-offset_initialized_False-offset_0-opcode_MSTORE8 True False 0 MSTORE8
...fork_Osaka-blockchain_test-big_memory_expansion_True-offset_initialized_False-offset_1-opcode_MLOAD True False 1 MLOAD
...fork_Osaka-blockchain_test-big_memory_expansion_True-offset_initialized_False-offset_1-opcode_MSTORE True False 1 MSTORE
...fork_Osaka-blockchain_test-big_memory_expansion_True-offset_initialized_False-offset_1-opcode_MSTORE8 True False 1 MSTORE8
...fork_Osaka-blockchain_test-big_memory_expansion_True-offset_initialized_False-offset_31-opcode_MLOAD True False 31 MLOAD
...fork_Osaka-blockchain_test-big_memory_expansion_True-offset_initialized_False-offset_31-opcode_MSTORE True False 31 MSTORE
...fork_Osaka-blockchain_test-big_memory_expansion_True-offset_initialized_False-offset_31-opcode_MSTORE8 True False 31 MSTORE8
...fork_Osaka-blockchain_test-big_memory_expansion_False-offset_initialized_True-offset_0-opcode_MLOAD False True 0 MLOAD
...fork_Osaka-blockchain_test-big_memory_expansion_False-offset_initialized_True-offset_0-opcode_MSTORE False True 0 MSTORE
...fork_Osaka-blockchain_test-big_memory_expansion_False-offset_initialized_True-offset_0-opcode_MSTORE8 False True 0 MSTORE8
...fork_Osaka-blockchain_test-big_memory_expansion_False-offset_initialized_True-offset_1-opcode_MLOAD False True 1 MLOAD
...fork_Osaka-blockchain_test-big_memory_expansion_False-offset_initialized_True-offset_1-opcode_MSTORE False True 1 MSTORE
...fork_Osaka-blockchain_test-big_memory_expansion_False-offset_initialized_True-offset_1-opcode_MSTORE8 False True 1 MSTORE8
...fork_Osaka-blockchain_test-big_memory_expansion_False-offset_initialized_True-offset_31-opcode_MLOAD False True 31 MLOAD
...fork_Osaka-blockchain_test-big_memory_expansion_False-offset_initialized_True-offset_31-opcode_MSTORE False True 31 MSTORE
...fork_Osaka-blockchain_test-big_memory_expansion_False-offset_initialized_True-offset_31-opcode_MSTORE8 False True 31 MSTORE8
...fork_Osaka-blockchain_test-big_memory_expansion_False-offset_initialized_False-offset_0-opcode_MLOAD False False 0 MLOAD
...fork_Osaka-blockchain_test-big_memory_expansion_False-offset_initialized_False-offset_0-opcode_MSTORE False False 0 MSTORE
...fork_Osaka-blockchain_test-big_memory_expansion_False-offset_initialized_False-offset_0-opcode_MSTORE8 False False 0 MSTORE8
...fork_Osaka-blockchain_test-big_memory_expansion_False-offset_initialized_False-offset_1-opcode_MLOAD False False 1 MLOAD
...fork_Osaka-blockchain_test-big_memory_expansion_False-offset_initialized_False-offset_1-opcode_MSTORE False False 1 MSTORE
...fork_Osaka-blockchain_test-big_memory_expansion_False-offset_initialized_False-offset_1-opcode_MSTORE8 False False 1 MSTORE8
...fork_Osaka-blockchain_test-big_memory_expansion_False-offset_initialized_False-offset_31-opcode_MLOAD False False 31 MLOAD
...fork_Osaka-blockchain_test-big_memory_expansion_False-offset_initialized_False-offset_31-opcode_MSTORE False False 31 MSTORE
...fork_Osaka-blockchain_test-big_memory_expansion_False-offset_initialized_False-offset_31-opcode_MSTORE8 False False 31 MSTORE8