-- 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.41.0 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 -> 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 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 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 -- | convert between (WordN 256) and Word256 type family ToSizzle (t :: Type) :: Type -- | Conversion from a fixed-sized BV to a sized bit-vector. class ToSizzleBV a -- | Convert a fixed-sized bit-vector to the corresponding sized -- bit-vector, toSizzle :: ToSizzleBV a => a -> ToSizzle a -- | Convert a fixed-sized bit-vector to the corresponding sized -- bit-vector, toSizzle :: (ToSizzleBV a, Num (ToSizzle a), Integral a) => a -> ToSizzle a -- | Capture the correspondence between sized and fixed-sized BVs type family FromSizzle (t :: Type) :: Type -- | Conversion from a sized BV to a fixed-sized bit-vector. class FromSizzleBV a -- | Convert a sized bit-vector to the corresponding fixed-sized -- bit-vector, for instance 'SWord 16' to SWord16. See also -- toSized. fromSizzle :: FromSizzleBV a => a -> FromSizzle a -- | Convert a sized bit-vector to the corresponding fixed-sized -- bit-vector, for instance 'SWord 16' to SWord16. See also -- toSized. fromSizzle :: (FromSizzleBV a, Num (FromSizzle a), Integral a) => a -> FromSizzle a newtype Addr Addr :: Word160 -> Addr [addressWord160] :: Addr -> Word160 newtype SAddr SAddr :: SWord 160 -> SAddr [saddressWord160] :: SAddr -> SWord 160 strip0x :: ByteString -> ByteString newtype ByteStringS ByteStringS :: ByteString -> ByteStringS hexByteString :: String -> ByteString -> ByteString hexText :: Text -> ByteString readN :: Integral a => String -> a readNull :: Read a => a -> String -> a wordField :: Object -> Text -> Parser W256 addrField :: Object -> Text -> Parser Addr addrFieldMaybe :: Object -> Text -> Parser (Maybe Addr) dataField :: Object -> Text -> Parser ByteString toWord512 :: W256 -> Word512 fromWord512 :: Word512 -> W256 num :: (Integral a, Num b) => a -> b padLeft :: Int -> ByteString -> ByteString padRight :: Int -> ByteString -> ByteString truncpad :: Int -> [SWord 8] -> [SWord 8] 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 instance GHC.Generics.Generic EVM.Types.Nibble instance GHC.Enum.Bounded EVM.Types.Nibble instance Data.Bits.FiniteBits EVM.Types.Nibble instance Data.Bits.Bits 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.Classes.Eq EVM.Types.ByteStringS instance GHC.Num.Num EVM.Types.SAddr instance GHC.Generics.Generic EVM.Types.Addr instance Data.Bits.Bits 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.W256 instance GHC.Enum.Bounded EVM.Types.W256 instance Data.Bits.FiniteBits EVM.Types.W256 instance Data.Bits.Bits EVM.Types.W256 instance GHC.Classes.Eq EVM.Types.W256 instance GHC.Enum.Enum 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.Generics.Generic EVM.Types.Int512 instance Data.Data.Data EVM.Types.Int512 instance GHC.Generics.Generic EVM.Types.Word512 instance Data.Data.Data EVM.Types.Word512 instance GHC.Show.Show EVM.Types.Nibble instance GHC.Show.Show EVM.Types.ByteStringS instance GHC.Read.Read EVM.Types.ByteStringS instance GHC.Show.Show EVM.Types.SAddr instance EVM.Types.ToSizzleBV EVM.Types.W256 instance EVM.Types.ToSizzleBV EVM.Types.Addr instance EVM.Types.FromSizzleBV (Data.SBV.Core.Sized.WordN 256) instance EVM.Types.FromSizzleBV (Data.SBV.Core.Sized.WordN 160) 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.Read.Read EVM.Types.W256 instance GHC.Show.Show 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.Arr.Ix EVM.Types.Int512 instance Data.Bits.Bits EVM.Types.Int512 instance Data.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.Arr.Ix EVM.Types.Word512 instance Data.Bits.Bits EVM.Types.Word512 instance Data.Bits.FiniteBits EVM.Types.Word512 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 octets160 :: Addr -> ByteString rlpWord256 :: W256 -> RLP rlpWord160 :: Addr -> RLP instance GHC.Classes.Eq EVM.RLP.RLP instance GHC.Show.Show EVM.RLP.RLP 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 OpDifficulty :: 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 :: !W256 -> 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 keccak :: ByteString -> W256 abiKeccak :: ByteString -> Word32 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.Classes.Eq EVM.Patricia.Ref instance GHC.Classes.Eq EVM.Patricia.Node instance GHC.Show.Show EVM.Patricia.Node 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.Base.Functor (EVM.Patricia.KV k v) instance GHC.Show.Show (EVM.Patricia.NodeDB EVM.Patricia.Node) instance GHC.Show.Show EVM.Patricia.Ref module EVM.Concrete wordAt :: Int -> ByteString -> W256 readByteOrZero :: Int -> ByteString -> Word8 byteStringSliceWithDefaultZeroes :: Int -> Int -> ByteString -> ByteString -- | This type can give insight into the provenance of a term data Whiff Dull :: Whiff FromKeccak :: ByteString -> Whiff Var :: String -> Whiff InfixBinOp :: String -> Whiff -> Whiff -> Whiff BinOp :: String -> Whiff -> Whiff -> Whiff UnOp :: String -> Whiff -> Whiff w256 :: W256 -> Word data Word C :: Whiff -> W256 -> Word wordValue :: Word -> W256 sliceMemory :: (Integral a, Integral b) => a -> b -> ByteString -> ByteString writeMemory :: ByteString -> Word -> Word -> Word -> ByteString -> ByteString readMemoryWord :: Word -> ByteString -> Word readMemoryWord32 :: Word -> ByteString -> Word setMemoryWord :: Word -> Word -> ByteString -> ByteString setMemoryByte :: Word -> Word8 -> ByteString -> ByteString readBlobWord :: Word -> ByteString -> Word blobSize :: ByteString -> Word keccakBlob :: ByteString -> Word (^) :: W256 -> W256 -> W256 createAddress :: Addr -> W256 -> Addr create2Address :: Addr -> W256 -> ByteString -> Addr instance GHC.Show.Show EVM.Concrete.Whiff instance GHC.Show.Show EVM.Concrete.Word instance GHC.Read.Read EVM.Concrete.Word instance Data.Bits.Bits EVM.Concrete.Word instance Data.Bits.FiniteBits EVM.Concrete.Word instance GHC.Enum.Bounded EVM.Concrete.Word instance GHC.Classes.Eq EVM.Concrete.Word instance GHC.Enum.Enum EVM.Concrete.Word instance GHC.Real.Integral EVM.Concrete.Word instance GHC.Num.Num EVM.Concrete.Word instance GHC.Real.Real EVM.Concrete.Word instance GHC.Classes.Ord EVM.Concrete.Word module EVM.Transaction data Transaction Transaction :: ByteString -> W256 -> W256 -> W256 -> W256 -> W256 -> Maybe Addr -> W256 -> W256 -> Transaction [txData] :: Transaction -> ByteString [txGasLimit] :: Transaction -> W256 [txGasPrice] :: Transaction -> W256 [txNonce] :: Transaction -> W256 [txR] :: Transaction -> W256 [txS] :: Transaction -> W256 [txToAddr] :: Transaction -> Maybe Addr [txV] :: Transaction -> W256 [txValue] :: Transaction -> W256 ecrec :: W256 -> W256 -> W256 -> W256 -> Maybe Addr sender :: Int -> Transaction -> Maybe Addr signingData :: Int -> Transaction -> ByteString txGasCost :: FeeSchedule Word -> Transaction -> Word instance GHC.Show.Show EVM.Transaction.Transaction instance Data.Aeson.Types.FromJSON.FromJSON EVM.Transaction.Transaction module EVM.Symbolic -- | Symbolic words of 256 bits, possibly annotated with additional -- "insightful" information data SymWord S :: Whiff -> SWord 256 -> SymWord -- | Convenience functions transporting between the concrete and symbolic -- realm sw256 :: SWord 256 -> SymWord litWord :: Word -> SymWord w256lit :: W256 -> SymWord litAddr :: Addr -> SAddr litBytes :: ByteString -> [SWord 8] maybeLitWord :: SymWord -> Maybe Word maybeLitAddr :: SAddr -> Maybe Addr maybeLitBytes :: [SWord 8] -> Maybe ByteString -- | Note: these forms are crude and in general, the continuation passing -- style forceConcrete alternatives should be prefered for -- better error handling when used during EVM execution forceLit :: SymWord -> Word forceLitBytes :: [SWord 8] -> ByteString -- | Arithmetic operations on SymWord sdiv :: SymWord -> SymWord -> SymWord smod :: SymWord -> SymWord -> SymWord addmod :: SymWord -> SymWord -> SymWord -> SymWord mulmod :: SymWord -> SymWord -> SymWord -> SymWord slt :: SymWord -> SymWord -> SymWord sgt :: SymWord -> SymWord -> SymWord -- | Operations over symbolic memory (list of symbolic bytes) swordAt :: Int -> [SWord 8] -> SymWord readByteOrZero' :: Int -> [SWord 8] -> SWord 8 sliceWithZero' :: Int -> Int -> [SWord 8] -> [SWord 8] writeMemory' :: [SWord 8] -> Word -> Word -> Word -> [SWord 8] -> [SWord 8] readMemoryWord' :: Word -> [SWord 8] -> SymWord readMemoryWord32' :: Word -> [SWord 8] -> SWord 32 setMemoryWord' :: Word -> SymWord -> [SWord 8] -> [SWord 8] setMemoryByte' :: Word -> SWord 8 -> [SWord 8] -> [SWord 8] readSWord' :: Word -> [SWord 8] -> SymWord select' :: (Ord b, Num b, SymVal b, Mergeable a) => [a] -> a -> SBV b -> a readSWordWithBound :: SWord 32 -> Buffer -> SWord 32 -> SymWord -- | Operations over buffers (concrete or symbolic) -- -- A buffer is a list of bytes. For concrete execution, this is simply -- ByteString. In symbolic settings, it is a list of symbolic -- bitvectors of size 8. data Buffer ConcreteBuffer :: ByteString -> Buffer SymbolicBuffer :: [SWord 8] -> Buffer len :: Buffer -> Int grab :: Int -> Buffer -> Buffer ditch :: Int -> Buffer -> Buffer readByteOrZero :: Int -> Buffer -> SWord 8 sliceWithZero :: Int -> Int -> Buffer -> Buffer writeMemory :: Buffer -> Word -> Word -> Word -> Buffer -> Buffer readMemoryWord :: Word -> Buffer -> SymWord readMemoryWord32 :: Word -> Buffer -> SWord 32 setMemoryWord :: Word -> SymWord -> Buffer -> Buffer setMemoryByte :: Word -> SWord 8 -> Buffer -> Buffer readSWord :: Word -> Buffer -> SymWord instance GHC.Show.Show EVM.Symbolic.Buffer instance GHC.Base.Semigroup EVM.Symbolic.Buffer instance GHC.Base.Monoid EVM.Symbolic.Buffer instance Data.SBV.Core.Model.EqSymbolic EVM.Symbolic.Buffer instance GHC.Show.Show EVM.Symbolic.SymWord instance Data.SBV.Core.Model.EqSymbolic EVM.Symbolic.SymWord instance GHC.Num.Num EVM.Symbolic.SymWord instance Data.Bits.Bits EVM.Symbolic.SymWord instance Data.SBV.Core.Model.SDivisible EVM.Symbolic.SymWord instance Data.SBV.Core.Model.Mergeable EVM.Symbolic.SymWord instance GHC.Enum.Bounded EVM.Symbolic.SymWord instance GHC.Classes.Eq EVM.Symbolic.SymWord instance GHC.Enum.Enum EVM.Symbolic.SymWord instance Data.SBV.Core.Model.OrdSymbolic EVM.Symbolic.SymWord 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 Event Event :: Text -> Anonymity -> [(AbiType, Indexed)] -> Event data Anonymity Anonymous :: Anonymity NotAnonymous :: Anonymity data Indexed Indexed :: Indexed NotIndexed :: Indexed putAbi :: AbiValue -> Put getAbi :: AbiType -> Get AbiValue getAbiSeq :: Int -> [AbiType] -> Get (Vector AbiValue) genAbiValue :: AbiType -> Gen AbiValue abiValueType :: AbiValue -> AbiType abiTypeSolidity :: AbiType -> Text abiCalldata :: Text -> Vector AbiValue -> ByteString abiMethod :: Text -> AbiValue -> ByteString emptyAbi :: AbiValue encodeAbiValue :: AbiValue -> ByteString decodeAbiValue :: AbiType -> ByteString -> AbiValue parseTypeName :: Vector AbiType -> Text -> Maybe AbiType makeAbiValue :: AbiType -> String -> AbiValue parseAbiValue :: AbiType -> ReadP AbiValue selector :: Text -> ByteString 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.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.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.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.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.AbiType instance GHC.Classes.Ord EVM.ABI.AbiType instance GHC.Classes.Eq EVM.ABI.AbiType instance GHC.Read.Read EVM.ABI.AbiType 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) data JumpType JumpInto :: JumpType JumpFrom :: JumpType JumpRegular :: JumpType data SolcContract SolcContract :: W256 -> W256 -> ByteString -> ByteString -> Text -> [(Text, AbiType)] -> Map Word32 Method -> Map W256 Event -> Maybe (Map Text StorageItem) -> Seq SrcMap -> Seq SrcMap -> Value -> 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 [_storageLayout] :: SolcContract -> Maybe (Map Text StorageItem) [_runtimeSrcmap] :: SolcContract -> Seq SrcMap [_creationSrcmap] :: SolcContract -> Seq SrcMap [_contractAst] :: SolcContract -> Value data StorageItem StorageItem :: SlotType -> Int -> Int -> StorageItem [_type] :: StorageItem -> SlotType [_offset] :: StorageItem -> Int [_slot] :: StorageItem -> Int data SourceCache SourceCache :: Map (Int, Int) ByteString -> Map Int (Text, ByteString) -> Map Int (Vector ByteString) -> Map Text Value -> SourceCache [_snippetCache] :: SourceCache -> Map (Int, Int) ByteString [_sourceFiles] :: SourceCache -> Map Int (Text, ByteString) [_sourceLines] :: SourceCache -> Map Int (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 :: Maybe (Text, AbiType) -> [(Text, AbiType)] -> Text -> Text -> Method [_methodOutput] :: Method -> Maybe (Text, AbiType) [_methodInputs] :: Method -> [(Text, AbiType)] [_methodName] :: Method -> Text [_methodSignature] :: Method -> Text data SlotType StorageMapping :: NonEmpty AbiType -> AbiType -> SlotType StorageValue :: AbiType -> SlotType methodName :: Lens' Method Text methodSignature :: Lens' Method Text methodInputs :: Lens' Method [(Text, AbiType)] methodOutput :: Lens' Method (Maybe (Text, AbiType)) abiMap :: Lens' SolcContract (Map Word32 Method) eventMap :: Lens' SolcContract (Map W256 Event) 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]) runtimeCode :: Lens' SolcContract ByteString snippetCache :: Lens' SourceCache (Map (Int, Int) ByteString) runtimeCodehash :: Lens' SolcContract W256 creationCodehash :: Lens' SolcContract W256 runtimeSrcmap :: Lens' SolcContract (Seq SrcMap) creationSrcmap :: Lens' SolcContract (Seq SrcMap) contractAst :: Lens' SolcContract Value sourceFiles :: Lens' SourceCache (Map Int (Text, ByteString)) sourceLines :: Lens' SourceCache (Map Int (Vector ByteString)) sourceAsts :: Lens' SourceCache (Map Text Value) stripBytecodeMetadata :: ByteString -> ByteString signature :: AsValue s => s -> 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 instance GHC.Classes.Ord EVM.Solidity.CodeType instance GHC.Classes.Eq EVM.Solidity.CodeType instance GHC.Show.Show EVM.Solidity.CodeType instance GHC.Show.Show EVM.Solidity.SrcMapParseState instance GHC.Generics.Generic EVM.Solidity.SolcContract instance GHC.Classes.Eq EVM.Solidity.SolcContract instance GHC.Show.Show EVM.Solidity.SolcContract 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.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.SourceCache instance GHC.Classes.Eq EVM.Solidity.SourceCache instance GHC.Show.Show EVM.Solidity.SourceCache 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.Classes.Eq EVM.Solidity.StorageItem instance GHC.Show.Show EVM.Solidity.StorageItem instance GHC.Classes.Eq EVM.Solidity.SlotType 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 :: Word -> Word -> Error UnrecognizedOpcode :: Word8 -> Error SelfDestruction :: Error StackUnderrun :: Error BadJumpDestination :: Error Revert :: ByteString -> Error NoSuchContract :: Addr -> Error OutOfGas :: Word -> Word -> Error BadCheatCode :: Maybe Word32 -> Error StackLimitExceeded :: Error IllegalOverflow :: Error Query :: Query -> Error Choose :: Choose -> Error StateChangeWhileStatic :: Error InvalidMemoryAccess :: Error CallDepthLimitReached :: Error MaxCodeSizeExceeded :: Word -> Word -> Error PrecompileFailure :: Error UnexpectedSymbolicArg :: Error DeadPath :: Error -- | The possible result states of a VM data VMResult -- | An operation failed VMFailure :: Error -> VMResult -- | Reached STOP, RETURN, or end-of-code VMSuccess :: Buffer -> VMResult -- | The state of a stepwise EVM execution data VM VM :: Maybe VMResult -> FrameState -> [Frame] -> Env -> Block -> TxState -> Seq Log -> TreePos Empty Trace -> Cache -> Word -> [SBool] -> Map CodeLocation Int -> VM [_result] :: VM -> Maybe VMResult [_state] :: VM -> FrameState [_frames] :: VM -> [Frame] [_env] :: VM -> Env [_block] :: VM -> Block [_tx] :: VM -> TxState [_logs] :: VM -> Seq Log [_traces] :: VM -> TreePos Empty Trace [_cache] :: VM -> Cache [_burned] :: VM -> Word [_pathConditions] :: VM -> [SBool] [_iterations] :: VM -> Map CodeLocation Int data Trace Trace :: W256 -> Int -> TraceData -> Trace [_traceCodehash] :: Trace -> W256 [_traceOpIx] :: Trace -> Int [_traceData] :: Trace -> TraceData data TraceData EventTrace :: Log -> TraceData FrameTrace :: FrameContext -> TraceData QueryTrace :: Query -> TraceData ErrorTrace :: Error -> TraceData EntryTrace :: Text -> TraceData ReturnTrace :: Buffer -> FrameContext -> TraceData -- | Queries halt execution until resolved through RPC calls or SMT queries data Query [PleaseFetchContract] :: Addr -> (Contract -> EVM ()) -> Query [PleaseFetchSlot] :: Addr -> Word -> (Word -> EVM ()) -> Query [PleaseAskSMT] :: SymWord -> [SBool] -> (JumpCondition -> EVM ()) -> Query data Choose [PleaseChoosePath] :: (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 regarding JUMPI data JumpCondition Iszero :: Bool -> JumpCondition Unknown :: JumpCondition Inconsistent :: JumpCondition -- | 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 (CodeLocation, Int) Bool -> Cache [_fetched] :: Cache -> Map Addr Contract [_path] :: Cache -> Map (CodeLocation, Int) Bool -- | A way to specify an initial VM state data VMOpts VMOpts :: Contract -> (Buffer, SWord 32) -> SymWord -> Addr -> SAddr -> Addr -> W256 -> W256 -> W256 -> W256 -> Addr -> W256 -> W256 -> W256 -> W256 -> FeeSchedule Word -> W256 -> Bool -> StorageModel -> VMOpts [vmoptContract] :: VMOpts -> Contract [vmoptCalldata] :: VMOpts -> (Buffer, SWord 32) [vmoptValue] :: VMOpts -> SymWord [vmoptAddress] :: VMOpts -> Addr [vmoptCaller] :: VMOpts -> SAddr [vmoptOrigin] :: VMOpts -> Addr [vmoptGas] :: VMOpts -> W256 [vmoptGaslimit] :: VMOpts -> W256 [vmoptNumber] :: VMOpts -> W256 [vmoptTimestamp] :: VMOpts -> W256 [vmoptCoinbase] :: VMOpts -> Addr [vmoptDifficulty] :: VMOpts -> W256 [vmoptMaxCodeSize] :: VMOpts -> W256 [vmoptBlockGaslimit] :: VMOpts -> W256 [vmoptGasprice] :: VMOpts -> W256 [vmoptSchedule] :: VMOpts -> FeeSchedule Word [vmoptChainId] :: VMOpts -> W256 [vmoptCreate] :: VMOpts -> Bool [vmoptStorageModel] :: VMOpts -> StorageModel -- | A log entry data Log Log :: Addr -> Buffer -> [SymWord] -> Log -- | 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 :: W256 -> Map Addr Contract -> SubState -> FrameContext [creationContextCodehash] :: FrameContext -> W256 [creationContextReversion] :: FrameContext -> Map Addr Contract [creationContextSubstate] :: FrameContext -> SubState CallContext :: Word -> Word -> W256 -> Maybe Word -> Buffer -> Map Addr Contract -> SubState -> FrameContext [callContextOffset] :: FrameContext -> Word [callContextSize] :: FrameContext -> Word [callContextCodehash] :: FrameContext -> W256 [callContextAbi] :: FrameContext -> Maybe Word [callContextData] :: FrameContext -> Buffer [callContextReversion] :: FrameContext -> Map Addr Contract [callContextSubState] :: FrameContext -> SubState -- | The "registers" of the VM along with memory and data stack data FrameState FrameState :: Addr -> Addr -> ByteString -> Int -> [SymWord] -> Buffer -> Int -> (Buffer, SWord 32) -> SymWord -> SAddr -> Word -> Buffer -> Bool -> FrameState [_contract] :: FrameState -> Addr [_codeContract] :: FrameState -> Addr [_code] :: FrameState -> ByteString [_pc] :: FrameState -> Int [_stack] :: FrameState -> [SymWord] [_memory] :: FrameState -> Buffer [_memorySize] :: FrameState -> Int [_calldata] :: FrameState -> (Buffer, SWord 32) [_callvalue] :: FrameState -> SymWord [_caller] :: FrameState -> SAddr [_gas] :: FrameState -> Word [_returndata] :: FrameState -> Buffer [_static] :: FrameState -> Bool -- | The state that spans a whole transaction data TxState TxState :: Word -> Word -> Addr -> Addr -> SymWord -> SubState -> Bool -> Map Addr Contract -> TxState [_gasprice] :: TxState -> Word [_txgaslimit] :: TxState -> Word [_origin] :: TxState -> Addr [_toAddr] :: TxState -> Addr [_value] :: TxState -> SymWord [_substate] :: TxState -> SubState [_isCreate] :: TxState -> Bool [_txReversion] :: TxState -> Map Addr Contract -- | The "accrued substate" across a transaction data SubState SubState :: [Addr] -> [Addr] -> [(Addr, Word)] -> SubState [_selfdestructs] :: SubState -> [Addr] [_touchedAccounts] :: SubState -> [Addr] [_refunds] :: SubState -> [(Addr, Word)] -- | 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. data ContractCode -- | Constructor code, during contract creation InitCode :: ByteString -> ContractCode -- | Instance code, after contract creation RuntimeCode :: ByteString -> ContractCode -- | A contract can either have concrete or symbolic storage depending on -- what type of execution we are doing data Storage Concrete :: Map Word SymWord -> Storage Symbolic :: SArray (WordN 256) (WordN 256) -> Storage -- | The state of a contract data Contract Contract :: ContractCode -> Storage -> Word -> Word -> W256 -> Vector Int -> Vector (Int, Op) -> Bool -> Map Word Word -> Contract [_contractcode] :: Contract -> ContractCode [_storage] :: Contract -> Storage [_balance] :: Contract -> Word [_nonce] :: Contract -> Word [_codehash] :: Contract -> W256 [_opIxMap] :: Contract -> Vector Int [_codeOps] :: Contract -> Vector (Int, Op) [_external] :: Contract -> Bool [_origStorage] :: Contract -> Map Word Word -- | When doing symbolic execution, we have three different ways to model -- the storage of contracts. This determines not only the initial -- contract storage model but also how RPC or state fetched contracts -- will be modeled. data StorageModel -- | Uses Concrete Storage. Reading / Writing from abstract -- locations causes a runtime failure. Can be nicely combined with RPC. ConcreteS :: StorageModel -- | Uses Storage Storage. Reading / Writing never reaches RPC, but -- always done using an SMT array with no default value. SymbolicS :: StorageModel -- | Uses Storage Storage. Reading / Writing never reaches RPC, but -- always done using an SMT array with 0 as the default value. InitialS :: StorageModel -- | Various environmental data data Env Env :: Map Addr Contract -> Word -> StorageModel -> Map Word ByteString -> [([SWord 8], SWord 256)] -> Env [_contracts] :: Env -> Map Addr Contract [_chainId] :: Env -> Word [_storageModel] :: Env -> StorageModel [_sha3Crack] :: Env -> Map Word ByteString [_keccakUsed] :: Env -> [([SWord 8], SWord 256)] -- | Data about the block data Block Block :: Addr -> Word -> Word -> Word -> Word -> Word -> FeeSchedule Word -> Block [_coinbase] :: Block -> Addr [_timestamp] :: Block -> Word [_number] :: Block -> Word [_difficulty] :: Block -> Word [_gaslimit] :: Block -> Word [_maxCodeSize] :: Block -> Word [_schedule] :: Block -> FeeSchedule Word blankState :: FrameState static :: Lens' FrameState Bool stack :: Lens' FrameState [SymWord] returndata :: Lens' FrameState Buffer pc :: Lens' FrameState Int memorySize :: Lens' FrameState Int memory :: Lens' FrameState Buffer gas :: Lens' FrameState Word contract :: Lens' FrameState Addr codeContract :: Lens' FrameState Addr code :: Lens' FrameState ByteString callvalue :: Lens' FrameState SymWord caller :: Lens' FrameState SAddr calldata :: Lens' FrameState (Buffer, SWord 32) frameState :: Lens' Frame FrameState frameContext :: Lens' Frame FrameContext timestamp :: Lens' Block Word schedule :: Lens' Block (FeeSchedule Word) number :: Lens' Block Word maxCodeSize :: Lens' Block Word gaslimit :: Lens' Block Word difficulty :: Lens' Block Word coinbase :: Lens' Block Addr value :: Lens' TxState SymWord txgaslimit :: Lens' TxState Word txReversion :: Lens' TxState (Map Addr Contract) toAddr :: Lens' TxState Addr substate :: Lens' TxState SubState origin :: Lens' TxState Addr isCreate :: Lens' TxState Bool gasprice :: Lens' TxState Word touchedAccounts :: Lens' SubState [Addr] selfdestructs :: Lens' SubState [Addr] refunds :: Lens' SubState [(Addr, Word)] storage :: Lens' Contract Storage origStorage :: Lens' Contract (Map Word Word) opIxMap :: Lens' Contract (Vector Int) nonce :: Lens' Contract Word external :: Lens' Contract Bool contractcode :: Lens' Contract ContractCode codehash :: Lens' Contract W256 codeOps :: Lens' Contract (Vector (Int, Op)) balance :: Lens' Contract Word storageModel :: Lens' Env StorageModel sha3Crack :: Lens' Env (Map Word ByteString) keccakUsed :: Lens' Env [([SWord 8], SWord 256)] contracts :: Lens' Env (Map Addr Contract) chainId :: Lens' Env Word path :: Lens' Cache (Map (CodeLocation, Int) Bool) fetched :: Lens' Cache (Map Addr Contract) traceOpIx :: Lens' Trace Int traceData :: Lens' Trace TraceData traceCodehash :: Lens' Trace W256 tx :: Lens' VM TxState traces :: Lens' VM (TreePos Empty Trace) state :: Lens' VM FrameState result :: Lens' VM (Maybe VMResult) pathConditions :: Lens' VM [SBool] logs :: Lens' VM (Seq Log) iterations :: Lens' VM (Map CodeLocation Int) frames :: Lens' VM [Frame] env :: Lens' VM Env cache :: Lens' VM Cache burned :: Lens' VM Word block :: Lens' VM Block -- | An "external" view of a contract's bytecode, appropriate for e.g. -- EXTCODEHASH. bytecode :: Getter Contract ByteString currentContract :: VM -> Maybe Contract makeVm :: VMOpts -> VM -- | Initialize empty contract with given code initialContract :: ContractCode -> Contract contractWithStore :: ContractCode -> Storage -> Contract -- | Update program counter next :: ?op :: Word8 => EVM () -- | Executes the EVM one step exec1 :: EVM () -- | Checks a *CALL for failure; OOG, too many callframes, memory access -- etc. callChecks :: ?op :: Word8 => Contract -> Word -> Addr -> Word -> Word -> Word -> Word -> Word -> [SymWord] -> (Word -> EVM ()) -> EVM () precompiledContract :: ?op :: Word8 => Contract -> Word -> Addr -> Addr -> Word -> Word -> Word -> Word -> Word -> [SymWord] -> EVM () executePrecompile :: ?op :: Word8 => Addr -> Word -> Word -> Word -> Word -> Word -> [SymWord] -> EVM () truncpadlit :: Int -> ByteString -> ByteString lazySlice :: Word -> Word -> ByteString -> ByteString parseModexpLength :: ByteString -> (Word, Word, Word) isZero :: Word -> Word -> ByteString -> Bool asInteger :: ByteString -> Integer noop :: Monad m => m () pushTo :: MonadState s m => ASetter s s [a] [a] -> a -> m () pushToSequence :: MonadState s m => ASetter s s (Seq a) (Seq a) -> a -> m () getCodeLocation :: VM -> CodeLocation -- | Construct SMT Query and halt execution until resolved askSMT :: CodeLocation -> SymWord -> (Bool -> EVM ()) -> EVM () -- | Construct RPC Query and halt execution until resolved fetchAccount :: Addr -> (Contract -> EVM ()) -> EVM () readStorage :: Storage -> SymWord -> Maybe SymWord writeStorage :: SymWord -> SymWord -> Storage -> Storage accessStorage :: Addr -> SymWord -> (SymWord -> EVM ()) -> EVM () accountExists :: Addr -> VM -> Bool accountEmpty :: Contract -> Bool finalize :: EVM () -- | Loads the selected contract as the current contract to execute loadContract :: Addr -> EVM () limitStack :: Int -> EVM () -> EVM () notStatic :: EVM () -> EVM () -- | Burn gas, failing if insufficient gas is available burn :: Word -> EVM () -> EVM () forceConcreteAddr :: SAddr -> (Addr -> EVM ()) -> EVM () forceConcrete :: SymWord -> (Word -> EVM ()) -> EVM () forceConcrete2 :: (SymWord, SymWord) -> ((Word, Word) -> EVM ()) -> EVM () forceConcrete3 :: (SymWord, SymWord, SymWord) -> ((Word, Word, Word) -> EVM ()) -> EVM () forceConcrete4 :: (SymWord, SymWord, SymWord, SymWord) -> ((Word, Word, Word, Word) -> EVM ()) -> EVM () forceConcrete5 :: (SymWord, SymWord, SymWord, SymWord, SymWord) -> ((Word, Word, Word, Word, Word) -> EVM ()) -> EVM () forceConcrete6 :: (SymWord, SymWord, SymWord, SymWord, SymWord, SymWord) -> ((Word, Word, Word, Word, Word, Word) -> EVM ()) -> EVM () forceConcreteBuffer :: Buffer -> (ByteString -> EVM ()) -> EVM () refund :: Word -> EVM () unRefund :: Word -> EVM () touchAccount :: Addr -> EVM () selfdestruct :: Addr -> EVM () cheatCode :: Addr cheat :: ?op :: Word8 => (Word, Word) -> (Word, Word) -> EVM () type CheatAction = ([AbiType], [AbiValue] -> EVM (Maybe AbiValue)) cheatActions :: Map Word32 CheatAction delegateCall :: ?op :: Word8 => Contract -> Word -> Addr -> Addr -> Word -> Word -> Word -> Word -> Word -> [SymWord] -> EVM () -> EVM () collision :: Maybe Contract -> Bool create :: ?op :: Word8 => Addr -> Contract -> Word -> Word -> [SymWord] -> Addr -> ByteString -> EVM () -- | Replace a contract's code, like when CREATE returns from the -- constructor code. replaceCode :: Addr -> ContractCode -> EVM () replaceCodeOfSelf :: ContractCode -> EVM () resetState :: EVM () vmError :: Error -> EVM () underrun :: EVM () -- | A stack frame can be popped in three ways. data FrameResult -- | STOP, RETURN, or no more code FrameReturned :: Buffer -> FrameResult -- | REVERT FrameReverted :: Buffer -> FrameResult -- | Any other error FrameErrored :: Error -> FrameResult -- | This function defines how to pop the current stack frame in either of -- the ways specified by FrameResult. -- -- It also handles the case when the current stack frame is the only one; -- in this case, we set the final _result of the VM execution. finishFrame :: FrameResult -> EVM () accessUnboundedMemoryRange :: FeeSchedule Word -> Word -> Word -> EVM () -> EVM () accessMemoryRange :: FeeSchedule Word -> Word -> Word -> EVM () -> EVM () accessMemoryWord :: FeeSchedule Word -> Word -> EVM () -> EVM () copyBytesToMemory :: Buffer -> Word -> Word -> Word -> EVM () copyCallBytesToMemory :: Buffer -> Word -> Word -> Word -> EVM () readMemory :: Word -> Word -> VM -> Buffer word256At :: Functor f => Word -> (SymWord -> f SymWord) -> Buffer -> f Buffer withTraceLocation :: MonadState VM m => TraceData -> m Trace pushTrace :: TraceData -> EVM () insertTrace :: TraceData -> EVM () popTrace :: EVM () zipperRootForest :: TreePos Empty a -> Forest a traceForest :: VM -> Forest Trace traceLog :: MonadState VM m => Log -> m () push :: Word -> EVM () pushSym :: SymWord -> EVM () stackOp1 :: ?op :: Word8 => (SymWord -> Word) -> (SymWord -> SymWord) -> EVM () stackOp2 :: ?op :: Word8 => ((SymWord, SymWord) -> Word) -> ((SymWord, SymWord) -> SymWord) -> EVM () stackOp3 :: ?op :: Word8 => ((SymWord, SymWord, SymWord) -> Word) -> ((SymWord, SymWord, SymWord) -> SymWord) -> EVM () checkJump :: Integral n => n -> [SymWord] -> EVM () opSize :: Word8 -> Int mkOpIxMap :: ByteString -> Vector Int vmOp :: VM -> Maybe Op vmOpIx :: VM -> Maybe Int opParams :: VM -> Map String SymWord readOp :: Word8 -> ByteString -> Op mkCodeOps :: ByteString -> Vector (Int, Op) costOfCall :: FeeSchedule Word -> Bool -> Word -> Word -> Word -> (Word, Word) costOfCreate :: FeeSchedule Word -> Word -> Word -> (Word, Word) costOfPrecompile :: FeeSchedule Word -> Addr -> Buffer -> Word memoryCost :: FeeSchedule Word -> Word -> Word symSHA256N :: SInteger -> SInteger -> SWord 256 symkeccakN :: SInteger -> SInteger -> SWord 256 toSInt :: [SWord 8] -> SInteger -- | Although we'd like to define this directly as an uninterpreted -- function, we cannot because [a] is not a symbolic type. We must -- convert the list into a suitable symbolic type first. The only -- important property of this conversion is that it is injective. We -- embedd the bytestring as a pair of symbolic integers, this is a fairly -- easy solution. symkeccak' :: [SWord 8] -> SWord 256 symSHA256 :: [SWord 8] -> [SWord 8] ceilDiv :: (Num a, Integral a) => a -> a -> a allButOne64th :: (Num a, Integral a) => a -> a log2 :: FiniteBits b => b -> Int instance GHC.Show.Show EVM.FrameResult instance GHC.Base.Semigroup EVM.Cache instance GHC.Base.Monoid EVM.Cache instance GHC.Show.Show EVM.VMOpts instance GHC.Show.Show EVM.StorageModel instance GHC.Read.Read EVM.StorageModel instance GHC.Show.Show EVM.Cache instance GHC.Show.Show EVM.Storage instance GHC.Classes.Eq EVM.ContractCode instance GHC.Show.Show EVM.ContractCode instance GHC.Show.Show EVM.JumpCondition instance GHC.Show.Show EVM.Error instance GHC.Show.Show EVM.VMResult instance GHC.Show.Show EVM.Contract instance GHC.Classes.Eq EVM.Contract instance GHC.Show.Show EVM.Query instance GHC.Show.Show EVM.Choose instance Options.Generic.ParseField EVM.StorageModel instance GHC.Classes.Eq EVM.Storage module EVM.Fetch -- | Abstract representation of an RPC fetch request data RpcQuery a [QueryCode] :: Addr -> RpcQuery ByteString [QueryBalance] :: Addr -> RpcQuery W256 [QueryNonce] :: Addr -> RpcQuery W256 [QuerySlot] :: Addr -> W256 -> RpcQuery W256 [QueryChainId] :: RpcQuery W256 data BlockNumber Latest :: BlockNumber BlockNumber :: W256 -> BlockNumber rpc :: String -> [String] -> Value class ToRPC a toRPC :: ToRPC a => a -> String readText :: Read a => Text -> a fetchQuery :: Show a => BlockNumber -> (Value -> IO (Maybe Text)) -> RpcQuery a -> IO (Maybe a) fetchWithSession :: Text -> Session -> Value -> IO (Maybe Text) fetchContractWithSession :: BlockNumber -> Text -> Addr -> Session -> IO (Maybe Contract) fetchSlotWithSession :: BlockNumber -> Text -> Session -> Addr -> W256 -> IO (Maybe Word) fetchContractFrom :: BlockNumber -> Text -> Addr -> IO (Maybe Contract) fetchSlotFrom :: BlockNumber -> Text -> Addr -> W256 -> IO (Maybe Word) http :: BlockNumber -> Text -> Fetcher zero :: Fetcher type Fetcher = Query -> IO (EVM ()) oracle :: State -> Maybe (BlockNumber, Text) -> StorageModel -> Fetcher checksat :: SBool -> Query CheckSatResult instance GHC.Show.Show (EVM.Fetch.RpcQuery a) instance EVM.Fetch.ToRPC EVM.Types.Addr instance EVM.Fetch.ToRPC EVM.Types.W256 instance EVM.Fetch.ToRPC EVM.Fetch.BlockNumber module EVM.Facts data File File :: Path -> Data -> File [filePath] :: File -> Path [fileData] :: File -> Data data Fact BalanceFact :: Addr -> Word -> Fact [addr] :: Fact -> Addr [what] :: Fact -> Word NonceFact :: Addr -> Word -> Fact [addr] :: Fact -> Addr [what] :: Fact -> Word StorageFact :: Addr -> Word -> Word -> Fact [addr] :: Fact -> Addr [what] :: Fact -> Word [which] :: Fact -> Word CodeFact :: Addr -> ByteString -> Fact [addr] :: Fact -> Addr [blob] :: Fact -> ByteString newtype Data Data :: ASCII -> Data [dataASCII] :: Data -> ASCII data Path Path :: [ASCII] -> ASCII -> Path apply :: VM -> Set Fact -> VM contractFacts :: Addr -> Contract -> [Fact] vmFacts :: VM -> Set Fact factToFile :: Fact -> File fileToFact :: File -> Maybe Fact instance GHC.Show.Show EVM.Facts.File instance GHC.Classes.Ord EVM.Facts.File instance GHC.Classes.Eq EVM.Facts.File instance GHC.Show.Show EVM.Facts.Data instance GHC.Classes.Ord EVM.Facts.Data instance GHC.Classes.Eq EVM.Facts.Data instance GHC.Show.Show EVM.Facts.Path instance GHC.Classes.Ord EVM.Facts.Path instance GHC.Classes.Eq EVM.Facts.Path instance GHC.Show.Show EVM.Facts.Fact instance GHC.Classes.Eq EVM.Facts.Fact instance EVM.Facts.AsASCII EVM.Types.Addr instance EVM.Facts.AsASCII EVM.Concrete.Word instance EVM.Facts.AsASCII Data.ByteString.Internal.ByteString instance GHC.Classes.Ord EVM.Facts.Fact module EVM.Facts.Git saveFacts :: RepoAt -> Set Fact -> IO () loadFacts :: RepoAt -> IO (Set Fact) newtype RepoAt RepoAt :: String -> RepoAt instance GHC.Show.Show EVM.Facts.Git.RepoAt instance GHC.Classes.Ord EVM.Facts.Git.RepoAt instance GHC.Classes.Eq EVM.Facts.Git.RepoAt module EVM.Exec ethrunAddress :: Addr vmForEthrunCreation :: ByteString -> VM exec :: MonadState VM m => m VMResult run :: MonadState VM m => m VM execWhile :: MonadState VM m => (VM -> Bool) -> m Int module EVM.Stepper -- | The instruction type of the operational monad data Action a -- | Keep executing until an intermediate result is reached [Exec] :: Action VMResult -- | Keep executing until an intermediate state is reached [Run] :: Action VM -- | Wait for a query to be resolved [Wait] :: Query -> Action () -- | Multiple things can happen [Ask] :: Choose -> Action () -- | Embed a VM state transformation [EVM] :: EVM a -> Action a -- | Type alias for an operational monad of Action type Stepper a = Program Action a exec :: Stepper VMResult -- | Run the VM until final result, resolving all queries execFully :: Stepper (Either Error Buffer) -- | Run the VM until its final state runFully :: Stepper VM wait :: Query -> Stepper () ask :: Choose -> Stepper () evm :: EVM a -> Stepper a entering :: Text -> Stepper a -> Stepper a enter :: Text -> Stepper () interpret :: Fetcher -> Stepper a -> StateT VM IO a module EVM.SymExec -- | Convenience functions for generating large symbolic byte strings sbytes32 :: Query [SWord 8] -- | Convenience functions for generating large symbolic byte strings sbytes256 :: Query [SWord 8] -- | Convenience functions for generating large symbolic byte strings sbytes512 :: Query [SWord 8] -- | Convenience functions for generating large symbolic byte strings sbytes1024 :: Query [SWord 8] sbytes128 :: QueryT IO [SWord 8] -- | Abstract calldata argument generation We don't assume input types are -- restricted to their proper range here; such assumptions should instead -- be given as preconditions. This could catch some interesting calldata -- mismanagement errors. symAbiArg :: AbiType -> Query ([SWord 8], SWord 32) -- | Generates calldata matching given type signature, optionally -- specialized with concrete arguments. Any argument given as -- "symbolic" or omitted at the tail of the list are kept -- symbolic. symCalldata :: Text -> [AbiType] -> [String] -> Query ([SWord 8], SWord 32) abstractVM :: Maybe (Text, [AbiType]) -> [String] -> ByteString -> StorageModel -> Query VM loadSymVM :: ContractCode -> Storage -> StorageModel -> SAddr -> SymWord -> (Buffer, SWord 32) -> VM -- | Interpreter which explores all paths at | branching points. | returns -- a list of possible final evm states interpret :: Fetcher -> Maybe Integer -> Stepper a -> StateT VM IO [a] maxIterationsReached :: VM -> Maybe Integer -> Maybe Bool type Precondition = VM -> SBool type Postcondition = (VM, VM) -> SBool checkAssert :: ContractCode -> Maybe Integer -> Maybe (Text, [AbiType]) -> [String] -> Query (Either (VM, [VM]) VM) checkAssertions :: Postcondition verifyContract :: ContractCode -> Maybe Integer -> Maybe (Text, [AbiType]) -> [String] -> StorageModel -> Precondition -> Maybe Postcondition -> Query (Either (VM, [VM]) VM) pruneDeadPaths :: [VM] -> [VM] -- | Symbolically execute the VM and check all endstates against the -- postcondition, if available. Returns `Right VM` if the postcondition -- can be violated, where VM is a prestate counterexample, or -- `Left (VM, [VM])`, a pair of prestate and post vm states. verify :: VM -> Maybe Integer -> Maybe (BlockNumber, Text) -> Maybe Postcondition -> Query (Either (VM, [VM]) VM) -- | Compares two contract runtimes for trace equivalence by running two -- VMs and comparing the end states. equivalenceCheck :: ByteString -> ByteString -> Maybe Integer -> Maybe (Text, [AbiType]) -> Query (Either ([VM], [VM]) VM) both' :: (a -> b) -> (a, a) -> (b, b) showCounterexample :: VM -> Maybe (Text, [AbiType]) -> Query () module EVM.Debug data Mode Debug :: Mode Run :: Mode object :: [(Doc, Doc)] -> Doc prettyContract :: Contract -> Doc prettyContracts :: Map Addr Contract -> Doc srcMapCodePos :: SourceCache -> SrcMap -> Maybe (Text, Int) srcMapCode :: SourceCache -> SrcMap -> Maybe ByteString instance GHC.Show.Show EVM.Debug.Mode instance GHC.Classes.Eq EVM.Debug.Mode module EVM.Dapp data DappInfo DappInfo :: FilePath -> Map Text SolcContract -> Map W256 (CodeType, SolcContract) -> SourceCache -> [(Text, [(Text, [AbiType])])] -> Map W256 Event -> Map Int Value -> (SrcMap -> Maybe Value) -> DappInfo [_dappRoot] :: DappInfo -> FilePath [_dappSolcByName] :: DappInfo -> Map Text SolcContract [_dappSolcByHash] :: DappInfo -> Map W256 (CodeType, SolcContract) [_dappSources] :: DappInfo -> SourceCache [_dappUnitTests] :: DappInfo -> [(Text, [(Text, [AbiType])])] [_dappEventMap] :: DappInfo -> Map W256 Event [_dappAstIdMap] :: DappInfo -> Map Int Value [_dappAstSrcMap] :: DappInfo -> SrcMap -> Maybe Value dappUnitTests :: Lens' DappInfo [(Text, [(Text, [AbiType])])] dappSources :: Lens' DappInfo SourceCache dappSolcByName :: Lens' DappInfo (Map Text SolcContract) dappSolcByHash :: Lens' DappInfo (Map W256 (CodeType, SolcContract)) dappRoot :: Lens' DappInfo FilePath dappEventMap :: Lens' DappInfo (Map W256 Event) dappAstSrcMap :: Lens' DappInfo (SrcMap -> Maybe Value) dappAstIdMap :: Lens' DappInfo (Map Int Value) dappInfo :: FilePath -> Map Text SolcContract -> SourceCache -> DappInfo unitTestMarkerAbi :: Word32 findUnitTests :: (Text -> Bool) -> [SolcContract] -> [(Text, [(Text, [AbiType])])] unitTestMethodsFiltered :: (Text -> Bool) -> SolcContract -> [(Text, [AbiType])] unitTestMethods :: SolcContract -> [(Text, [AbiType])] traceSrcMap :: DappInfo -> Trace -> Maybe SrcMap showTraceLocation :: DappInfo -> Trace -> Either Text Text module EVM.StorageLayout findContractDefinition :: DappInfo -> SolcContract -> Maybe Value storageLayout :: DappInfo -> SolcContract -> [Text] storageVariablesForContract :: Value -> Maybe [Text] nodeIs :: Text -> Value -> Bool isStorageVariableDeclaration :: Value -> Bool slotTypeForDeclaration :: Value -> SlotType grokDeclarationType :: Value -> SlotType grokMappingType :: [Value] -> SlotType grokValueType :: Value -> AbiType module EVM.Format data Signedness Signed :: Signedness Unsigned :: Signedness showDec :: Signedness -> W256 -> Text showWordExact :: Word -> Text humanizeInteger :: (Num a, Integral a, Show a) => a -> Text showAbiValues :: Vector AbiValue -> Text showAbiArray :: Vector AbiValue -> Text showAbiValue :: AbiValue -> Text isPrintable :: ByteString -> Bool formatBytes :: ByteString -> Text formatSBytes :: Buffer -> Text formatQString :: ByteString -> Text formatString :: ByteString -> Text formatSString :: Buffer -> Text formatBinary :: ByteString -> Text formatSBinary :: Buffer -> Text showTraceTree :: DappInfo -> VM -> Text showTrace :: DappInfo -> Trace -> Text getAbiMethodOutput :: DappInfo -> W256 -> Word -> Maybe (Text, AbiType) getAbiTypes :: Text -> [Maybe AbiType] showCall :: [AbiType] -> Buffer -> Text showError :: ByteString -> Text showValues :: [AbiType] -> Buffer -> Text showValue :: AbiType -> Buffer -> Text maybeContractName :: Maybe SolcContract -> Text maybeAbiName :: SolcContract -> Word -> Maybe Text contractNamePart :: Text -> Text contractPathPart :: Text -> Text instance GHC.Show.Show EVM.Format.Signedness module EVM.Flatten flatten :: DappInfo -> Text -> IO () module EVM.UnitTest data UnitTestOptions UnitTestOptions :: (Query -> IO (EVM ())) -> Maybe Int -> Maybe Integer -> Text -> Int -> Maybe (Text, ByteString) -> (VM -> VM) -> DappInfo -> TestVMParams -> UnitTestOptions [oracle] :: UnitTestOptions -> Query -> IO (EVM ()) [verbose] :: UnitTestOptions -> Maybe Int [maxIter] :: UnitTestOptions -> Maybe Integer [match] :: UnitTestOptions -> Text [fuzzRuns] :: UnitTestOptions -> Int [replay] :: UnitTestOptions -> Maybe (Text, ByteString) [vmModifier] :: UnitTestOptions -> VM -> VM [dapp] :: UnitTestOptions -> DappInfo [testParams] :: UnitTestOptions -> TestVMParams data TestVMParams TestVMParams :: Addr -> Addr -> Addr -> W256 -> W256 -> W256 -> W256 -> Addr -> W256 -> W256 -> W256 -> W256 -> W256 -> W256 -> W256 -> TestVMParams [testAddress] :: TestVMParams -> Addr [testCaller] :: TestVMParams -> Addr [testOrigin] :: TestVMParams -> Addr [testGasCreate] :: TestVMParams -> W256 [testGasCall] :: TestVMParams -> W256 [testBalanceCreate] :: TestVMParams -> W256 [testBalanceCall] :: TestVMParams -> W256 [testCoinbase] :: TestVMParams -> Addr [testNumber] :: TestVMParams -> W256 [testTimestamp] :: TestVMParams -> W256 [testGaslimit] :: TestVMParams -> W256 [testGasprice] :: TestVMParams -> W256 [testMaxCodeSize] :: TestVMParams -> W256 [testDifficulty] :: TestVMParams -> W256 [testChainId] :: TestVMParams -> W256 defaultGasForCreating :: W256 defaultGasForInvoking :: W256 defaultBalanceForCreator :: W256 defaultBalanceForCreated :: W256 defaultMaxCodeSize :: W256 type ABIMethod = Text -- | Assuming a constructor is loaded, this stepper will run the -- constructor to create the test contract, give it an initial balance, -- and run `setUp()'. initializeUnitTest :: UnitTestOptions -> Stepper () -- | Assuming a test contract is loaded and initialized, this stepper will -- run the specified test method and return whether it succeeded. runUnitTest :: UnitTestOptions -> ABIMethod -> AbiValue -> Stepper Bool execTest :: UnitTestOptions -> ABIMethod -> AbiValue -> Stepper Bool checkFailures :: UnitTestOptions -> ABIMethod -> AbiValue -> Bool -> Stepper Bool -- | Randomly generates the calldata arguments and runs the test fuzzTest :: UnitTestOptions -> Text -> [AbiType] -> VM -> Property tick :: Text -> IO () -- | This is like an unresolved source mapping. data OpLocation OpLocation :: !W256 -> !Int -> OpLocation [srcCodehash] :: OpLocation -> !W256 [srcOpIx] :: OpLocation -> !Int srcMapForOpLocation :: DappInfo -> OpLocation -> Maybe SrcMap type CoverageState = (VM, MultiSet OpLocation) currentOpLocation :: VM -> OpLocation execWithCoverage :: StateT CoverageState IO VMResult runWithCoverage :: StateT CoverageState IO VM interpretWithCoverage :: UnitTestOptions -> Stepper a -> StateT CoverageState IO a coverageReport :: DappInfo -> MultiSet SrcMap -> Map Text (Vector (Int, ByteString)) coverageForUnitTestContract :: UnitTestOptions -> Map Text SolcContract -> SourceCache -> (Text, [(Text, [AbiType])]) -> IO (MultiSet SrcMap) runUnitTestContract :: UnitTestOptions -> Map Text SolcContract -> SourceCache -> (Text, [(Text, [AbiType])]) -> IO Bool indentLines :: Int -> Text -> Text passOutput :: VM -> UnitTestOptions -> Text -> Text failOutput :: VM -> UnitTestOptions -> Text -> Text formatTestLogs :: Map W256 Event -> Seq Log -> Text formatTestLog :: Map W256 Event -> Log -> Maybe Text word32Bytes :: Word32 -> ByteString setupCall :: TestVMParams -> Text -> AbiValue -> EVM () initialUnitTestVm :: UnitTestOptions -> SolcContract -> VM getParametersFromEnvironmentVariables :: IO TestVMParams instance GHC.Show.Show EVM.UnitTest.OpLocation instance GHC.Classes.Ord EVM.UnitTest.OpLocation instance GHC.Classes.Eq EVM.UnitTest.OpLocation module EVM.VMTest data Case parseSuite :: ByteString -> Either String (Map String Case) parseBCSuite :: ByteString -> Either String (Map String Case) vmForCase :: Case -> VM checkExpectation :: Bool -> Case -> VM -> IO Bool instance GHC.Show.Show EVM.VMTest.BlockchainError instance Data.Aeson.Types.FromJSON.FromJSON EVM.VMTest.Contract instance Data.Aeson.Types.FromJSON.FromJSON EVM.VMTest.Case instance Data.Aeson.Types.FromJSON.FromJSON EVM.VMTest.BlockchainCase instance Data.Aeson.Types.FromJSON.FromJSON EVM.VMTest.Block instance GHC.Show.Show EVM.VMTest.Case instance GHC.Show.Show EVM.VMTest.Expectation instance GHC.Show.Show EVM.VMTest.BlockchainCase instance GHC.Show.Show EVM.VMTest.Contract instance GHC.Show.Show EVM.VMTest.Block module EVM.TTY data Name AbiPane :: Name StackPane :: Name BytecodePane :: Name TracePane :: Name SolidityPane :: Name TestPickerPane :: Name BrowserPane :: Name Pager :: Name type UiWidget = Widget Name data UiVmState UiVmState :: VM -> Int -> Map Int (VM, Stepper ()) -> Stepper () -> List Name (Int, SymWord) -> List Name (Int, Op) -> List Name Text -> List Name (Int, ByteString) -> Maybe String -> Bool -> Maybe SolcContract -> UnitTestOptions -> UiVmState [_uiVm] :: UiVmState -> VM [_uiStep] :: UiVmState -> Int [_uiSnapshots] :: UiVmState -> Map Int (VM, Stepper ()) [_uiStepper] :: UiVmState -> Stepper () [_uiStackList] :: UiVmState -> List Name (Int, SymWord) [_uiBytecodeList] :: UiVmState -> List Name (Int, Op) [_uiTraceList] :: UiVmState -> List Name Text [_uiSolidityList] :: UiVmState -> List Name (Int, ByteString) [_uiMessage] :: UiVmState -> Maybe String [_uiShowMemory] :: UiVmState -> Bool [_uiSolc] :: UiVmState -> Maybe SolcContract [_uiTestOpts] :: UiVmState -> UnitTestOptions data UiTestPickerState UiTestPickerState :: List Name (Text, Text) -> DappInfo -> UnitTestOptions -> UiTestPickerState [_testPickerList] :: UiTestPickerState -> List Name (Text, Text) [_testPickerDapp] :: UiTestPickerState -> DappInfo [_testOpts] :: UiTestPickerState -> UnitTestOptions data UiBrowserState UiBrowserState :: List Name (Addr, Contract) -> UiVmState -> UiBrowserState [_browserContractList] :: UiBrowserState -> List Name (Addr, Contract) [_browserVm] :: UiBrowserState -> UiVmState data UiState ViewVm :: UiVmState -> UiState ViewContracts :: UiBrowserState -> UiState ViewPicker :: UiTestPickerState -> UiState ViewHelp :: UiVmState -> UiState uiVm :: Lens' UiVmState VM uiTraceList :: Lens' UiVmState (List Name Text) uiTestOpts :: Lens' UiVmState UnitTestOptions uiStepper :: Lens' UiVmState (Stepper ()) uiStep :: Lens' UiVmState Int uiStackList :: Lens' UiVmState (List Name (Int, SymWord)) uiSolidityList :: Lens' UiVmState (List Name (Int, ByteString)) uiSolc :: Lens' UiVmState (Maybe SolcContract) uiSnapshots :: Lens' UiVmState (Map Int (VM, Stepper ())) uiShowMemory :: Lens' UiVmState Bool uiMessage :: Lens' UiVmState (Maybe String) uiBytecodeList :: Lens' UiVmState (List Name (Int, Op)) testPickerList :: Lens' UiTestPickerState (List Name (Text, Text)) testPickerDapp :: Lens' UiTestPickerState DappInfo testOpts :: Lens' UiTestPickerState UnitTestOptions browserVm :: Lens' UiBrowserState UiVmState browserContractList :: Lens' UiBrowserState (List Name (Addr, Contract)) _ViewHelp :: Prism' UiState UiVmState _ViewPicker :: Prism' UiState UiTestPickerState _ViewContracts :: Prism' UiState UiBrowserState _ViewVm :: Prism' UiState UiVmState snapshotInterval :: Int type Pred a = a -> Bool data StepMode -- | Run a specific number of steps Step :: !Int -> StepMode -- | Finish when a VM predicate holds StepUntil :: Pred VM -> StepMode -- | Each step command in the terminal should finish immediately with one -- of these outcomes. data Continuation a -- | Program finished Stopped :: a -> Continuation a -- | Took one step; more steps to go Continue :: Stepper a -> Continuation a -- | This turns a Stepper into a state action usable from within -- the TTY loop, yielding a StepOutcome depending on the -- StepMode. interpret :: (?fetcher :: Fetcher, ?maxIter :: Maybe Integer) => StepMode -> Stepper a -> StateT UiVmState IO (Continuation a) isUnitTestContract :: Text -> DappInfo -> Bool mkVty :: IO Vty runFromVM :: Maybe Integer -> DappInfo -> (Query -> IO (EVM ())) -> VM -> IO VM initUiVmState :: VM -> UnitTestOptions -> Stepper () -> UiVmState concreteTests :: UnitTestOptions -> (Text, [(Text, [AbiType])]) -> [(Text, Text)] main :: UnitTestOptions -> FilePath -> FilePath -> IO () takeStep :: (?fetcher :: Fetcher, ?maxIter :: Maybe Integer) => UiVmState -> StepMode -> EventM n (Next UiState) appEvent :: (?fetcher :: Fetcher, ?maxIter :: Maybe Integer) => UiState -> BrickEvent Name e -> EventM Name (Next UiState) app :: UnitTestOptions -> App UiState () Name initialUiVmStateForTest :: UnitTestOptions -> (Text, Text) -> UiVmState myTheme :: [(AttrName, Attr)] drawUi :: UiState -> [UiWidget] drawHelpView :: [UiWidget] drawTestPicker :: UiTestPickerState -> [UiWidget] drawVmBrowser :: UiBrowserState -> [UiWidget] drawVm :: UiVmState -> [UiWidget] drawHelpBar :: UiWidget stepOneOpcode :: Stepper a -> StateT UiVmState IO () isNextSourcePosition :: UiVmState -> Pred VM isNextSourcePositionWithoutEntering :: UiVmState -> Pred VM isExecutionHalted :: UiVmState -> Pred VM currentSrcMap :: DappInfo -> VM -> Maybe SrcMap currentSolc :: DappInfo -> VM -> Maybe SolcContract renderVm :: UiVmState -> UiVmState updateUiVmState :: UiVmState -> VM -> UiVmState drawStackPane :: UiVmState -> UiWidget showWordExplanation :: W256 -> DappInfo -> Text drawBytecodePane :: UiVmState -> UiWidget dim :: Widget n -> Widget n withHighlight :: Bool -> Widget n -> Widget n prettyIfConcrete :: Buffer -> String drawTracePane :: UiVmState -> UiWidget drawSolidityPane :: UiVmState -> UiWidget ifTallEnough :: Int -> Widget n -> Widget n -> Widget n opWidget :: (Integral a, Show a) => (a, Op) -> Widget n selectedAttr :: AttrName dimAttr :: AttrName wordAttr :: AttrName boldAttr :: AttrName activeAttr :: AttrName instance GHC.Classes.Ord EVM.TTY.Name instance GHC.Show.Show EVM.TTY.Name instance GHC.Classes.Eq EVM.TTY.Name module EVM.Emacs data UiVmState UiVmState :: VM -> Stepper () -> Maybe SolcContract -> Maybe DappInfo -> Int -> UiVmState -> Fetcher -> Maybe Text -> Set W256 -> UiVmState [_uiVm] :: UiVmState -> VM [_uiVmNextStep] :: UiVmState -> Stepper () [_uiVmSolc] :: UiVmState -> Maybe SolcContract [_uiVmDapp] :: UiVmState -> Maybe DappInfo [_uiVmStepCount] :: UiVmState -> Int [_uiVmFirstState] :: UiVmState -> UiVmState [_uiVmFetcher] :: UiVmState -> Fetcher [_uiVmMessage] :: UiVmState -> Maybe Text [_uiVmSentHashes] :: UiVmState -> Set W256 uiVmStepCount :: Lens' UiVmState Int uiVmSolc :: Lens' UiVmState (Maybe SolcContract) uiVmSentHashes :: Lens' UiVmState (Set W256) uiVmNextStep :: Lens' UiVmState (Stepper ()) uiVmMessage :: Lens' UiVmState (Maybe Text) uiVmFirstState :: Lens' UiVmState UiVmState uiVmFetcher :: Lens' UiVmState Fetcher uiVmDapp :: Lens' UiVmState (Maybe DappInfo) uiVm :: Lens' UiVmState VM type Pred a = a -> Bool data StepMode -- | Finish after one opcode step StepOne :: StepMode -- | Run a specific number of steps StepMany :: !Int -> StepMode -- | Finish before the next opcode StepNone :: StepMode -- | Finish when a VM predicate holds StepUntil :: Pred VM -> StepMode data StepOutcome a -- | Program finished Returned :: a -> StepOutcome a -- | Took one step; more steps to go Stepped :: Stepper a -> StepOutcome a -- | Came across blocking request Blocked :: IO (Stepper a) -> StepOutcome a interpret :: StepMode -> Stepper a -> State UiVmState (StepOutcome a) stepOneOpcode :: UiVmState -> UiVmState updateUiVmState :: UiVmState -> VM -> UiVmState updateSentHashes :: UiVmState -> UiVmState type Sexp = WellFormedSExpr HaskLikeAtom prompt :: Console (Maybe Sexp) class SDisplay a sexp :: SDisplay a => a -> SExpr Text display :: SDisplay a => a -> Text txt :: Show a => a -> Text data UiState UiStarted :: UiState UiDappLoaded :: DappInfo -> UiState UiVm :: UiVmState -> UiState type Console a = StateT UiState IO a output :: SDisplay a => a -> Console () main :: IO () loop :: Console () handle :: Sexp -> Console () handleCmd :: UiState -> (Text, [Sexp]) -> Console () atFileLine :: DappInfo -> Text -> Int -> VM -> Bool codeByHash :: W256 -> VM -> Maybe ByteString allHashes :: VM -> Set W256 prettifyCode :: ByteString -> String outputVm :: Console () isNextSourcePosition :: UiVmState -> Pred VM -- | Specifies whether to do I/O blocking or VM halting while stepping. -- When we step backwards, we don't want to allow those things. parseStepMode :: UiVmState -> Text -> Maybe StepMode data StepPolicy -- | Allow blocking and returning StepNormally :: StepPolicy -- | Forbid blocking and returning StepTimidly :: StepPolicy takeStep :: UiVmState -> StepPolicy -> StepMode -> Console () quoted :: Text -> Text sexpMemory :: Buffer -> SExpr Text defaultUnitTestOptions :: MonadIO m => m UnitTestOptions initialStateForTest :: UnitTestOptions -> (Text, Text) -> UiVmState instance EVM.Emacs.SDisplay EVM.Dapp.DappInfo instance EVM.Emacs.SDisplay (Data.SCargot.Repr.SExpr Data.Text.Internal.Text) instance EVM.Emacs.SDisplay EVM.Storage instance EVM.Emacs.SDisplay EVM.VM instance EVM.Emacs.SDisplay EVM.Types.Addr instance EVM.Emacs.SDisplay EVM.Contract instance EVM.Emacs.SDisplay EVM.Types.W256 instance EVM.Emacs.SDisplay (Data.SBV.Core.Sized.SWord 256) instance EVM.Emacs.SDisplay EVM.Symbolic.SymWord instance EVM.Emacs.SDisplay (Data.SBV.Core.Sized.SWord 8) instance EVM.Emacs.SDisplay EVM.Symbolic.Buffer instance (EVM.Emacs.SDisplay k, EVM.Emacs.SDisplay v) => EVM.Emacs.SDisplay (Data.Map.Internal.Map k v) instance EVM.Emacs.SDisplay a => EVM.Emacs.SDisplay (GHC.Maybe.Maybe a) instance EVM.Emacs.SDisplay EVM.VMResult instance EVM.Emacs.SDisplay EVM.Frame instance EVM.Emacs.SDisplay EVM.FrameContext instance EVM.Emacs.SDisplay EVM.FrameState instance EVM.Emacs.SDisplay a => EVM.Emacs.SDisplay [a] instance EVM.Emacs.SDisplay GHC.Base.String instance EVM.Emacs.SDisplay EVM.Concrete.Word instance EVM.Emacs.SDisplay Data.ByteString.Internal.ByteString module EVM.Dev loadDappInfo :: String -> String -> IO DappInfo ghciTest :: String -> String -> Maybe String -> IO [Bool] runBCTest :: (String, Case) -> IO Bool ghciBCTest :: String -> IO () ghciTty :: String -> String -> Maybe String -> IO () ghciEmacs :: IO () foo :: IO ()