-
Notifications
You must be signed in to change notification settings - Fork 146
Description
The goal is to enable bitswap to support different methods of fetching a block,
so that it can access non-bitswap sources like filecoin nodes which may use
graphsync (via https://github.com/filecoin-project/go-data-transfer) and eventually
other payment-based methods.
Fundamentally, Bitswap brokers information about which peers have a cid.
This is captured in the form (cid, peer_id). It is implied that the method of
fetching is the bitswap transfer protocol.
To generalize Bitswap, we need to change the information that is associated with a cid.
For each cid, we would like to keep track of multiple "routing expressions" each of which
describes a different method to fetch the block.
Routing expressions are expressions in the routing language syntax, which represent
valid descriptions of methods to fetch a block, according to the existing Routing Language Spec.
For instance,
fetch(
cid=link("Qm15"),
proto=bitswap,
providers=[multiaddr("/ip4/8.1.1.9:44")],
)
or
fetch(
cid=link("Qm15"),
proto=graphsync,
graphsync_voucher=0x12ef78cd,
providers=[multiaddr("/ip4/8.1.1.9:44")],
)
In essence, the routing information brokered should be of the form (cid, list of routing expressions).
This entails changes to every part of bitswap that touches routing information (for cids):
-
The first (of two) entry points of new routing information is access to the DHT,
which is abstracted behind the interface ProviderFinder. This interface has to be
generalized accodingly, essentially to match the generic composable routing interface.
This interface should also be moved to go-composable-routing repo (it does not belong in bitswap).- ProviderFinder is implemented by ProviderQueryManager, which acts
as middleware between bitswap and making routing calls to the DHT, which
adds throttling, dedup, batching. ProviderQueryManager must be:- generalized to use the composable routing interface (to make it middleware officially)
- ideally broken down into independent middleware blocks (batching, throttling, dedup) which are chained
- moved to go-composable-routing repo
- ProviderFinder is implemented by ProviderQueryManager, which acts
-
The second (of two) entrypoints of new routing information is reception of "have" messages
from the bitswap gossip protocol. On reception, the "have" information must be converted into
a routing expression, so that it can be treated in the same manner as other routing information
downstream. -
The logic that reacts to new routing informatoin must also be updated.
At the moment the only routing information that enters bitswap is "have" information,
and it is acted on immediately by firing/queuing respective "want" requests.
Going forward, routing information that corresponds to "have" messages can be treated as before.
However, we need to decide how to schedule fetching from non-bitswap sources (like filecoin/graphsync)
and generally how to prioritize/parallelize fetching from different sources (bitswap and non-bitswap).
Remarks
This is an absolute minimum plan to enable the integration. Going forward, a lot of additions can be made to improve the scale and speed of the routing process in bitswap. E.g. the "have" messages can be generalized to communicate multiple sources for a block, so that peers can share with each other knowledge about where else the block can be downloaded. E.g. "I have the block, but I also know that this filecoin miner has the block you want too, and they also have the entire directory where the block lives."
Related
IPFS / Filecoin interop plan: https://hackmd.io/JoZiAAtnTpqAKuQaEUra4g
PRs comprising the resolution of this issue
Step 1: ipfs/go-bitswap#512
Follow-up tasks
After this issue is resolved, the following (smaller) issues must be addressed before IPFS is fully ready to talk to the Golden Path product: ipfs/go-bitswap#509, https://github.com/ipfs/go-bitswap/issues/510