Skip to content

Commit

Permalink
kevm-pyk/{evm,*.py}: add option --break-on-jump (#2653)
Browse files Browse the repository at this point in the history
  • Loading branch information
ehildenb authored Nov 7, 2024
1 parent 1a7a2a6 commit ccee56b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions kevm-pyk/src/kevm_pyk/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ def create_kcfg_explore() -> KCFGExplore:
max_iterations=options.max_iterations,
cut_point_rules=KEVMSemantics.cut_point_rules(
options.break_on_jumpi,
options.break_on_jump,
options.break_on_calls,
options.break_on_storage,
options.break_on_basic_blocks,
Expand Down
9 changes: 9 additions & 0 deletions kevm-pyk/src/kevm_pyk/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ def get_argument_type() -> dict[str, Callable]:
class ExploreOptions(Options):
break_every_step: bool
break_on_jumpi: bool
break_on_jump: bool
break_on_calls: bool
break_on_storage: bool
break_on_basic_blocks: bool
Expand All @@ -350,6 +351,7 @@ class ExploreOptions(Options):
def default() -> dict[str, Any]:
return {
'break_every_step': False,
'break_on_jump': False,
'break_on_jumpi': False,
'break_on_calls': False,
'break_on_storage': False,
Expand Down Expand Up @@ -1040,6 +1042,13 @@ def explore_args(self) -> ArgumentParser:
dest='break_on_jumpi',
default=None,
action='store_true',
help='Store a node for every EVM jumpi opcode.',
)
args.add_argument(
'--break-on-jump',
dest='break_on_jump',
default=None,
action='store_true',
help='Store a node for every EVM jump opcode.',
)
args.add_argument(
Expand Down
3 changes: 3 additions & 0 deletions kevm-pyk/src/kevm_pyk/kevm.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ def custom_step(self, cterm: CTerm) -> KCFGExtendResult | None:
@staticmethod
def cut_point_rules(
break_on_jumpi: bool,
break_on_jump: bool,
break_on_calls: bool,
break_on_storage: bool,
break_on_basic_blocks: bool,
Expand All @@ -172,6 +173,8 @@ def cut_point_rules(
cut_point_rules = []
if break_on_jumpi:
cut_point_rules.extend(['EVM.jumpi.true', 'EVM.jumpi.false'])
if break_on_jump:
cut_point_rules.extend(['EVM.jump'])
if break_on_basic_blocks:
cut_point_rules.append('EVM.end-basic-block')
if break_on_calls or break_on_basic_blocks:
Expand Down
3 changes: 2 additions & 1 deletion kevm-pyk/src/kevm_pyk/kproj/evm-semantics/evm.md
Original file line number Diff line number Diff line change
Expand Up @@ -1076,7 +1076,8 @@ The `JUMP*` family of operations affect the current program counter.
syntax UnStackOp ::= "JUMP"
// ---------------------------
rule <k> JUMP DEST => #endBasicBlock ... </k>
rule [jump]:
<k> JUMP DEST => #endBasicBlock ... </k>
<pc> _ => DEST </pc>
<jumpDests> DESTS </jumpDests>
requires DEST <Int lengthBytes(DESTS) andBool DESTS[DEST] ==Int 1
Expand Down

0 comments on commit ccee56b

Please sign in to comment.