Skip to content

fix(tests/zkevm): update jump seq for valid dest #1710

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 3 additions & 15 deletions tests/zkevm/test_worst_compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -762,24 +762,12 @@ def code_loop_precompile_call(calldata: Bytecode, attack_block: Bytecode, fork:
def test_worst_jumps(state_test: StateTestFiller, pre: Alloc, fork: Fork):
"""Test running a JUMP-intensive contract."""
env = Environment()
max_code_size = fork.max_code_size()

def jump_seq():
return Op.JUMP(Op.ADD(Op.PC, 1)) + Op.JUMPDEST

bytes_per_seq = len(jump_seq())
seqs_per_call = max_code_size // bytes_per_seq

# Create and deploy the jump-intensive contract
jumps_code = sum([jump_seq() for _ in range(seqs_per_call)])
jumps_address = pre.deploy_contract(code=bytes(jumps_code))

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

tx = Transaction(
to=caller_address,
to=jumps_address,
gas_limit=env.gas_limit,
sender=pre.fund_eoa(),
)
Expand Down