Skip to content

Update hevm to 0f08514c6cbd9f9688a5c7199915c78df59109fe #1346

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/scripts/install-libff.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ cd libff
git checkout v0.2.1
git submodule init && git submodule update

ARGS=("-DCMAKE_INSTALL_PREFIX=$PREFIX" "-DWITH_PROCPS=OFF")
ARGS=("-DCMAKE_INSTALL_PREFIX=$PREFIX" "-DWITH_PROCPS=OFF" "-DCMAKE_POLICY_VERSION_MINIMUM=3.5")
CXXFLAGS=""
if [ "$HOST_OS" = "macOS" ]; then
OPENSSL_PREFIX=$(brew --prefix openssl)
Expand Down
4 changes: 2 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
hevm = pkgs: pkgs.lib.pipe ((hsPkgs pkgs).callCabal2nix "hevm" (pkgs.fetchFromGitHub {
owner = "ethereum";
repo = "hevm";
rev = "release/0.54.2";
sha256 = "sha256-h0e6QeMBIUkyANYdrGjrqZ2M4fnODOB0gNPQtsrAiL8=";
rev = "0f08514c6cbd9f9688a5c7199915c78df59109fe";
sha256 = "sha256-mxIs09i67u6r4RcIZpj18DrAxmrF6pjLWb0wUiIZOFQ=";
}) { secp256k1 = pkgs.secp256k1; })
([
pkgs.haskell.lib.compose.dontCheck
Expand Down
3 changes: 2 additions & 1 deletion lib/Echidna/Etheno.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import Text.Read (readMaybe)

import EVM
import EVM.ABI (AbiType(..), AbiValue(..), decodeAbiValue, selector)
import EVM.Effects (defaultConfig)
import EVM.Exec (exec)
import EVM.Types

Expand Down Expand Up @@ -173,7 +174,7 @@ execEthenoTxs et = do
runFully vm
where
runFully vm = do
res <- fromEVM exec
res <- fromEVM $ exec defaultConfig
case (res, et) of
(_ , AccountCreated _) -> pure ()
(Reversion, _) -> void $ put vm
Expand Down
3 changes: 2 additions & 1 deletion lib/Echidna/Events.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import Data.Vector (fromList)
import EVM (traceForest)
import EVM.ABI (Event(..), Indexed(..), decodeAbiValue, AbiType(..), AbiValue(..))
import EVM.Dapp (DappContext(..), DappInfo(..))
import EVM.Expr (maybeLitWordSimp)
import EVM.Format (showValues, showError, contractNamePart)
import EVM.Solidity (SolcContract(..))
import EVM.Types
Expand All @@ -37,7 +38,7 @@ extractEvents decodeErrors dappInfo vm =
where
showTrace trace =
let ?context = DappContext { info = dappInfo, contracts = vm.env.contracts, labels = vm.labels } in
let codehash' = fromJust $ maybeLitWord trace.contract.codehash
let codehash' = fromJust $ maybeLitWordSimp trace.contract.codehash
maybeContractName = maybeContractNameFromCodeHash dappInfo codehash'
in case trace.tracedata of
EventTrace addr bytes (topic:_) ->
Expand Down
5 changes: 3 additions & 2 deletions lib/Echidna/Exec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import System.Process qualified as P
import EVM (bytecode, replaceCodeOfSelf, loadContract, exec1, vmOpIx, clearTStorages)
import EVM.ABI
import EVM.Dapp (DappInfo)
import EVM.Effects (defaultConfig)
import EVM.Exec (exec, vmForEthrunCreation)
import EVM.Fetch qualified
import EVM.Format (hexText, showTraceTree)
Expand Down Expand Up @@ -240,7 +241,7 @@ execTx
=> VM Concrete RealWorld
-> Tx
-> m ((VMResult Concrete RealWorld, Gas), VM Concrete RealWorld)
execTx vm tx = runStateT (execTxWith (fromEVM exec) tx) vm
execTx vm tx = runStateT (execTxWith (fromEVM (exec defaultConfig)) tx) vm

-- | A type alias for the context we carry while executing instructions
type CoverageContext = (Bool, Maybe (VMut.IOVector CoverageInfo, Int))
Expand Down Expand Up @@ -289,7 +290,7 @@ execTxWithCov tx = do

-- | Execute one instruction on the EVM
stepVM :: VM Concrete RealWorld -> IO (VM Concrete RealWorld)
stepVM = stToIO . execStateT exec1
stepVM = stToIO . execStateT (exec1 defaultConfig)

-- | Add current location to the CoverageMap
addCoverage :: VM Concrete RealWorld -> IO ()
Expand Down
5 changes: 3 additions & 2 deletions lib/Echidna/SourceMapping.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import Data.Maybe (mapMaybe)
import Data.Vector qualified as V
import Echidna.Symbolic (forceWord)
import EVM.Dapp (DappInfo(..), findSrc)
import EVM.Expr (maybeLitByteSimp)
import EVM.Solidity (SolcContract(..))
import EVM.Types (Contract(..), ContractCode(..), RuntimeCode(..), W256, maybeLitByte)
import EVM.Types (Contract(..), ContractCode(..), RuntimeCode(..), W256)

-- | Map from contracts' codehashes to their compile-time codehash.
-- This is relevant when the immutables solidity feature is used;
Expand Down Expand Up @@ -80,7 +81,7 @@ findSrcByMetadata contr dapp = find compareMetadata (snd <$> Map.elems dapp.solc
(UnknownCode _) -> Nothing
(InitCode c _) -> Just c
(RuntimeCode (ConcreteRuntimeCode c)) -> Just c
(RuntimeCode (SymbolicRuntimeCode c)) -> Just $ BS.pack $ mapMaybe maybeLitByte $ V.toList c
(RuntimeCode (SymbolicRuntimeCode c)) -> Just $ BS.pack $ mapMaybe maybeLitByteSimp $ V.toList c

getBytecodeMetadata :: ByteString -> ByteString
getBytecodeMetadata bs =
Expand Down
8 changes: 4 additions & 4 deletions lib/Echidna/SymExec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,16 @@ exploreContract conf contract tx vm = do
let
fetcher = concOrSymFetcher tx solvers rpcInfo
dst = conf.solConf.contractAddr
calldata@(cd, constraints) = mkCalldata (Just (Sig method.methodSignature (snd <$> method.inputs))) []
vmSym = abstractVM calldata contract.runtimeCode Nothing False
vmSym' <- liftIO $ stToIO vmSym
calldata@(cd, constraints) <- mkCalldata (Just (Sig method.methodSignature (snd <$> method.inputs))) []
vmSym <- liftIO $ stToIO $ abstractVM calldata contract.runtimeCode Nothing False
vmReset <- liftIO $ snd <$> runStateT (fromEVM resetState) vm
let vm' = vmReset & execState (loadContract (LitAddr dst))
& vmMakeSymbolic
& #constraints .~ constraints
& #state % #callvalue .~ TxValue
& #state % #caller .~ SymAddr "caller"
& #state % #calldata .~ cd
& #env % #contracts .~ (Map.union vmSym'.env.contracts vm.env.contracts)
& #env % #contracts .~ Map.union vmSym.env.contracts vm.env.contracts
-- TODO we might want to switch vm's state.baseState value to to AbstractBase eventually.
-- Doing so might mess up concolic execution.
exprInter <- interpret fetcher maxIters askSmtIters Naive vm' runExpr
Expand Down Expand Up @@ -137,6 +136,7 @@ vmMakeSymbolic vm
, currentFork = vm.currentFork
, labels = vm.labels
, osEnv = vm.osEnv
, freshVar = vm.freshVar
}

frameStateMakeSymbolic :: FrameState Concrete s -> FrameState Symbolic s
Expand Down
2 changes: 1 addition & 1 deletion stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ packages:

extra-deps:
- git: https://github.com/ethereum/hevm.git
commit: 037ff11779d0089378f01cb103db1171dc642be2
commit: 0f08514c6cbd9f9688a5c7199915c78df59109fe

- smt2-parser-0.1.0.1@sha256:1e1a4565915ed851c13d1e6b8bb5185cf5d454da3b43170825d53e221f753d77,1421
- spawn-0.3@sha256:b91e01d8f2b076841410ae284b32046f91471943dc799c1af77d666c72101f02,1162
Expand Down