From d09340be221b805c2466d7df6257872c1ab2e96f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20L=C3=B3pez?= Date: Mon, 8 Jul 2024 17:05:28 +0200 Subject: [PATCH] Cleanup --- lib/Echidna/Exec.hs | 16 ++++++++-------- lib/Echidna/Output/Source.hs | 4 ++-- lib/Echidna/Types/Coverage.hs | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/Echidna/Exec.hs b/lib/Echidna/Exec.hs index a128ffdba..490ff163a 100644 --- a/lib/Echidna/Exec.hs +++ b/lib/Echidna/Exec.hs @@ -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 @@ -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 @@ -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 diff --git a/lib/Echidna/Output/Source.hs b/lib/Echidna/Output/Source.hs index 590eb8ff1..11490c964 100644 --- a/lib/Echidna/Output/Source.hs +++ b/lib/Echidna/Output/Source.hs @@ -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 diff --git a/lib/Echidna/Types/Coverage.hs b/lib/Echidna/Types/Coverage.hs index c9e34a255..81c61e37f 100644 --- a/lib/Echidna/Types/Coverage.hs +++ b/lib/Echidna/Types/Coverage.hs @@ -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) @@ -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 =