Skip to content

Commit

Permalink
Resolve a fixme in head logic
Browse files Browse the repository at this point in the history
Also fix the compilation after splitting the decommit branch.
  • Loading branch information
v0d1ch committed May 9, 2024
1 parent d3182b7 commit a825d81
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
15 changes: 4 additions & 11 deletions hydra-node/src/Hydra/HeadLogic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import Data.Set ((\\))
import Data.Set qualified as Set
import GHC.Records (getField)
import Hydra.API.ClientInput (ClientInput (..))
import Hydra.API.HTTPServer (DraftCommitTxRequest (utxoToCommit))
import Hydra.API.ServerOutput qualified as ServerOutput
import Hydra.Chain (
ChainEvent (..),
Expand Down Expand Up @@ -89,9 +88,7 @@ import Hydra.Ledger (
Ledger (..),
TxIdType,
UTxOType,
ValidationResult (..),
applyTransactions,
canApply,
txId,
utxoFromTx,
withoutUTxO,
Expand Down Expand Up @@ -457,16 +454,12 @@ onOpenNetworkReqSn env ledger st otherParty sn requestedTxIds mDecommitTx =
case mDecommitTx of
Nothing -> cont (confirmedUTxO, Nothing)
Just decommitTx ->
-- FIXME: Why don't we apply the decommitTx to the confirmed UTxO? Right
-- now the inputs would still remain on the L2 state and actually don't
-- get removed by 'withoutUTxO' below, because the utxoToCommit are not
-- in confirmedUTxO (but the inputs of the decommitTx would be).
case canApply ledger currentSlot confirmedUTxO decommitTx of
Invalid err ->
case applyTransactions ledger currentSlot confirmedUTxO [decommitTx] of
Left (_, err) ->
Error $ RequireFailed $ DecommitDoesNotApply decommitTx err
Valid -> do
Right newConfirmedUTxO -> do
let utxoToDecommit = utxoFromTx decommitTx
let activeUTxO = confirmedUTxO `withoutUTxO` utxoToDecommit
let activeUTxO = newConfirmedUTxO `withoutUTxO` utxoToDecommit
cont (activeUTxO, Just utxoToDecommit)

-- NOTE: at this point we know those transactions apply on the localUTxO because they
Expand Down
2 changes: 1 addition & 1 deletion hydra-node/test/Hydra/Chain/Direct/StateSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ import Hydra.Chain.Direct.State (
unsafeObserveInitAndCommits,
)
import Hydra.Chain.Direct.State qualified as Transition
import Hydra.Chain.Direct.Tx (AbortObservation (..), CloseObservation (..), ClosedThreadOutput (closedContesters), CollectComObservation (..), CommitObservation (..), ContestObservation (..), DecrementObservation (..), FanoutObservation (..), HeadObservation (..), IncrementObservation (..), NotAnInitReason (..), observeCommitTx, observeHeadTx, observeInitTx)
import Hydra.Chain.Direct.Tx (AbortObservation (..), CloseObservation (..), ClosedThreadOutput (closedContesters), CollectComObservation (..), CommitObservation (..), ContestObservation (..), DecrementObservation (..), FanoutObservation (..), HeadObservation (..), NotAnInitReason (..), observeCommitTx, observeHeadTx, observeInitTx)
import Hydra.ContestationPeriod (toNominalDiffTime)
import Hydra.Contract.HeadTokens qualified as HeadTokens
import Hydra.Contract.Initial qualified as Initial
Expand Down

0 comments on commit a825d81

Please sign in to comment.