Skip to content

Commit 0f61ca9

Browse files
authored
Merge pull request #190144 from arcz/echidna-2.0.2
echidna: 1.7.3 -> 2.0.2
2 parents 7192eca + 6cabade commit 0f61ca9

5 files changed

Lines changed: 179 additions & 6 deletions

File tree

pkgs/development/haskell-modules/configuration-hackage2nix/broken.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2143,7 +2143,6 @@ broken-packages:
21432143
- heterogeneous-list-literals
21442144
- hetris
21452145
- heukarya
2146-
- hevm
21472146
- HExcel
21482147
- hexchat
21492148
- hexif

pkgs/development/haskell-modules/configuration-nix.nix

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,8 +738,10 @@ self: super: builtins.intersectAttrs super {
738738
'';
739739
}) super.haskell-language-server;
740740

741+
# NOTE: this patch updates the hevm code to work with the latest packages that broke the build
742+
# it's temporary until hevm version 0.50.0 is released - https://github.com/ethereum/hevm/milestone/1
741743
# tests depend on a specific version of solc
742-
hevm = dontCheck (doJailbreak super.hevm);
744+
hevm = dontCheck (appendPatch ./patches/hevm-update-deps.patch super.hevm);
743745

744746
# hadolint enables static linking by default in the cabal file, so we have to explicitly disable it.
745747
# https://github.com/hadolint/hadolint/commit/e1305042c62d52c2af4d77cdce5d62f6a0a3ce7b
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
diff --git a/hevm.cabal b/hevm.cabal
2+
index cf36961e..3b31f595 100644
3+
--- a/hevm.cabal
4+
+++ b/hevm.cabal
5+
@@ -71,6 +71,10 @@ library
6+
-Wall -Wno-deprecations
7+
extra-libraries:
8+
secp256k1, ff
9+
+ if os(darwin)
10+
+ extra-libraries: c++
11+
+ else
12+
+ extra-libraries: stdc++
13+
c-sources:
14+
ethjet/tinykeccak.c, ethjet/ethjet.c
15+
cxx-sources:
16+
@@ -88,7 +92,7 @@ library
17+
transformers >= 0.5.6 && < 0.6,
18+
tree-view >= 0.5 && < 0.6,
19+
abstract-par >= 0.3.3 && < 0.4,
20+
- aeson >= 1.5.6 && < 1.6,
21+
+ aeson >= 2.0 && < 2.1,
22+
bytestring >= 0.10.8 && < 0.11,
23+
scientific >= 0.3.6 && < 0.4,
24+
binary >= 0.8.6 && < 0.9,
25+
@@ -97,7 +101,7 @@ library
26+
vector >= 0.12.1 && < 0.13,
27+
ansi-wl-pprint >= 0.6.9 && < 0.7,
28+
base16-bytestring >= 1.0.0 && < 2.0,
29+
- brick >= 0.58 && < 0.63,
30+
+ brick >= 0.58 && < 0.69,
31+
megaparsec >= 9.0.0 && < 10.0,
32+
mtl >= 2.2.2 && < 2.3,
33+
directory >= 1.3.3 && < 1.4,
34+
@@ -105,13 +109,13 @@ library
35+
vty >= 5.25.1 && < 5.34,
36+
cereal >= 0.5.8 && < 0.6,
37+
cryptonite >= 0.27 && <= 0.29,
38+
- memory >= 0.14.18 && < 0.16,
39+
+ memory >= 0.14.18 && < 0.20,
40+
data-dword >= 0.3.1 && < 0.4,
41+
fgl >= 5.7.0 && < 5.8,
42+
free >= 5.1.3 && < 5.2,
43+
haskeline >= 0.8.0 && < 0.9,
44+
process >= 1.6.5 && < 1.7,
45+
- lens >= 4.17.1 && < 4.20,
46+
+ lens >= 4.17.1 && < 5.1,
47+
lens-aeson >= 1.0.2 && < 1.2,
48+
monad-par >= 0.3.5 && < 0.4,
49+
multiset >= 0.3.4 && < 0.4,
50+
@@ -124,7 +128,6 @@ library
51+
sbv >= 8.9,
52+
semver-range >= 0.2.7 && < 0.3,
53+
temporary >= 1.3 && < 1.4,
54+
- text-format >= 0.3.2 && < 0.4,
55+
witherable >= 0.3.5 && < 0.5,
56+
wreq >= 0.5.3 && < 0.6,
57+
regex-tdfa >= 1.2.3 && < 1.4,
58+
@@ -190,7 +193,6 @@ executable hevm
59+
sbv,
60+
temporary,
61+
text,
62+
- text-format,
63+
unordered-containers,
64+
vector,
65+
vty
66+
diff --git a/src/EVM/Solidity.hs b/src/EVM/Solidity.hs
67+
index b7d0f36b..4e9d6892 100644
68+
--- a/src/EVM/Solidity.hs
69+
+++ b/src/EVM/Solidity.hs
70+
@@ -70,6 +70,7 @@ import Control.Monad
71+
import Control.Lens hiding (Indexed, (.=))
72+
import qualified Data.String.Here as Here
73+
import Data.Aeson hiding (json)
74+
+import qualified Data.Aeson.KeyMap as KeyMap
75+
import Data.Aeson.Types
76+
import Data.Aeson.Lens
77+
import Data.Scientific
78+
@@ -714,8 +715,8 @@ astIdMap = foldMap f
79+
f :: Value -> Map Int Value
80+
f (Array x) = foldMap f x
81+
f v@(Object x) =
82+
- let t = foldMap f (HMap.elems x)
83+
- in case HMap.lookup "id" x of
84+
+ let t = foldMap f (KeyMap.elems x)
85+
+ in case KeyMap.lookup "id" x of
86+
Nothing -> t
87+
Just (Number i) -> t <> Map.singleton (round i) v
88+
Just _ -> t
89+
diff --git a/src/EVM/SymExec.hs b/src/EVM/SymExec.hs
90+
index 5bbf1c03..b828098e 100644
91+
--- a/src/EVM/SymExec.hs
92+
+++ b/src/EVM/SymExec.hs
93+
@@ -40,8 +40,8 @@ type EquivalenceResult = ProofResult ([VM], [VM]) VM ()
94+
95+
-- | Convenience functions for generating large symbolic byte strings
96+
sbytes32, sbytes128, sbytes256, sbytes512, sbytes1024 :: Query ([SWord 8])
97+
-sbytes32 = toBytes <$> freshVar_ @ (WordN 256)
98+
-sbytes128 = toBytes <$> freshVar_ @ (WordN 1024)
99+
+sbytes32 = toBytes <$> freshVar_ @(WordN 256)
100+
+sbytes128 = toBytes <$> freshVar_ @(WordN 1024)
101+
sbytes256 = liftA2 (++) sbytes128 sbytes128
102+
sbytes512 = liftA2 (++) sbytes256 sbytes256
103+
sbytes1024 = liftA2 (++) sbytes512 sbytes512
104+
diff --git a/src/EVM/Types.hs b/src/EVM/Types.hs
105+
index fdd2368d..1dc29e83 100644
106+
--- a/src/EVM/Types.hs
107+
+++ b/src/EVM/Types.hs
108+
@@ -434,17 +434,17 @@ readN s = fromIntegral (read s :: Integer)
109+
readNull :: Read a => a -> String -> a
110+
readNull x = fromMaybe x . Text.Read.readMaybe
111+
112+
-wordField :: JSON.Object -> Text -> JSON.Parser W256
113+
+wordField :: JSON.Object -> Key -> JSON.Parser W256
114+
wordField x f = ((readNull 0) . Text.unpack)
115+
<$> (x .: f)
116+
117+
-addrField :: JSON.Object -> Text -> JSON.Parser Addr
118+
+addrField :: JSON.Object -> Key -> JSON.Parser Addr
119+
addrField x f = (read . Text.unpack) <$> (x .: f)
120+
121+
-addrFieldMaybe :: JSON.Object -> Text -> JSON.Parser (Maybe Addr)
122+
+addrFieldMaybe :: JSON.Object -> Key -> JSON.Parser (Maybe Addr)
123+
addrFieldMaybe x f = (Text.Read.readMaybe . Text.unpack) <$> (x .: f)
124+
125+
-dataField :: JSON.Object -> Text -> JSON.Parser ByteString
126+
+dataField :: JSON.Object -> Key -> JSON.Parser ByteString
127+
dataField x f = hexText <$> (x .: f)
128+
129+
toWord512 :: W256 -> Word512

pkgs/tools/security/echidna/default.nix

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{ lib
2-
, fetchpatch
32
, fetchFromGitHub
43
# Haskell deps
54
, mkDerivation, aeson, ansi-terminal, base, base16-bytestring, binary, brick
@@ -8,19 +7,24 @@
87
, MonadRandom, mtl, optparse-applicative, process, random, stm, tasty
98
, tasty-hunit, tasty-quickcheck, temporary, text, transformers , unix, unliftio
109
, unliftio-core, unordered-containers, vector, vector-instances, vty
11-
, wl-pprint-annotated, word8, yaml , extra, ListLike, semver
10+
, wl-pprint-annotated, word8, yaml, extra, ListLike, semver
1211
}:
1312
mkDerivation rec {
1413
pname = "echidna";
15-
version = "1.7.3";
14+
version = "2.0.2";
1615

1716
src = fetchFromGitHub {
1817
owner = "crytic";
1918
repo = "echidna";
2019
rev = "v${version}";
21-
sha256 = "sha256-NkAAXYa1bbCNUO0eDM7LQbyC3//RRFAKmEHGH2Dhl/M=";
20+
sha256 = "sha256-WmlQWgn4qfRmx3PdzY7wzT9AyU7Re2T1CWJ7yGjcVac=";
2221
};
2322

23+
# NOTE: echidna is behind with aeson because of hevm, this patch updates
24+
# the code to work with the major aeson update that broke the build
25+
# it's temporary until hevm version 0.50.0 is released - https://github.com/ethereum/hevm/milestone/1
26+
patches = [ ./echidna-update-aeson.patch ];
27+
2428
isLibrary = true;
2529
isExecutable = true;
2630
libraryHaskellDepends = [
@@ -51,4 +55,5 @@ mkDerivation rec {
5155
license = lib.licenses.agpl3Plus;
5256
maintainers = with lib.maintainers; [ arturcygan ];
5357
platforms = lib.platforms.unix;
58+
mainProgram = "echidna-test";
5459
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
diff --git a/lib/Echidna/Config.hs b/lib/Echidna/Config.hs
2+
index f8d5777..3d761fe 100644
3+
--- a/lib/Echidna/Config.hs
4+
+++ b/lib/Echidna/Config.hs
5+
@@ -13,8 +13,8 @@ import Control.Monad.State (StateT(..), runStateT)
6+
import Control.Monad.Trans (lift)
7+
import Data.Bool (bool)
8+
import Data.Aeson
9+
+import Data.Aeson.KeyMap (keys)
10+
import Data.Has (Has(..))
11+
-import Data.HashMap.Strict (keys)
12+
import Data.HashSet (fromList, insert, difference)
13+
import Data.Maybe (fromMaybe)
14+
import Data.Text (isPrefixOf)
15+
@@ -23,11 +23,13 @@ import EVM.Types (w256)
16+
17+
import qualified Control.Monad.Fail as M (MonadFail(..))
18+
import qualified Data.ByteString as BS
19+
+import qualified Data.Aeson.Key as Key
20+
+import qualified Data.HashSet as HS
21+
import qualified Data.List.NonEmpty as NE
22+
import qualified Data.Yaml as Y
23+
24+
import Echidna.Test
25+
-import Echidna.Types.Campaign
26+
+import Echidna.Types.Campaign
27+
import Echidna.Mutator.Corpus (defaultMutationConsts)
28+
import Echidna.Types.Config (EConfigWithUsage(..), EConfig(..))
29+
import Echidna.Types.Solidity
30+
@@ -52,7 +54,7 @@ instance FromJSON EConfigWithUsage where
31+
_ -> mempty
32+
(c, ks) <- runStateT (parser v') $ fromList []
33+
let found = fromList (keys v')
34+
- return $ EConfigWithUsage c (found `difference` ks) (ks `difference` found)
35+
+ return $ EConfigWithUsage c (HS.map Key.toText $ found `difference` ks) (HS.map Key.toText $ ks `difference` found)
36+
-- this parser runs in StateT and comes equipped with the following
37+
-- equivalent unary operators:
38+
-- x .:? k (Parser) <==> x ..:? k (StateT)

0 commit comments

Comments
 (0)