Skip to content

Commit 9a71c71

Browse files
LouisTsai-CsieCarsons-Eels
authored andcommitted
fix(tests/zkevm): update jump seq for valid dest (ethereum#1710)
* fix(tests/zkevm): update jump seq for valid dest * refactor: update worst jump test case * refactor: remove unused fork parameter
1 parent 664d75d commit 9a71c71

File tree

1 file changed

+4
-17
lines changed

1 file changed

+4
-17
lines changed

tests/zkevm/test_worst_compute.py

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
Transaction,
2828
add_kzg_version,
2929
)
30-
from ethereum_test_tools.code.generators import While
3130
from ethereum_test_tools.vm.opcode import Opcodes as Op
3231
from ethereum_test_types import TransactionType
3332
from ethereum_test_vm.opcode import Opcode
@@ -776,27 +775,15 @@ def code_loop_precompile_call(calldata: Bytecode, attack_block: Bytecode, fork:
776775
@pytest.mark.zkevm
777776
@pytest.mark.valid_from("Cancun")
778777
@pytest.mark.slow
779-
def test_worst_jumps(state_test: StateTestFiller, pre: Alloc, fork: Fork):
778+
def test_worst_jumps(state_test: StateTestFiller, pre: Alloc):
780779
"""Test running a JUMP-intensive contract."""
781780
env = Environment()
782-
max_code_size = fork.max_code_size()
783-
784-
def jump_seq():
785-
return Op.JUMP(Op.ADD(Op.PC, 1)) + Op.JUMPDEST
786-
787-
bytes_per_seq = len(jump_seq())
788-
seqs_per_call = max_code_size // bytes_per_seq
789-
790-
# Create and deploy the jump-intensive contract
791-
jumps_code = sum([jump_seq() for _ in range(seqs_per_call)])
792-
jumps_address = pre.deploy_contract(code=bytes(jumps_code))
793781

794-
# Call the contract repeatedly until gas runs out.
795-
caller_code = While(body=Op.POP(Op.CALL(address=jumps_address)))
796-
caller_address = pre.deploy_contract(caller_code)
782+
jumps_code = Op.JUMPDEST + Op.JUMP(Op.PUSH0)
783+
jumps_address = pre.deploy_contract(jumps_code)
797784

798785
tx = Transaction(
799-
to=caller_address,
786+
to=jumps_address,
800787
gas_limit=env.gas_limit,
801788
sender=pre.fund_eoa(),
802789
)

0 commit comments

Comments
 (0)