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

fix(dagutils): rework diff algorithm #82

Closed
wants to merge 1 commit into from

Conversation

schomatis
Copy link
Contributor

Still some blocking fixmes to finalize but need a review at this point since this algorithm is tentatively filling in the blanks of some unsupported cases from before.

Toward ipfs/kubo#4801.

@schomatis schomatis requested a review from lidel January 27, 2022 15:53
@schomatis schomatis self-assigned this Jan 27, 2022
@lidel lidel mentioned this pull request Jan 28, 2022
Comment on lines +115 to +118
if !bytes.Equal(a.Data(), b.Data()) {
// FIXME: This is a very dirty way of reporting a difference in Data()
// but the current `Change` API doesn't support anything but links.
out = append(out, &Change{Type: Mod, Path: "<NODE-DATA>", Before: a.Cid(), After: b.Cid()})
Copy link
Member

@lidel lidel Jan 28, 2022

Choose a reason for hiding this comment

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

Wrote some thoughts and relevant examples in ipfs/kubo#4801 (comment)

Perhaps switching to Logical Format described there, with Data and Links/<index>/Name prefixes in Change.Path would remove the need for hacks like this.

Having that, ipfs object diff would ignore/strip this additional prefix data,
but ipfs dag diff could take advantage of it and show more detailed DAG diff.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@lidel I'm not sure I follow the concrete direction you're requesting there; I think I'll need that to be lowered a bit more to the codebase I'm dealing with here.

From what I'm understanding in the linked proposal a dag diff would now be:

  • dag get to the JSON format already in place
  • diff the JSON outputs

Which would operate completely in the go-ipfs repo and not here (this work would could apply as the new, a little less broken, object diff command if you want).

Copy link
Member

Choose a reason for hiding this comment

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

Indeed, generating the dag diff based on dag-json representation would make things easier and less error-prone.
Since everything would be serialized to dag-json representation, we could support dag-pb, raw amd dag-cbor CIDs out of the box.

👉 @schomatis I think we should give that a try and park this PR for now – focus on go-ipfs and its JSON-Patch-based dag diff instead.

Regarding this PR (when we revisit it later)

  • is Diff only used in object diff or are there other places where we use diff implementation from here?
  • if unused, perhaps we should remove Diff and DiffEnumerate, and switch ipfs object diff to use dag diff behind the scenes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

is Diff only used in object diff or are there other places where we use diff implementation from here?

AFAIK object diff ((*ObjectAPI)Diff) is the only consumer.

switch ipfs object diff to use dag diff behind the scenes?

Yes, that was the plan. Deprecate object diff and point it (either explicitly or implicitly as you propose) to dag diff.

@BigLep BigLep added this to the Best Effort Track milestone Mar 10, 2022
@BigLep
Copy link
Contributor

BigLep commented Mar 10, 2022

@schomatis : correct me if this is wrong, but this will get reevaluated after ipfs/kubo#8711 lands.

@schomatis
Copy link
Contributor Author

Yes, I think it's fair to close this at this point, we'll likely go with the JSON variant in ipfs/kubo#8711.

@schomatis schomatis closed this Mar 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants