Skip to content

Commit

Permalink
Align on close and context tx to spec and documment missing gaps
Browse files Browse the repository at this point in the history
  • Loading branch information
ffakenz committed Jul 4, 2024
1 parent 4a44e81 commit 701563f
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions hydra-node/src/Hydra/HeadLogic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,8 @@ onOpenClientClose ::
OpenState tx ->
Outcome tx
onOpenClientClose st =
-- Spec: η ← combine(S⁻.𝑈)
-- Spec: missing?
-- η ← combine(S⁻.𝑈)
-- ηω ← combine(outputs(S⁻.txω))
-- ξ ← S⁻.σ
-- postTx (close, S⁻.v, S⁻.s, η, ηω,ξ)
Expand Down Expand Up @@ -922,15 +923,22 @@ onOpenChainCloseTx ::
UTCTime ->
Outcome tx
onOpenChainCloseTx openState newChainState closedSnapshotNumber contestationDeadline =
-- Spec Gap: out of order & missing?
-- η ← combine(S⁻.𝑈)
-- ηω ← combine(outputs(S⁻.txω))
-- ξ ← S⁻.σ
newState HeadClosed{chainState = newChainState, contestationDeadline}
<> causes
( notifyClient
: [ OnChainEffect
{ postChainTx = ContestTx{headId, headParameters, confirmedSnapshot, version}
}
| doContest
]
)
<> cause notifyClient
<> ( -- Spec: if S⁻.s > sc
-- postTx (contest, S⁻.v, S⁻.s, η, ηω, ξ)
if doContest
then
cause
OnChainEffect
{ postChainTx = ContestTx{headId, headParameters, confirmedSnapshot, version}
}
else noop
)
where
doContest =
number (getSnapshot confirmedSnapshot) > closedSnapshotNumber
Expand Down Expand Up @@ -961,10 +969,16 @@ onClosedChainContestTx ::
UTCTime ->
Outcome tx
onClosedChainContestTx closedState newChainState snapshotNumber contestationDeadline =
-- Spec Gap: out of order & missing?
-- η ← combine(S⁻.𝑈)
-- ηω ← combine(outputs(S⁻.txω))
-- ξ ← S⁻.σ
newState HeadContested{chainState = newChainState, contestationDeadline}
<> if
| snapshotNumber < number (getSnapshot confirmedSnapshot) ->
| -- Spec: if S⁻.s > sc
snapshotNumber < number (getSnapshot confirmedSnapshot) ->
cause notifyClients
-- Spec: postTx (contest, S⁻.v, S⁻.s, η, ηω, ξ)
<> cause OnChainEffect{postChainTx = ContestTx{headId, headParameters, confirmedSnapshot, version}}
| snapshotNumber > number (getSnapshot confirmedSnapshot) ->
-- TODO: A more recent snapshot number was succesfully contested, we will
Expand Down

0 comments on commit 701563f

Please sign in to comment.