Skip to content

Commit

Permalink
Wait on unresolved decommit
Browse files Browse the repository at this point in the history
Signed-off-by: Sasha Bogicevic <[email protected]>
  • Loading branch information
v0d1ch committed Sep 11, 2024
1 parent 1e3279c commit 7b32889
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
17 changes: 10 additions & 7 deletions hydra-node/src/Hydra/HeadLogic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ onOpenNetworkReqSn env ledger st otherParty sv sn requestedTxIds mDecommitTx mIn
, number = sn
, confirmed = requestedTxIds
, utxo = u
, utxoToCommit = mIncrementUTxO
, utxoToDecommit = mUtxoToDecommit
}
-- Spec: η ← combine(𝑈)
Expand Down Expand Up @@ -856,19 +857,21 @@ onOpenChainDepositTx ::
UTxOType tx ->
Outcome tx
onOpenChainDepositTx env st utxo =
if not snapshotInFlight && isLeader parameters party nextSn
then -- TODO: shall we include deposit tx in the ReqSn?
cause (NetworkEffect $ ReqSn version nextSn (txId <$> localTxs) Nothing (Just utxo))
else noop
waitOnUnresolvedDecommit $
if not snapshotInFlight && isLeader parameters party nextSn
then cause (NetworkEffect $ ReqSn version nextSn (txId <$> localTxs) Nothing (Just utxo))
else noop
where
-- TODO: implement me!
waitOnResolvedDecrement cont = undefined
waitOnUnresolvedDecommit cont =
case decommitTx of
Nothing -> cont
Just tx -> wait $ WaitOnUnresolvedDecommit{decommitTx = tx}

nextSn = confirmedSn + 1

Environment{party} = env

CoordinatedHeadState{localTxs, confirmedSnapshot, seenSnapshot, version} = coordinatedHeadState
CoordinatedHeadState{localTxs, confirmedSnapshot, seenSnapshot, version, decommitTx} = coordinatedHeadState

Snapshot{number = confirmedSn} = getSnapshot confirmedSnapshot

Expand Down
1 change: 1 addition & 0 deletions hydra-node/src/Hydra/HeadLogic/Outcome.hs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ data WaitReason tx
| WaitOnTxs {waitingForTxIds :: [TxIdType tx]}
| WaitOnContestationDeadline
| WaitOnNotApplicableDecommitTx {notApplicableReason :: DecommitInvalidReason tx}
| WaitOnUnresolvedDecommit {decommitTx :: tx}
deriving stock (Generic)

deriving stock instance IsTx tx => Eq (WaitReason tx)
Expand Down
2 changes: 2 additions & 0 deletions hydra-node/test/Hydra/HeadLogicSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ spec =
, number = 1
, confirmed = []
, utxo = activeUTxO
, utxoToCommit = Nothing
, utxoToDecommit = Just $ utxoRefs [3]
}
s0 =
Expand Down Expand Up @@ -1014,5 +1015,6 @@ testSnapshot number version confirmed utxo =
, number
, confirmed
, utxo
, utxoToCommit = mempty
, utxoToDecommit = mempty
}

0 comments on commit 7b32889

Please sign in to comment.