Skip to content

Commit

Permalink
Advance blocks in forks
Browse files Browse the repository at this point in the history
  • Loading branch information
arcz committed Jun 8, 2023
1 parent 2e52418 commit bb70dc7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/Echidna/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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

0 comments on commit bb70dc7

Please sign in to comment.