Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
elopez committed Jul 8, 2024
1 parent adb2060 commit d09340b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
16 changes: 8 additions & 8 deletions lib/Echidna/Exec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ execTxWithCov tx = do
Just (vec, pc) -> do
let txResultBit = fromEnum $ getResult $ fst r
VMut.read vec pc >>= \case
(opIx, depths, txResults, execQty) | not (txResults `testBit` txResultBit) -> do
VMut.write vec pc (opIx, depths, txResults `setBit` txResultBit, execQty)
(opIx, depths, txResults) | not (txResults `testBit` txResultBit) -> do
VMut.write vec pc (opIx, depths, txResults `setBit` txResultBit)
pure True -- we count this as new coverage
_ -> pure False
_ -> pure False
Expand Down Expand Up @@ -287,7 +287,7 @@ execTxWithCov tx = 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 (-1, 0, 0, 0)
forM_ [0..size-1] $ \i -> VMut.write vec i (-1, 0, 0)
pure $ Just vec

statsRef <- getTLS env.statsRef
Expand All @@ -310,12 +310,12 @@ execTxWithCov tx = do
-- of `contract` for everything; it may be safe to remove this check.
when (pc < VMut.length vec) $
VMut.read vec pc >>= \case
(_, depths, results, execQty) | depth < 64 && not (depths `testBit` depth) -> do
VMut.write vec pc (opIx, depths `setBit` depth, results `setBit` fromEnum Stop, execQty + 1)
VMut.modify (fromJust maybeStatsVec) (\(execQty, revertQty) -> (execQty + 1, revertQty)) pc
(_, 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, execQty) -> do
VMut.write vec pc (opIx', depths, results, execQty + 1)
(opIx', depths, results) -> do
VMut.modify (fromJust maybeStatsVec) (\(execQty, revertQty) -> (execQty + 1, revertQty)) opIx'
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 @@ -181,8 +181,8 @@ srcMapCov sc covMap statMap contracts = do
linesCovered c =
case Map.lookup c.runtimeCodehash covMap of
Just vec -> VU.foldl' (\acc covInfo -> case covInfo of
(-1, _, _, _) -> acc -- not covered
(opIx, _stackDepths, txResults, _) ->
(-1, _, _) -> acc -- not covered
(opIx, _stackDepths, txResults) ->
case srcMapForOpLocation c opIx of
Just srcMap ->
case srcMapCodePos sc srcMap of
Expand Down
4 changes: 2 additions & 2 deletions lib/Echidna/Types/Coverage.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type StatsMap = Map W256 (IOVector StatsInfo)
type StatsMapV = Map W256 (Vector StatsInfo)

-- | Basic coverage information
type CoverageInfo = (OpIx, StackDepths, TxResults, ExecQty)
type CoverageInfo = (OpIx, StackDepths, TxResults)

-- | Basic stats information
type StatsInfo = (ExecQty, RevertQty)
Expand Down Expand Up @@ -55,7 +55,7 @@ scoveragePoints cm = do
sum <$> mapM (V.foldl' countCovered 0) (Map.elems cm)

countCovered :: Int -> CoverageInfo -> Int
countCovered acc (opIx,_,_,_) = if opIx == -1 then acc else acc + 1
countCovered acc (opIx,_,_) = if opIx == -1 then acc else acc + 1

unpackTxResults :: TxResults -> [TxResult]
unpackTxResults txResults =
Expand Down

0 comments on commit d09340b

Please sign in to comment.