Closed JaredCorduan closed 2 years ago
more details about how to fix this:
The function encodeLangViews
is the problem.
There are two problems:
Ord
instance order is unlikely to agree with the required order (this needs to be fixed before plutus V2 is released)The right thing to do is
encodePreEncoded
to encode all of the keys and values encodeMapLen LEN
token getLanguageView
result for PlutusV1
to preserve the previous incorrect behaviorthe actual encoding for plutus V1 is now described here: https://github.com/input-output-hk/cardano-ledger/blob/7155301bcddc9cc2efe9cd98ad9c2521e9a0d085/eras/alonzo/test-suite/cddl-files/alonzo.cddl#L111-L115
The intention was for all the CBOR in the
LangDepView
to be canonical CBOR. TheCostModel
, however, is using an indefinite length list encoding: https://github.com/input-output-hk/cardano-ledger-specs/blob/3ff2b08c7e094a3b9035fafb170e0e1da9b75401/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Scripts.hs#L172-L175The tests here:
https://github.com/input-output-hk/cardano-ledger-specs/blob/3ff2b08c7e094a3b9035fafb170e0e1da9b75401/eras/alonzo/test-suite/test/Test/Cardano/Ledger/Alonzo/Serialisation/Canonical.hs#L36-L43
failed to catch this bug since we have a cbor-in-cbor encoding.
We need to now: