Skip to content

Commit

Permalink
Fix faulty corpus transaction detection (#1184)
Browse files Browse the repository at this point in the history
* Fix faulty corpus transaction detection

* Don't execute NoCalls
  • Loading branch information
arcz authored Feb 2, 2024
1 parent 1d0c937 commit f641d1a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
4 changes: 3 additions & 1 deletion lib/Echidna/Campaign.hs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ replayCorpus
-> m ()
replayCorpus vm txSeqs =
forM_ (zip [1..] txSeqs) $ \(i, (file, txSeq)) -> do
let maybeFaultyTx = List.find (\tx -> LitAddr tx.dst `notElem` Map.keys vm.env.contracts) txSeq
let maybeFaultyTx =
List.find (\tx -> LitAddr tx.dst `notElem` Map.keys vm.env.contracts) $
List.filter (\case Tx { call = NoCall } -> False; _ -> True) txSeq
case maybeFaultyTx of
Nothing -> do
_ <- callseq vm txSeq
Expand Down
13 changes: 8 additions & 5 deletions lib/Echidna/Exec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,14 @@ execTxWith executeTx tx = do
#traces .= emptyEvents
vmBeforeTx <- get
setupTx tx
gasLeftBeforeTx <- gets (.state.gas)
vmResult <- runFully
gasLeftAfterTx <- gets (.state.gas)
handleErrorsAndConstruction vmResult vmBeforeTx
pure (vmResult, gasLeftBeforeTx - gasLeftAfterTx)
case tx.call of
NoCall -> pure (VMSuccess (ConcreteBuf ""), 0)
_ -> do
gasLeftBeforeTx <- gets (.state.gas)
vmResult <- runFully
gasLeftAfterTx <- gets (.state.gas)
handleErrorsAndConstruction vmResult vmBeforeTx
pure (vmResult, gasLeftBeforeTx - gasLeftAfterTx)
where
runFully = do
config <- asks (.cfg)
Expand Down
1 change: 0 additions & 1 deletion lib/Echidna/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ setupTx tx@Tx{call = NoCall} = fromEVM $ do
{ state = vm.state
, block = advanceBlock vm.block tx.delay
}
modify' $ execState $ loadContract (LitAddr tx.dst)

setupTx tx@Tx{call} = fromEVM $ do
resetState
Expand Down

0 comments on commit f641d1a

Please sign in to comment.