Skip to content

Fix Yul block execution after control-flow checkpoints - #85

Open
smoelius wants to merge 1 commit into
NethermindEth:mainfrom
trail-of-forks:fix-interpreter-bug
Open

Fix Yul block execution after control-flow checkpoints#85
smoelius wants to merge 1 commit into
NethermindEth:mainfrom
trail-of-forks:fix-interpreter-bug

Conversation

@smoelius

Copy link
Copy Markdown

This bug was found by Codex, and the PR was produced by Codex.

This PR fixes Yul block execution so that a block stops evaluating subsequent
statements once a statement produces a non-normal control-flow state, such as
the state produced by break, continue, or leave.

Previously, exec continued executing the rest of a .Block after any
successful Except.ok result, even if the returned Yul state was a control-flow
state rather than a normal .Ok state. That meant a block like:

{
  break
  let x := 1
}

would continue into let x := 1 after break, instead of stopping at the break
state.

The block execution case now continues only when the intermediate state is
.Ok; otherwise it returns the checkpoint state unchanged.

Testing

Added EvmYul.Yul.InterpreterTests.exec_block_stops_after_break, which checks
that:

{
  break
  let x := 1
}

evaluates to .Checkpoint (.Break ...) without executing the later let.

Tested with:

lake build EvmYul.Yul.InterpreterTests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant