-
Notifications
You must be signed in to change notification settings - Fork 318
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
CIP-0068 | Allow [* bounded_bytes] for images #809
CIP-0068 | Allow [* bounded_bytes] for images #809
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a pretty straight forward and simple change to the standard. Given that it was always/already possible to pass an array value for a URI in CIP-25 I assume that implementers of CIP-68 have been implicitly supporting this functionality even though it was not explicitly defined in the CDDL.
As this is a breaking change to the standard, please make sure to mark it as a new version (or a different CIP). |
@@ -191,7 +191,7 @@ metadata = | |||
; A valid Uniform Resource Identifier (URI) as a UTF-8 encoded bytestring. | |||
; The URI scheme must be one of `https` (HTTP), `ipfs` (IPFS), `ar` (Arweave) or `data` (on-chain). | |||
; Data URLs (on-chain data) must comply to RFC2397. | |||
uri = bounded_bytes ; UTF-8 | |||
uri = bounded_bytes / [ * bounded_bytes ] ; UTF-8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use bytes(*)
instead of array(*)
in the first place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To add to @mmahut question:
Lucid does encode long strings as bytes(*) (using Data.to(new Constr(0, [Data.fromJson(metadata)...
).
// excerpt from cbor.me of an image uri encoded as bytes(*) 5F tag
5F # bytes(*)
58 40 # bytes(64)
697066733A2F2F516D5543584D546376754A7077484633674142527236396365515232754547324673696B3943795768384D556F51766572796C6F6E67757269 # "ipfs://QmUCXMTcvuJpwHF3gABRr69ceQR2uEG2Fsik9CyWh8MUoQverylonguri"
58 19 # bytes(25)
646566696E6974656C796D6F72657468616E36346279746573 # "definitelymorethan64bytes"
FF # primitive(*)
Does the change proposed in this PR mean that array(*) should be use instead?
// excerpt from cbor.me of an image uri encoded as array(*) 9F tag
9F # array(*)
58 40 # bytes(64)
68747470733A2F2F6173736574317870743436647A336E39377979336C3937633035666A6C73727976357267677274306E6361372E6170652E6E667463646E2E # "https://asset1xpt46dz3n97yy3l97c05fjlsryv5rggrt0nca7.ape.nftcdn."
58 40 # bytes(64)
696F2F696D6167653F73697A653D32353626746B3D506E307935746651766165654C6A4277764C646A506158684A322D445F735352664E4A6856386854336C6F # "io/image?size=256&tk=Pn0y5tfQvaeeLjBwvLdjPaXhJ2-D_sSRfNJhV8hT3lo"
FF # primitive(*)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both bytes() and array() should be fine. In both instances it splits the values up into 64 byte chunks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few people including myself assumed this was already part of the standard since it works for CIP-25 as well and many dapps already support the array format
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not good at reading CDDL, does [ * bounded_bytes ]
allows for both indefinite byte string (5F) and indefinite array (9F) tags?
Since ref implementation is using lucid, which implements this using indefinite byte string (5F), shouldn't that be the preffered way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CDDL does not really have a concept of a "chunked, indefinite length string".
Essentially the expected behavior for a decoder would be to convert from an array into a concatenated string whether an indefinite byte string or an array of max-length 64 byte strings...
As Nick mentioned, this is how it has "always worked" since the early days of CIP-25 and my presumption is that most decoders are already accounting for this possible scenario. Adding it as an option to the spec I don't think warrants a version bump as I'm fairly confident we could find multiple instances of this already being used and supported even though not officially documented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CDDL does not really have a concept of a "chunked, indefinite length string".
Ah, interesting and rather disappointing. Thanks for the insight.
Essentially the expected behavior for a decoder would be to convert from an array into a concatenated string whether an indefinite byte string or an array of max-length 64 byte strings...
As Nick mentioned, this is how it has "always worked" since the early days of CIP-25 and my presumption is that most decoders are already accounting for this possible scenario. Adding it as an option to the spec I don't think warrants a version bump as I'm fairly confident we could find multiple instances of this already being used and supported even though not officially documented.
What about other fields such as src
and description
. I would assume the same presumption applies?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fairly confident we could find multiple instances of this already being used and supported even though not officially documented (...)
The fact that various instance of this has been implemented doesn't mean we can break the standard.
The standard says the URI is of bounded_bytes
and changing that breaks the standard.
For example, why Nick opened this PR in the first place is that Blockfrost honors this CIP (while other explorers do not). We are okay to implement this as CIP68v3.
Also modify Line # 436 to match the proposed new format for URI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I echo the concerns of @mmahut
This could break existing tooling, this change should be included in a version/CIP
I feel strongly we (@Crypto2099 @rphair) have to be strict with this.
Even if some tools may have been supporting this, that does not guarantee that all tools do.
So introducing a change like this (without version bump), would likely break some implementations.
I agree the version bump would be essential. I've put this issue up for discussion at end of our next meeting (a week from today: https://hackmd.io/@cip-editors/88) so hopefully can poll some more implementors about what they've been doing & how they would respond to a version bump. |
Bumping the version for this makes sense to me I'm fine with that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes to version number have been made. Seems an otherwise straightforward modification to the standard.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me after latest commits assigning the proposed changes to a Version 3. cc @mmahut
Shouldn't the same change also be made to |
Note that SpaceBudz v2, one of the very first CIP-68 projects (with Matrix Berry) from CIP-68 co-author was already using See for example
It's therefore very likely that most tools parsing CIP68 tokens already support at least Also changing the version to support |
Correct me if I'm wrong, but I think bytes() a array() are two different concepts. |
@SmaugPool this is correct. Definition of |
Indeed, and as My understanding of |
I think this is not necessarily explicit because a lot of this is wrapped up in this comment block from the Ledger spec mentioned by Ales:
It may be beneficial to these standards to specify any/all points that are currently defined as
Or, if the intent is to clarify the existing standard to explain/show that these user-generated arrays are not necessary or beneficial, perhaps we should simply change the definitions to be: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Version has been incremented, good to see this merged.
Keeping in mind @Crypto2099 #809 (comment) about clarifications in the future, my understanding of the above is that the version bump resolves any potential difficulties & this mainly hasn't been merged due to time running out at CIP meetings. |
I don't think the merged change makes any clearer that I find this change and version bump confusing overall. |
In the Cardano node, Plutus Data bytes are limited to 64 bytes. There is an issue where IPFS V2 uris are 66 bytes so they require the use of an NFT.
This is already the case for CIP-25 NFTs so it should also be the case for CIP-68.
This pr adds: / [ * bounded_bytes ] to the uri pattern.