We do not systematically RollForward
First step to roll backward in ModelSpec is to split blocks generation from rolling forward.
First step to roll backward in ModelSpec is to split blocks generation from rolling forward.
import Control.Monad.Class.MonadFork (labelThisThread)
import Control.Monad.Class.MonadSTM (
MonadLabelledSTM,
MonadSTM (newTVarIO, writeTVar),
labelTQueueIO,
modifyTVar,
newTQueueIO,
readTVarIO,
tryReadTQueue,
writeTQueue,
)
import Data.Sequence (Seq (Empty, (:|>)))
import qualified Data.Sequence as Seq
import qualified Data.Sequence.Strict as StrictSeq
import Hydra.BehaviorSpec (
ConnectToChain (..),
m (ConnectToChain Tx m, Async m ())
mockChainAndNetwork tr seedKeys nodes cp = do
queue <- newTQueueIO
chain <- newTVarIO (0, Empty)
labelTQueueIO queue "chain-queue"
tickThread <- async (labelThisThread "chain" >> simulateTicks queue)
tickThread <- async (labelThisThread "chain" >> simulateTicks queue chain)
let chainComponent = \node -> do
let Environment{party = ownParty, otherParties} = env node
let (vkey, vkeys) = findOwnCardanoKey ownParty seedKeys
return (ConnectToChain{..}, tickThread)
where
blockTime = 20 -- seconds
simulateTicks queue = forever $ do
simulateTicks ::
TQueue m (Ledger.ValidatedTx LedgerEra) ->
TVar m (Int, Seq Util.Block) ->
m ()
simulateTicks queue chain = forever $ do
threadDelay blockTime
hasTx <- atomically $ tryReadTQueue queue
case hasTx of
Just tx -> do
let block = mkBlock tx
allHandlers <- fmap chainHandler <$> readTVarIO nodes
forM_ allHandlers (`onRollForward` block)
Nothing -> pure ()
atomically $ modifyTVar chain $ appendToChain block
pure ()
Nothing -> do
(position, blocks) <- atomically $ readTVar chain
case Seq.lookup position blocks of
Just block -> do
rollForward block
atomically $ writeTVar chain (position + 1, blocks)
Nothing ->
pure ()
appendToChain block (cursor, blocks) =
(cursor, blocks :|> block)
rollForward block = do
allHandlers <- fmap chainHandler <$> readTVarIO nodes
forM_ allHandlers (`onRollForward` block)
-- | Find Cardano vkey corresponding to our Hydra vkey using signing keys lookup.
-- This is a bit cumbersome and a tribute to the fact the `HydraNode` itself has no
Previous work on the builders/etc updates rust but introduced things caused the WASM to no longer compile. This updates the WASM bindings as well. Includes genesis module that wasn't pushed before.
updatet hackage index
Fix db-sync checks of scripts in reference txin