Skip to content

Commit 98dbafa

Browse files
committed
Remove invalid tx from allTxs when seeing TxInvalid
Signed-off-by: Sasha Bogicevic <[email protected]>
1 parent cdd0516 commit 98dbafa

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

hydra-node/src/Hydra/HeadLogic.hs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -323,16 +323,6 @@ onOpenNetworkReqTx env ledger st ttl tx =
323323
| ttl > 0 ->
324324
wait (WaitOnNotApplicableTx err)
325325
| otherwise ->
326-
-- XXX: We might want to remove invalid txs from allTxs here to
327-
-- prevent them piling up infinitely. However, this is not really
328-
-- covered by the spec and this could be problematic in case of
329-
-- conflicting transactions paired with network latency and/or
330-
-- message resubmission. For example: Assume tx2 depends on tx1, but
331-
-- only tx2 is seen by a participant and eventually times out
332-
-- because of network latency when receiving tx1. The leader,
333-
-- however, saw both as valid and requests a snapshot including
334-
-- both. This is a valid request and if we would have removed tx2
335-
-- from allTxs, we would make the head stuck.
336326
newState TxInvalid{headId, utxo = localUTxO, transaction = tx, validationError = err}
337327

338328
maybeRequestSnapshot nextSn outcome =
@@ -1783,7 +1773,10 @@ aggregate st = \case
17831773
Open ost@OpenState{} -> Open ost{currentSlot = chainSlot}
17841774
_otherState -> st
17851775
IgnoredHeadInitializing{} -> st
1786-
TxInvalid{} -> st
1776+
TxInvalid{transaction} -> case st of
1777+
Open ost@OpenState{coordinatedHeadState = coordState@CoordinatedHeadState{allTxs = allTransactions}} ->
1778+
Open ost{coordinatedHeadState = coordState{allTxs = foldr Map.delete allTransactions [txId transaction]}}
1779+
_otherState -> st
17871780
Checkpoint state' -> state'
17881781

17891782
aggregateState ::

0 commit comments

Comments
 (0)