Open koslambrou opened 1 month ago
Hi @koslambrou, thanks a lot for the reported issue and your PR fixing it. Our application code is also affected by this issue, specifically because we're still supporting some contracts using Plutus V1 with datum hash.
Besides this, we noticed that fromAlonzoTxOut
function in the same file is also setting TxOutDatumNone
as datum for all cases:
https://github.com/IntersectMBO/cardano-api/blob/cardano-api-9.2.0.0/cardano-api/internal/Cardano/Api/Tx/Body.hs#L2002-L2015
Would you please take a look and see if it's related to this issue? Thanks!
@infrmtcs This issue is not related to the PR you mentioned, it is a different problem.
Also, thanks for pointing out the fromAlonzoTxOut
function. I updated the PR to include a fix for this.
Internal/External Internal
Summary
Probable bug on
9.1
, andmain
.We are indexing the JSON representation of
TxOut
in a database. However, the encoding/decoding fails for someTxOut
that have inline datum inside it.After JSON encoding a
TxOut
encountered in Preprod, we get the following error after trying to decode it:Then, I inspected the CBOR representation of the inline datum before and after JSON serialization.
Before JSON serialization, for some
txOut
, doing:returned
"\216y\159\216y\159\SOH\161\216y\159\216y\159X\FS\SOH#Eg\137\SOH#Eg\137\SOH#Eg\137\SOH#Eg\137\SOH#Eg\137\SOH#E\255\216z\159\255\255\NUL\SOH\SOH\SOH\164\SOH\216y\159\SOH\SOH\255\STX\216y\159\STX\STX\255\ETX\216y\159\ETX\ETX\255\EOT\216y\159\EOT\EOT\255\255\255"
Then, doing:
returned
"\216y\159\216y\159\SOH\161\216y\159\216y\159X\FS\SOH#Eg\137\SOH#Eg\137\SOH#Eg\137\SOH#Eg\137\SOH#Eg\137\SOH#E\255\216z\128\255\NUL\SOH\SOH\SOH\164\SOH\216y\159\SOH\SOH\255\STX\216y\159\STX\STX\255\ETX\216y\159\ETX\ETX\255\EOT\216y\159\EOT\EOT\255\255\255"
In short, the returned CBOR representations are different. Seems like we lose information when serializing to JSON.