You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In conway.cddl, there are many types which are maps.
As per CDDL spec, maps are allowed to have duplicate keys.
But the node doesn't allow duplicate keys in some places, and allows in some other places.
For example, the multiasset type is defined as a map:
It would be helpful for library/tools authors to have comments in the CDDL file around map types, describing whether duplicate keys are allowed or not.
The text was updated successfully, but these errors were encountered:
Duplicate keys are not allowed in any of the maps in cbor, simply because the mapping must be unique from keys to values. The difference is in some cases we fail hard on duplicates while in others we discard the duplicate mapping from the map. It is a bit unfortunate, but it has to do with the limitation of current implementation of serialization that we have (See #4009). Although we do have strong plans on fixing it throughout all of the ledger types.
As far as the tooling is concerned, IMHO it should not allow duplicate keys, because that is the ultimate goal. That being said, I am totally for documenting this discrepancy for every map/set occurrence in the cddl
@lehins, could you also provide documentation on how map duplicates are handled in each case? Additionally, could you explain how the discard logic will work? Will it retain the first or the last value, and will it be sorted, etc.?
In
conway.cddl
, there are many types which are maps.As per CDDL spec, maps are allowed to have duplicate keys.
But the node doesn't allow duplicate keys in some places, and allows in some other places.
For example, the multiasset type is defined as a map:
cardano-ledger/eras/conway/impl/cddl-files/conway.cddl
Line 564 in 28ab388
The mint type, which is an instance of multiasset, can have duplicate keys.
cardano-ledger/eras/conway/impl/cddl-files/conway.cddl
Line 576 in 28ab388
But the multiasset field of the value type can't have.
cardano-ledger/eras/conway/impl/cddl-files/conway.cddl
Line 574 in 28ab388
It would be helpful for library/tools authors to have comments in the CDDL file around map types, describing whether duplicate keys are allowed or not.
The text was updated successfully, but these errors were encountered: