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

ipfs object diff: check object contents #4775

Closed
schomatis opened this issue Mar 6, 2018 · 8 comments
Closed

ipfs object diff: check object contents #4775

schomatis opened this issue Mar 6, 2018 · 8 comments

Comments

@schomatis
Copy link
Contributor

As explained by @magik6k in a comment, the command ipfs object diff doesn't specifically check the data of the objects, just the hash (CID) of its links. My question, in order to work on a solution, is what is an object? (in the context at least of the ipfs object command).

The command ipfs object put handles the ProtoNode structure while the command ipfs object diff handles the IPLD Node interface, which is implemented by ProtoNode, but I don't see that Node gives access to the data of the ProtoNode, just RawData (through the Block interface), but that also includes the bytes from the serialized links (besides data).

Should the Diff function check the underlying type of the interface to specifically look at data (and if so, it should have to look for all the particularities of each type that implements the interface to perform a correct comparison)? Is there an Equals/Compare function that already abstracts these details? I would really appreciate if someone could point me to more documentation (PR/issue/spec) of how the different data types of IPFS are stacked and interact (e.g., the blocks are one layer below, unixfs is above, etc.)

@magik6k
Copy link
Member

magik6k commented Mar 6, 2018

But the merkledag.utils.Diff (which is used by ipfs object diff) does expect the nodes to be Protobuf nodes:

https://github.com/ipfs/go-ipfs/blob/c00482ab1931c582388022540b38d27b12f20ea0/merkledag/utils/diff.go#L109-L110

What I meant in the comment was to use the cleanA/B nodes to get the data to compare.

@schomatis
Copy link
Contributor Author

@magik6k Thanks again for the clarification. I see now that the check of the links works as a filter of RawNode and similar types before the cast, I'll prepare the PR then and let you know.

https://github.com/ipfs/go-ipfs/blob/c00482ab1931c582388022540b38d27b12f20ea0/merkledag/utils/diff.go#L97-L110

@schomatis
Copy link
Contributor Author

Also, care should also be taken in the checks to ensure that RawNode nodes don't pass to the conversion stage.

mkdir dir
touch dir/file
ipfs add dir -r --cid-version 1
# added zb2rhk8YBkoAB3KCZScAnrZbSfReGyRtBwqLsDtHb6V8JKVDP dir/file
# added zdj7Wd7esoDPpKVgEU1AP928fAp8Rjzm6DFme1ptKA8q79CBT dir

ipfs object diff zdj7Wd7esoDPpKVgEU1AP928fAp8Rjzm6DFme1ptKA8q79CBT zb2rhk8YBkoAB3KCZScAnrZbSfReGyRtBwqLsDtHb6V8JKVDP
Error: interface conversion: format.Node is *merkledag.RawNode, not *merkledag.ProtoNode

I'll add this case to the tests.

@schomatis
Copy link
Contributor Author

@whyrusleeping Could you confirm that Diff is assuming ProtoNode nodes as input? In that case is it ok to error out when receiving RawNode? If not, how the different cases should be handled?

@Stebalien
Copy link
Member

So, object diff was designed to work over ProtoNode. However, IMO, it would make sense to treat RawNodes as protonodes with no links (within the object commands).

FYI, IIRC, the plan is to deprecate these commands anyways. We really should have an ipfs dag diff.

@schomatis
Copy link
Contributor Author

@Stebalien Thanks for the heads up, in your opinion is it worth working on this? The main problem with this command is already address with #4767, this issue was about some more specific corner cases.

@Stebalien
Copy link
Member

Meh. I'm not that interested in putting too much work into the ipfs object commands in general (would rather focus on ipfs dag diff).

@schomatis
Copy link
Contributor Author

Ok, closing this then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants