Skip to content

test_worst_address_state_warm()

Documentation for tests/benchmark/test_worst_stateful_opcodes.py::test_worst_address_state_warm@88e9fb8f.

Generate fixtures for these test cases for Osaka with:

fill -v tests/benchmark/test_worst_stateful_opcodes.py::test_worst_address_state_warm -m benchmark

Test running a block with as many stateful opcodes doing warm access for an account.

Source code in tests/benchmark/test_worst_stateful_opcodes.py
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
@pytest.mark.parametrize(
    "opcode",
    [
        Op.BALANCE,
        Op.EXTCODESIZE,
        Op.EXTCODEHASH,
        Op.CALL,
        Op.CALLCODE,
        Op.DELEGATECALL,
        Op.STATICCALL,
    ],
)
@pytest.mark.parametrize(
    "absent_target",
    [
        True,
        False,
    ],
)
def test_worst_address_state_warm(
    benchmark_test: BenchmarkTestFiller,
    pre: Alloc,
    opcode: Op,
    absent_target: bool,
) -> None:
    """
    Test running a block with as many stateful opcodes doing warm access
    for an account.
    """
    # Setup
    target_addr = Address(100_000)
    post = {}
    if not absent_target:
        code = Op.STOP + Op.JUMPDEST * 100
        target_addr = pre.deploy_contract(balance=100, code=code)
        post[target_addr] = Account(balance=100, code=code)

    # Execution
    setup = Op.MSTORE(0, target_addr)
    attack_block = Op.POP(opcode(address=Op.MLOAD(0)))
    benchmark_test(
        post=post,
        code_generator=JumpLoopGenerator(setup=setup, attack_block=attack_block),
    )

Parametrized Test Cases

This test case is only parametrized by fork.

Test ID (Abbreviated) absent_target opcode
...fork_Prague-blockchain_test-absent_target_True-opcode_BALANCE True BALANCE
...fork_Prague-blockchain_test-absent_target_True-opcode_EXTCODESIZE True EXTCODESIZE
...fork_Prague-blockchain_test-absent_target_True-opcode_EXTCODEHASH True EXTCODEHASH
...fork_Prague-blockchain_test-absent_target_True-opcode_CALL True CALL
...fork_Prague-blockchain_test-absent_target_True-opcode_CALLCODE True CALLCODE
...fork_Prague-blockchain_test-absent_target_True-opcode_DELEGATECALL True DELEGATECALL
...fork_Prague-blockchain_test-absent_target_True-opcode_STATICCALL True STATICCALL
...fork_Prague-blockchain_test-absent_target_False-opcode_BALANCE False BALANCE
...fork_Prague-blockchain_test-absent_target_False-opcode_EXTCODESIZE False EXTCODESIZE
...fork_Prague-blockchain_test-absent_target_False-opcode_EXTCODEHASH False EXTCODEHASH
...fork_Prague-blockchain_test-absent_target_False-opcode_CALL False CALL
...fork_Prague-blockchain_test-absent_target_False-opcode_CALLCODE False CALLCODE
...fork_Prague-blockchain_test-absent_target_False-opcode_DELEGATECALL False DELEGATECALL
...fork_Prague-blockchain_test-absent_target_False-opcode_STATICCALL False STATICCALL
...fork_Osaka-blockchain_test-absent_target_True-opcode_BALANCE True BALANCE
...fork_Osaka-blockchain_test-absent_target_True-opcode_EXTCODESIZE True EXTCODESIZE
...fork_Osaka-blockchain_test-absent_target_True-opcode_EXTCODEHASH True EXTCODEHASH
...fork_Osaka-blockchain_test-absent_target_True-opcode_CALL True CALL
...fork_Osaka-blockchain_test-absent_target_True-opcode_CALLCODE True CALLCODE
...fork_Osaka-blockchain_test-absent_target_True-opcode_DELEGATECALL True DELEGATECALL
...fork_Osaka-blockchain_test-absent_target_True-opcode_STATICCALL True STATICCALL
...fork_Osaka-blockchain_test-absent_target_False-opcode_BALANCE False BALANCE
...fork_Osaka-blockchain_test-absent_target_False-opcode_EXTCODESIZE False EXTCODESIZE
...fork_Osaka-blockchain_test-absent_target_False-opcode_EXTCODEHASH False EXTCODEHASH
...fork_Osaka-blockchain_test-absent_target_False-opcode_CALL False CALL
...fork_Osaka-blockchain_test-absent_target_False-opcode_CALLCODE False CALLCODE
...fork_Osaka-blockchain_test-absent_target_False-opcode_DELEGATECALL False DELEGATECALL
...fork_Osaka-blockchain_test-absent_target_False-opcode_STATICCALL False STATICCALL