-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Pinning new cbor object doesn't appear to work #3570
Comments
Possibly related to #3453 |
Also #3553 |
@lgierth N.B. there are no errors returned here except for the final gets failing to find anything. |
This could be a simple case of special cases for Protobuf nodes, in which case the fix should be simple. I'll look into it. |
The pinning is failing for me. That is likely the problem. I am surprised it works for you:
However I am doing this with the daemon offline. |
Okay, the cbor package is panicking when trying to decode the block in order to pin it. Here is the full backtrace:
@ianopolous could you try this with the daemon offline and make sure the block is valid cbor object. |
Offline I get the same error. Also if I try and pin the first object I get:
The first one is just a cbor byte[]. If this isn't allowed then that needs to be made clear. My reading of the docs was that any cbor is valid (and it would be a shame if not, as that will bloat the serialization with unnecessary stuff) The second object has the following breakdown: |
@ianopolous thanks,I think this is a bug in the cbor library. I am afraid I am not that familiar with cbor objects so not sure how qualified I am to fix this. I will give it another shot before giving up tomorrow (Tuesday). |
@kevina I would guess the cbor library is fine, but that ipfs is assuming the root cbor object is a map, not a general cbor object. |
Yeah, I wasnt really thinking about having base 'non-map' cbor objects being handled when writing the cbor ipld stuff. We can either disallow that for now, or i can figure out how to rewrite the handling in the package to deal with those types of cbor things. It really comes down to whats in the ipld spec, is |
@ianopolous I'm thinking that the objects you created are not valid ipld-cbor objects. We're thinking that only 'map type' top level objects should be allowed. (which means we need to guard against this) |
Can I ask why? As it adds a lot of unnecessary bytes to serialization, which matters in things with lots of small objects, like merkle-btrees. It is also conceptually simpler to allow any root object. I would assume in this case that you couldn't follow any ipld path through it, as it is effectively a leaf node as far as ipld is concerned? If you do decide to continue with that path I assume you will also restrict the keys in cbor maps to Strings, and if so, you should also make that clear. |
I think the same case will also be encountered if you have an ipld selector path internal to an object, which ends up at a non map cbor object. |
@diasdavid @nicola @jbenet @lgierth What do you guys think here? |
@ianopolous could you give a clear description of your usecase here? It seems like youre trying to put your own format over the top of the dag-cbor format |
Our usecase is a merkle-btree with lots of small nodes forming non leaf nodes, and leaf nodes which are actual file fragments (encrypted) and thus close to the IPFS object size limit (they are currently just a cbor byte[]). The non leaf nodes are a list of up to 16 (label, value, target) tuples where label is the key in the btree, and value and target are (optional) multihashes which end up as merkle links in the cbor. $value points to an encrypted metadata blob which in turn points to encrypted file fragments. $target points to another merkle-btree node. We handle the navigation of the btree client side, but need to ability to just pin the root and have the whole tree pinned. The non leaf nodes have cbor merkle links to other nodes. |
if the links are encrypted, theres no way that pin can handle traversing the graph |
Also, you can use the 'raw' type for data which doesnt need to be a dag-cbor formatted object. |
The files are encrypted, the links are in the clear obviously. |
Ah, okay. What does the json representation of your cbor structure look like? |
My understanding from reading all the docs and code I could get my hands on was that I could write an arbitrary cbor object (using block put) which may contain special cbor tagged merkle links, and that recursive pinning will work based on this. |
We never use JSON because it is terrible for binary data. Given a JSON that supports byte[] then any cbor structure that restricts map keys to strings is trivially mappable to JSON + byte[]. |
@ianopolous No, its not arbitrary CBOR. Its ipld objects, that are CBOR encoded, see: https://github.com/ipld/specs/tree/master/ipld Any cbor object can be represented as json though, i'm just trying to get an idea of the structure you have visually. |
Conversation on mutable links here: ipld/specs#9 |
Let me reframe this conversation so that we have a common vocabulary on this!
My opinion
Please, tell me if you see some concerns in this. |
@nicola I agree, ipld objects really should be intended to be dealt with by ipld libraries. Dealing with the tag stuff isnt that much work, and any cbor tool will convert it to a 'tag' object in json (which will properly roundtrip). As an example, @ianopolous did all the tag stuff correctly reading the spec before i even knew about it. It was then pretty simple for me to switch my code over to using the tags. @diasdavid If you really feel strongly about this, i'd love to hear a case where using the tag bites the user in a way thats really hard to deal with. |
However, i will ask that when we move forward with the tag approach, we select a value between 40 and 95 (the first unassigned range). using 258 consumes one extra byte per link and i'm all about saving bytes |
Is anyone opposed to using a tag of 42? Its in the unallocated range here: https://www.iana.org/assignments/cbor-tags/cbor-tags.xhtml and should be fair game. If no opposition is voiced, i'll move forward with that tomorrow. Also, we need to reach consensus on the multiaddr thing... |
On the multiaddr thing:
The last part. i meant that "all ipld paths are valid multi-addresses, but not the other way around", and for now no mutable links. (this may relax in the future, but at this time, no mutable links).
Why? IPLD links should be able to be paths, like: |
Though, since it looks like @whyrusleeping and @diasdavid both assumed that links were only CIDs (not sure why ;P), i'm ok to relax the spec constraints there, and say that for now it's only a CID, and not a full path. if people want to do a full path and enforce it now, speak now! (i prefer paths) |
@whyrusleeping Indeed, given a standard cbor library, it was easy to implement an ipld parser using the tags. In my opinion, mutable (authenticated) links should be a layer up. Otherwise even a simple pinning operation could require arbitrary ipns lookups each with their own validity scheme, which would combine into something very hard to reason about. If the links are restricted to cids (or cid+path), then the resulting structures are very easy to understand and reason about. I say this even though my use case would be a lot easier with ipns links in ipld (I have a hierarchy of write access controlled directories, each with their own ipns key). For me it would great to be able to pin the root and be done, but I can also handle this on the application level, and keep the ipld structure simple. |
Alright, going to move forward with all this tomorrow. The cid's put in the links will be prefixed with a multibase code for binary (a single zero byte) for consistency. Doing this will allow us to easily upgrade to multiaddr paths later on (if buf[0] != 0 ) |
I don't feel strongly about it, I just raised the concern for the question made "How can we make this simple". We are going to document a lot anyway, it is just more a bunch of notes saying "use these libraries".
The resolver knows how to resolve paths, but I haven't made tests for links to be paths (missed that one). Nothing that can't be added :) |
go-ipfs will not support paths in links for a long time. please don't implement that, it won't interop. |
@ianopolous did you implement path support, or just cid support? |
Please do paths, even if go doesn't support them currently it should at least be able to ignore them such that other implementations can use paths, they are one of the big features of IPLD. |
@jbenet Originally I used general multi-addresses, then changed it to cids, but it's easy to change back. It's just a parser. |
The spec for multiaddr ipld paths doesnt even exist yet. When we get to the point where we know what we're wanting to implement there then maybe we can think about implementing it |
Alright, heres my PR to the CBOR code: ipfs/go-ipld-cbor#5 I changed the cbor tag to 42, and changed links to contain a binary-multibase (the byte |
It's great to see the answer to the ultimate question of life, the universe and everything making it into the ipld spec. :-) |
@ianopolous I've merged the changes into master, and i've tested pinning a few different cbor objects, as well as added a test for it. Mind testing it independently and reporting back? I'm going to optimistically close this issue (open it again if i'm wrong) |
Hmm, with 0.4.5-pre2-416f025 it hangs if I try and pin the first object in this issue (the cbor byte[]) through the cli, e.g.: echo -e "\x4b\x67\x27\x64\x61\x79\x20\x49\x50\x46\x53\x21" | ipfs block put --format=cbor
ipfs pin add zdpuAue4NBRG6ZH5M7aJvvdjdNbFkwZZCooKWM1m2faRAodRe |
@whyrusleeping I also don't seem to have the permissions to reopen the issue. |
@ianopolous hrm... doing that gets me 'merkledag not found'. Is that object a link? |
For some reason ipfs thinks that object has a link to: |
It's just a cbor byte array. No links. The byte array contents are the UTF8 bytes of "g'day IPFS!" |
huh, it doesnt appear the cbor code likes roundtripping that byte array... |
@ianopolous lol, i found the issue. Using echo adds an extra newline to the end of the input, which when using 'block put', gets added as part of the block. But when the cbor library parses this block, it ignores that newline since its not part of the actual format, resulting in a different hash. If you use printf instead of echo there, you should get the expected behaviour. I'm not sure if i'm calling this a bug yet... |
@whyrusleeping Sorry, my bad. I can confirm that pinning a cbor byte[] works now. As well as pinning a merkle link to said byte[]. |
Version information:
go-ipfs version: 0.4.5-dev-4cb236c
Repo version: 4
System version: amd64/linux
Golang version: go1.7.1
Type:
Bug
Priority:
P0
Description:
Pinning a new cbor object created using block.put doesn't appear to work. To reproduce:
The gc should NOT remove the two blocks added (it currently removes both). And the subsequent gets should succeed.
The first block is just a cbor byte array of 'gday IPFS!'
The second is just a cbor merkle link to /ipfs/zdpuAue4N...
N.B. I may not have the correct serialization for the merkle link, but as far as I can tell it is correct (a cbor tag of 258 for the multiaddr)
The text was updated successfully, but these errors were encountered: