Skip to content

Commit

Permalink
Fix MockChain submission during multiple rollbacks
Browse files Browse the repository at this point in the history
There could be situations with race conditions when multiple
RollbackAndForward actions were generated by the model.

By using the correct "view" onto the chain, the mock chain can evaluate
transactions more consistently.
  • Loading branch information
ch1bo committed Feb 19, 2024
1 parent 85a65fa commit 3ac3fb2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion hydra-node/test/Hydra/Model/MockChain.hs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,12 @@ mockChainAndNetwork tr seedKeys commits = do
-- Validate transactions on submission and queue them for inclusion if valid.
let submitTx tx =
atomically $ do
(_, _, _, utxo) <- readTVar chain
-- NOTE: Determine the current "view" on the chain (important while
-- rolled back, before new roll forwards were issued)
(_, position, blocks, globalUTxO) <- readTVar chain
let utxo = case Seq.lookup (fromIntegral position) blocks of
Nothing -> globalUTxO
Just (_, _, blockUTxO) -> blockUTxO
-- TODO: dry with block tx validation
case evaluateTx tx utxo of
Left err ->
Expand Down

0 comments on commit 3ac3fb2

Please sign in to comment.