Skip to content
This repository has been archived by the owner on Oct 23, 2022. It is now read-only.

Pinning support #11

Closed
dvc94ch opened this issue Feb 27, 2019 · 17 comments
Closed

Pinning support #11

dvc94ch opened this issue Feb 27, 2019 · 17 comments
Assignees
Labels
enhancement New feature or request repo

Comments

@dvc94ch
Copy link
Contributor

dvc94ch commented Feb 27, 2019

Related issue is garbage collection of unpinned blocks

@dvc94ch dvc94ch added enhancement New feature or request repo labels Mar 2, 2019
@saresend
Copy link
Contributor

Would there be guidance available for this? I'd be interested in tackling it

@dvc94ch
Copy link
Contributor Author

dvc94ch commented Mar 23, 2020

I guess the best is to dive in. What sort of guidance did you have in mind?

You probably want to have a table in the datastore Cid -> bool. There's a utility in libipld to find all cids recursively, since supporting recursive pinning is very useful. We might drop rocksdb in the future in favor of sled.

If you have an ipld datastructure you will want to pin the root. After you make a change you want to pin the new root and unpin the old one. We might end up requiring two different types of pinning, as when streaming for example we only the buffered part of the file to be pinned. There we want to manage individual blocks manually.

@koivunej
Copy link
Collaborator

Related: the discussion in #84 and the ipfs/specs discussion linked from there.

@saresend
Copy link
Contributor

I didn't have anything too specific in mind, just wanted to check that you guys would be willing to support the changes since I'm still ramping up on IPFS stuff! I'll take a look and hopefully have a PR up soon

@aphelionz
Copy link
Contributor

Great @saresend and welcome! We look forward to it.

@saresend
Copy link
Contributor

Have something very tentative up at #117, would be interested in seeing if the direction here is correct!

@aphelionz
Copy link
Contributor

@dvc94ch Should we leave this open to capture the remaining work or close and create new issue(s)?

@koivunej
Copy link
Collaborator

koivunej commented Apr 8, 2020

For posterity: The testing of #90 requires /pin/add so it will likely be added during that, for the conformance tests. If I'll implement it I'll keep it as constrained as possible (for example, non-recursive if allowed by the tests, which I understand only require single block pinning).

@saresend
Copy link
Contributor

saresend commented Apr 8, 2020

Hey, sorry that I haven't got around to it just yet, expect a PR up in the next couple of days! @koivunej Let me know if you want to take that work, don't want to duplicate if you're already working on it.

@koivunej
Copy link
Collaborator

@saresend I'll be soon (hopefully!) moving over to this. I want to handle #238 first though and lets just say it hasn't been so fast moving as I would had hoped. After #238 moving refs over to ipfs for different kinds of pins should start to move forward.

Regarding #152. If you want, we could iron out what exists at the moment and get it merged in. Let me know.

bors bot added a commit that referenced this issue Aug 25, 2020
332: refactor: ipfs.dag().resolve(..) from ipfs-http r=koivunej a=koivunej

This PR continues refactoring/rewriting the ipfs-http IpfsPath resolving, so that we can move refs into ipfs, so that we can implement pinning and unpinning. Realized while doing this that perhaps pinning api operated just on Cids so this may have been unnecessary, however refs works on IpfsPaths so not really sure yet.

The result of `IpfsDag::resolve` may be already loaded block, it's actually always a loaded block. Made some changes to ipfs::unixfs::cat to accept either `Block` or `Cid`. There may have been similar changes as well.

Step forward on #238 and towards #11. It is more lines added than removed probably due to more refined return types and solved local resolving or not following links (the test doesn't work though but the concept or implementation hint makes sense). Previous version did not support local resolving at all, nor could that had been added there in any way.

Co-authored-by: Joonas Koivunen <joonas@equilibrium.co>
bors bot added a commit that referenced this issue Aug 26, 2020
337: refactor: move refs as Ipfs::refs and ipfs::refs::iplds_refs r=koivunej a=koivunej

This PR moves `refs` from `ipfs-http` to `ipfs`. Ended up moving only a `iplds_refs` which needs pre-resolved `IpfsPaths`. As for short term I think this should help towards #11.

I was originally planning to make this into a version which would accept both `IpfsPath` (or `CidPath`) and already projected `(Cid, Ipld)` but the duplication of code would be quite unavoidable, as the http side will have to "buffer" all IpfsPath resolution *before* calling a version of `iplds_refs` which would accept a `TryStream<Ok = (Cid, Ipld), Error = _>` instead of `IntoIterator<Item = (Cid, Ipld)>`. I did continue this solution and did try out prefetching options for unixfs_cat for example, but I'll leave them for next PRs since they will complicate the API quite a bit.

