Skip to content

Commit d514f50

Browse files
committed
Updated spec and align some details
1 parent 0fd1052 commit d514f50

File tree

6 files changed

+18
-18
lines changed

6 files changed

+18
-18
lines changed

flake.lock

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
flake-parts.url = "github:hercules-ci/flake-parts";
1010
haskellNix.url = "github:input-output-hk/haskell.nix";
1111
hydra-coding-standards.url = "github:cardano-scaling/hydra-coding-standards/0.6.0";
12-
hydra-spec.url = "github:cardano-scaling/hydra-formal-specification";
12+
# TODO: update to master
13+
hydra-spec.url = "github:cardano-scaling/hydra-formal-specification/deposit-protocol-changes";
1314
iohk-nix.url = "github:input-output-hk/iohk-nix";
1415
lint-utils = {
1516
url = "github:homotopic/lint-utils";

hydra-node/src/Hydra/Chain/Direct/Handlers.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ import Hydra.Tx (
7070
HeadParameters (..),
7171
UTxOType,
7272
headSeedToTxIn,
73-
txInToHeadSeed,
7473
)
7574
import Hydra.Tx.ContestationPeriod (toNominalDiffTime)
7675
import Hydra.Tx.Deposit (DepositObservation (..), depositTx)
@@ -179,7 +178,7 @@ mkChain tracer queryTimeHandle wallet ctx LocalChainState{getLatest} submitTx =
179178
validBefore <- case currentPointInTime timeHandle of
180179
-- XXX: We only need the current slot and this would never fail
181180
Left failureReason -> throwError FailedToConstructDepositTx{failureReason}
182-
Right (s, _) -> pure $ s + 200 -- XXX: configurable and unify with maxGraceTime
181+
Right (s, _) -> pure $ s + fromInteger (truncate maxGraceTime)
183182
lift . finalizeTx wallet ctx spendableUTxO lookupUTxO $
184183
depositTx (networkId ctx) headId commitBlueprintTx validBefore deadline
185184
, -- Submit a cardano transaction to the cardano-node using the

hydra-node/src/Hydra/Chain/Direct/State.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ import Hydra.Tx (
9191
mkSimpleBlueprintTx,
9292
partyToChain,
9393
registryUTxO,
94-
txInToHeadSeed,
9594
utxoFromTx,
9695
)
9796
import Hydra.Tx.Abort (AbortTxError (..), abortTx)
@@ -798,7 +797,7 @@ observeInit _ctx _allVerificationKeys tx = do
798797

799798
-- | Observe an commit transition using a 'InitialState' and 'observeCommitTx'.
800799
-- NOTE: This function is a bit fragile as it assumes commit output on first
801-
-- output whilte the underlying observeCommitTx could deal with commit outputs
800+
-- output while the underlying observeCommitTx could deal with commit outputs
802801
-- at any index. Only use this function in tests and benchmarks.
803802
observeCommit ::
804803
ChainContext ->

hydra-node/src/Hydra/HeadLogic.hs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -403,15 +403,17 @@ onOpenNetworkReqSn ::
403403
Maybe (TxIdType tx) ->
404404
Outcome tx
405405
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
407407
requireReqSn $
408408
-- Spec: wait ŝ = ̅S.s
409409
waitNoSnapshotInFlight $
410+
-- TODO: is this really needed?
410411
-- Spec: wait v = v̂
411412
waitOnSnapshotVersion $
412-
-- Spec: require tx𝜔 = ⊥ ∨ 𝑈𝛼 = ∅
413+
-- TODO: this is missing!? Spec: require tx𝜔 = ⊥ ∨ tx𝛼 = ⊥
414+
-- Require any pending utxo to decommit to be consistent
413415
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
415417
waitForDeposit activeUTxOAfterDecommit $ \(activeUTxO, mUtxoToCommit) ->
416418
-- Resolve transactions by-id
417419
waitResolvableTxs $ \requestedTxs -> do
@@ -487,14 +489,11 @@ onOpenNetworkReqSn env ledger st otherParty sv sn requestedTxIds mDecommitTx mDe
487489
case mDepositTxId of
488490
Nothing -> cont (activeUTxOAfterDecommit, Nothing)
489491
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
490494
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}
494496
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
498497
| status == Inactive -> wait WaitOnDepositActivation{depositTxId}
499498
| status == Expired -> Error $ RequireFailed RequestedDepositExpired{depositTxId}
500499
| otherwise ->
@@ -503,7 +502,7 @@ onOpenNetworkReqSn env ledger st otherParty sv sn requestedTxIds mDecommitTx mDe
503502
if sv == confVersion && isJust confUTxOToCommit
504503
then
505504
if confUTxOToCommit == Just deposited
506-
then cont (activeUTxOAfterDecommit <> fromMaybe mempty confUTxOToCommit, confUTxOToCommit)
505+
then cont (activeUTxOAfterDecommit <> deposited, confUTxOToCommit)
507506
else Error $ RequireFailed ReqSnCommitNotSettled
508507
else do
509508
let activeUTxOAfterCommit = activeUTxOAfterDecommit <> deposited

hydra-node/src/Hydra/HeadLogic/Outcome.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ data WaitReason tx
233233
| WaitOnNotApplicableDecommitTx {notApplicableReason :: DecommitInvalidReason tx}
234234
| WaitOnUnresolvedCommit {commitUTxO :: UTxOType tx}
235235
| WaitOnUnresolvedDecommit {decommitTx :: tx}
236+
| WaitOnDepositObserved {depositTxId :: TxIdType tx}
236237
| WaitOnDepositActivation {depositTxId :: TxIdType tx}
237238
deriving stock (Generic)
238239

0 commit comments

Comments
 (0)