Skip to content

test_worst_zero_param()

Documentation for tests/zkevm/test_worst_compute.py::test_worst_zero_param@64f949d0.

Generate fixtures for these test cases for Prague with:

fill -v tests/zkevm/test_worst_compute.py::test_worst_zero_param --fork Prague

Test running a block with as many zero-parameter opcodes as possible.

Source code in tests/zkevm/test_worst_compute.py
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
@pytest.mark.valid_from("Cancun")
@pytest.mark.parametrize(
    "opcode",
    [
        Op.ADDRESS,
        Op.ORIGIN,
        Op.CALLER,
        Op.CODESIZE,
        Op.GASPRICE,
        Op.COINBASE,
        Op.TIMESTAMP,
        Op.NUMBER,
        Op.PREVRANDAO,
        Op.GASLIMIT,
        Op.CHAINID,
        Op.BASEFEE,
        Op.BLOBBASEFEE,
        Op.GAS,
        # Note that other 0-param opcodes are covered in separate tests.
    ],
)
def test_worst_zero_param(
    state_test: StateTestFiller,
    pre: Alloc,
    opcode: Op,
    fork: Fork,
):
    """Test running a block with as many zero-parameter opcodes as possible."""
    env = Environment()

    opcode_sequence = opcode * fork.max_stack_height()
    target_contract_address = pre.deploy_contract(code=opcode_sequence)

    calldata = Bytecode()
    attack_block = Op.POP(Op.STATICCALL(Op.GAS, target_contract_address, 0, 0, 0, 0))
    code = code_loop_precompile_call(calldata, attack_block, fork)
    code_address = pre.deploy_contract(code=code)

    tx = Transaction(
        to=code_address,
        gas_limit=env.gas_limit,
        sender=pre.fund_eoa(),
    )

    state_test(
        env=env,
        pre=pre,
        post={},
        tx=tx,
    )

Parametrized Test Cases

The interactive table below is also available as a standalone page.

