@@ -403,15 +403,17 @@ onOpenNetworkReqSn ::
403
403
Maybe (TxIdType tx ) ->
404
404
Outcome tx
405
405
onOpenNetworkReqSn env ledger st otherParty sv sn requestedTxIds mDecommitTx mDepositTxId =
406
- -- Spec: require s = ŝ + 1 ∧ leader(s) = j
406
+ -- Spec: require v = v̂ ∧ s = ŝ + 1 ∧ leader(s) = j
407
407
requireReqSn $
408
408
-- Spec: wait ŝ = ̅S.s
409
409
waitNoSnapshotInFlight $
410
+ -- TODO: is this really needed?
410
411
-- Spec: wait v = v̂
411
412
waitOnSnapshotVersion $
412
- -- Spec: require tx𝜔 = ⊥ ∨ 𝑈𝛼 = ∅
413
+ -- TODO: this is missing!? Spec: require tx𝜔 = ⊥ ∨ tx𝛼 = ⊥
414
+ -- Require any pending utxo to decommit to be consistent
413
415
requireApplicableDecommitTx $ \ (activeUTxOAfterDecommit, mUtxoToDecommit) ->
414
- -- TODO: Spec updates for these checks in here
416
+ -- Wait for the deposit and require any pending commit to be consistent
415
417
waitForDeposit activeUTxOAfterDecommit $ \ (activeUTxO, mUtxoToCommit) ->
416
418
-- Resolve transactions by-id
417
419
waitResolvableTxs $ \ requestedTxs -> do
@@ -487,14 +489,11 @@ onOpenNetworkReqSn env ledger st otherParty sv sn requestedTxIds mDecommitTx mDe
487
489
case mDepositTxId of
488
490
Nothing -> cont (activeUTxOAfterDecommit, Nothing )
489
491
Just depositTxId ->
492
+ -- XXX: We may need to wait quite long here and this makes losing
493
+ -- the 'ReqSn' due to a restart (fail-recovery) quite likely
490
494
case Map. lookup depositTxId pendingDeposits of
491
- -- REVIEW: Is this also a wait? It could be that another node has such
492
- -- low deposit period that we have not yet seen the deposit on chain?
493
- Nothing -> Error $ RequireFailed NoMatchingDeposit
495
+ Nothing -> wait WaitOnDepositObserved {depositTxId}
494
496
Just Deposit {status, deposited}
495
- -- TODO: this needs to go into the spec!
496
- -- XXX: We may need to wait quite long here and this makes losing
497
- -- the 'ReqSn' due to a restart (fail-recovery) quite likely
498
497
| status == Inactive -> wait WaitOnDepositActivation {depositTxId}
499
498
| status == Expired -> Error $ RequireFailed RequestedDepositExpired {depositTxId}
500
499
| otherwise ->
@@ -503,7 +502,7 @@ onOpenNetworkReqSn env ledger st otherParty sv sn requestedTxIds mDecommitTx mDe
503
502
if sv == confVersion && isJust confUTxOToCommit
504
503
then
505
504
if confUTxOToCommit == Just deposited
506
- then cont (activeUTxOAfterDecommit <> fromMaybe mempty confUTxOToCommit , confUTxOToCommit)
505
+ then cont (activeUTxOAfterDecommit <> deposited , confUTxOToCommit)
507
506
else Error $ RequireFailed ReqSnCommitNotSettled
508
507
else do
509
508
let activeUTxOAfterCommit = activeUTxOAfterDecommit <> deposited
0 commit comments