From 94357637910e1a83557b5954c70dfaa25640d7bd Mon Sep 17 00:00:00 2001 From: Jochem Brouwer Date: Fri, 5 Dec 2025 00:40:43 +0100 Subject: [PATCH 1/2] feat(benchmarks): add keccak benchmark with updated memory --- tests/benchmark/compute/instruction/test_keccak.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/benchmark/compute/instruction/test_keccak.py b/tests/benchmark/compute/instruction/test_keccak.py index f117a17323..5d136d6bd0 100644 --- a/tests/benchmark/compute/instruction/test_keccak.py +++ b/tests/benchmark/compute/instruction/test_keccak.py @@ -70,17 +70,23 @@ def test_keccak_max_permutations( @pytest.mark.parametrize("mem_alloc", [b"", b"ff", b"ff" * 32]) @pytest.mark.parametrize("offset", [0, 31, 1024]) +@pytest.mark.parametrize("mem_update", [True, False]) def test_keccak( benchmark_test: BenchmarkTestFiller, offset: int, mem_alloc: bytes, + mem_update: bool ) -> None: """Benchmark KECCAK256 instruction with diff input data and offsets.""" + + code_hash = Op.SHA3(offset, Op.CALLDATASIZE) + attack_block = Op.MSTORE(Op.PUSH0, code_hash) if mem_update else Op.POP(code_hash) + benchmark_test( target_opcode=Op.SHA3, code_generator=JumpLoopGenerator( setup=Op.CALLDATACOPY(offset, Op.PUSH0, Op.CALLDATASIZE), - attack_block=Op.POP(Op.SHA3(offset, Op.CALLDATASIZE)), + attack_block=attack_block, tx_kwargs={"data": mem_alloc}, ), ) From 948c4966b5cec1f6aa4936db30b99ef681399041 Mon Sep 17 00:00:00 2001 From: fselmo Date: Fri, 6 Feb 2026 15:19:37 -0700 Subject: [PATCH 2/2] chore: fix lint --- tests/benchmark/compute/instruction/test_keccak.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/benchmark/compute/instruction/test_keccak.py b/tests/benchmark/compute/instruction/test_keccak.py index 5d136d6bd0..874ba139de 100644 --- a/tests/benchmark/compute/instruction/test_keccak.py +++ b/tests/benchmark/compute/instruction/test_keccak.py @@ -75,12 +75,13 @@ def test_keccak( benchmark_test: BenchmarkTestFiller, offset: int, mem_alloc: bytes, - mem_update: bool + mem_update: bool, ) -> None: """Benchmark KECCAK256 instruction with diff input data and offsets.""" - code_hash = Op.SHA3(offset, Op.CALLDATASIZE) - attack_block = Op.MSTORE(Op.PUSH0, code_hash) if mem_update else Op.POP(code_hash) + attack_block = ( + Op.MSTORE(Op.PUSH0, code_hash) if mem_update else Op.POP(code_hash) + ) benchmark_test( target_opcode=Op.SHA3,