-
Notifications
You must be signed in to change notification settings - Fork 160
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
dag-cbor,dag-json: relax strictness rules for decoders #214
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.
I'm happy about having this as a must
on encode and should
on decode.
8a6ce41
to
c8c08e1
Compare
so I was just writing a response to this and getting references to existing code when I noticed that I actually do some decode strictness in JS for dag-cbor:
When I wrote the new codec stack for dag-cbor I started building in a decode strictness option but only did the easiest bits, with the hopes of getting to the rest later (I still hope to); and I enabled that strictness all the way up to the So the non-strict pieces for the JS codec is:
Floating point values are rarely used and we recommend against them; but map key ordering is something we can't afford to break, cbor-gen does it wrong, the Filecoin genesis block has it wrong, 🤷. So I've pushed another commit that adjusts things somewhat. The decode strictness section now starts with:
And I've also added cbor-gen to the implementations list while I'm in there, which lead me to add a recommendation for what to use for both JS and Go.. I'm not comfortable recommending cbor-gen while whyrusleeping/cbor-gen#56 remains unmerged. |
@@ -68,12 +68,12 @@ Therefore the DAG-CBOR codec must: | |||
|
|||
### Decode strictness | |||
|
|||
DAG-CBOR decoders should not enforce all of the above strictness requirements by default, but may provide an opt-in for systems where round-trip determinism is a desireable feature and backward compatibility with old, non-strict data is unnecessary. | |||
Due to the existence and active use of historical data, and the existence and active use of non-conforming encoders, DAG-CBOR decoders may relax strictness requirements by default. A strictness opt-in may be offered for systems where round-trip determinism is a desirable feature and backward compatibility with old, non-strict data is unnecessary. |
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 like this wording even more! I was close commenting that I would prefer a "may" over a "should", but then didn't want to block this PR.
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.
LGTM. The wording and explanation is clear and concise.
Fixes: #196 Current text reflects an idealistic perspective, not a pragmatic one that accounts for historical data and handling data from encoders that don't quite follow the rules. Nor do the current statements requiring strictness reflect the reality of our current decoders, which are lose and don't even yet have full opt-in strictness modes; even though we note the lack of strictness in the implementation notes.
c8c08e1
to
34d125e
Compare
Fixes: #196
Current text reflects an idealistic perspective, not a pragmatic one that
accounts for historical data and handling data from encoders that don't quite
follow the rules. Nor do the current statements requiring strictness reflect
the reality of our current decoders, which are lose and don't even yet have
full opt-in strictness modes; even though we note the lack of strictness in
the implementation notes.