-
Notifications
You must be signed in to change notification settings - Fork 415
feat(test-benchmark): add terminating opcode benchmark #2027
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: forks/amsterdam
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,8 +2,11 @@ | |||||||||
|
|
||||||||||
| import pytest | ||||||||||
| from execution_testing import ( | ||||||||||
| Alloc, | ||||||||||
| BenchmarkTestFiller, | ||||||||||
| Bytecode, | ||||||||||
| Environment, | ||||||||||
| ExtCallGenerator, | ||||||||||
| Fork, | ||||||||||
| JumpLoopGenerator, | ||||||||||
| Op, | ||||||||||
|
|
@@ -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) | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 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
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
It's a tiny bit more explicit. |
||||||||||
| else: | ||||||||||
| attack_block = opcode | ||||||||||
|
|
||||||||||
| benchmark_test( | ||||||||||
| code_generator=ExtCallGenerator( | ||||||||||
| setup=setup, | ||||||||||
| attack_block=attack_block, | ||||||||||
| ), | ||||||||||
| ) | ||||||||||
There was a problem hiding this comment.
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?