-
Notifications
You must be signed in to change notification settings - Fork 185
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
refactor(iroh-willow): use willow-rs #2616
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Documentation for this PR has been generated and is available at: https://n0-computer.github.io/iroh/pr/2616/docs/iroh/ Last updated: 2024-08-13T14:01:09Z |
Frando
force-pushed
the
willow-use-willow-rs
branch
3 times, most recently
from
August 12, 2024 22:53
de8aa4a
to
88bcdce
Compare
Frando
force-pushed
the
willow-use-willow-rs
branch
from
August 12, 2024 22:53
88bcdce
to
f43e0b4
Compare
Voronar
reviewed
Aug 13, 2024
Frando
changed the title
[wip] refactor(iroh-willow): use willow-rs
refactor(iroh-willow): use willow-rs
Aug 13, 2024
51 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Adopts
willow-rs
iniroh-willow
:willow-data-model
. Our implementations are replaced by type aliases onto the willow-data-model types with the generics filled in.meadowcap
. Our implementations are replaced by type aliases onto the meadowcap types with the generics filled in.The PR is large and not well readable because I adapted the module structure to be closer to willow-rs as well in the same go (a bit non-ideal, but I was already having to go over most imports once, so did it in one go). I will merge this as soon as all tests are green, and then refine in the main willow PR (#2231).
Breaking Changes
Many public types from iroh-willow are now type aliases instead of structs.
Notes & open questions
Based on #2231 and currently uses willow-rs git dependency with two PRs merged in: earthstar-project/willow-rs#45 and earthstar-project/willow-rs#46
Generics
Type aliases work well in many regards, but they don't really hide all the generics well, they appear in compiler error messages and rust-analyzer doc hovers etc and make all that quite unreadable. We talked about this a bit, and will have to improve the story at least for the public client API, and potentially also for ourselves working in the internals.
Encodings
This PR does not yet include spec-compliant encodings for WGPS messages, it still uses postcard with serde as an interim solution. To make this work with the willow-rs types which don't implement serde, I added wrapper types that takes the willow-encoding and maps them into serde. The proper encodings will still have to be written, same for the integration of ufotofu encoding with our in-memory pipe.
Key types
We currently have
UserId
andUserPublicKey
types (and same for namespace):Id
is a wrapper around[u8; 32]
, wheresPublicKey
is theed25519_dalek::VerifyingKey
. Converting from Id to PublicKey is fallible (because not all 32 bytes are valid ed pubkeys) and non-free (it involves numeric operations). Before this PR, we usedPublicKey
in meadowcap andId
in data-model. This is no longer possible because the generics have to map on the same time. We now useId
everywhere and convert toPublicKey
on demand.This is non-ideal because the conversion will happen far more often than needed. However willow currently assumes a non-fallible
successor()
function when aUserId
(UserPublicKey
) is used as a subspace id.What we likely want is an in-memory LRU cache for the converted versions. Or a type where the numeric pubkey is optional, but that would either need mutable access to the key for operations, or interior mutability.
Change checklist