Skip to content

Commit 48ba16f

Browse files
authored
Merge pull request #708 from ethereum/finish-all-frames
Finish all frames in case there are no solutions to multisol query
2 parents 382605c + fa24aaf commit 48ba16f

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4747
output in case of failure
4848
- Simple test cases for the CLI
4949
- Allow limiting the branch depth and width limitation via --max-depth and --max-width
50+
- When there are zero solutions to a multi-solution query it means that the
51+
currently executed branch is in fact impossible. In these cases, unwind all
52+
frames and return a Revert with empty returndata.
5053

5154
## Fixed
5255
- We now try to simplify expressions fully before trying to cast them to a concrete value

src/EVM.hs

+13-5
Original file line numberDiff line numberDiff line change
@@ -2324,6 +2324,15 @@ data FrameResult
23242324
| FrameErrored EvmError -- ^ Any other error
23252325
deriving Show
23262326

2327+
finishAllFramesAndStop :: VMOps t => EVM t s ()
2328+
finishAllFramesAndStop = do
2329+
vm <- get
2330+
case vm.frames of
2331+
[] -> finishFrame (FrameReturned mempty)
2332+
_ -> do
2333+
finishFrame (FrameReturned mempty)
2334+
finishAllFramesAndStop
2335+
23272336
-- | This function defines how to pop the current stack frame in either of
23282337
-- the ways specified by 'FrameResult'.
23292338
--
@@ -2518,8 +2527,7 @@ copyBytesToMemory bs size srcOffset memOffset =
25182527
assign (#state % #memory) $
25192528
SymbolicMemory $ copySlice srcOffset memOffset size bs buf
25202529
SymbolicMemory mem ->
2521-
assign (#state % #memory) $
2522-
SymbolicMemory $ copySlice srcOffset memOffset size bs mem
2530+
assign (#state % #memory) $ SymbolicMemory $ copySlice srcOffset memOffset size bs mem
25232531

25242532
copyCallBytesToMemory
25252533
:: Expr Buf -> Expr EWord -> Expr EWord -> EVM t s ()
@@ -3022,9 +3030,9 @@ instance VMOps Symbolic where
30223030
Just concVals -> do
30233031
assign #result Nothing
30243032
case (length concVals) of
3025-
-- zero solutions means that we are in a branch that's not possible. Revert.
3026-
-- TODO: stop execution of the EVM completely
3027-
0 -> finishFrame (FrameReverted (ConcreteBuf ""))
3033+
-- zero solutions means that we are in a branch that's not possible
3034+
-- so revert all frames and stop all execution on this branch
3035+
0 -> finishAllFramesAndStop
30283036
1 -> do
30293037
let val = head concVals
30303038
assign #result Nothing

0 commit comments

Comments
 (0)