Skip to content

Commit

Permalink
Further cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
elopez committed Jul 8, 2024
1 parent d09340b commit 97007bc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
10 changes: 4 additions & 6 deletions lib/Echidna/Exec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,9 @@ execTxWithCov tx = do
if size == 0 then pure Nothing else do
-- IO for making a new vec
vec <- VMut.new size
-- We use -1 for opIx to indicate that the location was not covered
forM_ [0..size-1] $ \i -> VMut.write vec i (0, 0)
pure $ Just vec

case maybeCovVec of
Nothing -> pure ()
Just vec -> do
Expand All @@ -308,14 +307,13 @@ execTxWithCov tx = do
-- bug in another place, investigate.
-- ... this should be fixed now, since we use `codeContract` instead
-- of `contract` for everything; it may be safe to remove this check.
when (pc < VMut.length vec) $
when (pc < VMut.length vec) $ do
VMut.modify (fromJust maybeStatsVec) (\(execQty, revertQty) -> (execQty + 1, revertQty)) opIx
VMut.read vec pc >>= \case
(_, depths, results) | depth < 64 && not (depths `testBit` depth) -> do
VMut.write vec pc (opIx, depths `setBit` depth, results `setBit` fromEnum Stop)
VMut.modify (fromJust maybeStatsVec) (\(execQty, revertQty) -> (execQty + 1, revertQty)) opIx
writeIORef covContextRef (True, Just (vec, pc))
(opIx', depths, results) -> do
VMut.modify (fromJust maybeStatsVec) (\(execQty, revertQty) -> (execQty + 1, revertQty)) opIx'
_ -> do
modifyIORef' covContextRef $ \(new, _) -> (new, Just (vec, pc))

-- | Get the VM's current execution location
Expand Down
4 changes: 2 additions & 2 deletions lib/Echidna/Output/Source.hs
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ srcMapCov sc covMap statMap contracts = do
updateLine (Just (r, q)) = Just ((<> unpackTxResults txResults) r, max q execQty)
updateLine Nothing = Just (unpackTxResults txResults, execQty)
fileStats = Map.lookup c.runtimeCodehash statMap
idxStats | isJust fileStats = (fromJust fileStats) U.! opIx :: StatsInfo
| otherwise = (fromInteger 0, fromInteger 0) :: StatsInfo
idxStats | isJust fileStats = (fromJust fileStats) U.! opIx
| otherwise = (fromInteger 0, fromInteger 0)
execQty = fst idxStats
Nothing -> acc
Nothing -> acc
Expand Down

0 comments on commit 97007bc

Please sign in to comment.