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

porting libp2p-rs #460

Open
kingwel-xie opened this issue Mar 8, 2021 · 2 comments
Open

porting libp2p-rs #460

kingwel-xie opened this issue Mar 8, 2021 · 2 comments

Comments

@kingwel-xie
Copy link

Hi,

We forked the code and managed to complete the porting to libp2p-rs. It can be found at: rust-ipfs on libp2p-rs. It was interesting when working on the code porting, basically we were simplifying the code as the libp2p-rs is actually providing simpler API. Well, it did take a few days to get it done because the APIs are completely different, but after that, we believe the code structure looks a bit more lightweight...

We added a new sample at examples/simple.rs for demo or you can simply run http/main.rs to give it a try.

Below is the key stuff we have done for porting and issues we found:

  1. p2p network service was rewritten to use libp2p-rs instead of rust-libp2p. Actually p2p is now a bundle of a few controllers: swarm, pubsub, kad and bitswap, which stand for the different network components respectively
  2. the wrapper of floodsub was abandoned since libp2p-rs-floodsub does not require the wrapper any more
  3. SubscriptionFuture is not applicable, same reason as above
  4. ipfs-future is removed. ipfs APIs can be invoked directly from ipfs which is cloneable. as a result, RepoEvent is no longer needed
  5. bitswap was rewritten to reflect the different protocol implementation of libp2p-rs
  6. some APIs were left behind due to not on the critical path, e.g, bootstrapper...
  7. A CLI was added to ease the debugging and testing. See examples/simple.rs for details
  8. ...

Issues: the implementation of bitswap looks like a prototype, when compared to go-bitswap. Certainly I'd be worried for the performance that each wanted Cid will cause a kad-dht get_providers() which is extremely expensive to my knowledge. I noticed there is a ‘FIXME’ comment there, but I'm afraid it is not the only thing to be fixed in the current bitswap code...

Anyway, this is what we figured these days. I'd be pleasured if you guys could take a look at the code and any comments are appreciated.

Regards,
Kingwel

@kingwel-xie kingwel-xie changed the title porting lib2p-rs porting libp2p-rs Mar 8, 2021
@koivunej
Copy link
Collaborator

Hi and thanks for the ping! I should commented on this earlier that I did notice this, but did't yet have time to go through. Some quick answers.

Issues: the implementation of bitswap looks like a prototype, when compared to go-bitswap. Certainly I'd be worried for the performance that each wanted Cid will cause a kad-dht get_providers() which is extremely expensive to my knowledge. I noticed there is a ‘FIXME’ comment there, but I'm afraid it is not the only thing to be fixed in the current bitswap code...

You are very much correct here. There is a long list of issues with the current very basic implementation. The applicable fixes have been documented by the {go,js}-ipfs devs. I have been busy with other work recently but meaning to get back on this next-ish, but it's unclear when the "next" is.

Anyway, this is what we figured these days. I'd be pleasured if you guys could take a look at the code and any comments are appreciated.

I'll be sure to ping you when I do get the chance. Thanks again!

@kingwel-xie
Copy link
Author

Sure, look forward to your comments.

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

No branches or pull requests

2 participants