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

feat(brave): delegated peers and content routing #739

Merged
merged 2 commits into from
Aug 12, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions add-on/src/lib/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ exports.optionDefaults = Object.freeze({
ipfsApiUrl: buildIpfsApiUrl(),
ipfsApiPollMs: 3000,
ipfsProxy: true, // window.ipfs
logNamespaces: 'jsipfs*,ipfs*,-*:ipns*,-ipfs:preload*,-ipfs-http-client:request*'
logNamespaces: 'jsipfs*,ipfs*,libp2p-delegated*,-*:ipns*,-ipfs:preload*,-ipfs-http-client:request*'
})

function buildCustomGatewayUrl () {
Expand Down Expand Up @@ -62,15 +62,21 @@ function buildDefaultIpfsNodeConfig () {
// Until we have MulticastDNS+DNS, peer discovery is done over ws-star
config.config.Addresses.Swarm = ['/dns4/ws-star1.par.dwebops.pub/tcp/443/wss/p2p-websocket-star']
// Until DHT and p2p transport are ready, delegate + preload
// Note: we use .preload.ipfs.io and .delegate.ipfs.io as means of http sharding (12 instead of 6 concurrent requests)
const delegates = [
'/dns4/node0.preload.ipfs.io/tcp/443/https',
'/dns4/node1.preload.ipfs.io/tcp/443/https'
'/dns4/node1.delegate.ipfs.io/tcp/443/https',
Copy link
Member Author

@lidel lidel Jul 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We got dedicated hostnames for use in delegate contexts: ipfs/js-ipfs#2291

'/dns4/node0.delegate.ipfs.io/tcp/443/https'
]
// Delegated Content and Peer Routing: https://github.com/ipfs/js-ipfs/pull/2195
// TODO: delegated routing blocked by https://github.com/libp2p/js-libp2p-delegated-content-routing/issues/12
// config.config.Addresses.Delegates = delegates
// TODO: are preloads needed? should Brave have own nodes?
config.preload = { enabled: true, addresses: delegates }
config.config.Addresses.Delegates = delegates
// TODO: when we have p2p transport, are preloads still needed? should Brave have own nodes?
config.preload = {
enabled: true,
addresses: [
'/dns4/node1.preload.ipfs.io/tcp/443/https',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will reuse delegates here, but for now I use .preload. hostnames to make it easier to see which requests are from libp2p's routing modules, and which ones are triggered by preload logic in js-ipfs.

'/dns4/node0.preload.ipfs.io/tcp/443/https'
]
}
/*
(Sidenote on why we need API for Web UI)
Gateway can run without API port,
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@
"private": true,
"preferGlobal": false,
"resolutions": {
"libp2p-delegated-content-routing": "0.3.1",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ensures fixes from libp2p/js-libp2p-delegated-content-routing#16 are in.

"libp2p-delegated-peer-routing": "0.3.1",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ensures fixes from libp2p/js-libp2p-delegated-peer-routing#12 are in.

"@hapi/hapi": "https://github.com/lidel/hapi/tarball/ccbf84ba5edc9b24564fdd166e3ee6d81c4c02d8/hapi.tar.gz",
"pino": "5.12.3",
"hapi-pino": "https://github.com/pinojs/hapi-pino/tarball/3767ed6b67601831e176e084ed82ba4ed9f726e6/hapi-pino.tar.gz",
Expand Down
34 changes: 17 additions & 17 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6798,7 +6798,7 @@ ipfs-css@0.12.0:
resolved "https://registry.yarnpkg.com/ipfs-css/-/ipfs-css-0.12.0.tgz#becf48dbdfb1c913006ff0c6dc6c56752a2cb6b3"
integrity sha512-bU72aEG1LR1MVUnHIXsCxdZqJwKpQrh0Wod2aI1o940hVxobZqHEVw5PISdhVdtK42IaHhtq25wAl0zZlUwyiA==

ipfs-http-client@33.1.0, ipfs-http-client@^33.0.1, ipfs-http-client@^33.0.2, ipfs-http-client@^33.1.0:
ipfs-http-client@33.1.0, ipfs-http-client@^33.1.0:
version "33.1.0"
resolved "https://registry.yarnpkg.com/ipfs-http-client/-/ipfs-http-client-33.1.0.tgz#4d3beceba27fcef26cf1940375a5f8c9d609f0dd"
integrity sha512-hkS8nXay3DGKb/KXU1RDvTyxnvkAdhS5enlXxNXaS7yKvADlf5SEuQGYjW+VknkPPQ4FNbY3JttQ3YW+LTuoRA==
Expand Down Expand Up @@ -8550,25 +8550,25 @@ libp2p-crypto@~0.16.0, libp2p-crypto@~0.16.1:
tweetnacl "^1.0.0"
ursa-optional "~0.9.10"

libp2p-delegated-content-routing@^0.2.3:
version "0.2.3"
resolved "https://registry.yarnpkg.com/libp2p-delegated-content-routing/-/libp2p-delegated-content-routing-0.2.3.tgz#de3e923e70cbcfbbc2de679a84ad1c1c342a8129"
integrity sha512-WbHunAEJj5HzhbHKEep9myfoGa7/g4rWytyHLuC3syxbVpc9Tv4oQK0dD8G09YofGpIr/I4yUPaJY1GM7skGQQ==
libp2p-delegated-content-routing@0.3.1, libp2p-delegated-content-routing@^0.2.3:
version "0.3.1"
resolved "https://registry.yarnpkg.com/libp2p-delegated-content-routing/-/libp2p-delegated-content-routing-0.3.1.tgz#45e1711074a68d457c9b4bd92682ad06fb8857c8"
integrity sha512-GgEj1FHzNFH6nL0fQ5sFZWcskfWkwVLL+GtY5wZbe9izXftyg5QDVdoKSlYWQUrEjaaAJE+T4KjvtK83T/C7Yg==
dependencies:
async "^2.6.2"
ipfs-http-client "^33.0.2"
debug "^4.1.1"
ipfs-http-client "^33.1.0"
multiaddr "^6.1.0"
peer-id "^0.12.2"
peer-info "^0.15.1"
p-queue "^6.1.0"

libp2p-delegated-peer-routing@^0.2.3:
version "0.2.3"
resolved "https://registry.yarnpkg.com/libp2p-delegated-peer-routing/-/libp2p-delegated-peer-routing-0.2.3.tgz#b2c27bee2bd6a9f0147fc2ec12b5e1c9c6c982eb"
integrity sha512-yr5NRgAnVmsvhIC5COyEda+ZdD42JVfBeShsHj7FaRdYay4kdEpUXqLXiC7bC6PMbYSh2d/TheO3ITTj4Kp1Fw==
libp2p-delegated-peer-routing@0.3.1, libp2p-delegated-peer-routing@^0.2.3:
version "0.3.1"
resolved "https://registry.yarnpkg.com/libp2p-delegated-peer-routing/-/libp2p-delegated-peer-routing-0.3.1.tgz#331d129559b2b257cef5e13260d7ac50d4731768"
integrity sha512-WAN2rBsuiS1xqrAaZthKX9vVtXar0nH7ACAWoTNsk2BaAhhds0Shri48NB5jN//kxLo+vC7+WVn4Rgdg3Dp2sA==
dependencies:
ipfs-http-client "^33.0.1"
peer-id "^0.12.2"
peer-info "^0.15.1"
debug "^4.1.1"
ipfs-http-client "^33.1.0"
p-queue "^6.1.0"
peer-id "~0.12.2"

libp2p-floodsub@^0.16.1:
version "0.16.1"
Expand Down Expand Up @@ -10737,7 +10737,7 @@ p-map@^2.0.0:
resolved "https://registry.yarnpkg.com/p-map/-/p-map-2.1.0.tgz#310928feef9c9ecc65b68b17693018a665cea175"
integrity sha512-y3b8Kpd8OAN444hxfBbFfj1FY/RjtTd8tzYwhUqNYXx0fXx2iX4maP4Qr6qhIKbQXI02wTLAda4fYUbDagTUFw==

p-queue@6.1.0:
p-queue@6.1.0, p-queue@^6.1.0:
version "6.1.0"
resolved "https://registry.yarnpkg.com/p-queue/-/p-queue-6.1.0.tgz#3f546275073b41e4af460e41459524b15c2753f3"
integrity sha512-907vNz/cY+JEsqGglo7o/Ia9E/wisahJGOp9HPfbAyCVGERQVmFGA4IyknxY1v+QRBiMKedL3ToOBXNEy9MKQA==
Expand Down