Skip to content

Commit

Permalink
Revert signable rep for Snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
v0d1ch committed Jan 23, 2024
1 parent c532d02 commit 23ff08a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
8 changes: 3 additions & 5 deletions hydra-node/src/Hydra/HeadLogic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -846,11 +846,9 @@ update env ledger st ev = case (st, ev) of
onOpenNetworkReqDec env openState transaction
(Open openState@OpenState{headId, coordinatedHeadState, currentSlot}, ClientEvent Decommit{decommitTx}) -> do
requireNoDecommitInFlight openState $
-- TODO: Spec: require U̅ ◦ decTx /= ⊥
requireValidDecommitTx $ \utxoToDecommit ->
requireValidDecommitTx $
Effects
[ ClientEffect ServerOutput.DecommitRequestReceived{headId, utxoToDecommit}
, NetworkEffect ReqDec{transaction = decommitTx}
[ NetworkEffect ReqDec{transaction = decommitTx}
]
where
-- TODO: Spec: require U̅ ◦ decTx /= ⊥
Expand All @@ -869,7 +867,7 @@ update env ledger st ev = case (st, ev) of
}
}
]
Right _ -> cont $ utxoFromTx decommitTx
Right _ -> cont

confirmedUTxO = (getSnapshot confirmedSnapshot).utxo

Expand Down
5 changes: 2 additions & 3 deletions hydra-node/src/Hydra/Snapshot.hs
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,8 @@ instance forall tx. IsTx tx => SignableRepresentation (Snapshot tx) where
LBS.toStrict $
serialise (toData $ toBuiltin $ serialiseToRawBytes headId)
<> serialise (toData $ toBuiltin $ toInteger number) -- CBOR(I(integer))
-- TODO: In the spec we have added new field but here we sign the diff
-- between two utxos.
<> serialise (toData $ toBuiltin $ hashUTxO @tx (utxo `withoutUTxO` maybe mempty id utxoToDecommit)) -- CBOR(B(bytestring)
<> serialise (toData $ toBuiltin $ hashUTxO @tx utxo) -- CBOR(B(bytestring)
<> maybe mempty (serialise . (toData . toBuiltin . hashUTxO @tx)) utxoToDecommit -- CBOR(B(bytestring)

instance (Typeable tx, ToCBOR (UTxOType tx), ToCBOR (TxIdType tx)) => ToCBOR (Snapshot tx) where
toCBOR Snapshot{headId, number, utxo, confirmed, utxoToDecommit} =
Expand Down
5 changes: 4 additions & 1 deletion hydra-node/test/Hydra/Chain/Direct/ContractSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,14 @@ prop_verifyOffChainSignatures =
onChainSig = List.head . toPlutusSignatures $ aggregate [offChainSig]
onChainParty = partyToChain $ deriveParty sk
snapshotNumber = toInteger number
utxoHash = toBuiltin $ hashUTxO @SimpleTx (utxo `withoutUTxO` maybe mempty id utxoToDecommit)
utxoHash =
(toBuiltin $ hashUTxO @SimpleTx utxo)
<> maybe mempty ((toBuiltin . hashUTxO @SimpleTx)) utxoToDecommit
in verifyPartySignature (headIdToCurrencySymbol headId) snapshotNumber utxoHash onChainParty onChainSig
& counterexample ("headId: " <> show headId)
& counterexample ("signed: " <> show onChainSig)
& counterexample ("party: " <> show onChainParty)
& counterexample ("utxoHash: " <> show utxoHash)
& counterexample ("message: " <> show (getSignableRepresentation snapshot))

prop_verifySnapshotSignatures :: Property
Expand Down

0 comments on commit 23ff08a

Please sign in to comment.