From 253ed967e806ebca9e449ee6fb79c7597da2e08a Mon Sep 17 00:00:00 2001 From: Sasha Bogicevic Date: Tue, 30 Apr 2024 16:56:18 +0200 Subject: [PATCH] Combine blueprint and commit tx metadata --- hydra-node/src/Hydra/Chain/Direct/Tx.hs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/hydra-node/src/Hydra/Chain/Direct/Tx.hs b/hydra-node/src/Hydra/Chain/Direct/Tx.hs index 99dd9a66493..6b5850c423a 100644 --- a/hydra-node/src/Hydra/Chain/Direct/Tx.hs +++ b/hydra-node/src/Hydra/Chain/Direct/Tx.hs @@ -33,7 +33,7 @@ import Cardano.Ledger.Api ( unRedeemers, witsTxL, ) -import Cardano.Ledger.BaseTypes (StrictMaybe (..)) +import Cardano.Ledger.BaseTypes (StrictMaybe (..), fromSMaybe) import Control.Lens ((.~), (<>~), (^.)) import Data.Aeson qualified as Aeson import Data.ByteString qualified as BS @@ -255,7 +255,7 @@ commitTx networkId scriptRegistry headId party commitBlueprintTx (initialInput, & bodyTxL . referenceInputsTxBodyL <>~ Set.fromList [toLedgerTxIn initialScriptRef] & bodyTxL . outputsTxBodyL .~ StrictSeq.singleton (toLedgerTxOut commitOutput) & bodyTxL . reqSignerHashesTxBodyL <>~ Set.singleton (toLedgerKeyHash vkh) - & bodyTxL . auxDataHashTxBodyL .~ SJust (hashAlonzoTxAuxData txAuxMetadata) + & bodyTxL . auxDataHashTxBodyL .~ combinedMetadata & bodyTxL . mintTxBodyL .~ mempty & auxDataTxL .~ addMetadata txAuxMetadata existingWits = toLedgerTx blueprintTx ^. witsTxL @@ -338,6 +338,12 @@ commitTx networkId scriptRegistry headId party commitBlueprintTx (initialInput, TxMetadata commitMetadataMap = commitMetadata txAuxMetadata = mkAlonzoTxAuxData @[] @LedgerEra (toShelleyMetadata commitMetadataMap) [] + + combinedMetadata = + let existingMetadataMap = fromSMaybe mempty $ getAuxMetadata <$> toLedgerTx blueprintTx ^. auxDataTxL + in SJust . hashAlonzoTxAuxData $ + mkAlonzoTxAuxData @[] @LedgerEra (Map.union (toShelleyMetadata commitMetadataMap) existingMetadataMap) [] + CommitBlueprintTx{lookupUTxO, blueprintTx} = commitBlueprintTx commitMetadata :: TxMetadata