Test ID (Abbreviated) opcode
...fork_Cancun-state_test-opcode_ADDRESS ADDRESS
...fork_Cancun-state_test-opcode_ORIGIN ORIGIN
...fork_Cancun-state_test-opcode_CALLER CALLER
...fork_Cancun-state_test-opcode_CODESIZE CODESIZE
...fork_Cancun-state_test-opcode_GASPRICE GASPRICE
...fork_Cancun-state_test-opcode_COINBASE COINBASE
...fork_Cancun-state_test-opcode_TIMESTAMP TIMESTAMP
...fork_Cancun-state_test-opcode_NUMBER NUMBER
...fork_Cancun-state_test-opcode_PREVRANDAO PREVRANDAO
...fork_Cancun-state_test-opcode_GASLIMIT GASLIMIT
...fork_Cancun-state_test-opcode_CHAINID CHAINID
...fork_Cancun-state_test-opcode_BASEFEE BASEFEE
...fork_Cancun-state_test-opcode_BLOBBASEFEE BLOBBASEFEE
...fork_Cancun-state_test-opcode_GAS GAS
...fork_Cancun-blockchain_test_from_state_test-opcode_ADDRESS ADDRESS
...fork_Cancun-blockchain_test_from_state_test-opcode_ORIGIN ORIGIN
...fork_Cancun-blockchain_test_from_state_test-opcode_CALLER CALLER
...fork_Cancun-blockchain_test_from_state_test-opcode_CODESIZE CODESIZE
...fork_Cancun-blockchain_test_from_state_test-opcode_GASPRICE GASPRICE
...fork_Cancun-blockchain_test_from_state_test-opcode_COINBASE COINBASE
...fork_Cancun-blockchain_test_from_state_test-opcode_TIMESTAMP TIMESTAMP
...fork_Cancun-blockchain_test_from_state_test-opcode_NUMBER NUMBER
...fork_Cancun-blockchain_test_from_state_test-opcode_PREVRANDAO PREVRANDAO
...fork_Cancun-blockchain_test_from_state_test-opcode_GASLIMIT GASLIMIT
...fork_Cancun-blockchain_test_from_state_test-opcode_CHAINID CHAINID
...fork_Cancun-blockchain_test_from_state_test-opcode_BASEFEE BASEFEE
...fork_Cancun-blockchain_test_from_state_test-opcode_BLOBBASEFEE BLOBBASEFEE
...fork_Cancun-blockchain_test_from_state_test-opcode_GAS GAS
...fork_Prague-state_test-opcode_ADDRESS ADDRESS
...fork_Prague-state_test-opcode_ORIGIN ORIGIN
...fork_Prague-state_test-opcode_CALLER CALLER
...fork_Prague-state_test-opcode_CODESIZE CODESIZE
...fork_Prague-state_test-opcode_GASPRICE GASPRICE
...fork_Prague-state_test-opcode_COINBASE COINBASE
...fork_Prague-state_test-opcode_TIMESTAMP TIMESTAMP
...fork_Prague-state_test-opcode_NUMBER NUMBER
...fork_Prague-state_test-opcode_PREVRANDAO PREVRANDAO
...fork_Prague-state_test-opcode_GASLIMIT GASLIMIT
...fork_Prague-state_test-opcode_CHAINID CHAINID
...fork_Prague-state_test-opcode_BASEFEE BASEFEE
...fork_Prague-state_test-opcode_BLOBBASEFEE BLOBBASEFEE
...fork_Prague-state_test-opcode_GAS GAS
...fork_Prague-blockchain_test_from_state_test-opcode_ADDRESS ADDRESS
...fork_Prague-blockchain_test_from_state_test-opcode_ORIGIN ORIGIN
...fork_Prague-blockchain_test_from_state_test-opcode_CALLER CALLER
...fork_Prague-blockchain_test_from_state_test-opcode_CODESIZE CODESIZE
...fork_Prague-blockchain_test_from_state_test-opcode_GASPRICE GASPRICE
...fork_Prague-blockchain_test_from_state_test-opcode_COINBASE COINBASE
...fork_Prague-blockchain_test_from_state_test-opcode_TIMESTAMP TIMESTAMP
...fork_Prague-blockchain_test_from_state_test-opcode_NUMBER NUMBER
...fork_Prague-blockchain_test_from_state_test-opcode_PREVRANDAO PREVRANDAO
...fork_Prague-blockchain_test_from_state_test-opcode_GASLIMIT GASLIMIT
...fork_Prague-blockchain_test_from_state_test-opcode_CHAINID CHAINID
...fork_Prague-blockchain_test_from_state_test-opcode_BASEFEE BASEFEE
...fork_Prague-blockchain_test_from_state_test-opcode_BLOBBASEFEE BLOBBASEFEE
...fork_Prague-blockchain_test_from_state_test-opcode_GAS GAS
...fork_Osaka-state_test-opcode_ADDRESS ADDRESS
...fork_Osaka-state_test-opcode_ORIGIN ORIGIN
...fork_Osaka-state_test-opcode_CALLER CALLER
...fork_Osaka-state_test-opcode_CODESIZE CODESIZE
...fork_Osaka-state_test-opcode_GASPRICE GASPRICE
...fork_Osaka-state_test-opcode_COINBASE COINBASE
...fork_Osaka-state_test-opcode_TIMESTAMP TIMESTAMP
...fork_Osaka-state_test-opcode_NUMBER NUMBER
...fork_Osaka-state_test-opcode_PREVRANDAO PREVRANDAO
...fork_Osaka-state_test-opcode_GASLIMIT GASLIMIT
...fork_Osaka-state_test-opcode_CHAINID CHAINID
...fork_Osaka-state_test-opcode_BASEFEE BASEFEE
...fork_Osaka-state_test-opcode_BLOBBASEFEE BLOBBASEFEE
...fork_Osaka-state_test-opcode_GAS GAS
...fork_Osaka-blockchain_test_from_state_test-opcode_ADDRESS ADDRESS
...fork_Osaka-blockchain_test_from_state_test-opcode_ORIGIN ORIGIN
...fork_Osaka-blockchain_test_from_state_test-opcode_CALLER CALLER
...fork_Osaka-blockchain_test_from_state_test-opcode_CODESIZE CODESIZE
...fork_Osaka-blockchain_test_from_state_test-opcode_GASPRICE GASPRICE
...fork_Osaka-blockchain_test_from_state_test-opcode_COINBASE COINBASE
...fork_Osaka-blockchain_test_from_state_test-opcode_TIMESTAMP TIMESTAMP
...fork_Osaka-blockchain_test_from_state_test-opcode_NUMBER NUMBER
...fork_Osaka-blockchain_test_from_state_test-opcode_PREVRANDAO PREVRANDAO
...fork_Osaka-blockchain_test_from_state_test-opcode_GASLIMIT GASLIMIT
...fork_Osaka-blockchain_test_from_state_test-opcode_CHAINID CHAINID
...fork_Osaka-blockchain_test_from_state_test-opcode_BASEFEE BASEFEE
...fork_Osaka-blockchain_test_from_state_test-opcode_BLOBBASEFEE BLOBBASEFEE
...fork_Osaka-blockchain_test_from_state_test-opcode_GAS GAS