From bb70dc7dc24fa42451d3c63454d25e05410c4a43 Mon Sep 17 00:00:00 2001 From: Artur Cygan Date: Thu, 8 Jun 2023 22:38:29 +0200 Subject: [PATCH] Advance blocks in forks --- lib/Echidna/Transaction.hs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/Echidna/Transaction.hs b/lib/Echidna/Transaction.hs index e80c7f137..7b88199ca 100644 --- a/lib/Echidna/Transaction.hs +++ b/lib/Echidna/Transaction.hs @@ -12,6 +12,7 @@ import Control.Monad.State.Strict (MonadState, gets, modify') import Data.Map (Map, toList) import Data.Map qualified as Map import Data.Maybe (mapMaybe) +import Data.Sequence (Seq) import Data.Set (Set) import Data.Set qualified as Set import Data.Vector qualified as V @@ -157,6 +158,7 @@ setupTx tx@Tx{call = NoCall} = fromEVM $ do modify' $ \vm -> vm { state = resetState vm.state , block = advanceBlock vm.block tx.delay + , forks = advanceForks vm.forks tx.delay } loadContract tx.dst @@ -169,6 +171,7 @@ setupTx tx@Tx{call} = fromEVM $ do , callvalue = Lit tx.value } , block = advanceBlock vm.block tx.delay + , forks = advanceForks vm.forks tx.delay , tx = vm.tx { gasprice = tx.gasprice, origin = tx.src } } case call of @@ -195,3 +198,7 @@ advanceBlock :: Block -> (W256, W256) -> Block advanceBlock blk (t,b) = blk { timestamp = Lit (forceLit blk.timestamp + t) , number = blk.number + b } + +advanceForks :: Seq ForkState -> (W256, W256) -> Seq ForkState +advanceForks forks delay = + (\(ForkState env block cache) -> ForkState env (advanceBlock block delay) cache) <$> forks