While moving the tests, I removed of the "duplicate" dependency on `hex` as `hex-literal` is a bit more straight forward.

### Checklist (can be deleted from PR description once items are checked)

- [x] **New** code is “linted” i.e. code formatting via rustfmt and language idioms via clippy
- [x] There are no extraneous changes like formatting, line reordering, etc. Keep the patch sizes small!
- [x] There are functional and/or unit tests written, and they are passing
- [x] There is suitable documentation. In our case, this means:
    - [x] Each command has a usage example and API specification
    - [x] Rustdoc tests are passing on all code-level comments
    - [x] Differences between Rust’s IPFS implementation and the Go or JS implementations are explained


Co-authored-by: Joonas Koivunen <joonas@equilibrium.co>
Co-authored-by: Joonas Koivunen <joonas.koivunen@gmail.com>
@koivunej koivunej mentioned this issue Aug 27, 2020
7 tasks
bors bot added a commit that referenced this issue Aug 27, 2020
342: feat: http pin/add r=ljedrz a=koivunej

Continued from #152 by @saresend cc #11 .

Closes #152.

This only adds the `pin/add` per current impl which passes the tests which don't verify anything. I am inclined to merge this in as is since the next PR is likely going to be a larger one.

### Checklist (can be deleted from PR description once items are checked)

- [x] **New** code is “linted” i.e. code formatting via rustfmt and language idioms via clippy
- [x] There are no extraneous changes like formatting, line reordering, etc. Keep the patch sizes small!
- [x] There are functional and/or unit tests written, and they are passing
- [ ] There is suitable documentation. In our case, this means:
    - [ ] Each command has a usage example and API specification
    - [ ] Rustdoc tests are passing on all code-level comments
    - [ ] Differences between Rust’s IPFS implementation and the Go or JS implementations are explained


Co-authored-by: saresend <saresend@usc.edu>
Co-authored-by: Joonas Koivunen <joonas@equilibrium.co>
@saresend
Copy link
Contributor

saresend commented Sep 1, 2020

Ah, so sorry just saw this. I've started work and been very busy. I should have some time later this week however, if there hasn't been too much development on this front since!

@aphelionz
Copy link
Contributor

Hey @saresend! 👋

@koivunej was able to take your work and build off of it here: #342 and the remaining work is in a follow-up PR #349. Thank you so much for getting the initial ball rolling.

I bet @koivunej and @ljedrz will have some ideas for things to do once Europe wakes up.

@saresend
Copy link
Contributor

saresend commented Sep 1, 2020

Awesome, sounds good! Sorry I went mia been moving for work and getting settled and haven't had too much time for open source lately. If there's still opportunity for me to help out on this feature, I'd love to re-involve myself!

@koivunej
Copy link
Collaborator

koivunej commented Sep 1, 2020

Regarding the topic of pinning, my #349 is not going to close the chapter at all. The #349 is "ok" for inmemory version. Once that's done, I'll continue over to a persistent block and data store with a bit different design: instead of "writing" all indirect pins explicitly I'll probably settle for a document per recursive pin, as bigger files are not a huge issue but gazillion small files are. Also, crash safety is easier to work towards with more atomic writes. I might still change the plans if I run into huge issues since we are at the moment on a deadline.

Regardless of how it ends up looking like I am already certain the solution will not perfect and help wanted/enhancement issues should be appearing in the near future :)

@saresend
Copy link
Contributor

saresend commented Sep 2, 2020

Sounds good, I'm not sure I'm the right person to chime in on architecture planning, but would absolutely be interested to follow along!

@aphelionz
Copy link
Contributor

aphelionz commented Sep 2, 2020

Either way, here's the list of issues that are marked as "help wanted" or "good first issue", the latest of which was just added :)

@koivunej
Copy link
Collaborator

koivunej commented Sep 5, 2020

Great to hear that @saresend! My latest batch of big PRs ending in #358 and #360 are an initial, feature-full as far as I know for fs based pinning. As you follow along be welcome to join in any reviews or you can open an issue. The more understandable the code is the better it is for everyone.

Closing as following the PRs #342, #349, #355, #358, #360 are merged. Known unfinished parts are tracked in at least #350, #351, #352.

@koivunej koivunej closed this as completed Sep 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request repo
Projects
None yet
Development

No branches or pull requests

4 participants