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

Implement bitswap in the network behaviour using libp2p_bitswap. #6795

Open
wants to merge 17 commits into
base: master
from

Conversation

@expenses
Copy link
Contributor

expenses commented Aug 3, 2020

I believe this would be a good start to implementing #6075. As libp2p-bitswap still needs some work (see #6075 (comment)), this PR probably needs a lot of work in order to be merged. A few points:

  • Ideally the Bitswap behaviour would be wrapped in a Toggle so that it's only activated when a chain requests it, but we can't do that until libp2p/rust-libp2p#1684 gets merged.
  • I think we should be inserting the bitswap blocks into the DHT as well, so that nodes we're not directly connected to will be able to access them.
    * As the idea is to allow the fetching of preimages by an IPFS client, I'm not sure if we should be messing about with IPLD as well, or if this is too low level for that.

polkadot companion: paritytech/polkadot#1550

expenses added 4 commits Jul 30, 2020
expenses added 2 commits Aug 3, 2020
client/network/src/service.rs Outdated Show resolved Hide resolved
client/network/src/service.rs Outdated Show resolved Hide resolved
client/network/src/behaviour.rs Outdated Show resolved Hide resolved
client/network/src/behaviour.rs Outdated Show resolved Hide resolved
client/network/src/behaviour.rs Outdated Show resolved Hide resolved
client/network/src/behaviour.rs Outdated Show resolved Hide resolved
client/network/src/protocol/event.rs Outdated Show resolved Hide resolved
@expenses expenses requested a review from tomaka Aug 3, 2020
expenses added 2 commits Aug 3, 2020
@dvc94ch
Copy link
Contributor

dvc94ch commented Aug 3, 2020

One problem is that ipfs data will leak, as there isn't a way of disposing of it. And since it's content addressed you'll need to ref count the blocks as the data is deduplicated.

To get "ipld" support you just need to implement the ipld store traits, you can easily do that, and then you get all the ipld codecs and ipld collections for free.

@dvc94ch
Copy link
Contributor

dvc94ch commented Aug 4, 2020

I was planning on reimplementing bitswap as a light client notification protocol, but it doesn't seem there is a way to perform the get-providers dht query from the NetworkService. This would be an alternative that would also work for us. I'm going to make the entire network implementation of ipfs-embed replaceable so that I can drop in the light client. The db is already shared between ipfs-embed and the light-client.

@tomaka do you think exposing get-provider and start-providing in NetworkService could be a faster way forward?

expenses added 4 commits Aug 5, 2020
@expenses expenses marked this pull request as ready for review Aug 6, 2020
expenses added 3 commits Aug 6, 2020
@tomaka
Copy link
Member

tomaka commented Aug 6, 2020

This PR doesn't do anything related to the DHT yet as far as I can tell, but one thing to be aware of is that we're customizing the name of the Kademlia protocol to include the id of the chain, as a way to prevent nodes from different chains from connecting to each other.

I suppose that it would fundamentally be better to also connected to a shared DHT, or to IPFS itself, rather than to only the DHT of a specific chain. However, this would be problematic as we are already now suffering from problems caused by the high number of TCP sockets.

a light client notification protocol

Request-response protocols, added in #6634, would be more appropriate I think. They are similar to RPC queries, whereas if you try to emulate request-reponses on top of notifications you will suffer from all sorts of issues.

@tomaka do you think exposing get-provider and start-providing in NetworkService could be a faster way forward?

That'd be totally reasonable.

@dvc94ch
Copy link
Contributor

dvc94ch commented Aug 6, 2020

This PR doesn't do anything related to the DHT yet as far as I can tell, but one thing to be aware of is that we're customizing the name of the Kademlia protocol to include the id of the chain, as a way to prevent nodes from different chains from connecting to each other.

This is what we want as we're using custom codecs and hashers based on the sp-trie module. We have a prototype "chain" pallet that let's you deal with comonalities between chains of ipfs blocks that store user or team data. The "chain" pallet has a list of "authorities" that are allowed to update the head and prove that the ancestor was the previous head. We found this pattern useful for data that is not interesting for all users, like for example your "twitter feed" and where users can follow one of these "chains" to both get updates and replicate the blocks. In the far future we can maybe leverage a more sophisticated incetivized availability system.

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

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.