-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Ethereum virtual machine evaluator -- -- Hevm implements the Ethereum virtual machine semantics. . It can be -- used as a library, and it also comes with an executable that can run -- unit test suites, optionally with a visual TTY debugger. @package hevm @version 0.50.2 module EVM.Demand -- | This is an easy way to force full evaluation of a value inside of the -- IO monad, being essentially just the composition of evaluate -- and force. demand :: (MonadIO m, NFData a) => a -> m () module EVM.FeeSchedule data FeeSchedule n FeeSchedule :: n -> n -> n -> n -> n -> n -> n -> n -> n -> n -> n -> n -> n -> n -> n -> n -> n -> n -> n -> n -> n -> n -> n -> n -> n -> n -> n -> n -> n -> n -> n -> n -> n -> n -> n -> n -> n -> n -> n -> n -> n -> n -> n -> n -> n -> n -> n -> n -> n -> FeeSchedule n [g_zero] :: FeeSchedule n -> n [g_base] :: FeeSchedule n -> n [g_verylow] :: FeeSchedule n -> n [g_low] :: FeeSchedule n -> n [g_mid] :: FeeSchedule n -> n [g_high] :: FeeSchedule n -> n [g_extcode] :: FeeSchedule n -> n [g_balance] :: FeeSchedule n -> n [g_sload] :: FeeSchedule n -> n [g_jumpdest] :: FeeSchedule n -> n [g_sset] :: FeeSchedule n -> n [g_sreset] :: FeeSchedule n -> n [r_sclear] :: FeeSchedule n -> n [g_selfdestruct] :: FeeSchedule n -> n [g_selfdestruct_newaccount] :: FeeSchedule n -> n [r_selfdestruct] :: FeeSchedule n -> n [g_create] :: FeeSchedule n -> n [g_codedeposit] :: FeeSchedule n -> n [g_call] :: FeeSchedule n -> n [g_callvalue] :: FeeSchedule n -> n [g_callstipend] :: FeeSchedule n -> n [g_newaccount] :: FeeSchedule n -> n [g_exp] :: FeeSchedule n -> n [g_expbyte] :: FeeSchedule n -> n [g_memory] :: FeeSchedule n -> n [g_txcreate] :: FeeSchedule n -> n [g_txdatazero] :: FeeSchedule n -> n [g_txdatanonzero] :: FeeSchedule n -> n [g_transaction] :: FeeSchedule n -> n [g_log] :: FeeSchedule n -> n [g_logdata] :: FeeSchedule n -> n [g_logtopic] :: FeeSchedule n -> n [g_sha3] :: FeeSchedule n -> n [g_sha3word] :: FeeSchedule n -> n [g_copy] :: FeeSchedule n -> n [g_blockhash] :: FeeSchedule n -> n [g_extcodehash] :: FeeSchedule n -> n [g_quaddivisor] :: FeeSchedule n -> n [g_ecadd] :: FeeSchedule n -> n [g_ecmul] :: FeeSchedule n -> n [g_pairing_point] :: FeeSchedule n -> n [g_pairing_base] :: FeeSchedule n -> n [g_fround] :: FeeSchedule n -> n [r_block] :: FeeSchedule n -> n [g_cold_sload] :: FeeSchedule n -> n [g_cold_account_access] :: FeeSchedule n -> n [g_warm_storage_read] :: FeeSchedule n -> n [g_access_list_address] :: FeeSchedule n -> n [g_access_list_storage_key] :: FeeSchedule n -> n type EIP n = Num n => FeeSchedule n -> FeeSchedule n eip150 :: EIP n eip160 :: EIP n homestead :: Num n => FeeSchedule n metropolis :: Num n => FeeSchedule n eip1108 :: EIP n eip1884 :: EIP n eip2028 :: EIP n eip2200 :: EIP n istanbul :: Num n => FeeSchedule n eip2929 :: EIP n berlin :: Num n => FeeSchedule n instance GHC.Show.Show n => GHC.Show.Show (EVM.FeeSchedule.FeeSchedule n) module EVM.Hexdump -- | prettyHex renders a ByteString as a multi-line -- String complete with addressing, hex digits, and ASCII -- representation. -- -- Sample output -- --
-- Length: 100 (0x64) bytes -- 0000: 4b c1 ad 8a 5b 47 d7 57 48 64 e7 cc 5e b5 2f 6e K...[G.WHd..^./n -- 0010: c5 b3 a4 73 44 3b 97 53 99 2d 54 e7 1b 2f 91 12 ...sD;.S.-T../.. -- 0020: c8 1a ff c4 3b 2b 72 ea 97 e2 9f e2 93 ad 23 79 ....;+r.......#y -- 0030: e8 0f 08 54 02 14 fa 09 f0 2d 34 c9 08 6b e1 64 ...T.....-4..k.d -- 0040: d1 c5 98 7e d6 a1 98 e2 97 da 46 68 4e 60 11 15 ...~......FhN`.. -- 0050: d8 32 c6 0b 70 f5 2e 76 7f 8d f2 3b ed de 90 c6 .2..p..v...;.... -- 0060: 93 12 9c e1 .... --prettyHex :: Int -> ByteString -> String -- | simpleHex converts a ByteString to a String -- showing the octets grouped in 32-bit words. -- -- Sample output -- --
-- 4b c1 ad 8a 5b 47 d7 57 --simpleHex :: ByteString -> String module EVM.Precompiled -- | Run a given precompiled contract using the C library. execute :: Int -> ByteString -> Int -> Maybe ByteString module EVM.TTYCenteredList -- | Turn a list state value into a widget given an item drawing function. renderList :: (Ord n, Show n) => (Bool -> e -> Widget n) -> Bool -> List n e -> Widget n drawListElements :: (Ord n, Show n) => Bool -> List n e -> (Bool -> e -> Widget n) -> Widget n module EVM.Types data Word512 Word512 :: {-# UNPACK #-} !Word256 -> {-# UNPACK #-} !Word256 -> Word512 data Int512 Int512 :: {-# UNPACK #-} !Int256 -> {-# UNPACK #-} !Word256 -> Int512 newtype W256 W256 :: Word256 -> W256 -- | Expr implements an abstract respresentation of an EVM program -- -- This type can give insight into the provenance of a term which is -- useful, both for the aesthetic purpose of printing terms in a richer -- way, but also to allow optimizations on the AST instead of letting the -- SMT solver do all the heavy lifting. -- -- Memory, calldata, and returndata are all represented as a Buf. -- Semantically speaking a Buf is a byte array with of size 2^256. -- -- Bufs have two base constructors: - AbstractBuf: all elements are fully -- abstract values - ConcreteBuf bs: all elements past (length bs) are -- zero -- -- Bufs can be read from with: - ReadByte idx buf: read the byte at idx -- from buf - ReadWord idx buf: read the byte at idx from buf -- -- Bufs can be written to with: - WriteByte idx val buf: write val to idx -- in buf - WriteWord idx val buf: write val to idx in buf - CopySlice -- srcOffset dstOffset size src dst: overwrite dstOffset -> dstOffset -- + size in dst with srcOffset -> srcOffset + size from src -- -- Note that the shared usage of Buf does allow for the -- construction of some badly typed Expr instances (e.g. an MSTORE on top -- of the contents of calldata instead of some previous instance of -- memory), we accept this for the sake of simplifying pattern matches -- against a Buf expression. -- -- Storage expressions are similar, but instead of writing regions of -- bytes, we write a word to a particular key in a given addresses -- storage. Note that as with a Buf, writes can be sequenced on top of -- concrete, empty and fully abstract starting states. -- -- One important principle is that of local context: e.g. each term -- representing a write to a Buf Storage Logs will always -- contain a copy of the state that is being added to, this ensures that -- all context relevant to a given operation is contained within the term -- that represents that operation. -- -- When dealing with Expr instances we assume that concrete expressions -- have been reduced to their smallest possible representation (i.e. a -- Lit, ConcreteBuf, or ConcreteStore). Failure to -- adhere to this invariant will result in your concrete term being -- treated as symbolic, and may produce unexpected errors. In the future -- we may wish to consider encoding the concreteness of a given term -- directly in the type of that term, since such type level shenanigans -- tends to complicate implementation, we skip this for now. data EType Buf :: EType Storage :: EType Log :: EType EWord :: EType Byte :: EType End :: EType data Error Invalid :: Error IllegalOverflow :: Error StackLimitExceeded :: Error InvalidMemoryAccess :: Error BadJumpDestination :: Error SelfDestruct :: Error TmpErr :: String -> Error data GVar (a :: EType) [BufVar] :: Int -> GVar Buf [StoreVar] :: Int -> GVar Storage data Expr (a :: EType) [Lit] :: W256 -> Expr EWord [Var] :: Text -> Expr EWord [GVar] :: GVar a -> Expr a [LitByte] :: Word8 -> Expr Byte [IndexWord] :: Expr EWord -> Expr EWord -> Expr Byte [EqByte] :: Expr Byte -> Expr Byte -> Expr EWord [JoinBytes] :: Expr Byte -> Expr Byte -> Expr Byte -> Expr Byte -> Expr Byte -> Expr Byte -> Expr Byte -> Expr Byte -> Expr Byte -> Expr Byte -> Expr Byte -> Expr Byte -> Expr Byte -> Expr Byte -> Expr Byte -> Expr Byte -> Expr Byte -> Expr Byte -> Expr Byte -> Expr Byte -> Expr Byte -> Expr Byte -> Expr Byte -> Expr Byte -> Expr Byte -> Expr Byte -> Expr Byte -> Expr Byte -> Expr Byte -> Expr Byte -> Expr Byte -> Expr Byte -> Expr EWord [Revert] :: [Prop] -> Expr Buf -> Expr End [Failure] :: [Prop] -> Error -> Expr End [Return] :: [Prop] -> Expr Buf -> Expr Storage -> Expr End [ITE] :: Expr EWord -> Expr End -> Expr End -> Expr End [Add] :: Expr EWord -> Expr EWord -> Expr EWord [Sub] :: Expr EWord -> Expr EWord -> Expr EWord [Mul] :: Expr EWord -> Expr EWord -> Expr EWord [Div] :: Expr EWord -> Expr EWord -> Expr EWord [SDiv] :: Expr EWord -> Expr EWord -> Expr EWord [Mod] :: Expr EWord -> Expr EWord -> Expr EWord [SMod] :: Expr EWord -> Expr EWord -> Expr EWord [AddMod] :: Expr EWord -> Expr EWord -> Expr EWord -> Expr EWord [MulMod] :: Expr EWord -> Expr EWord -> Expr EWord -> Expr EWord [Exp] :: Expr EWord -> Expr EWord -> Expr EWord [SEx] :: Expr EWord -> Expr EWord -> Expr EWord [Min] :: Expr EWord -> Expr EWord -> Expr EWord [LT] :: Expr EWord -> Expr EWord -> Expr EWord [GT] :: Expr EWord -> Expr EWord -> Expr EWord [LEq] :: Expr EWord -> Expr EWord -> Expr EWord [GEq] :: Expr EWord -> Expr EWord -> Expr EWord [SLT] :: Expr EWord -> Expr EWord -> Expr EWord [SGT] :: Expr EWord -> Expr EWord -> Expr EWord [Eq] :: Expr EWord -> Expr EWord -> Expr EWord [IsZero] :: Expr EWord -> Expr EWord [And] :: Expr EWord -> Expr EWord -> Expr EWord [Or] :: Expr EWord -> Expr EWord -> Expr EWord [Xor] :: Expr EWord -> Expr EWord -> Expr EWord [Not] :: Expr EWord -> Expr EWord [SHL] :: Expr EWord -> Expr EWord -> Expr EWord [SHR] :: Expr EWord -> Expr EWord -> Expr EWord [SAR] :: Expr EWord -> Expr EWord -> Expr EWord [Keccak] :: Expr Buf -> Expr EWord [SHA256] :: Expr Buf -> Expr EWord [Origin] :: Expr EWord [BlockHash] :: Expr EWord -> Expr EWord [Coinbase] :: Expr EWord [Timestamp] :: Expr EWord [BlockNumber] :: Expr EWord [PrevRandao] :: Expr EWord [GasLimit] :: Expr EWord [ChainId] :: Expr EWord [BaseFee] :: Expr EWord [CallValue] :: Int -> Expr EWord [Caller] :: Int -> Expr EWord [Address] :: Int -> Expr EWord [Balance] :: Int -> Int -> Expr EWord -> Expr EWord [SelfBalance] :: Int -> Int -> Expr EWord [Gas] :: Int -> Int -> Expr EWord [CodeSize] :: Expr EWord -> Expr EWord [ExtCodeHash] :: Expr EWord -> Expr EWord [LogEntry] :: Expr EWord -> Expr Buf -> [Expr EWord] -> Expr Log [Create] :: Expr EWord -> Expr EWord -> Expr EWord -> Expr Buf -> [Expr Log] -> Expr Storage -> Expr EWord [Create2] :: Expr EWord -> Expr EWord -> Expr EWord -> Expr EWord -> Expr Buf -> [Expr Log] -> Expr Storage -> Expr EWord [Call] :: Expr EWord -> Maybe (Expr EWord) -> Expr EWord -> Expr EWord -> Expr EWord -> Expr EWord -> Expr EWord -> [Expr Log] -> Expr Storage -> Expr EWord [CallCode] :: Expr EWord -> Expr EWord -> Expr EWord -> Expr EWord -> Expr EWord -> Expr EWord -> Expr EWord -> [Expr Log] -> Expr Storage -> Expr EWord [DelegeateCall] :: Expr EWord -> Expr EWord -> Expr EWord -> Expr EWord -> Expr EWord -> Expr EWord -> Expr EWord -> [Expr Log] -> Expr Storage -> Expr EWord [EmptyStore] :: Expr Storage [ConcreteStore] :: Map W256 (Map W256 W256) -> Expr Storage [AbstractStore] :: Expr Storage [SLoad] :: Expr EWord -> Expr EWord -> Expr Storage -> Expr EWord [SStore] :: Expr EWord -> Expr EWord -> Expr EWord -> Expr Storage -> Expr Storage [ConcreteBuf] :: ByteString -> Expr Buf [AbstractBuf] :: Text -> Expr Buf [ReadWord] :: Expr EWord -> Expr Buf -> Expr EWord [ReadByte] :: Expr EWord -> Expr Buf -> Expr Byte [WriteWord] :: Expr EWord -> Expr EWord -> Expr Buf -> Expr Buf [WriteByte] :: Expr EWord -> Expr Byte -> Expr Buf -> Expr Buf [CopySlice] :: Expr EWord -> Expr EWord -> Expr EWord -> Expr Buf -> Expr Buf -> Expr Buf [BufLength] :: Expr Buf -> Expr EWord data Prop [PEq] :: forall a. Typeable a => Expr a -> Expr a -> Prop [PLT] :: Expr EWord -> Expr EWord -> Prop [PGT] :: Expr EWord -> Expr EWord -> Prop [PGEq] :: Expr EWord -> Expr EWord -> Prop [PLEq] :: Expr EWord -> Expr EWord -> Prop [PNeg] :: Prop -> Prop [PAnd] :: Prop -> Prop -> Prop [POr] :: Prop -> Prop -> Prop [PBool] :: Bool -> Prop (.&&) :: Prop -> Prop -> Prop infixr 3 .&& (.||) :: Prop -> Prop -> Prop infixr 2 .|| (.<) :: Expr EWord -> Expr EWord -> Prop infix 4 .< (.<=) :: Expr EWord -> Expr EWord -> Prop infix 4 .<= (.>) :: Expr EWord -> Expr EWord -> Prop infix 4 .> (.>=) :: Expr EWord -> Expr EWord -> Prop infix 4 .>= (.==) :: Typeable a => Expr a -> Expr a -> Prop infix 4 .== (./=) :: Typeable a => Expr a -> Expr a -> Prop infix 4 ./= unlit :: Expr EWord -> Maybe W256 unlitByte :: Expr Byte -> Maybe Word8 newtype ByteStringS ByteStringS :: ByteString -> ByteStringS newtype Addr Addr :: Word160 -> Addr [addressWord160] :: Addr -> Word160 maybeLitWord :: Expr EWord -> Maybe W256 toChecksumAddress :: String -> String strip0x :: ByteString -> ByteString strip0x' :: String -> String hexByteString :: String -> ByteString -> ByteString hexText :: Text -> ByteString readN :: Integral a => String -> a readNull :: Read a => a -> String -> a wordField :: Object -> Key -> Parser W256 word64Field :: Object -> Key -> Parser Word64 addrField :: Object -> Key -> Parser Addr addrFieldMaybe :: Object -> Key -> Parser (Maybe Addr) dataField :: Object -> Key -> Parser ByteString toWord512 :: W256 -> Word512 fromWord512 :: Word512 -> W256 num :: (Integral a, Num b) => a -> b padLeft :: Int -> ByteString -> ByteString padLeftStr :: Int -> String -> String padRight :: Int -> ByteString -> ByteString padRight' :: Int -> String -> String -- | Right padding / truncating truncpad :: Int -> [SWord 8] -> -- [SWord 8] truncpad n xs = if m > n then take n xs else mappend xs -- (replicate (n - m) 0) where m = length xs padLeft' :: Int -> Vector (Expr Byte) -> Vector (Expr Byte) word256 :: ByteString -> Word256 word :: ByteString -> W256 byteAt :: (Bits a, Bits b, Integral a, Num b) => a -> Int -> b fromBE :: Integral a => ByteString -> a asBE :: Integral a => a -> ByteString word256Bytes :: W256 -> ByteString word160Bytes :: Addr -> ByteString newtype Nibble Nibble :: Word8 -> Nibble hi :: Word8 -> Nibble lo :: Word8 -> Nibble toByte :: Nibble -> Nibble -> Word8 unpackNibbles :: ByteString -> [Nibble] packNibbles :: [Nibble] -> ByteString toWord64 :: W256 -> Maybe Word64 toInt :: W256 -> Maybe Int keccakBytes :: ByteString -> ByteString word32 :: [Word8] -> Word32 keccak :: Expr Buf -> Expr EWord keccak' :: ByteString -> W256 abiKeccak :: ByteString -> Word32 concatMapM :: Monad m => (a -> m [b]) -> [a] -> m [b] regexMatches :: Text -> Text -> Bool instance GHC.Generics.Generic EVM.Types.Word512 instance Data.Data.Data EVM.Types.Word512 instance GHC.Generics.Generic EVM.Types.Int512 instance Data.Data.Data EVM.Types.Int512 instance GHC.Enum.Bounded EVM.Types.W256 instance GHC.Classes.Eq EVM.Types.W256 instance GHC.Enum.Enum EVM.Types.W256 instance GHC.Bits.FiniteBits EVM.Types.W256 instance GHC.Bits.Bits EVM.Types.W256 instance GHC.Generics.Generic EVM.Types.W256 instance GHC.Classes.Ord EVM.Types.W256 instance GHC.Real.Real EVM.Types.W256 instance GHC.Real.Integral EVM.Types.W256 instance GHC.Num.Num EVM.Types.W256 instance GHC.Classes.Ord EVM.Types.Error instance GHC.Classes.Eq EVM.Types.Error instance GHC.Show.Show EVM.Types.Error instance GHC.Classes.Eq EVM.Types.ByteStringS instance GHC.Bits.FiniteBits EVM.Types.Addr instance GHC.Bits.Bits EVM.Types.Addr instance GHC.Generics.Generic EVM.Types.Addr instance GHC.Classes.Eq EVM.Types.Addr instance GHC.Enum.Enum EVM.Types.Addr instance GHC.Classes.Ord EVM.Types.Addr instance GHC.Real.Real EVM.Types.Addr instance GHC.Real.Integral EVM.Types.Addr instance GHC.Num.Num EVM.Types.Addr instance GHC.Generics.Generic EVM.Types.Nibble instance GHC.Enum.Bounded EVM.Types.Nibble instance GHC.Classes.Eq EVM.Types.Nibble instance GHC.Enum.Enum EVM.Types.Nibble instance GHC.Classes.Ord EVM.Types.Nibble instance GHC.Real.Real EVM.Types.Nibble instance GHC.Real.Integral EVM.Types.Nibble instance GHC.Num.Num EVM.Types.Nibble instance GHC.Show.Show (EVM.Types.GVar a) instance GHC.Classes.Eq (EVM.Types.GVar a) instance GHC.Classes.Ord (EVM.Types.GVar a) instance GHC.Show.Show (EVM.Types.Expr a) instance GHC.Classes.Eq (EVM.Types.Expr a) instance GHC.Classes.Ord (EVM.Types.Expr a) instance GHC.Show.Show EVM.Types.Prop instance GHC.Show.Show EVM.Types.Nibble instance GHC.Read.Read EVM.Types.Addr instance GHC.Show.Show EVM.Types.Addr instance Data.Aeson.Types.FromJSON.FromJSON EVM.Types.Addr instance Data.Aeson.Types.FromJSON.FromJSONKey EVM.Types.Addr instance Options.Generic.ParseField EVM.Types.Addr instance Options.Generic.ParseFields EVM.Types.Addr instance Options.Generic.ParseRecord EVM.Types.Addr instance GHC.Show.Show EVM.Types.ByteStringS instance Data.Aeson.Types.ToJSON.ToJSON EVM.Types.ByteStringS instance GHC.Classes.Eq EVM.Types.Prop instance GHC.Classes.Ord EVM.Types.Prop instance GHC.Read.Read EVM.Types.W256 instance GHC.Show.Show EVM.Types.W256 instance Data.Aeson.Types.ToJSON.ToJSON EVM.Types.W256 instance Data.Aeson.Types.FromJSON.FromJSON EVM.Types.W256 instance Data.Aeson.Types.FromJSON.FromJSONKey EVM.Types.W256 instance Options.Generic.ParseField EVM.Types.W256 instance Options.Generic.ParseFields EVM.Types.W256 instance Options.Generic.ParseRecord EVM.Types.W256 instance Data.BinaryWord.BinaryWord EVM.Types.Word512 instance Data.DoubleWord.Base.DoubleWord EVM.Types.Int512 instance GHC.Classes.Eq EVM.Types.Int512 instance GHC.Classes.Ord EVM.Types.Int512 instance GHC.Enum.Bounded EVM.Types.Int512 instance GHC.Enum.Enum EVM.Types.Int512 instance GHC.Num.Num EVM.Types.Int512 instance GHC.Real.Real EVM.Types.Int512 instance GHC.Real.Integral EVM.Types.Int512 instance GHC.Show.Show EVM.Types.Int512 instance GHC.Read.Read EVM.Types.Int512 instance Data.Hashable.Class.Hashable EVM.Types.Int512 instance GHC.Ix.Ix EVM.Types.Int512 instance GHC.Bits.Bits EVM.Types.Int512 instance GHC.Bits.FiniteBits EVM.Types.Int512 instance Data.BinaryWord.BinaryWord EVM.Types.Int512 instance Data.DoubleWord.Base.DoubleWord EVM.Types.Word512 instance GHC.Classes.Eq EVM.Types.Word512 instance GHC.Classes.Ord EVM.Types.Word512 instance GHC.Enum.Bounded EVM.Types.Word512 instance GHC.Enum.Enum EVM.Types.Word512 instance GHC.Num.Num EVM.Types.Word512 instance GHC.Real.Real EVM.Types.Word512 instance GHC.Real.Integral EVM.Types.Word512 instance GHC.Show.Show EVM.Types.Word512 instance GHC.Read.Read EVM.Types.Word512 instance Data.Hashable.Class.Hashable EVM.Types.Word512 instance GHC.Ix.Ix EVM.Types.Word512 instance GHC.Bits.Bits EVM.Types.Word512 instance GHC.Bits.FiniteBits EVM.Types.Word512 module EVM.Traversals foldProp :: forall b. Monoid b => (forall a. Expr a -> b) -> b -> Prop -> b -- | Recursively folds a given function over a given expression Recursion -- schemes do this & a lot more, but defining them over GADT's isn't -- worth the hassle foldExpr :: forall b c. Monoid b => (forall a. Expr a -> b) -> b -> Expr c -> b mapProp :: (forall a. Expr a -> Expr a) -> Prop -> Prop -- | Recursively applies a given function to every node in a given expr -- instance Recursion schemes do this & a lot more, but defining them -- over GADT's isn't worth the hassle mapExpr :: (forall a. Expr a -> Expr a) -> Expr b -> Expr b mapExprM :: Monad m => (forall a. Expr a -> m (Expr a)) -> Expr b -> m (Expr b) mapPropM :: Monad m => (forall a. Expr a -> m (Expr a)) -> Prop -> m Prop module EVM.RLP data RLP BS :: ByteString -> RLP List :: [RLP] -> RLP slice :: Int -> Int -> ByteString -> ByteString itemInfo :: ByteString -> (Int, Int, Bool, Bool) rlpdecode :: ByteString -> Maybe RLP rlplengths :: ByteString -> Int -> Int -> [(Int, Int)] rlpencode :: RLP -> ByteString encodeLen :: Int -> ByteString -> ByteString rlpList :: [RLP] -> ByteString octets :: W256 -> ByteString octetsFull :: Int -> W256 -> ByteString octets160 :: Addr -> ByteString rlpWord256 :: W256 -> RLP rlpWordFull :: W256 -> RLP rlpAddrFull :: Addr -> RLP rlpWord160 :: Addr -> RLP instance GHC.Classes.Eq EVM.RLP.RLP instance GHC.Show.Show EVM.RLP.RLP module EVM.Patricia data KV k v a Put :: k -> v -> a -> KV k v a Get :: k -> (v -> a) -> KV k v a newtype DB k v a DB :: Free (KV k v) a -> DB k v a insertDB :: k -> v -> DB k v () lookupDB :: k -> DB k v v runDB :: Monad m => (k -> v -> m ()) -> (k -> m v) -> DB k v a -> m a type Path = [Nibble] data Ref Hash :: ByteString -> Ref Literal :: Node -> Ref data Node Empty :: Node Shortcut :: Path -> Either Ref ByteString -> Node Full :: Seq Ref -> ByteString -> Node encodePath :: Path -> Bool -> ByteString rlpRef :: Ref -> RLP rlpNode :: Node -> RLP type NodeDB = DB ByteString Node putNode :: Node -> NodeDB Ref getNode :: Ref -> NodeDB Node lookupPath :: Ref -> Path -> NodeDB ByteString getVal :: Path -> Node -> NodeDB ByteString emptyRef :: Ref emptyRefs :: Seq Ref addPrefix :: Path -> Node -> NodeDB Node insertRef :: Ref -> Path -> ByteString -> NodeDB Ref update :: Node -> Path -> ByteString -> NodeDB Node delete :: Node -> Path -> NodeDB Node insert :: Ref -> ByteString -> ByteString -> NodeDB Ref lookupIn :: Ref -> ByteString -> NodeDB ByteString type Trie = StateT Ref NodeDB runTrie :: DB ByteString ByteString a -> Trie a type MapDB k v a = StateT (Map k v) Maybe a runMapDB :: Ord k => DB k v a -> MapDB k v a insertValues :: [(ByteString, ByteString)] -> Maybe Ref calcRoot :: [(ByteString, ByteString)] -> Maybe ByteString instance GHC.Base.Functor (EVM.Patricia.KV k v) instance GHC.Base.Monad (EVM.Patricia.DB k v) instance GHC.Base.Applicative (EVM.Patricia.DB k v) instance GHC.Base.Functor (EVM.Patricia.DB k v) instance GHC.Classes.Eq EVM.Patricia.Ref instance GHC.Classes.Eq EVM.Patricia.Node instance GHC.Show.Show EVM.Patricia.Node instance GHC.Show.Show (EVM.Patricia.NodeDB EVM.Patricia.Node) instance GHC.Show.Show EVM.Patricia.Ref module EVM.Op data Op OpStop :: Op OpAdd :: Op OpMul :: Op OpSub :: Op OpDiv :: Op OpSdiv :: Op OpMod :: Op OpSmod :: Op OpAddmod :: Op OpMulmod :: Op OpExp :: Op OpSignextend :: Op OpLt :: Op OpGt :: Op OpSlt :: Op OpSgt :: Op OpEq :: Op OpIszero :: Op OpAnd :: Op OpOr :: Op OpXor :: Op OpNot :: Op OpByte :: Op OpShl :: Op OpShr :: Op OpSar :: Op OpSha3 :: Op OpAddress :: Op OpBalance :: Op OpOrigin :: Op OpCaller :: Op OpCallvalue :: Op OpCalldataload :: Op OpCalldatasize :: Op OpCalldatacopy :: Op OpCodesize :: Op OpCodecopy :: Op OpGasprice :: Op OpExtcodesize :: Op OpExtcodecopy :: Op OpReturndatasize :: Op OpReturndatacopy :: Op OpExtcodehash :: Op OpBlockhash :: Op OpCoinbase :: Op OpTimestamp :: Op OpNumber :: Op OpPrevRandao :: Op OpGaslimit :: Op OpChainid :: Op OpSelfbalance :: Op OpPop :: Op OpMload :: Op OpMstore :: Op OpMstore8 :: Op OpSload :: Op OpSstore :: Op OpJump :: Op OpJumpi :: Op OpPc :: Op OpMsize :: Op OpGas :: Op OpJumpdest :: Op OpCreate :: Op OpCall :: Op OpStaticcall :: Op OpCallcode :: Op OpReturn :: Op OpDelegatecall :: Op OpCreate2 :: Op OpRevert :: Op OpSelfdestruct :: Op OpDup :: !Word8 -> Op OpSwap :: !Word8 -> Op OpLog :: !Word8 -> Op OpPush :: Expr EWord -> Op OpUnknown :: Word8 -> Op opString :: (Integral a, Show a) => (a, Op) -> String instance GHC.Classes.Eq EVM.Op.Op instance GHC.Show.Show EVM.Op.Op module EVM.Keccak keccakAssumptions :: [Prop] -> [Expr Buf] -> [Expr Storage] -> [Prop] instance GHC.Show.Show EVM.Keccak.BuilderState -- | Helper functions for working with Expr instances. All functions here -- will return a concrete result if given a concrete input. module EVM.Expr op1 :: (Expr EWord -> Expr EWord) -> (W256 -> W256) -> Expr EWord -> Expr EWord op2 :: (Expr EWord -> Expr EWord -> Expr EWord) -> (W256 -> W256 -> W256) -> Expr EWord -> Expr EWord -> Expr EWord op3 :: (Expr EWord -> Expr EWord -> Expr EWord -> Expr EWord) -> (W256 -> W256 -> W256 -> W256) -> Expr EWord -> Expr EWord -> Expr EWord -> Expr EWord -- | If a given binary op is commutative, then we always force Lits to the -- lhs if only one argument is a Lit. This makes writing pattern matches -- in the simplifier easier. normArgs :: (Expr EWord -> Expr EWord -> Expr EWord) -> (W256 -> W256 -> W256) -> Expr EWord -> Expr EWord -> Expr EWord add :: Expr EWord -> Expr EWord -> Expr EWord sub :: Expr EWord -> Expr EWord -> Expr EWord mul :: Expr EWord -> Expr EWord -> Expr EWord div :: Expr EWord -> Expr EWord -> Expr EWord sdiv :: Expr EWord -> Expr EWord -> Expr EWord mod :: Expr EWord -> Expr EWord -> Expr EWord smod :: Expr EWord -> Expr EWord -> Expr EWord addmod :: Expr EWord -> Expr EWord -> Expr EWord -> Expr EWord mulmod :: Expr EWord -> Expr EWord -> Expr EWord -> Expr EWord exp :: Expr EWord -> Expr EWord -> Expr EWord sex :: Expr EWord -> Expr EWord -> Expr EWord lt :: Expr EWord -> Expr EWord -> Expr EWord gt :: Expr EWord -> Expr EWord -> Expr EWord leq :: Expr EWord -> Expr EWord -> Expr EWord geq :: Expr EWord -> Expr EWord -> Expr EWord slt :: Expr EWord -> Expr EWord -> Expr EWord sgt :: Expr EWord -> Expr EWord -> Expr EWord eq :: Expr EWord -> Expr EWord -> Expr EWord iszero :: Expr EWord -> Expr EWord and :: Expr EWord -> Expr EWord -> Expr EWord or :: Expr EWord -> Expr EWord -> Expr EWord xor :: Expr EWord -> Expr EWord -> Expr EWord not :: Expr EWord -> Expr EWord shl :: Expr EWord -> Expr EWord -> Expr EWord shr :: Expr EWord -> Expr EWord -> Expr EWord sar :: Expr EWord -> Expr EWord -> Expr EWord -- | Extracts the byte at a given index from a Buf. -- -- We do our best to return a concrete value wherever possible, but -- fallback to an abstract expresion if nescessary. Note that a Buf is an -- infinite structure, so reads outside of the bounds of a ConcreteBuf -- return 0. This is inline with the semantics of calldata and memory, -- but not of returndata. readByte :: Expr EWord -> Expr Buf -> Expr Byte -- | Reads n bytes starting from idx in buf and returns a left padded word -- -- If n is >= 32 this is the same as readWord readBytes :: Int -> Expr EWord -> Expr Buf -> Expr EWord -- | Reads the word starting at idx from the given buf readWord :: Expr EWord -> Expr Buf -> Expr EWord readWordFromBytes :: Expr EWord -> Expr Buf -> Expr EWord -- | Copies a slice of src into dst. -- -- 0 srcOffset srcOffset + size length src -- ┌--------------┬------------------┬-----------------┐ src: | | ------ -- sl ------ | | └--------------┴------------------┴-----------------┘ -- -- 0 dstOffset dstOffset + size length dst -- ┌--------┬------------------┬-----------------┐ dst: | hd | | tl | -- └--------┴------------------┴-----------------┘ maxBytes :: W256 copySlice :: Expr EWord -> Expr EWord -> Expr EWord -> Expr Buf -> Expr Buf -> Expr Buf writeByte :: Expr EWord -> Expr Byte -> Expr Buf -> Expr Buf writeWord :: Expr EWord -> Expr EWord -> Expr Buf -> Expr Buf -- | Returns the length of a given buffer -- -- If there are any writes to abstract locations, or CopySlices with an -- abstract size or dstOffset, an abstract expresion will be returned. bufLength :: Expr Buf -> Expr EWord -- | If a buffer has a concrete prefix, we return it's length here concPrefix :: Expr Buf -> Maybe Integer word256At :: Functor f => Expr EWord -> (Expr EWord -> f (Expr EWord)) -> Expr Buf -> f (Expr Buf) -- | Returns the first n bytes of buf take :: W256 -> Expr Buf -> Expr Buf -- | Returns everything but the first n bytes of buf drop :: W256 -> Expr Buf -> Expr Buf slice :: Expr EWord -> Expr EWord -> Expr Buf -> Expr Buf toList :: Expr Buf -> Maybe (Vector (Expr Byte)) fromList :: Vector (Expr Byte) -> Expr Buf -- | Removes any irrelevant writes when reading from a buffer simplifyReads :: Expr a -> Expr a -- | Strips writes from the buffer that can be statically determined to be -- out of range TODO: are the bounds here correct? I think there might be -- some off by one mistakes... stripWrites :: W256 -> W256 -> Expr Buf -> Expr Buf -- | Reads the word at the given slot from the given storage expression. -- -- Note that we return a Nothing instead of a 0x0 if we are reading from -- a store that is backed by a ConcreteStore or an EmptyStore and there -- have been no explicit writes to the requested slot. This makes -- implementing rpc storage lookups much easier. If the store is backed -- by an AbstractStore we always return a symbolic value. readStorage :: Expr EWord -> Expr EWord -> Expr Storage -> Maybe (Expr EWord) readStorage' :: Expr EWord -> Expr EWord -> Expr Storage -> Expr EWord -- | Writes a value to a key in a storage expression. -- -- Concrete writes on top of a concrete or empty store will produce a new -- ConcreteStore, otherwise we add a new write to the storage expression. writeStorage :: Expr EWord -> Expr EWord -> Expr EWord -> Expr Storage -> Expr Storage -- | Simple recursive match based AST simplification Note: may not -- terminate! simplify :: Expr a -> Expr a litAddr :: Addr -> Expr EWord litCode :: ByteString -> [Expr Byte] to512 :: W256 -> Word512 isLitByte :: Expr Byte -> Bool isLitWord :: Expr EWord -> Bool -- | Returns the byte at idx from the given word. indexWord :: Expr EWord -> Expr EWord -> Expr Byte padByte :: Expr Byte -> Expr EWord -- | Converts a list of bytes into a W256. TODO: semantics if the input is -- too large? bytesToW256 :: [Word8] -> W256 padBytesLeft :: Int -> [Expr Byte] -> [Expr Byte] joinBytes :: [Expr Byte] -> Expr EWord eqByte :: Expr Byte -> Expr Byte -> Expr EWord min :: Expr EWord -> Expr EWord -> Expr EWord numBranches :: Expr End -> Int allLit :: [Expr Byte] -> Bool instance GHC.Base.Semigroup (EVM.Types.Expr 'EVM.Types.Buf) instance GHC.Base.Monoid (EVM.Types.Expr 'EVM.Types.Buf) module EVM.Concrete wordAt :: Int -> ByteString -> W256 readByteOrZero :: Int -> ByteString -> Word8 byteStringSliceWithDefaultZeroes :: Int -> Int -> ByteString -> ByteString sliceMemory :: (Integral a, Integral b) => a -> b -> ByteString -> ByteString writeMemory :: ByteString -> W256 -> W256 -> W256 -> ByteString -> ByteString (^) :: W256 -> W256 -> W256 createAddress :: Addr -> W256 -> Addr create2Address :: Addr -> W256 -> ByteString -> Addr module EVM.CSE type BufEnv = Map Int (Expr Buf) type StoreEnv = Map Int (Expr Storage) eliminateExpr :: Expr a -> (Expr a, BufEnv, StoreEnv) -- | Common subexpression elimination pass for list of Prop eliminateProps :: [Prop] -> ([Prop], BufEnv, StoreEnv) instance GHC.Show.Show EVM.CSE.BuilderState module EVM.SMT data CexVars CexVars :: [Text] -> [Text] -> [Text] -> [Text] -> CexVars [calldataV] :: CexVars -> [Text] [buffersV] :: CexVars -> [Text] [blockContextV] :: CexVars -> [Text] [txContextV] :: CexVars -> [Text] data SMTCex SMTCex :: Map (Expr EWord) W256 -> Map (Expr Buf) ByteString -> Map (Expr EWord) W256 -> Map (Expr EWord) W256 -> SMTCex [vars] :: SMTCex -> Map (Expr EWord) W256 [buffers] :: SMTCex -> Map (Expr Buf) ByteString [blockContext] :: SMTCex -> Map (Expr EWord) W256 [txContext] :: SMTCex -> Map (Expr EWord) W256 getVar :: SMTCex -> Text -> W256 data SMT2 SMT2 :: [Builder] -> CexVars -> SMT2 formatSMT2 :: SMT2 -> Text -- | Reads all intermediate variables from the builder state and produces -- SMT declaring them as constants declareIntermediates :: BufEnv -> StoreEnv -> SMT2 assertProps :: [Prop] -> SMT2 prelude :: SMT2 declareBufs :: [Builder] -> SMT2 referencedBufs :: Expr a -> [Builder] referencedBufs' :: Prop -> [Builder] referencedVars' :: Prop -> [Builder] referencedFrameContext' :: Prop -> [Builder] referencedBlockContext' :: Prop -> [Builder] declareVars :: [Builder] -> SMT2 referencedVars :: Expr a -> [Builder] declareFrameContext :: [Builder] -> SMT2 referencedFrameContext :: Expr a -> [Builder] declareBlockContext :: [Builder] -> SMT2 referencedBlockContext :: Expr a -> [Builder] exprToSMT :: Expr a -> Builder sp :: Builder -> Builder -> Builder zero :: Builder one :: Builder propToSMT :: Prop -> Builder -- | Supported solvers data Solver Z3 :: Solver CVC5 :: Solver Bitwuzla :: Solver Custom :: Text -> Solver -- | A running solver instance data SolverInstance SolverInstance :: Solver -> Handle -> Handle -> Handle -> ProcessHandle -> SolverInstance [_type] :: SolverInstance -> Solver [_stdin] :: SolverInstance -> Handle [_stdout] :: SolverInstance -> Handle [_stderr] :: SolverInstance -> Handle [_process] :: SolverInstance -> ProcessHandle -- | A channel representing a group of solvers newtype SolverGroup SolverGroup :: Chan Task -> SolverGroup -- | A script to be executed, a list of models to be extracted in the case -- of a sat result, and a channel where the result should be written data Task Task :: SMT2 -> Chan CheckSatResult -> Task [script] :: Task -> SMT2 [resultChan] :: Task -> Chan CheckSatResult -- | The result of a call to (check-sat) data CheckSatResult Sat :: SMTCex -> CheckSatResult Unsat :: CheckSatResult Unknown :: CheckSatResult Error :: Text -> CheckSatResult isSat :: CheckSatResult -> Bool isErr :: CheckSatResult -> Bool isUnsat :: CheckSatResult -> Bool checkSat :: SolverGroup -> SMT2 -> IO CheckSatResult parseW256 :: SpecConstant -> W256 parseInteger :: SpecConstant -> Integer parseW8 :: SpecConstant -> Word8 parseErr :: Show a => a -> b parseVar :: Text -> Expr EWord parseBlockCtx :: Text -> Expr EWord parseFrameCtx :: Text -> Expr EWord getVars :: (Text -> Expr EWord) -> SolverInstance -> [Text] -> IO (Map (Expr EWord) W256) getBufs :: SolverInstance -> [Text] -> IO (Map (Expr Buf) ByteString) parseSC :: (Num a, Eq a) => SpecConstant -> a withSolvers :: Solver -> Natural -> Maybe Natural -> (SolverGroup -> IO a) -> IO a -- | Arguments used when spawing a solver instance solverArgs :: Solver -> Maybe Natural -> [Text] -- | Spawns a solver instance, and sets the various global config options -- that we use for our queries spawnSolver :: Solver -> Maybe Natural -> IO SolverInstance -- | Cleanly shutdown a running solver instnace stopSolver :: SolverInstance -> IO () -- | Sends a list of commands to the solver. Returns the first error, if -- there was one. sendScript :: SolverInstance -> SMT2 -> IO (Either Text ()) -- | Sends a single command to the solver, returns the first available line -- from the output buffer sendCommand :: SolverInstance -> Text -> IO Text -- | Sends a string to the solver and appends a newline, returns the first -- available line from the output buffer sendLine :: SolverInstance -> Text -> IO Text -- | Sends a string to the solver and appends a newline, doesn't return -- stdout sendLine' :: SolverInstance -> Text -> IO () -- | Returns a string representation of the model for the requested -- variable getValue :: SolverInstance -> Text -> IO Text -- | Reads lines from h until we have a balanced sexpr readSExpr :: Handle -> IO [Text] -- | Stores a region of src into dst copySlice :: Expr EWord -> Expr EWord -> Expr EWord -> Builder -> Builder -> Builder -- | Unrolls an exponentiation into a series of multiplications expandExp :: Expr EWord -> W256 -> Builder -- | Concatenates a list of bytes into a larger bitvector concatBytes :: [Expr Byte] -> Builder -- | Concatenates a list of bytes into a larger bitvector writeBytes :: ByteString -> Expr Buf -> Builder encodeConcreteStore :: Map W256 (Map W256 W256) -> Builder instance GHC.Show.Show EVM.SMT.CexVars instance GHC.Classes.Eq EVM.SMT.CexVars instance GHC.Show.Show EVM.SMT.SMTCex instance GHC.Classes.Eq EVM.SMT.SMTCex instance GHC.Show.Show EVM.SMT.SMT2 instance GHC.Classes.Eq EVM.SMT.SMT2 instance GHC.Classes.Eq EVM.SMT.CheckSatResult instance GHC.Show.Show EVM.SMT.CheckSatResult instance GHC.Show.Show EVM.SMT.Solver instance GHC.Base.Semigroup EVM.SMT.SMT2 instance GHC.Base.Monoid EVM.SMT.SMT2 instance GHC.Base.Semigroup EVM.SMT.CexVars instance GHC.Base.Monoid EVM.SMT.CexVars module EVM.ABI data AbiValue AbiUInt :: Int -> Word256 -> AbiValue AbiInt :: Int -> Int256 -> AbiValue AbiAddress :: Addr -> AbiValue AbiBool :: Bool -> AbiValue AbiBytes :: Int -> ByteString -> AbiValue AbiBytesDynamic :: ByteString -> AbiValue AbiString :: ByteString -> AbiValue AbiArrayDynamic :: AbiType -> Vector AbiValue -> AbiValue AbiArray :: Int -> AbiType -> Vector AbiValue -> AbiValue AbiTuple :: Vector AbiValue -> AbiValue data AbiType AbiUIntType :: Int -> AbiType AbiIntType :: Int -> AbiType AbiAddressType :: AbiType AbiBoolType :: AbiType AbiBytesType :: Int -> AbiType AbiBytesDynamicType :: AbiType AbiStringType :: AbiType AbiArrayDynamicType :: AbiType -> AbiType AbiArrayType :: Int -> AbiType -> AbiType AbiTupleType :: Vector AbiType -> AbiType data AbiKind Dynamic :: AbiKind Static :: AbiKind data AbiVals NoVals :: AbiVals CAbi :: [AbiValue] -> AbiVals SAbi :: [Expr EWord] -> AbiVals abiKind :: AbiType -> AbiKind data Event Event :: Text -> Anonymity -> [(Text, AbiType, Indexed)] -> Event data SolError SolError :: Text -> [AbiType] -> SolError data Anonymity Anonymous :: Anonymity NotAnonymous :: Anonymity data Indexed Indexed :: Indexed NotIndexed :: Indexed putAbi :: AbiValue -> Put getAbi :: AbiType -> Get AbiValue -- | Decode a sequence type (e.g. tuple / array). Will fail for non -- sequence types getAbiSeq :: Int -> [AbiType] -> Get (Vector AbiValue) genAbiValue :: AbiType -> Gen AbiValue abiValueType :: AbiValue -> AbiType abiTypeSolidity :: AbiType -> Text abiMethod :: Text -> AbiValue -> ByteString emptyAbi :: AbiValue encodeAbiValue :: AbiValue -> ByteString decodeAbiValue :: AbiType -> ByteString -> AbiValue decodeBuf :: [AbiType] -> Expr Buf -> AbiVals decodeStaticArgs :: Int -> Int -> Expr Buf -> [Expr EWord] formatString :: ByteString -> String parseTypeName :: Vector AbiType -> Text -> Maybe AbiType makeAbiValue :: AbiType -> String -> AbiValue parseAbiValue :: AbiType -> ReadP AbiValue selector :: Text -> ByteString instance GHC.Generics.Generic EVM.ABI.AbiType instance GHC.Classes.Ord EVM.ABI.AbiType instance GHC.Classes.Eq EVM.ABI.AbiType instance GHC.Read.Read EVM.ABI.AbiType instance GHC.Generics.Generic EVM.ABI.AbiValue instance GHC.Classes.Ord EVM.ABI.AbiValue instance GHC.Classes.Eq EVM.ABI.AbiValue instance GHC.Read.Read EVM.ABI.AbiValue instance GHC.Generics.Generic EVM.ABI.AbiKind instance GHC.Classes.Ord EVM.ABI.AbiKind instance GHC.Classes.Eq EVM.ABI.AbiKind instance GHC.Read.Read EVM.ABI.AbiKind instance GHC.Show.Show EVM.ABI.AbiKind instance GHC.Generics.Generic EVM.ABI.Anonymity instance GHC.Classes.Eq EVM.ABI.Anonymity instance GHC.Classes.Ord EVM.ABI.Anonymity instance GHC.Show.Show EVM.ABI.Anonymity instance GHC.Generics.Generic EVM.ABI.Indexed instance GHC.Classes.Eq EVM.ABI.Indexed instance GHC.Classes.Ord EVM.ABI.Indexed instance GHC.Show.Show EVM.ABI.Indexed instance GHC.Generics.Generic EVM.ABI.Event instance GHC.Classes.Eq EVM.ABI.Event instance GHC.Classes.Ord EVM.ABI.Event instance GHC.Show.Show EVM.ABI.Event instance GHC.Generics.Generic EVM.ABI.SolError instance GHC.Classes.Eq EVM.ABI.SolError instance GHC.Classes.Ord EVM.ABI.SolError instance GHC.Show.Show EVM.ABI.SolError instance GHC.Show.Show EVM.ABI.AbiVals instance GHC.Read.Read EVM.ABI.Boolz instance GHC.Show.Show EVM.ABI.AbiValue instance Test.QuickCheck.Arbitrary.Arbitrary EVM.ABI.AbiValue instance GHC.Show.Show EVM.ABI.AbiType instance Test.QuickCheck.Arbitrary.Arbitrary EVM.ABI.AbiType module EVM.Solidity solidity :: Text -> Text -> IO (Maybe ByteString) solcRuntime :: Text -> Text -> IO (Maybe ByteString) solidity' :: Text -> IO (Text, Text) yul' :: Text -> IO (Text, Text) yul :: Text -> Text -> IO (Maybe ByteString) yulRuntime :: Text -> Text -> IO (Maybe ByteString) data JumpType JumpInto :: JumpType JumpFrom :: JumpType JumpRegular :: JumpType data SolcContract SolcContract :: W256 -> W256 -> ByteString -> ByteString -> Text -> [(Text, AbiType)] -> Map Word32 Method -> Map W256 Event -> Map W256 SolError -> Map W256 [Reference] -> Maybe (Map Text StorageItem) -> Seq SrcMap -> Seq SrcMap -> SolcContract [_runtimeCodehash] :: SolcContract -> W256 [_creationCodehash] :: SolcContract -> W256 [_runtimeCode] :: SolcContract -> ByteString [_creationCode] :: SolcContract -> ByteString [_contractName] :: SolcContract -> Text [_constructorInputs] :: SolcContract -> [(Text, AbiType)] [_abiMap] :: SolcContract -> Map Word32 Method [_eventMap] :: SolcContract -> Map W256 Event [_errorMap] :: SolcContract -> Map W256 SolError [_immutableReferences] :: SolcContract -> Map W256 [Reference] [_storageLayout] :: SolcContract -> Maybe (Map Text StorageItem) [_runtimeSrcmap] :: SolcContract -> Seq SrcMap [_creationSrcmap] :: SolcContract -> Seq SrcMap data StorageItem StorageItem :: SlotType -> Int -> Int -> StorageItem [_type] :: StorageItem -> SlotType [_offset] :: StorageItem -> Int [_slot] :: StorageItem -> Int data SourceCache SourceCache :: [(Text, ByteString)] -> [Vector ByteString] -> Map Text Value -> SourceCache [_sourceFiles] :: SourceCache -> [(Text, ByteString)] [_sourceLines] :: SourceCache -> [Vector ByteString] [_sourceAsts] :: SourceCache -> Map Text Value data SrcMap SM :: {-# UNPACK #-}Int -> {-# UNPACK #-}Int -> {-# UNPACK #-}Int -> JumpType -> {-# UNPACK #-}Int -> SrcMap [srcMapOffset] :: SrcMap -> {-# UNPACK #-}Int [srcMapLength] :: SrcMap -> {-# UNPACK #-}Int [srcMapFile] :: SrcMap -> {-# UNPACK #-}Int [srcMapJump] :: SrcMap -> JumpType [srcMapModifierDepth] :: SrcMap -> {-# UNPACK #-}Int data CodeType Creation :: CodeType Runtime :: CodeType data Method Method :: [(Text, AbiType)] -> [(Text, AbiType)] -> Text -> Text -> Mutability -> Method [_methodOutput] :: Method -> [(Text, AbiType)] [_methodInputs] :: Method -> [(Text, AbiType)] [_methodName] :: Method -> Text [_methodSignature] :: Method -> Text [_methodMutability] :: Method -> Mutability data SlotType StorageMapping :: NonEmpty AbiType -> AbiType -> SlotType StorageValue :: AbiType -> SlotType data Reference Reference :: Int -> Int -> Reference [_refStart] :: Reference -> Int [_refLength] :: Reference -> Int data Mutability -- | specified to not read blockchain state Pure :: Mutability -- | specified to not modify the blockchain state View :: Mutability -- | function does not accept Ether - the default NonPayable :: Mutability -- | function accepts Ether Payable :: Mutability methodName :: Lens' Method Text methodSignature :: Lens' Method Text methodInputs :: Lens' Method [(Text, AbiType)] methodOutput :: Lens' Method [(Text, AbiType)] methodMutability :: Lens' Method Mutability abiMap :: Lens' SolcContract (Map Word32 Method) eventMap :: Lens' SolcContract (Map W256 Event) errorMap :: Lens' SolcContract (Map W256 SolError) storageLayout :: Lens' SolcContract (Maybe (Map Text StorageItem)) contractName :: Lens' SolcContract Text constructorInputs :: Lens' SolcContract [(Text, AbiType)] creationCode :: Lens' SolcContract ByteString functionAbi :: Text -> IO Method makeSrcMaps :: Text -> Maybe (Seq SrcMap) readSolc :: FilePath -> IO (Maybe (Map Text SolcContract, SourceCache)) readJSON :: Text -> Maybe (Map Text SolcContract, Map Text Value, [(Text, Maybe ByteString)]) readStdJSON :: Text -> Maybe (Map Text SolcContract, Map Text Value, [(Text, Maybe ByteString)]) readCombinedJSON :: Text -> Maybe (Map Text SolcContract, Map Text Value, [(Text, Maybe ByteString)]) runtimeCode :: Lens' SolcContract ByteString runtimeCodehash :: Lens' SolcContract W256 creationCodehash :: Lens' SolcContract W256 runtimeSrcmap :: Lens' SolcContract (Seq SrcMap) creationSrcmap :: Lens' SolcContract (Seq SrcMap) sourceFiles :: Lens' SourceCache [(Text, ByteString)] sourceLines :: Lens' SourceCache [Vector ByteString] sourceAsts :: Lens' SourceCache (Map Text Value) immutableReferences :: Lens' SolcContract (Map W256 [Reference]) -- | When doing CREATE and passing constructor arguments, Solidity loads -- the argument data via the creation bytecode, since there is no -- "calldata" for CREATE. -- -- This interferes with our ability to look up the current contract by -- codehash, so we must somehow strip away this extra suffix. Luckily we -- can detect the end of the actual bytecode by looking for the "metadata -- hash". (Not 100% correct, but works in practice.) -- -- Actually, we strip away the entire BZZR suffix too, because as long as -- the codehash matches otherwise, we don't care if there is some -- difference there. stripBytecodeMetadata :: ByteString -> ByteString stripBytecodeMetadataSym :: [Expr Byte] -> [Expr Byte] signature :: AsValue s => s -> Text solc :: Language -> Text -> IO Text data Language Solidity :: Language Yul :: Language stdjson :: Language -> Text -> Text parseMethodInput :: AsValue s => s -> (Text, AbiType) lineSubrange :: Vector ByteString -> (Int, Int) -> Int -> Maybe (Int, Int) -- | Every node in the AST has an ID, and other nodes reference those IDs. -- This function recurses through the tree looking for objects with the -- "id" key and makes a big map from ID to value. astIdMap :: Foldable f => f Value -> Map Int Value astSrcMap :: Map Int Value -> SrcMap -> Maybe Value containsLinkerHole :: Text -> Bool makeSourceCache :: [(Text, Maybe ByteString)] -> Map Text Value -> IO SourceCache instance GHC.Show.Show EVM.Solidity.Language instance Data.Aeson.Types.ToJSON.ToJSON EVM.Solidity.StandardJSON instance GHC.Classes.Eq EVM.Solidity.SlotType instance GHC.Classes.Eq EVM.Solidity.StorageItem instance GHC.Show.Show EVM.Solidity.StorageItem instance GHC.Generics.Generic EVM.Solidity.Mutability instance GHC.Classes.Ord EVM.Solidity.Mutability instance GHC.Classes.Eq EVM.Solidity.Mutability instance GHC.Show.Show EVM.Solidity.Mutability instance GHC.Generics.Generic EVM.Solidity.Method instance GHC.Classes.Ord EVM.Solidity.Method instance GHC.Classes.Eq EVM.Solidity.Method instance GHC.Show.Show EVM.Solidity.Method instance GHC.Generics.Generic EVM.Solidity.SourceCache instance GHC.Classes.Eq EVM.Solidity.SourceCache instance GHC.Show.Show EVM.Solidity.SourceCache instance GHC.Classes.Eq EVM.Solidity.Reference instance GHC.Show.Show EVM.Solidity.Reference instance GHC.Generics.Generic EVM.Solidity.JumpType instance GHC.Classes.Ord EVM.Solidity.JumpType instance GHC.Classes.Eq EVM.Solidity.JumpType instance GHC.Show.Show EVM.Solidity.JumpType instance GHC.Generics.Generic EVM.Solidity.SrcMap instance GHC.Classes.Ord EVM.Solidity.SrcMap instance GHC.Classes.Eq EVM.Solidity.SrcMap instance GHC.Show.Show EVM.Solidity.SrcMap instance GHC.Generics.Generic EVM.Solidity.SolcContract instance GHC.Classes.Eq EVM.Solidity.SolcContract instance GHC.Show.Show EVM.Solidity.SolcContract instance GHC.Show.Show EVM.Solidity.SrcMapParseState instance GHC.Classes.Ord EVM.Solidity.CodeType instance GHC.Classes.Eq EVM.Solidity.CodeType instance GHC.Show.Show EVM.Solidity.CodeType instance Data.Aeson.Types.FromJSON.FromJSON EVM.Solidity.Reference instance GHC.Base.Semigroup EVM.Solidity.SourceCache instance GHC.Base.Monoid EVM.Solidity.SourceCache instance GHC.Show.Show EVM.Solidity.SlotType instance GHC.Read.Read EVM.Solidity.SlotType module EVM -- | EVM failure modes data Error BalanceTooLow :: W256 -> W256 -> Error UnrecognizedOpcode :: Word8 -> Error SelfDestruction :: Error StackUnderrun :: Error BadJumpDestination :: Error Revert :: Expr Buf -> Error OutOfGas :: Word64 -> Word64 -> Error BadCheatCode :: Maybe Word32 -> Error StackLimitExceeded :: Error IllegalOverflow :: Error Query :: Query -> Error Choose :: Choose -> Error StateChangeWhileStatic :: Error InvalidMemoryAccess :: Error CallDepthLimitReached :: Error MaxCodeSizeExceeded :: W256 -> W256 -> Error InvalidFormat :: Error PrecompileFailure :: Error UnexpectedSymbolicArg :: Int -> String -> [Expr a] -> Error DeadPath :: Error NotUnique :: Expr EWord -> Error SMTTimeout :: Error FFI :: [AbiValue] -> Error NonceOverflow :: Error -- | The possible result states of a VM data VMResult -- | An operation failed VMFailure :: Error -> VMResult -- | Reached STOP, RETURN, or end-of-code VMSuccess :: Expr Buf -> VMResult -- | The state of a stepwise EVM execution data VM VM :: Maybe VMResult -> FrameState -> [Frame] -> Env -> Block -> TxState -> [Expr Log] -> TreePos Empty Trace -> Cache -> Word64 -> Map CodeLocation Int -> [Prop] -> [Prop] -> Bool -> VM [_result] :: VM -> Maybe VMResult [_state] :: VM -> FrameState [_frames] :: VM -> [Frame] [_env] :: VM -> Env [_block] :: VM -> Block [_tx] :: VM -> TxState [_logs] :: VM -> [Expr Log] [_traces] :: VM -> TreePos Empty Trace [_cache] :: VM -> Cache [_burned] :: VM -> Word64 [_iterations] :: VM -> Map CodeLocation Int [_constraints] :: VM -> [Prop] [_keccakEqs] :: VM -> [Prop] [_allowFFI] :: VM -> Bool data Trace Trace :: Int -> Contract -> TraceData -> Trace [_traceOpIx] :: Trace -> Int [_traceContract] :: Trace -> Contract [_traceData] :: Trace -> TraceData data TraceData EventTrace :: Expr EWord -> Expr Buf -> [Expr EWord] -> TraceData FrameTrace :: FrameContext -> TraceData QueryTrace :: Query -> TraceData ErrorTrace :: Error -> TraceData EntryTrace :: Text -> TraceData ReturnTrace :: Expr Buf -> FrameContext -> TraceData -- | Queries halt execution until resolved through RPC calls or SMT queries data Query [PleaseFetchContract] :: Addr -> (Contract -> EVM ()) -> Query [PleaseFetchSlot] :: Addr -> W256 -> (W256 -> EVM ()) -> Query [PleaseAskSMT] :: Expr EWord -> [Prop] -> (BranchCondition -> EVM ()) -> Query [PleaseDoFFI] :: [String] -> (ByteString -> EVM ()) -> Query data Choose [PleaseChoosePath] :: Expr EWord -> (Bool -> EVM ()) -> Choose -- | Alias for the type of e.g. exec1. type EVM a = State VM a type CodeLocation = (Addr, Int) -- | The possible return values of a SMT query data BranchCondition Case :: Bool -> BranchCondition Unknown :: BranchCondition Inconsistent :: BranchCondition -- | The possible return values of a `is unique` SMT query data IsUnique a Unique :: a -> IsUnique a Multiple :: IsUnique a InconsistentU :: IsUnique a TimeoutU :: IsUnique a -- | The cache is data that can be persisted for efficiency: any expensive -- query that is constant at least within a block. data Cache Cache :: Map Addr Contract -> Map W256 (Map W256 W256) -> Map (CodeLocation, Int) Bool -> Cache [_fetchedContracts] :: Cache -> Map Addr Contract [_fetchedStorage] :: Cache -> Map W256 (Map W256 W256) [_path] :: Cache -> Map (CodeLocation, Int) Bool data StorageBase Concrete :: StorageBase Symbolic :: StorageBase -- | A way to specify an initial VM state data VMOpts VMOpts :: Contract -> (Expr Buf, [Prop]) -> StorageBase -> Expr EWord -> W256 -> Addr -> Expr EWord -> Addr -> Word64 -> Word64 -> W256 -> Expr EWord -> Addr -> W256 -> W256 -> Word64 -> W256 -> W256 -> FeeSchedule Word64 -> W256 -> Bool -> Map Addr [W256] -> Bool -> VMOpts [vmoptContract] :: VMOpts -> Contract [vmoptCalldata] :: VMOpts -> (Expr Buf, [Prop]) [vmoptStorageBase] :: VMOpts -> StorageBase [vmoptValue] :: VMOpts -> Expr EWord [vmoptPriorityFee] :: VMOpts -> W256 [vmoptAddress] :: VMOpts -> Addr [vmoptCaller] :: VMOpts -> Expr EWord [vmoptOrigin] :: VMOpts -> Addr [vmoptGas] :: VMOpts -> Word64 [vmoptGaslimit] :: VMOpts -> Word64 [vmoptNumber] :: VMOpts -> W256 [vmoptTimestamp] :: VMOpts -> Expr EWord [vmoptCoinbase] :: VMOpts -> Addr [vmoptPrevRandao] :: VMOpts -> W256 [vmoptMaxCodeSize] :: VMOpts -> W256 [vmoptBlockGaslimit] :: VMOpts -> Word64 [vmoptGasprice] :: VMOpts -> W256 [vmoptBaseFee] :: VMOpts -> W256 [vmoptSchedule] :: VMOpts -> FeeSchedule Word64 [vmoptChainId] :: VMOpts -> W256 [vmoptCreate] :: VMOpts -> Bool [vmoptTxAccessList] :: VMOpts -> Map Addr [W256] [vmoptAllowFFI] :: VMOpts -> Bool -- | An entry in the VM's "call/create stack" data Frame Frame :: FrameContext -> FrameState -> Frame [_frameContext] :: Frame -> FrameContext [_frameState] :: Frame -> FrameState -- | Call/create info data FrameContext CreationContext :: Addr -> Expr EWord -> Map Addr Contract -> SubState -> FrameContext [creationContextAddress] :: FrameContext -> Addr [creationContextCodehash] :: FrameContext -> Expr EWord [creationContextReversion] :: FrameContext -> Map Addr Contract [creationContextSubstate] :: FrameContext -> SubState CallContext :: Addr -> Addr -> W256 -> W256 -> Expr EWord -> Maybe W256 -> Expr Buf -> (Map Addr Contract, Expr Storage) -> SubState -> FrameContext [callContextTarget] :: FrameContext -> Addr [callContextContext] :: FrameContext -> Addr [callContextOffset] :: FrameContext -> W256 [callContextSize] :: FrameContext -> W256 [callContextCodehash] :: FrameContext -> Expr EWord [callContextAbi] :: FrameContext -> Maybe W256 [callContextData] :: FrameContext -> Expr Buf [callContextReversion] :: FrameContext -> (Map Addr Contract, Expr Storage) [callContextSubState] :: FrameContext -> SubState -- | The "registers" of the VM along with memory and data stack data FrameState FrameState :: Addr -> Addr -> ContractCode -> Int -> [Expr EWord] -> Expr Buf -> Word64 -> Expr Buf -> Expr EWord -> Expr EWord -> Word64 -> Expr Buf -> Bool -> FrameState [_contract] :: FrameState -> Addr [_codeContract] :: FrameState -> Addr [_code] :: FrameState -> ContractCode [_pc] :: FrameState -> Int [_stack] :: FrameState -> [Expr EWord] [_memory] :: FrameState -> Expr Buf [_memorySize] :: FrameState -> Word64 [_calldata] :: FrameState -> Expr Buf [_callvalue] :: FrameState -> Expr EWord [_caller] :: FrameState -> Expr EWord [_gas] :: FrameState -> Word64 [_returndata] :: FrameState -> Expr Buf [_static] :: FrameState -> Bool -- | The state that spans a whole transaction data TxState TxState :: W256 -> Word64 -> W256 -> Addr -> Addr -> Expr EWord -> SubState -> Bool -> Map Addr Contract -> TxState [_gasprice] :: TxState -> W256 [_txgaslimit] :: TxState -> Word64 [_txPriorityFee] :: TxState -> W256 [_origin] :: TxState -> Addr [_toAddr] :: TxState -> Addr [_value] :: TxState -> Expr EWord [_substate] :: TxState -> SubState [_isCreate] :: TxState -> Bool [_txReversion] :: TxState -> Map Addr Contract -- | The "accrued substate" across a transaction data SubState SubState :: [Addr] -> [Addr] -> Set Addr -> Set (Addr, W256) -> [(Addr, Word64)] -> SubState [_selfdestructs] :: SubState -> [Addr] [_touchedAccounts] :: SubState -> [Addr] [_accessedAddresses] :: SubState -> Set Addr [_accessedStorageKeys] :: SubState -> Set (Addr, W256) [_refunds] :: SubState -> [(Addr, Word64)] -- | A contract is either in creation (running its "constructor") or -- post-creation, and code in these two modes is treated differently by -- instructions like EXTCODEHASH, so we distinguish these two -- code types. -- -- The definition follows the structure of code output by solc. We need -- to use some heuristics here to deal with symbolic data regions that -- may be present in the bytecode since the fully abstract case is -- impractical: -- --