-
Notifications
You must be signed in to change notification settings - Fork 63
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
fix(core): plutus list now encodes to canonical CBOR #1319
fix(core): plutus list now encodes to canonical CBOR #1319
Conversation
|
Note: this PR is wrong @AngelCastilloB @mkazlauskas @iccicci. The situation is a bit more subtle. Plutus encodes lists as indefinite lists EXCEPT empty lists. Empty lists are encoded as finite empty lists for a reason beyond human understanding.
(edit: nevermind that last bit, only the cardano-ledger does that, not Plutus). |
Hello @KtorZ thanks for the clarification, BTW where is all this specified 😅 ? I cant find any of this in the CDDL files. I will make the changes to the serialization classes for lists and maps. |
I know.. It's Haskell code. But that's the ground truth. Which now makes me realize: disregard my comment about maps, only the ledger does that. Plutus seems more reasonable here and only use definite maps. Though now it creates two different serialisation behaviors. Nice. And for the list part, you need to dig as far as the default implementation of |
I did reference Data.hs when writing our serializers, but I didn't dig deep enough it seems:
Its kind of random to be honest, anyways, I will make the change to the List. Thanks for the heads up! |
Completely. I suppose it's for saving one byte. Talk about premature optimization heh. It's really beyond me that a base library providing default serializer would not enforce a canonical encoding. And I can't also blame the Plutus team for not necessarily noticing. |
Context
PlutusList is not encoding following canonical CBOR (uses indefinite length array rather than the definite length form). see #1318
Proposed Solution
PlutusList should encode by default using definite length CBOR arrays.