-
Notifications
You must be signed in to change notification settings - Fork 376
tests(benchmark): add missing scenario and optimization #1768
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
Changes from all commits
b5c2255
1b44dea
ac154c4
ca5d64a
2b6823a
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 |
|---|---|---|
|
|
@@ -22,6 +22,15 @@ def test_gas_op( | |
| ) | ||
|
|
||
|
|
||
| def test_pc_op( | ||
|
Collaborator
Author
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. We miss the benchmark for |
||
| benchmark_test: BenchmarkTestFiller, | ||
| ) -> None: | ||
| """Benchmark PC instruction.""" | ||
| benchmark_test( | ||
| code_generator=ExtCallGenerator(attack_block=Op.PC), | ||
| ) | ||
|
|
||
|
|
||
| def test_jumps( | ||
| benchmark_test: BenchmarkTestFiller, | ||
| pre: Alloc, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
|
|
||
| import math | ||
|
|
||
| import pytest | ||
| from execution_testing import ( | ||
| BenchmarkTestFiller, | ||
| Fork, | ||
|
|
@@ -15,15 +16,15 @@ | |
| KECCAK_RATE = 136 | ||
|
|
||
|
|
||
| def test_keccak( | ||
| def test_keccak_max_permutations( | ||
| benchmark_test: BenchmarkTestFiller, | ||
| fork: Fork, | ||
| gas_benchmark_value: int, | ||
| tx_gas_limit: int, | ||
| ) -> None: | ||
| """Benchmark KECCAK256 instruction.""" | ||
| """Benchmark KECCAK256 instruction to maximize permutations per block.""" | ||
| # Intrinsic gas cost is paid once. | ||
| intrinsic_gas_calculator = fork.transaction_intrinsic_cost_calculator() | ||
| available_gas = gas_benchmark_value - intrinsic_gas_calculator() | ||
| available_gas = tx_gas_limit - intrinsic_gas_calculator() | ||
|
|
||
| gsc = fork.gas_costs() | ||
| mem_exp_gas_calculator = fork.memory_expansion_gas_calculator() | ||
|
|
@@ -64,3 +65,20 @@ def test_keccak( | |
| attack_block=Op.POP(Op.SHA3(Op.PUSH0, Op.DUP1)), | ||
| ), | ||
| ) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("mem_alloc", [b"", b"ff", b"ff" * 32]) | ||
| @pytest.mark.parametrize("offset", [0, 31, 1024]) | ||
| def test_keccak( | ||
|
Comment on lines
+70
to
+72
Collaborator
Author
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. Instead of finding the optimal length, add a new case that parametrized initial memory layout and access offset. Request by gas repricing effort. |
||
| benchmark_test: BenchmarkTestFiller, | ||
| offset: int, | ||
| mem_alloc: bytes, | ||
| ) -> None: | ||
| """Benchmark KECCAK256 instruction with diff input data and offsets.""" | ||
| benchmark_test( | ||
| code_generator=JumpLoopGenerator( | ||
| setup=Op.CALLDATACOPY(offset, Op.PUSH0, Op.CALLDATASIZE), | ||
| attack_block=Op.POP(Op.SHA3(offset, Op.CALLDATASIZE)), | ||
| tx_kwargs={"data": mem_alloc}, | ||
| ), | ||
| ) | ||
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.
Adding extra BLOCKHASH operation for benchmarking, as it was one of the slowest operations.
Cases: