-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Datum round-trip corrupts datum bytes #1214
Comments
Thank you for reporting. It seems reasonable to use the memoized bytes instead of redoing the serialisation both in terms of hash correctness and performance. |
@kderme yes indeed. The principle that the ledger follows is to remember the original bytes and to never re-serialise, and db-sync should do the same. |
Datum test failed when run on
|
I believe this has been fixed and the observed issue is actually in CLI IntersectMBO/cardano-node#4433. Feel free to reopen if not |
Just to clarify for posterity, the ledger does not re-serialize any user-submitted data! |
Re-serialization error caused some of these to not match the original bytes. This is fixed in `cardano-db-sync >= 13.0.5`, see also IntersectMBO/cardano-db-sync#1214
Re-serialization error caused some of these to not match the original bytes. This is fixed in `cardano-db-sync >= 13.0.5`, see also IntersectMBO/cardano-db-sync#1214
Problem Report
The cardano-ledger code provides no guarantees about round-tripping the serialization; For example, if a datum uses fixed-length arrays in it's CBOR encoding, the cardano-ledger will re-serialize it with indefinite-length arrays.
WIth cardano-db-sync, this manifests as storing the wrong bytes for a datum. For example, consider this datum:
https://testnet.cexplorer.io/datum/06269f665176dc65b334d685b2f64826c092875ca77e15007b5f690ecc9db1af
(cexplorer.io is powered by cardano-db-sync)
If you grab the bytes seen at the bottom of the page, they will not hash to
06269...
as expected. It turns out, this is because the bytes on the wire are different:This can cause issues with down-stream applications that depend on this data, such as making the UTXO un-spendable, since the app has the incorrect datum as a witness.
We originally encountered this with Ogmios, and the lovely @KtorZ helped me figure out what was going on, and fixed it in Ogmios. For an example of this fix, and/or a more detailed writeup, see:
CardanoSolutions/ogmios@3f614c3
I also opened a ticket for discussion with the Ledger team on this, seen here:
IntersectMBO/cardano-ledger#2943
The text was updated successfully, but these errors were encountered: