-
Notifications
You must be signed in to change notification settings - Fork 87
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
Fix dependent diff updates being rejected #605
Conversation
Add unit test for diffing properties.
…fix/resolve-diff-updates
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.
Unfortunately, I can't confirm it's working on my side. The example from #593 is printing the expected result, but that seems to be a coincidence. No matter how many diffs I publish in try_from_index_with_document
,
index.get(
this
.current_message_id()
.unwrap_or_else(|| current_document.message_id()),
).unwrap().len()
is always 1
.
For instance, if I run an example that adds service-1
, deletes service-1
and adds service-2
, the service
property is still empty when being resolved, even though I confirmed three diffs are being published.
Thanks for catching that! Turns out there's an entirely unrelated bug to what this PR fixes and I tested insufficiently (multiple times). Almost all Current unit tests failed to catch this since they instantiate |
Opened #611 to fix the deserialisation bug, |
Seems to be fixed, I manually checked the examples this time! |
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.
Looks good to me, can confirm my example is also working now 👌! Thank you very much for fixing this!
@@ -311,6 +311,7 @@ impl IotaDocument { | |||
} | |||
|
|||
/// Remove a [`Service`] identified by the given [`IotaDIDUrl`] from the document. | |||
// TODO: return an error or bool if no service was removed? |
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 agree, then we can remove this:
identity.rs/identity-account/src/updates/update.rs
Lines 264 to 267 in 630a61e
ensure!( | |
state.document().service().query(&service_url).is_some(), | |
UpdateError::ServiceNotFound | |
); |
Doesn't need to be in this PR.
Description of change
Fixes the
DiffChain
rejectingDiffMessages
that update document sections added in previous diffs. From the example given in #593: adding a service in a diff update then editing or removing it in another diff update will result in the latter update being rejected/discarded by theDiffChain
during resolution.Thank you to @PhilippGackstatter and @abdulmth for identifying and investigating the issue!
This also flattens the properties of
DocumentMetadata
serialization (this ensures unhandled fields are captured during deserialization), which may lead to breaking changes if any existing user-defined custom fields conflict with hardcoded field names.WARNING: this may result in resolutions of IOTA DID Documents that contain diff updates being different after this is merged.
Links to any relevant issues
Fixes #593
Type of change
How the change has been tested
Existing and new tests pass, including examples.
Change checklist