Vyper fixes (#645)

* Workaround to run vyper contracts without slither

* More vyper fixes

* fix
pull/650/head
Gustavo Grieco 4 years ago committed by GitHub
parent 6b05be56b0
commit 31865b1942
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      lib/Echidna/Exec.hs
  2. 6
      lib/Echidna/Processor.hs
  3. 2
      lib/Echidna/Types/Signature.hs

@ -11,7 +11,7 @@ import Control.Lens
import Control.Monad.Catch (Exception, MonadThrow(..))
import Control.Monad.State.Strict (MonadState, execState)
import Data.Has (Has(..))
import Data.Maybe (fromMaybe, fromJust)
import Data.Maybe (fromMaybe)
import EVM
import EVM.Op (Op(..))
import EVM.Exec (exec, vmForEthrunCreation)
@ -106,7 +106,7 @@ usingCoverage cov = maybe (cov >> liftSH exec1 >> usingCoverage cov) pure =<< us
pointCoverage :: (MonadState x m, Has VM x) => Lens' x CoverageMap -> m ()
pointCoverage l = do
v <- use hasLens
l %= M.insertWith (const . S.insert $ (v ^. state . pc, fromJust $ vmOpIx v, Success))
l %= M.insertWith (const . S.insert $ (v ^. state . pc, fromMaybe 0 $ vmOpIx v, Success))
(fromMaybe (error "no contract information on coverage") $ h v)
mempty
where

@ -12,6 +12,7 @@ import Data.Aeson ((.:), decode, parseJSON, withEmbeddedJSON, withOb
import Data.Aeson.Types (FromJSON, Parser, Value(String))
import Data.List (nub)
import Data.Maybe (catMaybes)
import Data.Text (pack, isSuffixOf)
import Text.Read (readMaybe)
import System.Directory (findExecutable)
import System.Process (StdStream(..), readCreateProcessWithExitCode, proc, std_err)
@ -67,6 +68,9 @@ data SlitherInfo = SlitherInfo
, generationGraph :: M.HashMap ContractName (M.HashMap FunctionName [FunctionName])
} deriving (Show)
noInfo :: SlitherInfo
noInfo = SlitherInfo mempty mempty mempty mempty mempty
instance FromJSON SlitherInfo where
parseJSON = withObject "slitherOutput" $ \o -> do
-- take the value under 'description' through the path - $['results']['printers'][0]['description']
@ -119,7 +123,7 @@ instance FromJSON SlitherInfo where
-- Slither processing
runSlither :: (MonadIO m, MonadThrow m) => FilePath -> [String] -> m SlitherInfo
runSlither fp extraArgs = do
runSlither fp extraArgs = if ".vy" `isSuffixOf` pack fp then return noInfo else do
mp <- liftIO $ findExecutable "slither"
case mp of
Nothing -> throwM $ ProcessorNotFound "slither" "You should install it using 'pip3 install slither-analyzer --user'"

@ -36,7 +36,7 @@ getBytecodeMetadata :: ByteString -> ByteString
getBytecodeMetadata bs =
let stripCandidates = flip BS.breakSubstring bs <$> knownBzzrPrefixes in
case find ((/= mempty) . snd) stripCandidates of
Nothing -> mempty
Nothing -> bs -- if no metadata is found, return the complete bytecode
Just (_, m) -> m
knownBzzrPrefixes :: [ByteString]

Loading…
Cancel
Save