Skip to content
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

Forcelit when showing address in events #891

Merged
merged 1 commit into from
Jan 5, 2023
Merged
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
4 changes: 3 additions & 1 deletion lib/Echidna/Events.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import EVM.Format (showValues, showError, contractNamePart)
import EVM.Types (Expr(ConcreteBuf), W256, maybeLitWord)
import EVM.Solidity (contractName)

import Echidna.Types.Buffer (forceLit)

type EventMap = M.Map W256 Event
type Events = [Text]

Expand Down Expand Up @@ -53,7 +55,7 @@ extractEvents decodeErrors dappInfo' vm =
showValues [t | (_, t, NotIndexed) <- types] bytes <>
pack " from: " <>
maybe mempty (\ x -> x <> pack "@") maybeContractName <>
pack (show addr)]
pack (show $ forceLit addr)]
Nothing -> [pack $ show word]
ErrorTrace e ->
case e of
Expand Down
9 changes: 2 additions & 7 deletions lib/Echidna/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ import Data.Set (Set)
import Data.Vector qualified as V
import EVM hiding (value)
import EVM.ABI (abiValueType)
import EVM.Types (Expr(ConcreteBuf, Lit), EType(EWord), Addr, W256)
import EVM.Types (Expr(ConcreteBuf, Lit), Addr, W256)

import Echidna.ABI
import Echidna.Types.Random
import Echidna.Orphans.JSON ()
import Echidna.Types.Buffer (viewBuffer)
import Echidna.Types.Buffer (viewBuffer, forceLit)
import Echidna.Types.Signature (SignatureMap, SolCall, ContractA, FunctionHash, BytecodeMemo, lookupBytecodeMetadata)
import Echidna.Types.Tx
import Echidna.Types.World (World(..))
Expand Down Expand Up @@ -148,8 +148,3 @@ setupTx (Tx c s r g gp v (t, b)) = liftSH . sequence_ $
incrementBalance = (env . contracts . ix r . balance) += v
encode (n, vs) = abiCalldata
(encodeSig (n, abiValueType <$> vs)) $ V.fromList vs

forceLit :: Expr 'EWord -> W256
forceLit x = case x of
Lit x' -> x'
_ -> error "expected Lit"
7 changes: 6 additions & 1 deletion lib/Echidna/Types/Buffer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@
module Echidna.Types.Buffer where

import Data.ByteString (ByteString)
import EVM.Types (Expr(ConcreteBuf), EType(Buf))
import EVM.Types (Expr(ConcreteBuf, Lit), EType(Buf), EType(EWord), W256)

viewBuffer :: Expr 'Buf -> Maybe ByteString
viewBuffer (ConcreteBuf b) = Just b
viewBuffer _ = Nothing

forceLit :: Expr 'EWord -> W256
forceLit x = case x of
Lit x' -> x'
_ -> error "expected Lit"