fixed hash_script_data function #209
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I was finally able to reproduce the same script data hash in the serialization-lib as in the cardano-cli.
language_viewsis actually not the same ascostmdlsand the encoding is totally different. I was able to extract the encoded language_views from the cardano-node and then concatenated redemeers + datums + language_views, hashed it and received the correct hash.Since I don't know exactly how to create the languague_views encoding, I created a struct LanguageViews, which takes the raw bytes, that fixes at least the hash_script_data function. Maybe someone could help here to build this encoding fully in Rust.
This is the language_views encoding based on current mainnet protocol parameters:
Links that could help with building this encoding:
https://github.com/input-output-hk/cardano-ledger-specs/blob/d37757e273d10fb251681faa1a2a0cc1ac018384/alonzo/test/test/Test/Cardano/Ledger/Alonzo/Serialisation/Canonical.hs#L36-L43
https://github.com/input-output-hk/cardano-ledger-specs/blob/37322df14d44d1370e8a72b677815d64a92baa00/alonzo/impl/src/Cardano/Ledger/Alonzo/Tx.hs#L268-L276
https://github.com/input-output-hk/cardano-ledger-specs/blob/37322df14d44d1370e8a72b677815d64a92baa00/alonzo/impl/src/Cardano/Ledger/Alonzo/PParams.hs#L511-L525
https://github.com/input-output-hk/cardano-ledger-specs/blob/ec51e4fb1b17461ab612cf427b79f1742942e8cb/alonzo/impl/src/Cardano/Ledger/Alonzo/Scripts.hs#L172-L175