Skip to content

Commit c76fcd9

Browse files
refactor(benchmark): resolve contract size limit failing cases
1 parent c8b1911 commit c76fcd9

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

tests/benchmark/test_worst_compute.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2872,13 +2872,20 @@ def test_worst_push(
28722872
):
28732873
"""Test running a block with as many PUSH as possible."""
28742874
op = opcode[1] if opcode.has_data_portion() else opcode
2875-
opcode_sequence = op * fork.max_stack_height()
2876-
target_contract_address = pre.deploy_contract(code=opcode_sequence)
2875+
2876+
op_seq = Bytecode()
2877+
for _ in range(fork.max_stack_height()):
2878+
if len(op_seq) + len(op) > fork.max_code_size():
2879+
break
2880+
op_seq += op
2881+
2882+
target_contract_address = pre.deploy_contract(code=op_seq)
28772883

28782884
calldata = Bytecode()
28792885
attack_block = Op.POP(Op.STATICCALL(Op.GAS, target_contract_address, 0, 0, 0, 0))
28802886

28812887
code = code_loop_precompile_call(calldata, attack_block, fork)
2888+
28822889
code_address = pre.deploy_contract(code=code)
28832890

28842891
tx = Transaction(

0 commit comments

Comments
 (0)