diff --git a/CHANGELOG.md b/CHANGELOG.md index 02e373787..cb8729a5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## TODO + +## 1.4.0.1 +* HEVM updated to [af84e2ee0a0654fdaa91186384233cf1731ee7ce] + ## 1.4.0.0 * Filtering functions either blacklisting or whitelisting functions to call during a fuzzing campaign (#341) @@ -48,3 +53,4 @@ * Initial stable release [2cc059b49cae613025b925f0273b906e25484b68]: https://github.com/dapphub/dapptools/tree/2cc059b49cae613025b925f0273b906e25484b68 +[af84e2ee0a0654fdaa91186384233cf1731ee7ce]: https://github.com/dapphub/dapptools/tree/af84e2ee0a0654fdaa91186384233cf1731ee7ce diff --git a/lib/Echidna/ABI.hs b/lib/Echidna/ABI.hs index 229a0b7df..4e9ca3779 100644 --- a/lib/Echidna/ABI.hs +++ b/lib/Echidna/ABI.hs @@ -34,7 +34,8 @@ import Data.Vector.Instances () import Data.Word8 (Word8) import Numeric (showHex) -import EVM.ABI +import EVM.ABI hiding (genAbiValue) +import EVM.Types (Addr) import qualified Control.Monad.Random.Strict as R import qualified Data.ByteString as BS @@ -116,6 +117,7 @@ defaultDict = mkGenDict 0 [] [] 0 (const Nothing) -- We need the above since hlint doesn't notice DeriveAnyClass in StandaloneDeriving. deriving instance Hashable AbiType deriving instance Hashable AbiValue +deriving instance Hashable Addr -- | Construct a 'GenDict' from some dictionaries, a 'Float', a default seed, and a typing rule for -- return values diff --git a/lib/Echidna/Campaign.hs b/lib/Echidna/Campaign.hs index 7378c1a7b..4c3e38928 100644 --- a/lib/Echidna/Campaign.hs +++ b/lib/Echidna/Campaign.hs @@ -31,7 +31,7 @@ import Data.Text (Text) import Data.Traversable (traverse) import EVM import EVM.ABI (getAbi, AbiType(AbiAddressType), AbiValue(AbiAddress)) -import EVM.Types (Addr, addressWord160) +import EVM.Types (Addr) import Numeric (showHex) import System.Random (mkStdGen) @@ -291,7 +291,7 @@ callseq v w ql = do -- compute the addresses not present in the old VM via set difference diff = keys $ new \\ old -- and construct a set to union to the constants table - diffs = H.fromList [(AbiAddressType, S.fromList $ AbiAddress . addressWord160 <$> diff)] + diffs = H.fromList [(AbiAddressType, S.fromList $ AbiAddress <$> diff)] -- Save the global campaign state (also vm state, but that gets reset before it's used) hasLens .= snd s -- Update the gas estimation diff --git a/package.yaml b/package.yaml index 9753813a3..11f6d420a 100644 --- a/package.yaml +++ b/package.yaml @@ -3,7 +3,7 @@ name: echidna author: Trail of Bits maintainer: Trail of Bits -version: 1.4.0.0 +version: 1.4.0.1 ghc-options: -Wall -fno-warn-orphans -O2 -threaded +RTS -N -RTS @@ -13,11 +13,11 @@ dependencies: - ansi-terminal - base16-bytestring - binary - - brick + - brick <= 0.46 - base16-bytestring - bytestring >= 0.10.8 && < 0.11 - cborg - - containers >= 0.5.7 && < 0.6 + - containers - data-dword >= 0.3.1 && < 0.4 - data-has - deepseq @@ -26,7 +26,7 @@ dependencies: - filepath - hashable - hevm - - lens >= 4.15.1 && < 4.17 + - lens - lens-aeson - megaparsec - MonadRandom diff --git a/src/Main.hs b/src/Main.hs index 9131361da..5579f99ae 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -14,7 +14,6 @@ import System.IO (hPutStrLn, stderr) import EVM (env, contracts) import EVM.ABI (AbiValue(AbiAddress)) -import EVM.Types (Addr(..)) import Echidna.ABI import Echidna.Config @@ -62,7 +61,7 @@ main = do Options f c conf <- execParser opts cs <- Echidna.Solidity.contracts f ads <- addresses (v,w,ts) <- loadSpecified (pack <$> c) cs >>= prepareForTest - let ads' = AbiAddress . addressWord160 <$> v ^. env . EVM.contracts . to keys + let ads' = AbiAddress <$> v ^. env . EVM.contracts . to keys ui v w ts (Just $ mkGenDict (dictFreq $ view cConf cfg) (extractConstants cs ++ NE.toList ads ++ ads') [] g (returnTypes cs)) txs saveTxs cd (view corpus cpg) if not . isSuccess $ cpg then exitWith $ ExitFailure 1 else exitSuccess diff --git a/src/test/Spec.hs b/src/test/Spec.hs index c86a5e732..4d991b7ac 100644 --- a/src/test/Spec.hs +++ b/src/test/Spec.hs @@ -4,11 +4,11 @@ import Test.Tasty import Test.Tasty.HUnit -import Test.Tasty.QuickCheck(Arbitrary(..), Gen, (===), property, testProperty) +import Test.Tasty.QuickCheck(Arbitrary(..), Gen, (===), property, testProperty, resize) import EVM (env, contracts) -import EVM.Types (Addr(..)) import EVM.ABI (AbiValue(..)) +import EVM.Types (Addr) import qualified EVM.Concrete(Word(..)) import Echidna.ABI (SolCall, mkGenDict) @@ -226,8 +226,8 @@ integrationTests = testGroup "Solidity Integration Testing" [ ("echidna_test passed", solved "echidna_test") ] , testContract "basic/gasuse.sol" (Just "basic/gasuse.yaml") [ ("echidna_true failed", passed "echidna_true") - , ("g gas estimate wrong", gasInRange "g" 12000000 80000000) - , ("f_close1 gas estimate wrong", gasInRange "f_close1" 5000 7000) + , ("g gas estimate wrong", gasInRange "g" 15000000 40000000) + , ("f_close1 gas estimate wrong", gasInRange "f_close1" 1800 2000) , ("f_open1 gas estimate wrong", gasInRange "f_open1" 18000 23000) , ("push_b gas estimate wrong", gasInRange "push_b" 39000 45000) ] @@ -263,7 +263,7 @@ runContract fp n c = (v,w,ts) <- loadSolTests (fp NE.:| []) n cs <- Echidna.Solidity.contracts (fp NE.:| []) ads <- NE.toList <$> addresses - let ads' = AbiAddress . addressWord160 <$> v ^. env . EVM.contracts . to keys + let ads' = AbiAddress <$> v ^. env . EVM.contracts . to keys campaign (pure ()) v w ts (Just $ mkGenDict 0.15 (extractConstants cs ++ ads ++ ads') [] g (returnTypes cs)) [] getResult :: Text -> Campaign -> Maybe TestState @@ -309,14 +309,14 @@ instance Arbitrary EVM.Concrete.Word where arbitrary = fromInteger <$> arbitrary instance Arbitrary TxCall where - arbitrary = do + arbitrary = do s <- arbitrary - cs <- arbitrary + cs <- resize 32 arbitrary return $ SolCall (pack s, cs) instance Arbitrary Tx where arbitrary = let a :: Arbitrary a => Gen a - a = arbitrary in + a = arbitrary in Tx <$> a <*> a <*> a <*> a <*> a <*> a <*> a encodingJSONTests :: TestTree diff --git a/stack.yaml b/stack.yaml index 042f76789..dee760cb2 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,14 +1,15 @@ -resolver: lts-12.10 +resolver: lts-14.27 packages: - '.' extra-deps: - git: https://github.com/dapphub/dapptools.git - commit: 2cc059b49cae613025b925f0273b906e25484b68 + commit: af84e2ee0a0654fdaa91186384233cf1731ee7ce subdirs: - src/hevm +- brick-0.46 - ghci-pretty-0.0.2 - multiset-0.3.4.1 - restless-git-0.7 @@ -20,6 +21,8 @@ extra-deps: - ipprint-0.6 - sr-extra-1.46.3.2 - Unixutils-1.54.1 +- witherable-0.3.5 +- witherable-class-0 - github: dmjio/semver-range commit: d8d9db892ddb6ae267c9bcbc4f6602668433f12a