-
-
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
Routing: conform DHT to common Router interface #9079
Comments
@ajnavarro : Is this really about "delegated routing", or about having all our routing options (ipfs/go-delegated-routing and libp2p/go-libp2p-kad-dht) conforming to common pattern/interface? |
It's the latter, having all our routing options conforming to a common pattern. |
Example of delegated routing configuration with DHT router: {
"Type": "reframe",
"Enabled": true,
"Parameters": {
"Endpoint": "https://cid.contact/reframe",
"Priority": 100
}
},
{
"Type": "dht",
"Enabled": true,
"Parameters": {
"Priority": 200,
"DHTMode": "dhtclient", # It can also be "dht", "dhtserver" and "none" too. "dht" by default.
"TrackFullNetwork": false, # experimental dht
"Concurrency": 10 # we can expose internal configuration params to tweak DHTs.
"Prefix": "/ipfs" # shall we expose used prefix?
}
} |
I'm having some problems refactoring how DHT is created on Kubo. The main DHT Router is created at the same time than Host here: Lines 56 to 65 in 7ec0c24
It uses
I feel that everything is more complicated than it should be, so I'm tempted to refactor all DHT-related code to make it easier to update in the future. Maybe we don't want to spend time on this, so @lidel @guseggert @aschmahmann @Jorropo I would love to have some feedback about the following possible solutions:
WDYT? |
As we discussed, I will make a comparison between config files before, and after the change (I'll remove the irrelevant parts to have less noise): Before:Config file{
"Identity": {
[...]
},
"Datastore": {
[...]
},
"Addresses": {
"Swarm": [
"/ip4/0.0.0.0/tcp/4001",
"/ip6/::/tcp/4001",
"/ip4/0.0.0.0/udp/4001/quic",
"/ip6/::/udp/4001/quic"
],
"Announce": [],
"AppendAnnounce": [],
"NoAnnounce": [],
"API": "/ip4/127.0.0.1/tcp/5001",
"Gateway": "/ip4/127.0.0.1/tcp/8080"
},
"Discovery": {
"MDNS": {
"Enabled": true
}
},
"Routing": {
"Type": "dht",
"Routers": {}
},
"Bootstrap": [
"/dnsaddr/bootstrap.libp2p.io/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN",
"/dnsaddr/bootstrap.libp2p.io/p2p/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa",
"/dnsaddr/bootstrap.libp2p.io/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb",
"/dnsaddr/bootstrap.libp2p.io/p2p/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt",
"/ip4/104.131.131.82/tcp/4001/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
"/ip4/104.131.131.82/udp/4001/quic/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ"
],
"Gateway": {
[...]
},
"API": {
"HTTPHeaders": {}
},
"Swarm": {
"AddrFilters": null,
"DisableBandwidthMetrics": false,
"DisableNatPortMap": false,
"RelayClient": {},
"RelayService": {},
"Transports": {
"Network": {},
"Security": {},
"Multiplexers": {}
},
"ConnMgr": {
"Type": "basic",
"LowWater": 600,
"HighWater": 900,
"GracePeriod": "20s"
},
"ResourceMgr": {}
},
"AutoNAT": {},
"Pubsub": {
"Router": "",
"DisableSigning": false
},
"Peering": {
"Peers": null
},
"DNS": {
"Resolvers": {}
},
"Migration": {
[...]
},
"Provider": {
"Strategy": ""
},
"Reprovider": {
[...]
},
"Experimental": {
[...]
"AcceleratedDHTClient": false
},
"Plugins": {
[...]
},
"Pinning": {
[...]
},
"Internal": {}
}
After:Config file{
"Identity": {
[...]
},
"Datastore": {
[...]
},
"Addresses": {
"Swarm": [
"/ip4/0.0.0.0/tcp/4001",
"/ip6/::/tcp/4001",
"/ip4/0.0.0.0/udp/4001/quic",
"/ip6/::/udp/4001/quic"
],
"Announce": [],
"AppendAnnounce": [],
"NoAnnounce": [],
"API": "/ip4/127.0.0.1/tcp/5001",
"Gateway": "/ip4/127.0.0.1/tcp/8080"
},
"Discovery": {
"MDNS": {
"Enabled": true
}
},
"Routing": {
"Routers": {
"storetheindex": {
"Type": "reframe",
"Enabled": true,
"Parameters": {
"Endpoint": "https://cid.contact/reframe",
"Priority": 100
}
},
"ipfs-public-dht" : {
"Type" : "dht"
"Enabled" : "true"
"Methods" : ["put-ipns", "get-p2p-providers", ...]
"Parameters" : {
"Mode" : "auto"
"TrackFullNetworkDHT": true,
"ProtocolID" : "/ipfs/kad/1.0.0"
"Bootstrappers" : [
"/dnsaddr/bootstrap.libp2p.io/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN",
"/dnsaddr/bootstrap.libp2p.io/p2p/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa",
"/dnsaddr/bootstrap.libp2p.io/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb",
"/dnsaddr/bootstrap.libp2p.io/p2p/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt",
"/ip4/104.131.131.82/tcp/4001/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
"/ip4/104.131.131.82/udp/4001/quic/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ"
]
"Public-IP-Network" : "true"
}
}
"ipfs-lan-dht" : {
"Type" : "dht"
"Enabled" : "false"
"Methods" : ["put-ipns", "get-p2p-providers", ...]
"Parameters" : {
"Mode" : "server"
"ProtocolID" : "/ipfs/lan/kad/1.0.0"
"Bootstrappers" : []
"Public-IP-Network" : "false"
}
}
}
},
"Gateway": {
[...]
},
"API": {
"HTTPHeaders": {}
},
"Swarm": {
"AddrFilters": null,
"DisableBandwidthMetrics": false,
"DisableNatPortMap": false,
"RelayClient": {},
"RelayService": {},
"Transports": {
"Network": {},
"Security": {},
"Multiplexers": {}
},
"ConnMgr": {
"Type": "basic",
"LowWater": 600,
"HighWater": 900,
"GracePeriod": "20s"
},
"ResourceMgr": {}
},
"AutoNAT": {},
"Pubsub": {
"Router": "",
"DisableSigning": false
},
"Peering": {
"Peers": null
},
"DNS": {
"Resolvers": {}
},
"Migration": {
[...]
},
"Provider": {
"Strategy": ""
},
"Reprovider": {
[...]
},
"Experimental": {
[...]
},
"Plugins": {
[...]
},
"Pinning": {
[...]
},
"Internal": {}
}
Steps:
|
@ajnavarro : I'm not going to be able to engage thoroughly here, but wanted to drop a couple of thoughts:
|
@ajnavarro : As I was looking at this and thinking about #9083, I was wondering if we should generalize a bit more here. This should have more design but throwing this out as a starting point. Feel free to disregard if it's not useful, not moving in the right direction, is overcomplicating, etc. Basically I'm wondering if our routing configuration should look more like: "Routing": {
"Routers": {
"storetheindex": {...}, # what you already had
"ipfs-public-dht" : {...}, # what you already had
"ipfs-lan-dht" : {...}, # what you already had
"peer-routing" : {
"Type" : "bitswap-peer",
"Enabled" : true,
"Parameters" : {...}
},
"parallel-get-p2p-providers" : {
"Type" : "parallel", # A special router we create that can encapsulate other Routers
"Parameters" : {
"Routers" : [
{
"Name" : "storetheindex",
"TimeoutMs" : 200, # Optional - can rely on the outer timeout as well. Not sure how useful this is.
}, {
"Name" : "ipfs-public-dht",
}
],
"TimeoutMs" : "500",
"ReturnStrategy" : "BestEffort"
# This could be one of
# "First": return the response from the router whose response we get first
# "BestEffort": Combine all the results we get by the outer timeout value.
# "AllRequired": Only return a result within the timeout if we get a response from all the routers. Responses are merged.
}
},
"get-p2p-providers-chain" : {
"Type" : "parallel",
"Parameters" : {
"Routers" : [
{
"Name" : "peer-routing",
"DelayMs" : 0
}, {
"Name" : "parallel-get-p2p-providers",
"DelayMs" : 500 # Wait 500ms before starting this. If we get a response from peer-routing sooner, we'll have already returned because of the "First" return strategy.
},
],
"TimeoutMs" : 2000,
"ReturnStrategy" : "First",
}
}
},
"MethodToRouterMap" : {
"put-ipns" : "ipfs-public-dht",
"get-p2p-providers" : "get-p2p-providers-chain",
... # There should be a mapping from every method to a router
}
} |
@BigLep so the main idea is to create a special router that can encapsulate other routers defining how and when we call them.
|
@ajnavarro : I'll quickly engage to try and get the idea across. Please don't take this as direction for what we have to go. My idea here is that we should have a map of method to router to use for that method (
The "strategy" used for a method depends on the router that is specified for that method. For a specific method, one can create a new router composing a different "base" router and strategy if needed.
I think that lives in |
@ajnavarro : concerning the done criteria for this issue, it doesn't specify how multiple routers will be combined in terms of execution ordering and result merging. Will this use the "Routers Wrapper" mentioned in #9083 (comment) ? |
Per 2022-08-12 conversation, yes, this work is using https://github.com/libp2p/go-libp2p-routing-helpers |
@ajnavarro : per 2022-08-12 conversation, here's the issue about designing comprehensive routing config: #9188 . We're going to pause this current work to do some design to make sure we're aligned on our end state. |
New multi-router configuration system based on https://hackmd.io/G1KRDEX5T3qyfoBMkIrBew#Methods - Added a new routing type: "custom" - Added specific struct types for different Routers (instead of map[string]interface{}) - Added `Duration` config type, to make easier time string parsing - Added config documentation. - Use the latest go-delegated-routing library version with GET support. - Added changelog notes for this feature. It: - closes #9157 - closes #9079 - closes #9186
Description
Delegated routing implementation (#8997) currently only supports reframe routers. Implement DHT routers so they can be added as a new type on delegated routing config list. Actual DHT config initialization and behavior must work as before.
New design document here: https://hackmd.io/@ajnavarro/HJr059wC9
delegatred_test.go
Deprecate any old configuration param used to create the DHT(previous, simpler configuration will not be deprecated)parallel
andsequential
. libp2p/go-libp2p-routing-helpers#56)The text was updated successfully, but these errors were encountered: