Skip to content

Commit

Permalink
update hevm to 0.37, echidna 1.4.0.1 (#381)
Browse files Browse the repository at this point in the history
  • Loading branch information
incertia authored Mar 25, 2020
1 parent e38a467 commit 3a93b2c
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 19 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -48,3 +53,4 @@
* Initial stable release

[2cc059b49cae613025b925f0273b906e25484b68]: https://github.com/dapphub/dapptools/tree/2cc059b49cae613025b925f0273b906e25484b68
[af84e2ee0a0654fdaa91186384233cf1731ee7ce]: https://github.com/dapphub/dapptools/tree/af84e2ee0a0654fdaa91186384233cf1731ee7ce
4 changes: 3 additions & 1 deletion lib/Echidna/ABI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/Echidna/Campaign.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: echidna
author: Trail of Bits <echidna-dev@trailofbits.com>
maintainer: Trail of Bits <echidna-dev@trailofbits.com>

version: 1.4.0.0
version: 1.4.0.1

ghc-options: -Wall -fno-warn-orphans -O2 -threaded +RTS -N -RTS

Expand All @@ -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
Expand All @@ -26,7 +26,7 @@ dependencies:
- filepath
- hashable
- hevm
- lens >= 4.15.1 && < 4.17
- lens
- lens-aeson
- megaparsec
- MonadRandom
Expand Down
3 changes: 1 addition & 2 deletions src/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
16 changes: 8 additions & 8 deletions src/test/Spec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions stack.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

Expand Down

0 comments on commit 3a93b2c

Please sign in to comment.