From 861606f13cff10d931ac48d158b7851a03eb4fdd Mon Sep 17 00:00:00 2001 From: Jochem Brouwer Date: Fri, 5 Dec 2025 00:40:43 +0100 Subject: [PATCH] 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 4cefa708a4..e1a47dd51d 100644 --- a/tests/benchmark/compute/instruction/test_keccak.py +++ b/tests/benchmark/compute/instruction/test_keccak.py @@ -72,16 +72,22 @@ 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( 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}, ), )