Set reasonable initial block time and number (#455)

dev-mem-coverage
Gustavo Grieco 5 years ago committed by GitHub
parent 7dc502431c
commit ceb8fbc512
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      lib/Echidna/Solidity.hs
  2. 4
      lib/Echidna/Transaction.hs
  3. 6
      lib/Echidna/Types/Tx.hs

@ -36,7 +36,7 @@ import Echidna.ABI (encodeSig, hashSig, stripBytecodeMetadata, fa
import Echidna.Exec (execTx)
import Echidna.RPC (loadEthenoBatch)
import Echidna.Types.Signature (FunctionHash, SolSignature, SignatureMap)
import Echidna.Types.Tx (TxConf, TxCall(..), Tx(..))
import Echidna.Types.Tx (TxConf, TxCall(..), Tx(..), initialTimestamp, initialBlockNumber)
import Echidna.Types.World (World(..))
import Echidna.Processor
@ -162,7 +162,7 @@ loadLibraries :: (MonadIO m, MonadThrow m, MonadReader x m, Has SolConf x)
=> [SolcContract] -> Addr -> Addr -> VM -> m VM
loadLibraries [] _ _ vm = return vm
loadLibraries (l:ls) la d vm = loadLibraries ls (la + 1) d =<< loadRest
where loadRest = execStateT (execTx $ Tx (SolCreate $ l ^. creationCode) d la 8000030 0 0 (0,0)) vm
where loadRest = execStateT (execTx $ Tx (SolCreate $ l ^. creationCode) d la 8000030 0 0 (initialTimestamp, initialBlockNumber)) vm
-- | Generate a string to use as argument in solc to link libraries starting from addrLibrary
linkLibraries :: [String] -> String
@ -234,7 +234,7 @@ loadSpecified name cs = do
Just (t,_) -> throwM $ TestArgsFound t -- Test args check
Nothing -> do
vm <- loadLibraries ls addrLibrary d blank
let transaction = unless (isJust fp) $ void . execTx $ Tx (SolCreate bc) d ca 8000030 0 (w256 $ fromInteger balc) (0, 0)
let transaction = unless (isJust fp) $ void . execTx $ Tx (SolCreate bc) d ca 8000030 0 (w256 $ fromInteger balc) (initialTimestamp,initialBlockNumber)
vm' <- execStateT transaction vm
case currentContract vm' of
Just _ -> return (vm', neFuns, fst <$> tests, abiMapping)

@ -65,8 +65,10 @@ genTxWith m s r c g gp mv t = do
v' = genValue ps mv
rs = NE.fromList . catMaybes $ mkR <$> toList m
mkR = _2 (flip M.lookup mm . view (bytecode . to stripBytecodeMetadata))
(tt,tn) <- t
let t' = return (initialTimestamp + tt, initialBlockNumber + tn)
v'' <- v' <$> s' <*> r' <*> c'
Tx <$> (SolCall <$> c') <*> s' <*> (fst <$> r') <*> g <*> gp <*> v'' <*> t
Tx <$> (SolCall <$> c') <*> s' <*> (fst <$> r') <*> g <*> gp <*> v'' <*> t'
getSignatures :: MonadRandom m => SignatureMap -> Maybe SignatureMap -> m SignatureMap
getSignatures hmm Nothing = return hmm

@ -23,6 +23,12 @@ data TxCall = SolCreate ByteString
makePrisms ''TxCall
$(deriveJSON defaultOptions ''TxCall)
initialTimestamp :: Word
initialTimestamp = 1524785992 -- Thu Apr 26 23:39:52 UTC 2018
initialBlockNumber :: Word
initialBlockNumber = 4370000 -- Initial byzantium block
-- | A transaction is either a @CREATE@ or a regular call with an origin, destination, and value.
-- Note: I currently don't model nonces or signatures here.
data Tx = Tx { _call :: TxCall -- | Call

Loading…
Cancel
Save