Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Test fixtures for use by clients are available for each release on the [Github r
- πŸ”€ Relabel `@pytest.mark.repricing` markers in benchmark tests to reflect configurations requested for gas repricing analysis ([#1971](https://github.com/ethereum/execution-specs/pull/1971)).
- ✨ New EIP-7702 test cases added ([#1974](https://github.com/ethereum/execution-specs/pull/1974)).
- ✨ Add missing benchmark configurations / opcode to benchmark tests for repricing analysis([#2006](https://github.com/ethereum/execution-specs/pull/2006)).
- ✨ Add terminating opcode benchmark in mix scenario ([#2027](https://github.com/ethereum/execution-specs/pull/2027)).

## [v5.4.0](https://github.com/ethereum/execution-spec-tests/releases/tag/v5.4.0) - 2025-12-07

Expand Down
9 changes: 9 additions & 0 deletions tests/benchmark/compute/instruction/test_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,12 @@ def test_push(
attack_block=opcode[1] if opcode.has_data_portion() else opcode
),
)


@pytest.mark.repricing
def test_pop(benchmark_test: BenchmarkTestFiller) -> None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be worth it here to create a "from max stack height" version here?
One where we first push fork.max_stack_height() elements, then pop them all and repeat?

"""Benchmark POP instruction."""
benchmark_test(
target_opcode=Op.POP,
code_generator=JumpLoopGenerator(attack_block=Op.POP(Op.PUSH0)),
)
39 changes: 39 additions & 0 deletions tests/benchmark/compute/scenario/test_mix_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

import pytest
from execution_testing import (
Alloc,
BenchmarkTestFiller,
Bytecode,
Environment,
ExtCallGenerator,
Fork,
JumpLoopGenerator,
Op,
Expand Down Expand Up @@ -85,3 +88,39 @@ def test_jumpdest_analysis(
tx_kwargs={"data": tx_data},
),
)


@pytest.mark.repricing
@pytest.mark.parametrize("mem_size", [0, 32, 256, 1024])
@pytest.mark.parametrize("return_size", [0, 32, 256, 1024])
@pytest.mark.parametrize(
"opcode", [Op.INVALID, Op.STOP, Op.RETURN, Op.REVERT, Op.SELFDESTRUCT]
)
def test_terminate_ops(
benchmark_test: BenchmarkTestFiller,
opcode: Op,
return_size: int,
mem_size: int,
pre: Alloc,
env: Environment,
) -> None:
"""Benchmark Terminating Operations."""
fee_recipient = pre.fund_eoa(amount=1)
env.fee_recipient = fee_recipient

setup = Op.MSTORE8(mem_size - 1, 1) if mem_size > 0 else Bytecode()

attack_block = Bytecode()
if opcode == Op.SELFDESTRUCT:
attack_block = Op.SELFDESTRUCT(Op.COINBASE)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case we are testing moving funds to a warm account, but would it be worth it to send to a cold and new account in another version of this test?

We can make the ExtCallGenerator send 1 wei with each call so that the selfdestruct actually has an effect too.

Perhaps self-destruct deserves its own test function.

elif opcode.popped_stack_items > 0:
attack_block = opcode(Op.PUSH0, return_size)
Comment on lines +116 to +117
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
elif opcode.popped_stack_items > 0:
attack_block = opcode(Op.PUSH0, return_size)
elif opcode.kwargs == ["offset", "size"]:
attack_block = opcode(offset=Op.PUSH0, size=return_size)

It's a tiny bit more explicit.

else:
attack_block = opcode

benchmark_test(
code_generator=ExtCallGenerator(
setup=setup,
attack_block=attack_block,
),
)
Loading