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

Encoding relations API #51

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open

Encoding relations API #51

wants to merge 19 commits into from

Conversation

sgwilym
Copy link
Contributor

@sgwilym sgwilym commented Sep 11, 2024

Willow's site will soon define encoding relations for many encodings, which are a set of acceptable encodings for a given type. These will be useful for things like WGPS messages where we are decoding many messages and we do not want the implicit overhead of verifying that every message was encoded correctly.

We still want to retain the concept of canonical encodings, as these are important for things like Meadowcap signatures.

So this PR adds new RelationDecodable and RelativeRelationDecodable (open to suggestions) traits with a decode_relation and relative_decode_relation methods on them, respectively.

The methods have a default implementation which is an alias for Decodable / RelativeDecodable's decode_canonical and relative_decode_canonical.

I made these traits separate so that we can define types which have only a canonical decoder, or only a relation decoder (WGPS messages), or both!

Fuzz tests have been refactored to be synchronous and inclued additional checks on encoding tests.

There is also a new shell script for running all the fuzz tests sequentially (see the README) (closes #54).

Copy link
Contributor

@AljoschaMeyer AljoschaMeyer left a comment

Choose a reason for hiding this comment

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

Looks pretty good, just some small suggestions.

encoding/src/traits.rs Outdated Show resolved Hide resolved
encoding/src/traits.rs Outdated Show resolved Hide resolved
encoding/src/traits.rs Outdated Show resolved Hide resolved
encoding/src/traits.rs Outdated Show resolved Hide resolved
@AljoschaMeyer
Copy link
Contributor

How do we feel about not encoding with encoding relations?

I feel very good about that.

@sgwilym
Copy link
Contributor Author

sgwilym commented Sep 13, 2024

As I'm working through these encodings, I think I'm going to split off relation decoding into its own trait.

My motivation for this would be to make it possible to implement types without canonical decoders which check for errors.

For example, it would be a huge waste of time to implement canonical decoders for all of the WGPS message types, when we will only ever decode relations.

Thoughts @AljoschaMeyer?

@AljoschaMeyer
Copy link
Contributor

Sounds correct.

@sgwilym sgwilym added enhancement New feature or request optimization labels Sep 16, 2024
@sgwilym sgwilym marked this pull request as ready for review September 16, 2024 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request optimization
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Command for running all of the fuzz tests
2 participants