diff --git a/tests/benchmark/test_worst_compute.py b/tests/benchmark/test_worst_compute.py index e512ec0aa57..758d6d8ee35 100644 --- a/tests/benchmark/test_worst_compute.py +++ b/tests/benchmark/test_worst_compute.py @@ -1159,6 +1159,73 @@ def test_worst_jumps(state_test: StateTestFiller, pre: Alloc): ) +@pytest.mark.zkevm +@pytest.mark.valid_from("Cancun") +@pytest.mark.slow +def test_worst_jumpi_fallthrough( + state_test: StateTestFiller, + pre: Alloc, + fork: Fork, +): + """Test running a JUMPI-intensive contract with fallthrough.""" + env = Environment() + max_code_size = fork.max_code_size() + + def jumpi_seq(): + return Op.JUMPI(Op.PUSH0, Op.PUSH0) + + prefix_seq = Op.JUMPDEST + suffix_seq = Op.JUMP(Op.PUSH0) + bytes_per_seq = len(jumpi_seq()) + seqs_per_call = (max_code_size - len(prefix_seq) - len(suffix_seq)) // bytes_per_seq + + # Create and deploy the jumpi-intensive contract + jumpis_code = prefix_seq + jumpi_seq() * seqs_per_call + suffix_seq + assert len(jumpis_code) <= max_code_size + + jumpis_address = pre.deploy_contract(code=bytes(jumpis_code)) + + tx = Transaction( + to=jumpis_address, + gas_limit=env.gas_limit, + sender=pre.fund_eoa(), + ) + + state_test( + env=env, + pre=pre, + post={}, + tx=tx, + ) + + +@pytest.mark.zkevm +@pytest.mark.valid_from("Cancun") +@pytest.mark.slow +def test_worst_jumpis( + state_test: StateTestFiller, + pre: Alloc, +): + """Test running a JUMPI-intensive contract.""" + env = Environment() + + jumpi_code = Op.JUMPDEST + Op.JUMPI(Op.PUSH0, Op.NUMBER) + jumpi_address = pre.deploy_contract(jumpi_code) + + tx = Transaction( + to=jumpi_address, + gas_limit=env.gas_limit, + sender=pre.fund_eoa(), + ) + + state_test( + env=env, + pre=pre, + post={}, + tx=tx, + ) + + @pytest.mark.valid_from("Cancun") @pytest.mark.slow def test_worst_jumpdests(state_test: StateTestFiller, pre: Alloc, fork: Fork):