Skip to content
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

Specify requirements for Valid and Deterministic Encodings #57

Merged
merged 14 commits into from
Feb 16, 2023

Conversation

fxamacker
Copy link
Owner

@fxamacker fxamacker commented Feb 13, 2023

Add Serialization Considerations section and specify

  • Valid CCF Encoding Requirements
  • Deterministic CCF Encoding Requirements

Replace "ABRIDGED DRAFT" with "DRAFT" in Status of this Document section.

These requirements are necessary and have an impact on CCF codec speed and memory use.

Prior formats (JSON-Cadence Data Interchange and CBF) didn't specify requirements for validity or deterministic encoding. Updated benchmark comparisons (coming soon) should be viewed with this in mind. For example, sorting (as part of deterministic encoding) isn't free.

Add Serialization Considerations section and specify
- Valid CCF Encoding Requirements
- Deterministic CCF Encoding Requirements

These requirements are necessary and have an impact on CCF codec speed and memory use.

Prior formats didn't specify requirements for validity or deterministic encoding.  Updated benchmark comparisons (coming soon) should be viewed with this in mind.   For example, sorting (as part of deterministic encoding) isn't free.
@fxamacker fxamacker added the enhancement New feature or request label Feb 13, 2023
@fxamacker fxamacker self-assigned this Feb 13, 2023
Copy link
Collaborator

@turbolent turbolent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! This is very clear and makes sense 👍

Only got some questions regarding the "inferred" types.

ccf_specs.md Outdated Show resolved Hide resolved
ccf_specs.md Outdated Show resolved Hide resolved
ccf_specs.md Show resolved Hide resolved
ccf_specs.md Outdated Show resolved Hide resolved
ccf_specs.md Outdated Show resolved Hide resolved
fxamacker and others added 6 commits February 14, 2023 12:58
Under "Serialization Considerations", create a section to clarify encoding of Cadence types and values.

- Mention that for compactness, CCF encoding skips Cadence type encoding when type can be inferred.

- Describe CCF encoding when type can be inferred by using array of String to illustrate.

- Describe CCF encoding when type cannot be inferred by using array of AnyStruct to illustrate.

- Remove 4 bullet points in "Deterministic CCF Encoding Requirements" because they are replaced by
the new section, "Cadence Types and Values Encoding".
In "Valid CCF Encoding Requirements", add a line mentioning CCF encodings
must comply with "CCF Specified in CDDL Notation" section of this document.
Mention all parameter lists MUST be unique
as suggested by Bastian.
Co-authored-by: Bastian Müller <bastian@axiomzen.co>
Elements MUST be unique in `restricted-type` or `restricted-type-value`.
Mention that: 
 - `restricted-type.restrictions` MUST be sorted by restriction's `cadence-type-id`.
  - `restricted-type-value.restrictions` MUST be sorted by restriction's `cadence-type-id`.

Thanks @dsainati1 for answering question about Cadence restricted type!
@fxamacker
Copy link
Owner Author

@turbolent @j1010001 thanks for the meeting today! Feel free to add comments here from our meeting. I think we're on the same page about everything and just need to document it for clarity.

I'll incorporate feedback from our meeting into CCF specs and continue ongoing work on CCF codec.

Copy link
Collaborator

@turbolent turbolent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!

Added the notes from our sync

ccf_specs.md Show resolved Hide resolved
ccf_specs.md Show resolved Hide resolved
ccf_specs.md Outdated Show resolved Hide resolved
ccf_specs.md Outdated Show resolved Hide resolved
ccf_specs.md Outdated Show resolved Hide resolved
ccf_specs.md Outdated Show resolved Hide resolved
fxamacker and others added 3 commits February 15, 2023 16:59
Update "Deterministic CCF Encoding Requirements":
- Separate bullet points for field names and parameter lists because they are unrelated.
- Generalize to "all parameter lists" instead of just listing a specific case.
- Add `function-value.parameters` as another example of parameter list.

Co-authored-by: Bastian Müller <bastian@axiomzen.co>
A CCF-based protocol for encoding transaction arguments  might
want to specify that encoders MUST produce deterministic encodings.

Whereas, a CCF-based protocol for encoding script return values might
want to specify that encoders don't need to produce deterministic encodings
if the recipient doesn't care about values being encoded deterministically.

Co-authored-by: Bastian Müller <bastian@axiomzen.co>
@fxamacker fxamacker changed the title Specify requirements for Valid and Deterministic Specify requirements for Valid and Deterministic Encodings Feb 16, 2023
fxamacker and others added 2 commits February 16, 2023 11:28
For compactness, use more concise examples for omitting type info.

Co-authored-by: Bastian Müller <bastian@axiomzen.co>
Copy link
Collaborator

@turbolent turbolent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! 👌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants