Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix faulty corpus transaction detection #1184

Merged
merged 2 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Comment on lines +71 to +73
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the PR's mention of a future, more comprehensive fix to the Tx type to eliminate unnecessary fields for NoCall transactions, it's crucial to ensure that this temporary solution is revisited and potentially revised to align with those future changes. This will help maintain the integrity and efficiency of the transaction handling process in the long term.

Would you like to create a follow-up task or issue to revisit this logic once the comprehensive Tx type changes are implemented?

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