Merge pull request #230 from crytic/dev-hevm-0.30

Upgraded to hevm 0.30
pull/235/head
JP Smith 5 years ago committed by GitHub
commit afa2f7bc33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      .travis.yml
  2. 23
      .travis/install-libff.sh
  3. 11
      examples/solidity/exercises/testme.sol
  4. 6
      lib/Echidna/Exec.hs
  5. 2
      lib/Echidna/Solidity.hs
  6. 4
      lib/Echidna/Transaction.hs
  7. 17
      stack.yaml

@ -26,6 +26,7 @@ install:
- unset CC
- export PATH=$HOME/.local/bin:$PATH
- ./.travis/install-libsecp256k1.sh
- ./.travis/install-libff.sh
- ./.travis/install-ghr.sh
- ./.travis/install-stack.sh
- ./.travis/install-solc.sh

@ -0,0 +1,23 @@
#!/bin/sh
set -eux
if ls /usr/local/lib | grep -q libff; then exit 0; fi
git clone https://github.com/scipr-lab/libff --recursive
git submodule init && git submodule update
cd libff
ARGS="-DWITH_PROCPS=OFF"
CXXFLAGS=""
if [ "$TRAVIS_OS_NAME" = "osx" ]; then
export LDFLAGS=-L/usr/local/opt/openssl/lib
export CPPFLAGS=-I/usr/local/opt/openssl/include
export CXXFLAGS=-I/usr/local/opt/openssl/include
ARGS="$ARGS -DOPENSSL_INCLUDE_DIR=/usr/local/opt/openssl/include/openssl -DCURVE=ALT_BN128"
sed -i '' 's/STATIC/SHARED/' libff/CMakeLists.txt # Fix GHC segfaults from hell (idk why)
sed -i '' 's/STATIC/SHARED/' depends/CMakeLists.txt
fi
mkdir build
cd build
CXXFLAGS="-fPIC $CXXFLAGS" cmake $ARGS ..
make && sudo make install

@ -21,6 +21,7 @@ contract Canal {
}
}
}
function raise(bool first_gate) {
if(first_gate) {
first_gate_up = true;
@ -28,4 +29,14 @@ contract Canal {
second_gate_up = true;
}
}
function echidna_bothdown() returns (bool) {
return(first_gate_up || second_gate_up);
}
function echidna_can_lower_second() returns (bool) {
bool a0 = lower(true);
raise(true);
return(a0);
}
}

@ -69,8 +69,10 @@ execTxWith h m t = do og <- get
case (res, isRight $ t ^. call) of
(Reversion, _) -> put og
(VMFailure x, _) -> h x
(VMSuccess bc, True) -> hasLens %= execState ( replaceCodeOfSelf bc
>> loadContract (t ^. dst))
(VMSuccess bc, True) -> (hasLens %=) . execState $ do
env . contracts . at (t ^. dst) . _Just . contractcode .= InitCode ""
replaceCodeOfSelf (RuntimeCode bc)
loadContract (t ^. dst)
_ -> pure ()
return res

@ -100,7 +100,7 @@ contracts fp = do
populateAddresses :: [Addr] -> Integer -> VM -> VM
populateAddresses [] _ vm = vm
populateAddresses (a:as) b vm = populateAddresses as b (vm & set (env . EVM.contracts . at a) (Just account))
where account = initialContract mempty & set nonce 1 & set balance (w256 $ fromInteger b)
where account = initialContract (RuntimeCode mempty) & set nonce 1 & set balance (w256 $ fromInteger b)
-- | Given an optional contract name and a list of 'SolcContract's, try to load the specified
-- contract, or, if not provided, the first contract in the list, into a 'VM' usable for Echidna

@ -116,9 +116,9 @@ liftSH = S.state . runState . zoom hasLens
setupTx :: (MonadState x m, Has VM x) => Tx -> m ()
setupTx (Tx c s r v) = S.state . runState . zoom hasLens . sequence_ $
[ result .= Nothing, state . pc .= 0, state . stack .= mempty, state . memory .= mempty, state . gas .= 0xffffffff
, env . origin .= s, state . caller .= s, state . callvalue .= v, setup] where
, tx . origin .= s, state . caller .= s, state . callvalue .= v, setup] where
setup = case c of
Left cd -> loadContract r >> state . calldata .= encode cd
Right bc -> assign (env . contracts . at r) (Just $ initialContract bc) >> loadContract r
Right bc -> assign (env . contracts . at r) (Just $ initialContract (RuntimeCode bc)) >> loadContract r
encode (n, vs) = abiCalldata
(n <> "(" <> T.intercalate "," (abiTypeSolidity . abiValueType <$> vs) <> ")") $ V.fromList vs

@ -1,22 +1,27 @@
resolver: lts-12.18
resolver: lts-12.10
packages:
- '.'
extra-deps:
- git: https://github.com/dapphub/dapptools.git
commit: 80c39ced5653727e7e38873bb215a99bc6acc56c
subdirs:
- src/hevm
- ghci-pretty-0.0.2
- hevm-0.24
- HSH-2.1.3
- ipprint-0.6
- multiset-0.3.4.1
- readline-1.0.3.0
- restless-git-0.7
- rosezipper-0.2
- s-cargot-0.1.4.0
- sr-extra-1.46.3.2
- text-format-0.3.2
- tree-view-0.5
- HSH-2.1.3
- ipprint-0.6
- sr-extra-1.46.3.2
- Unixutils-1.54.1
- github: dmjio/semver-range
commit: d8d9db892ddb6ae267c9bcbc4f6602668433f12a
extra-include-dirs:
- /usr/local/opt/readline/include

Loading…
Cancel
Save