Skip to content

Commit

Permalink
Remove/demote TODO and XXXs
Browse files Browse the repository at this point in the history
  • Loading branch information
ch1bo committed Jul 23, 2024
1 parent 94ef180 commit 105ff76
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 30 deletions.
4 changes: 2 additions & 2 deletions hydra-node/src/Hydra/HeadLogic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ onOpenChainCloseTx openState newChainState closedSnapshotNumber contestationDead
if number (getSnapshot confirmedSnapshot) > closedSnapshotNumber
then
outcome
-- TODO: As we use 'version' in the contest here, this is implies
-- XXX: As we use 'version' in the contest here, this is implies
-- that our last 'confirmedSnapshot' must match version or
-- version-1. Assert this fact?
-- Spec: η ← combine(̅S.𝑈)
Expand Down Expand Up @@ -977,7 +977,7 @@ onClosedChainContestTx closedState newChainState snapshotNumber contestationDead
| -- Spec: if ̅S.s > sc
number (getSnapshot confirmedSnapshot) > snapshotNumber ->
cause notifyClients
-- TODO: As we use 'version' in the contest here, this is implies
-- XXX: As we use 'version' in the contest here, this is implies
-- that our last 'confirmedSnapshot' must match version or
-- version-1. Assert this fact?
-- Spec: η ← combine(̅S.𝑈)
Expand Down
1 change: 0 additions & 1 deletion hydra-node/test/Hydra/BehaviorSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,6 @@ spec = parallel $ do
waitUntil [n1, n2] $ DecommitApproved{headId = testHeadId, decommitTxId = txId decommitTx2, utxoToDecommit = utxoRefs [22]}
waitUntil [n1, n2] $ DecommitFinalized{headId = testHeadId, decommitTxId = txId decommitTx2}

-- TODO: Add it "can contest with decommit in flight"
it "can close with decommit in flight" $
shouldRunInSim $ do
withSimulatedChainAndNetwork $ \chain ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,6 @@ data CloseMutation
MutateContestationPeriod
deriving stock (Generic, Show, Enum, Bounded)

-- TODO: Add mutations which work "this way" around now. For example, before
-- we did mutate a close with signed snapshot to result in snapshot number 0,
-- which would trigger the validator. However, that would not be a faithful
-- representation of an "attack" anymore. Now, the tx creator needs to claim
-- what situation we are in now and how the snapshot signature is valid.
genCloseCurrentMutation :: (Tx, UTxO) -> Gen SomeMutation
genCloseCurrentMutation (tx, _utxo) =
oneof
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,6 @@ data CloseMutation
MutateContestationPeriod
deriving stock (Generic, Show, Enum, Bounded)

-- TODO: Add mutations which work "this way" around now. For example, before
-- we did mutate a close with signed snapshot to result in snapshot number 0,
-- which would trigger the validator. However, that would not be a faithful
-- representation of an "attack" anymore. Now, the tx creator needs to claim
-- what situation we are in now and how the snapshot signature is valid.
genCloseOutdatedMutation :: (Tx, UTxO) -> Gen SomeMutation
genCloseOutdatedMutation (tx, _utxo) =
oneof
Expand Down
32 changes: 15 additions & 17 deletions hydra-node/test/Hydra/Chain/Direct/TxTraceSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ instance StateModel Model where
snapshot <- genSnapshot
pure $ Some Decrement{actor, snapshot}
)
| -- XXX: We dont want to generate decrements if there is nothing in the head.
| -- We dont want to generate decrements if there is nothing in the head.
not (null utxoInHead)
]
Closed{} ->
Expand Down Expand Up @@ -389,9 +389,9 @@ instance StateModel Model where
Decrement{snapshot} ->
headState == Open
&& snapshot.version == currentVersion
-- XXX: you are decrementing from existing utxo in the head
-- you are decrementing from existing utxo in the head
&& all (`elem` Map.keys utxoInHead) (Map.keys (decommitUTxO snapshot) <> Map.keys (snapshotUTxO snapshot))
-- XXX: your tx is balanced with the utxo in the head
-- your tx is balanced with the utxo in the head
&& sum (decommitUTxO snapshot) + sum (snapshotUTxO snapshot) == sum utxoInHead
&& (not . null $ decommitUTxO snapshot)
Close{snapshot} ->
Expand All @@ -402,9 +402,9 @@ instance StateModel Model where
snapshot.number >= latestSnapshot
&& snapshot.version `elem` (currentVersion : [currentVersion - 1 | currentVersion > 0])
)
-- XXX: you are decrementing from existing utxo in the head
-- you are decrementing from existing utxo in the head
&& all (`elem` Map.keys utxoInHead) (Map.keys (decommitUTxO snapshot) <> Map.keys (snapshotUTxO snapshot))
-- XXX: your tx is balanced with the utxo in the head
-- your tx is balanced with the utxo in the head
&& sum (decommitUTxO snapshot) + sum (snapshotUTxO snapshot) == sum utxoInHead
where
Model{utxoInHead = initialUTxOInHead} = initialState
Expand All @@ -413,9 +413,9 @@ instance StateModel Model where
&& actor `notElem` alreadyContested
&& snapshot.version `elem` (currentVersion : [currentVersion - 1 | currentVersion > 0])
&& snapshot.number > latestSnapshot
-- XXX: you are decrementing from existing utxo in the head
-- you are decrementing from existing utxo in the head
&& all (`elem` Map.keys utxoInHead) (Map.keys (decommitUTxO snapshot) <> Map.keys (snapshotUTxO snapshot))
-- XXX: your tx is balanced with the utxo in the head
-- your tx is balanced with the utxo in the head
&& sum (decommitUTxO snapshot) + sum (snapshotUTxO snapshot) == sum utxoInHead
Fanout{utxo, deltaUTxO} ->
headState == Closed
Expand All @@ -433,35 +433,33 @@ instance StateModel Model where
Decrement{snapshot} ->
headState == Open
&& snapshot.version /= currentVersion
-- XXX: Ignore unbalanced decrements.
-- Ignore unbalanced decrements.
-- TODO: make them fail gracefully and test this?
&& sum (decommitUTxO snapshot) + sum (snapshotUTxO snapshot) == sum utxoInHead
-- XXX: Ignore decrements that work with non existing utxo in the head
-- Ignore decrements that work with non existing utxo in the head
&& all (`elem` Map.keys utxoInHead) (Map.keys (decommitUTxO snapshot) <> Map.keys (snapshotUTxO snapshot))
-- XXX: Ignore decrement without something to decommit
-- Ignore decrement without something to decommit
&& (not . null $ decommitUTxO snapshot)
Close{snapshot} ->
headState == Open
&& ( snapshot.number == 0
|| snapshot.version `elem` (currentVersion : [currentVersion - 1 | currentVersion > 0])
)
-- XXX: Ignore unbalanced close.
-- Ignore unbalanced close.
-- TODO: make them fail gracefully and test this?
&& sum (decommitUTxO snapshot) + sum (snapshotUTxO snapshot) == sum utxoInHead
-- XXX: Ignore close that work with non existing utxo in the head
-- Ignore close that work with non existing utxo in the head
&& all (`elem` Map.keys utxoInHead) (Map.keys (decommitUTxO snapshot) <> Map.keys (snapshotUTxO snapshot))
Contest{snapshot} ->
headState == Closed
-- XXX: Ignore unbalanced close.
-- Ignore unbalanced close.
-- TODO: make them fail gracefully and test this?
&& sum (decommitUTxO snapshot) + sum (snapshotUTxO snapshot) == sum utxoInHead
-- XXX: Ignore close that work with non existing utxo in the head
-- Ignore close that work with non existing utxo in the head
&& all (`elem` Map.keys utxoInHead) (Map.keys (decommitUTxO snapshot) <> Map.keys (snapshotUTxO snapshot))
Fanout{} ->
headState == Closed

-- XXX: Ignore fanouts which does not preserve the closing head

nextState :: Model -> Action Model a -> Var a -> Model
nextState m@Model{currentVersion} t _result =
case t of
Expand Down Expand Up @@ -774,7 +772,7 @@ newFanoutTx actor utxo deltaUTxO = do
spendableUTxO
Fixture.testSeedInput
(realWorldModelUTxO utxo)
-- XXX: Model world has no 'Maybe ModelUTxO', but real world does.
-- Model world has no 'Maybe ModelUTxO', but real world does.
(if null deltaUTxO then Nothing else Just $ realWorldModelUTxO deltaUTxO)
deadline
where
Expand Down

0 comments on commit 105ff76

Please sign in to comment.