-
Notifications
You must be signed in to change notification settings - Fork 85
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
Add separate identity-iota-core
, identity-account-storage
crates
#693
Conversation
…tangle ref back to identity-iota
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 approve of the overall approach but there are still dependencies that can be removed like iota-client
in identity-iota-core
and we should discuss the finer-details.
-
I think we have to delay this PR until both Update Stronghold #691 and Overhaul
CredentialValidator
, addPresentationValidator
#599 have been merged unfortunately, since they both alter many of the files moved in this PR. I do not think the merge conflicts would be easily resolvable without losing changes otherwise. -
We should decide whether to keep the
iota_core
andaccount_core
modules in the top-levelidentity
crate or re-export their types under theiota
andaccount
modules respectively. I am leaning towards re-exporting the types at the top-level for convenience to developers unless it doesn't make sense (e.g. the documentation and doc-comments still refer to those types underiota_core
). We should probably not re-export those types in the sub-crates, however, i.e. do not re-exportidentity_iota_core::IotaDocument
fromidentity_iota
. -
There are some dependencies like
iota-client
which can be removed/replaced withbee-message
. Edit: if necessary we can re-exportMessageId
fromidentity-iota-core
to avoid having to add thebee-message
dependency anywhere else. -
Error handling is a bit tricky since errors are just bubbled up from the sub-crates now. It's probably fine to leave it as-is for this PR? Not sure.
identity/src/lib.rs
Outdated
#[cfg(feature = "account")] | ||
#[cfg_attr(docsrs, doc(cfg(feature = "account")))] | ||
pub mod account_core { | ||
//! Storage Trait and Types definitions | ||
|
||
pub use identity_account_core::crypto::*; | ||
pub use identity_account_core::error::*; | ||
pub use identity_account_core::identity::*; | ||
pub use identity_account_core::storage::*; | ||
pub use identity_account_core::stronghold::*; | ||
pub use identity_account_core::types::*; | ||
pub use identity_account_core::utils::*; | ||
} |
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.
Discussion: I think we should re-export types from the _core
crates under the non-core namespace (unless there are conflicts). That is, move all these pub use identity_account_core
lines under pub mod account
. Similarly for identity_iota_core
and identity_iota
.
All this does is simplify imports and allow us to sub-divide crates as much as we want without causing breaking changes to the external interface, which I think is desirable. The Error
and Result
instances are a problem, I'm not sure if we want to adopt a convention of prefixing the crate name onto those like in this PR where e.g. IotaCoreError
is used instead of just Error
? Not sure, need to decide and implement the convention everywhere.
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.
The convenience of condensed imports may not be worth any confusion, just to be clear. Edit: weighed against the benefit of not causing breaking changes when we re-organise internal crates, of course, assuming we consider identity
the external API and not the constituent crates as well.
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.
Overall I agree with re-exporting types from _core
crates under the non-core namespace in identity
because consumers of the main identity
are likely not interested in how it is organized internally. This same principle also applies to errors hence I would prefer to avoid variants/names like IotaCoreError
if possible.
I am less sure about how much re-exports from sub(-sub) crates to unified modules in identity
protect us against introducing breaking changes in the external API upon further sub-division however. The types in our public API need to be interchangeable between minor versions, but cargo may not be able to "understand" that the types are actually still the same when their origin has changed from one sub crate to another. It might be possible to help express the compatibility of types between minor versions by using something like the semver trick however.
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 would prefer to avoid variants/names like IotaCoreError if possible.
The problem is that we cannot export two Error
enums of the same name under identity::iota
from identity_iota
and identity_iota_core
without changing the name of one or the other.
If we cannot avoid breaking changes by re-exporting types then I am somewhat less in favour of re-exporting them. The semver trick is fascinating but we should hopefully not plan to use it as a crutch.
identity-iota-core
, identity-account-storage
crates
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.
Thanks for the changes! I pushed some commits to fix the last few comments, hopefully without causing too many merge conflicts for the epic branch.
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 know this has been merged now, but: looks good to me. Just one comment unrelated to the split.
@@ -48,7 +49,7 @@ features = ["blake2b"] | |||
|
|||
[dev-dependencies] | |||
proptest = { version = "1.0.0", default-features = false, features = ["std"] } | |||
tokio = { version = "1.15", default-features = false, features = ["macros"] } | |||
tokio = { version = "1.17.0", default-features = false, features = ["macros"] } |
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.
Should we actually specify the highest possible version if we don't require it? To maximize compatibility within our crates and for our users, shouldn't we specify the lowest possible version that still satisfies our needs?
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 unsure of the circumstances in which we should not update to the latest version of Rust dependencies, particularly when they are semver compatible (edit: since as a library we're pulling in the latest compatible version automatically anyway).
In this case I found it prudent specifically because tokio 1.17.0
contains fixes to avoid panics.
I'll keep it in mind that we may not want to update all dependencies for compatibility reasons, especially if those updates contain API-breaking changes.
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 have no such justification for strum
, however. I just wanted the latest version (and forgot to update it everywhere).
identity-iota-core
, identity-account-storage
cratesidentity-iota-core
, identity-account-storage
crates
Description of change
Split identity-iota and identity-account into identity-iota-core and identity-account-core.
Links to any relevant issues
#669
Type of change
How the change has been tested
All existing tests are still present.
Change checklist