Skip to content

Commit f5f1be1

Browse files
kdermeerikd
authored andcommitted
Use Original bytes instead of reserialising
Closes: IntersectMBO#1214
1 parent 3310afc commit f5f1be1

File tree

1 file changed

+2
-10
lines changed
  • cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Generic/Tx

1 file changed

+2
-10
lines changed

cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Generic/Tx/Alonzo.hs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -287,12 +287,7 @@ mkTxScript (hsh, script) =
287287
plutusCborScript =
288288
case script of
289289
Alonzo.TimelockScript {} -> Nothing
290-
-- The serialization in cardano-api ignores the script version tag,
291-
-- but we handle both cases properly for posterity.
292-
Alonzo.PlutusScript Alonzo.PlutusV1 s ->
293-
Just . Api.serialiseToCBOR . Api.PlutusScript Api.PlutusScriptV1 $ Api.PlutusScriptSerialised s
294-
Alonzo.PlutusScript Alonzo.PlutusV2 s ->
295-
Just . Api.serialiseToCBOR . Api.PlutusScript Api.PlutusScriptV2 $ Api.PlutusScriptSerialised s
290+
plutusScript -> Just $ Ledger.originalBytes plutusScript
296291

297292
getPlutusSizes ::
298293
( HasField "wits" tx (Alonzo.TxWitness era)
@@ -315,7 +310,7 @@ txDataWitness tx =
315310
mkTxData <$> Map.toList (Alonzo.unTxDats $ Alonzo.txdats' (getField @"wits" tx))
316311

317312
mkTxData :: (Ledger.DataHash StandardCrypto, Alonzo.Data era) -> PlutusData
318-
mkTxData (dataHash, dt) = PlutusData (dataHashToBytes dataHash) (jsonData dt) (cborData dt)
313+
mkTxData (dataHash, dt) = PlutusData (dataHashToBytes dataHash) (jsonData dt) (Ledger.originalBytes dt)
319314
where
320315
jsonData :: Alonzo.Data era -> ByteString
321316
jsonData =
@@ -324,9 +319,6 @@ mkTxData (dataHash, dt) = PlutusData (dataHashToBytes dataHash) (jsonData dt) (c
324319
. Api.scriptDataToJson Api.ScriptDataJsonDetailedSchema
325320
. Api.fromAlonzoData
326321

327-
cborData :: Alonzo.Data era -> ByteString
328-
cborData = Api.serialiseToCBOR . Api.fromAlonzoData
329-
330322
extraKeyWits :: HasField "reqSignerHashes" (Ledger.TxBody era) (Set (Ledger.KeyHash d c))
331323
=> Ledger.TxBody era -> [ByteString]
332324
extraKeyWits txBody = Set.toList $

0 commit comments

Comments
 (0)